aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib_base.c2
-rw-r--r--src/lj_asm.c13
-rw-r--r--src/lj_ffrecord.c13
-rw-r--r--src/lj_ir.h2
-rw-r--r--src/lj_opt_fold.c3
5 files changed, 31 insertions, 2 deletions
diff --git a/src/lib_base.c b/src/lib_base.c
index 1665faee..a19926a7 100644
--- a/src/lib_base.c
+++ b/src/lib_base.c
@@ -136,7 +136,7 @@ LJLIB_ASM(setmetatable) LJLIB_REC(.)
136 return FFH_RES(1); 136 return FFH_RES(1);
137} 137}
138 138
139LJLIB_CF(getfenv) 139LJLIB_CF(getfenv) LJLIB_REC(.)
140{ 140{
141 GCfunc *fn; 141 GCfunc *fn;
142 cTValue *o = L->base; 142 cTValue *o = L->base;
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 0d6875a6..fb364c74 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -699,7 +699,7 @@ static void ra_left(ASMState *as, Reg dest, IRRef lref)
699 emit_loadu64(as, dest, ir_kint64(ir)->u64); 699 emit_loadu64(as, dest, ir_kint64(ir)->u64);
700 return; 700 return;
701#endif 701#endif
702 } else { 702 } else if (ir->o != IR_KPRI) {
703 lua_assert(ir->o == IR_KINT || ir->o == IR_KGC || 703 lua_assert(ir->o == IR_KINT || ir->o == IR_KGC ||
704 ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL); 704 ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL);
705 emit_loadi(as, dest, ir->i); 705 emit_loadi(as, dest, ir->i);
@@ -1191,6 +1191,16 @@ static void asm_newref(ASMState *as, IRIns *ir)
1191 asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); 1191 asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2);
1192} 1192}
1193 1193
1194static void asm_lref(ASMState *as, IRIns *ir)
1195{
1196 Reg r = ra_dest(as, ir, RSET_GPR);
1197#if LJ_TARGET_X86ORX64
1198 ra_left(as, r, ASMREF_L);
1199#else
1200 ra_leftov(as, r, ASMREF_L);
1201#endif
1202}
1203
1194/* -- Calls --------------------------------------------------------------- */ 1204/* -- Calls --------------------------------------------------------------- */
1195 1205
1196/* Collect arguments from CALL* and CARG instructions. */ 1206/* Collect arguments from CALL* and CARG instructions. */
@@ -1624,6 +1634,7 @@ static void asm_ir(ASMState *as, IRIns *ir)
1624 case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; 1634 case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break;
1625 case IR_FREF: asm_fref(as, ir); break; 1635 case IR_FREF: asm_fref(as, ir); break;
1626 case IR_STRREF: asm_strref(as, ir); break; 1636 case IR_STRREF: asm_strref(as, ir); break;
1637 case IR_LREF: asm_lref(as, ir); break;
1627 1638
1628 /* Loads and stores. */ 1639 /* Loads and stores. */
1629 case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: 1640 case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD:
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index 29916e71..de74a3ec 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -422,6 +422,19 @@ static void LJ_FASTCALL recff_xpcall(jit_State *J, RecordFFData *rd)
422 } /* else: Interpreter will throw. */ 422 } /* else: Interpreter will throw. */
423} 423}
424 424
425static void LJ_FASTCALL recff_getfenv(jit_State *J, RecordFFData *rd)
426{
427 TRef tr = J->base[0];
428 /* Only support getfenv(0) for now. */
429 if (tref_isint(tr) && tref_isk(tr) && IR(tref_ref(tr))->i == 0) {
430 TRef trl = emitir(IRT(IR_LREF, IRT_THREAD), 0, 0);
431 J->base[0] = emitir(IRT(IR_FLOAD, IRT_TAB), trl, IRFL_THREAD_ENV);
432 return;
433 }
434 recff_nyiu(J);
435 UNUSED(rd);
436}
437
425/* -- Math library fast functions ----------------------------------------- */ 438/* -- Math library fast functions ----------------------------------------- */
426 439
427static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd) 440static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd)
diff --git a/src/lj_ir.h b/src/lj_ir.h
index f50132ea..bd2723cd 100644
--- a/src/lj_ir.h
+++ b/src/lj_ir.h
@@ -97,6 +97,7 @@
97 _(UREFC, LW, ref, lit) \ 97 _(UREFC, LW, ref, lit) \
98 _(FREF, R , ref, lit) \ 98 _(FREF, R , ref, lit) \
99 _(STRREF, N , ref, ref) \ 99 _(STRREF, N , ref, ref) \
100 _(LREF, L , ___, ___) \
100 \ 101 \
101 /* Loads and Stores. These must be in the same order. */ \ 102 /* Loads and Stores. These must be in the same order. */ \
102 _(ALOAD, L , ref, ___) \ 103 _(ALOAD, L , ref, ___) \
@@ -193,6 +194,7 @@ IRFPMDEF(FPMENUM)
193 _(STR_LEN, offsetof(GCstr, len)) \ 194 _(STR_LEN, offsetof(GCstr, len)) \
194 _(FUNC_ENV, offsetof(GCfunc, l.env)) \ 195 _(FUNC_ENV, offsetof(GCfunc, l.env)) \
195 _(FUNC_PC, offsetof(GCfunc, l.pc)) \ 196 _(FUNC_PC, offsetof(GCfunc, l.pc)) \
197 _(THREAD_ENV, offsetof(lua_State, env)) \
196 _(TAB_META, offsetof(GCtab, metatable)) \ 198 _(TAB_META, offsetof(GCtab, metatable)) \
197 _(TAB_ARRAY, offsetof(GCtab, array)) \ 199 _(TAB_ARRAY, offsetof(GCtab, array)) \
198 _(TAB_NODE, offsetof(GCtab, node)) \ 200 _(TAB_NODE, offsetof(GCtab, node)) \
diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c
index 2ca04a69..a3c8723b 100644
--- a/src/lj_opt_fold.c
+++ b/src/lj_opt_fold.c
@@ -2104,6 +2104,7 @@ LJFOLDF(fwd_href_tdup)
2104** an aliased table, as it may invalidate all of the pointers and fields. 2104** an aliased table, as it may invalidate all of the pointers and fields.
2105** Only HREF needs the NEWREF check -- AREF and HREFK already depend on 2105** Only HREF needs the NEWREF check -- AREF and HREFK already depend on
2106** FLOADs. And NEWREF itself is treated like a store (see below). 2106** FLOADs. And NEWREF itself is treated like a store (see below).
2107** LREF is constant (per trace) since coroutine switches are not inlined.
2107*/ 2108*/
2108LJFOLD(FLOAD TNEW IRFL_TAB_ASIZE) 2109LJFOLD(FLOAD TNEW IRFL_TAB_ASIZE)
2109LJFOLDF(fload_tab_tnew_asize) 2110LJFOLDF(fload_tab_tnew_asize)
@@ -2221,6 +2222,8 @@ LJFOLDF(fload_cdata_ptr_int64_cnew)
2221} 2222}
2222 2223
2223LJFOLD(FLOAD any IRFL_STR_LEN) 2224LJFOLD(FLOAD any IRFL_STR_LEN)
2225LJFOLD(FLOAD any IRFL_FUNC_ENV)
2226LJFOLD(FLOAD any IRFL_THREAD_ENV)
2224LJFOLD(FLOAD any IRFL_CDATA_CTYPEID) 2227LJFOLD(FLOAD any IRFL_CDATA_CTYPEID)
2225LJFOLD(FLOAD any IRFL_CDATA_PTR) 2228LJFOLD(FLOAD any IRFL_CDATA_PTR)
2226LJFOLD(FLOAD any IRFL_CDATA_INT) 2229LJFOLD(FLOAD any IRFL_CDATA_INT)