summaryrefslogtreecommitdiff
path: root/src/lj_record.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_record.c')
-rw-r--r--src/lj_record.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index 94ea42ed..7b2e977e 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -148,15 +148,10 @@ static TRef sload(jit_State *J, int32_t slot)
148/* Get TRef for current function. */ 148/* Get TRef for current function. */
149static TRef getcurrf(jit_State *J) 149static TRef getcurrf(jit_State *J)
150{ 150{
151 if (J->base[-1]) { 151 if (J->base[-1])
152 IRIns *ir = IR(tref_ref(J->base[-1]));
153 if (ir->o == IR_FRAME) /* Shortcut if already specialized. */
154 return TREF(ir->op2, IRT_FUNC); /* Return TRef of KFUNC. */
155 return J->base[-1]; 152 return J->base[-1];
156 } else { 153 lua_assert(J->baseslot == 1);
157 lua_assert(J->baseslot == 1); 154 return sloadt(J, -1, IRT_FUNC, IRSLOAD_READONLY);
158 return sloadt(J, -1, IRT_FUNC, IRSLOAD_READONLY);
159 }
160} 155}
161 156
162/* Compare for raw object equality. 157/* Compare for raw object equality.
@@ -424,7 +419,7 @@ static BCReg rec_mm_prep(jit_State *J, ASMFunction cont)
424#else 419#else
425 trcont = lj_ir_kptr(J, (void *)cont); 420 trcont = lj_ir_kptr(J, (void *)cont);
426#endif 421#endif
427 J->base[top] = emitir(IRTG(IR_FRAME, IRT_PTR), trcont, trcont) | TREF_CONT; 422 J->base[top] = trcont | TREF_CONT;
428 for (s = J->maxslot; s < top; s++) 423 for (s = J->maxslot; s < top; s++)
429 J->base[s] = TREF_NIL; 424 J->base[s] = TREF_NIL;
430 return top+1; 425 return top+1;
@@ -1586,7 +1581,7 @@ static void check_call_unroll(jit_State *J, GCfunc *fn)
1586static int rec_call(jit_State *J, BCReg func, int cres, int nargs) 1581static int rec_call(jit_State *J, BCReg func, int cres, int nargs)
1587{ 1582{
1588 RecordFFData rd; 1583 RecordFFData rd;
1589 TRef *res = &J->base[func]; 1584 TRef trfunc, *res = &J->base[func];
1590 TValue *tv = &J->L->base[func]; 1585 TValue *tv = &J->L->base[func];
1591 1586
1592 if (tref_isfunc(res[0])) { /* Regular function call. */ 1587 if (tref_isfunc(res[0])) { /* Regular function call. */
@@ -1608,7 +1603,9 @@ static int rec_call(jit_State *J, BCReg func, int cres, int nargs)
1608 } 1603 }
1609 1604
1610 /* Specialize to the runtime value of the called function. */ 1605 /* Specialize to the runtime value of the called function. */
1611 res[0] = emitir(IRTG(IR_FRAME, IRT_FUNC), res[0], lj_ir_kfunc(J, rd.fn)) | TREF_FRAME; 1606 trfunc = lj_ir_kfunc(J, rd.fn);
1607 emitir(IRTG(IR_EQ, IRT_FUNC), res[0], trfunc);
1608 res[0] = trfunc | TREF_FRAME;
1612 1609
1613 if (isluafunc(rd.fn)) { /* Record call to Lua function. */ 1610 if (isluafunc(rd.fn)) { /* Record call to Lua function. */
1614 GCproto *pt = funcproto(rd.fn); 1611 GCproto *pt = funcproto(rd.fn);
@@ -2175,12 +2172,7 @@ static void rec_setup_side(jit_State *J, Trace *T)
2175 for (j = 0; j < n; j++) 2172 for (j = 0; j < n; j++)
2176 if (snap_ref(map[j]) == ref) { 2173 if (snap_ref(map[j]) == ref) {
2177 tr = J->slot[snap_slot(map[j])]; 2174 tr = J->slot[snap_slot(map[j])];
2178 if (ir->o == IR_FRAME && irt_isfunc(ir->t)) { 2175 goto setslot;
2179 lua_assert(s != 0);
2180 J->baseslot = s+1;
2181 J->framedepth++;
2182 }
2183 goto dupslot;
2184 } 2176 }
2185 } 2177 }
2186 bloomset(seen, ref); 2178 bloomset(seen, ref);
@@ -2190,30 +2182,24 @@ static void rec_setup_side(jit_State *J, Trace *T)
2190 case IR_KINT: tr = lj_ir_kint(J, ir->i); break; 2182 case IR_KINT: tr = lj_ir_kint(J, ir->i); break;
2191 case IR_KGC: tr = lj_ir_kgc(J, ir_kgc(ir), irt_t(ir->t)); break; 2183 case IR_KGC: tr = lj_ir_kgc(J, ir_kgc(ir), irt_t(ir->t)); break;
2192 case IR_KNUM: tr = lj_ir_knum_addr(J, ir_knum(ir)); break; 2184 case IR_KNUM: tr = lj_ir_knum_addr(J, ir_knum(ir)); break;
2193 case IR_FRAME: /* Placeholder FRAMEs don't need a guard. */ 2185 case IR_KPTR: tr = lj_ir_kptr(J, ir_kptr(ir)); break; /* Continuation. */
2194 if (irt_isfunc(ir->t)) { 2186 /* Inherited SLOADs don't need a guard or type check. */
2195 if (s != 0) { 2187 case IR_SLOAD:
2196 J->baseslot = s+1;
2197 J->framedepth++;
2198 }
2199 tr = lj_ir_kfunc(J, ir_kfunc(&T->ir[ir->op2]));
2200 tr = emitir_raw(IRT(IR_FRAME, IRT_FUNC), tr, tr) | TREF_FRAME;
2201 } else {
2202 tr = lj_ir_kptr(J, mref(T->ir[ir->op2].ptr, void));
2203 tr = emitir_raw(IRT(IR_FRAME, IRT_PTR), tr, tr) | TREF_CONT;
2204 }
2205 break;
2206 case IR_SLOAD: /* Inherited SLOADs don't need a guard or type check. */
2207 tr = emitir_raw(ir->ot & ~IRT_GUARD, s, 2188 tr = emitir_raw(ir->ot & ~IRT_GUARD, s,
2208 (ir->op2&IRSLOAD_READONLY) | IRSLOAD_INHERIT|IRSLOAD_PARENT); 2189 (ir->op2&IRSLOAD_READONLY) | IRSLOAD_INHERIT|IRSLOAD_PARENT);
2209 break; 2190 break;
2210 default: /* Parent refs are already typed and don't need a guard. */ 2191 /* Parent refs are already typed and don't need a guard. */
2192 default:
2211 tr = emitir_raw(IRT(IR_SLOAD, irt_type(ir->t)), s, 2193 tr = emitir_raw(IRT(IR_SLOAD, irt_type(ir->t)), s,
2212 IRSLOAD_INHERIT|IRSLOAD_PARENT); 2194 IRSLOAD_INHERIT|IRSLOAD_PARENT);
2213 break; 2195 break;
2214 } 2196 }
2215 dupslot: 2197 setslot:
2216 J->slot[s] = tr; 2198 J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */
2199 if ((sn & SNAP_FRAME) && s != 0) {
2200 J->baseslot = s+1;
2201 J->framedepth++;
2202 }
2217 } 2203 }
2218 J->base = J->slot + J->baseslot; 2204 J->base = J->slot + J->baseslot;
2219 J->maxslot = snap->nslots - J->baseslot; 2205 J->maxslot = snap->nslots - J->baseslot;