summaryrefslogtreecommitdiff
path: root/src/lj_jit.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_jit.h')
-rw-r--r--src/lj_jit.h36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/lj_jit.h b/src/lj_jit.h
index adb6f2d5..332596f0 100644
--- a/src/lj_jit.h
+++ b/src/lj_jit.h
@@ -152,34 +152,42 @@ typedef uint16_t TraceNo1; /* Stored trace number. */
152 152
153#define TRACE_INTERP 0 /* Fallback to interpreter. */ 153#define TRACE_INTERP 0 /* Fallback to interpreter. */
154 154
155/* Trace anchor. */ 155/* Trace object. */
156typedef struct Trace { 156typedef struct GCtrace {
157 IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */ 157 GCHeader;
158 uint8_t topslot; /* Top stack slot already checked to be allocated. */
159 uint8_t unused1;
158 IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */ 160 IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */
161 GCRef gclist;
162 IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */
159 IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */ 163 IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */
160 SnapShot *snap; /* Snapshot array. */
161 SnapEntry *snapmap; /* Snapshot map. */
162 uint16_t nsnap; /* Number of snapshots. */ 164 uint16_t nsnap; /* Number of snapshots. */
163 uint16_t nsnapmap; /* Number of snapshot map elements. */ 165 uint16_t nsnapmap; /* Number of snapshot map elements. */
166 SnapShot *snap; /* Snapshot array. */
167 SnapEntry *snapmap; /* Snapshot map. */
164 GCRef startpt; /* Starting prototype. */ 168 GCRef startpt; /* Starting prototype. */
165 BCIns startins; /* Original bytecode of starting instruction. */ 169 BCIns startins; /* Original bytecode of starting instruction. */
166 MCode *mcode; /* Start of machine code. */ 170 MCode *mcode; /* Start of machine code. */
167 MSize szmcode; /* Size of machine code. */ 171 MSize szmcode; /* Size of machine code. */
168 MSize mcloop; /* Offset of loop start in machine code. */ 172 MSize mcloop; /* Offset of loop start in machine code. */
173 uint16_t nchild; /* Number of child traces (root trace only). */
174 uint16_t spadjust; /* Stack pointer adjustment (offset in bytes). */
175 TraceNo1 traceno; /* Trace number. */
169 TraceNo1 link; /* Linked trace (or self for loops). */ 176 TraceNo1 link; /* Linked trace (or self for loops). */
170 TraceNo1 root; /* Root trace of side trace (or 0 for root traces). */ 177 TraceNo1 root; /* Root trace of side trace (or 0 for root traces). */
171 TraceNo1 nextroot; /* Next root trace for same prototype. */ 178 TraceNo1 nextroot; /* Next root trace for same prototype. */
172 TraceNo1 nextside; /* Next side trace of same root trace. */ 179 TraceNo1 nextside; /* Next side trace of same root trace. */
173 uint16_t nchild; /* Number of child traces (root trace only). */ 180 uint16_t unused2;
174 uint16_t spadjust; /* Stack pointer adjustment (offset in bytes). */
175 uint8_t topslot; /* Top stack slot already checked to be allocated. */
176 uint8_t unused1;
177 uint8_t unused2;
178 uint8_t unused3;
179#ifdef LUAJIT_USE_GDBJIT 181#ifdef LUAJIT_USE_GDBJIT
180 void *gdbjit_entry; /* GDB JIT entry. */ 182 void *gdbjit_entry; /* GDB JIT entry. */
181#endif 183#endif
182} Trace; 184} GCtrace;
185
186#define gco2trace(o) check_exp((o)->gch.gct == ~LJ_TTRACE, (GCtrace *)(o))
187#define traceref(J, n) \
188 check_exp((n)>0 && (MSize)(n)<J->sizetrace, (GCtrace *)gcref(J->trace[(n)]))
189
190LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtrace, gclist));
183 191
184/* Round-robin penalty cache for bytecodes leading to aborted traces. */ 192/* Round-robin penalty cache for bytecodes leading to aborted traces. */
185typedef struct HotPenalty { 193typedef struct HotPenalty {
@@ -233,7 +241,7 @@ typedef struct FoldState {
233 241
234/* JIT compiler state. */ 242/* JIT compiler state. */
235typedef struct jit_State { 243typedef struct jit_State {
236 Trace cur; /* Current trace. */ 244 GCtrace cur; /* Current trace. */
237 245
238 lua_State *L; /* Current Lua state. */ 246 lua_State *L; /* Current Lua state. */
239 const BCIns *pc; /* Current PC. */ 247 const BCIns *pc; /* Current PC. */
@@ -277,7 +285,7 @@ typedef struct jit_State {
277 MSize sizesnapmap; /* Size of temp. snapshot map buffer. */ 285 MSize sizesnapmap; /* Size of temp. snapshot map buffer. */
278 286
279 TraceNo curtrace; /* Current trace number (if not 0). Kept in J->cur. */ 287 TraceNo curtrace; /* Current trace number (if not 0). Kept in J->cur. */
280 Trace **trace; /* Array of traces. */ 288 GCRef *trace; /* Array of traces. */
281 TraceNo freetrace; /* Start of scan for next free trace. */ 289 TraceNo freetrace; /* Start of scan for next free trace. */
282 MSize sizetrace; /* Size of trace array. */ 290 MSize sizetrace; /* Size of trace array. */
283 291