aboutsummaryrefslogtreecommitdiff
path: root/src/lj_ffrecord.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_ffrecord.c')
-rw-r--r--src/lj_ffrecord.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index a08113ca..6cc05a24 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -96,18 +96,10 @@ static ptrdiff_t results_wanted(jit_State *J)
96 return -1; 96 return -1;
97} 97}
98 98
99#ifdef LUAJIT_TRACE_STITCHING
100/* This feature is disabled for now due to a design mistake. Sorry.
101**
102** It causes unpredictable behavior and crashes when a full trace flush
103** happens with a stitching continuation still in the stack somewhere.
104*/
105
106/* Trace stitching: add continuation below frame to start a new trace. */ 99/* Trace stitching: add continuation below frame to start a new trace. */
107static void recff_stitch(jit_State *J) 100static void recff_stitch(jit_State *J)
108{ 101{
109 ASMFunction cont = lj_cont_stitch; 102 ASMFunction cont = lj_cont_stitch;
110 TraceNo traceno = J->cur.traceno;
111 lua_State *L = J->L; 103 lua_State *L = J->L;
112 TValue *base = L->base; 104 TValue *base = L->base;
113 const BCIns *pc = frame_pc(base-1); 105 const BCIns *pc = frame_pc(base-1);
@@ -120,7 +112,7 @@ static void recff_stitch(jit_State *J)
120 setframe_ftsz(base+1, ((char *)(base+1) - (char *)pframe) + FRAME_CONT); 112 setframe_ftsz(base+1, ((char *)(base+1) - (char *)pframe) + FRAME_CONT);
121 setcont(base, cont); 113 setcont(base, cont);
122 setframe_pc(base, pc); 114 setframe_pc(base, pc);
123 if (LJ_DUALNUM) setintV(base-1, traceno); else base[-1].u64 = traceno; 115 setnilV(base-1); /* Incorrect, but rec_check_slots() won't run anymore. */
124 L->base += 2; 116 L->base += 2;
125 L->top += 2; 117 L->top += 2;
126 118
@@ -132,7 +124,9 @@ static void recff_stitch(jit_State *J)
132 trcont = lj_ir_kptr(J, (void *)cont); 124 trcont = lj_ir_kptr(J, (void *)cont);
133#endif 125#endif
134 J->base[0] = trcont | TREF_CONT; 126 J->base[0] = trcont | TREF_CONT;
135 J->base[-1] = LJ_DUALNUM ? lj_ir_kint(J,traceno) : lj_ir_knum_u64(J,traceno); 127 J->ktracep = lj_ir_k64_reserve(J);
128 lua_assert(irt_toitype_(IRT_P64) == LJ_TTRACE);
129 J->base[-1] = emitir(IRT(IR_XLOAD, IRT_P64), lj_ir_kptr(J, &J->ktracep->gcr), 0);
136 J->base += 2; 130 J->base += 2;
137 J->baseslot += 2; 131 J->baseslot += 2;
138 J->framedepth++; 132 J->framedepth++;
@@ -181,31 +175,6 @@ static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd)
181 175
182/* Must stop the trace for classic C functions with arbitrary side-effects. */ 176/* Must stop the trace for classic C functions with arbitrary side-effects. */
183#define recff_c recff_nyi 177#define recff_c recff_nyi
184#else
185/* Fallback handler for fast functions that are not recorded (yet). */
186static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd)
187{
188 setfuncV(J->L, &J->errinfo, J->fn);
189 lj_trace_err_info(J, LJ_TRERR_NYIFF);
190 UNUSED(rd);
191}
192
193/* Throw error for unsupported variant of fast function. */
194LJ_NORET static void recff_nyiu(jit_State *J, RecordFFData *rd)
195{
196 setfuncV(J->L, &J->errinfo, J->fn);
197 lj_trace_err_info(J, LJ_TRERR_NYIFFU);
198 UNUSED(rd);
199}
200
201/* Must abort the trace for classic C functions with arbitrary side-effects. */
202static void LJ_FASTCALL recff_c(jit_State *J, RecordFFData *rd)
203{
204 setfuncV(J->L, &J->errinfo, J->fn);
205 lj_trace_err_info(J, LJ_TRERR_NYICF);
206 UNUSED(rd);
207}
208#endif
209 178
210/* Emit BUFHDR for the global temporary buffer. */ 179/* Emit BUFHDR for the global temporary buffer. */
211static TRef recff_bufhdr(jit_State *J) 180static TRef recff_bufhdr(jit_State *J)