aboutsummaryrefslogtreecommitdiff
path: root/src/lj_ir.c
diff options
context:
space:
mode:
authorMike Pall <mike>2016-05-23 00:34:05 +0200
committerMike Pall <mike>2016-05-23 00:34:05 +0200
commitf26679c7195e99b32f95ea9f25b47b9981e15d3d (patch)
treed50e967a387b1a9853b83b464cf819eb3607b533 /src/lj_ir.c
parent9e99ccc360bc9784ebe5ce29d5fa2c72acfc5777 (diff)
downloadluajit-f26679c7195e99b32f95ea9f25b47b9981e15d3d.tar.gz
luajit-f26679c7195e99b32f95ea9f25b47b9981e15d3d.tar.bz2
luajit-f26679c7195e99b32f95ea9f25b47b9981e15d3d.zip
LJ_GC64: Add support for 64 bit GCobj constants in the IR.
Contributed by Peter Cawley.
Diffstat (limited to 'src/lj_ir.c')
-rw-r--r--src/lj_ir.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/lj_ir.c b/src/lj_ir.c
index 9c0a2224..0a206ebb 100644
--- a/src/lj_ir.c
+++ b/src/lj_ir.c
@@ -185,6 +185,12 @@ static LJ_AINLINE IRRef ir_nextk64(jit_State *J)
185 return ref; 185 return ref;
186} 186}
187 187
188#if LJ_GC64
189#define ir_nextkgc ir_nextk64
190#else
191#define ir_nextkgc ir_nextk
192#endif
193
188/* Intern int32_t constant. */ 194/* Intern int32_t constant. */
189TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k) 195TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k)
190{ 196{
@@ -268,15 +274,14 @@ TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t)
268{ 274{
269 IRIns *ir, *cir = J->cur.ir; 275 IRIns *ir, *cir = J->cur.ir;
270 IRRef ref; 276 IRRef ref;
271 lua_assert(!LJ_GC64); /* TODO_GC64: major changes required. */
272 lua_assert(!isdead(J2G(J), o)); 277 lua_assert(!isdead(J2G(J), o));
273 for (ref = J->chain[IR_KGC]; ref; ref = cir[ref].prev) 278 for (ref = J->chain[IR_KGC]; ref; ref = cir[ref].prev)
274 if (ir_kgc(&cir[ref]) == o) 279 if (ir_kgc(&cir[ref]) == o)
275 goto found; 280 goto found;
276 ref = ir_nextk(J); 281 ref = ir_nextkgc(J);
277 ir = IR(ref); 282 ir = IR(ref);
278 /* NOBARRIER: Current trace is a GC root. */ 283 /* NOBARRIER: Current trace is a GC root. */
279 setgcref(ir->gcr, o); 284 setgcref(ir[LJ_GC64].gcr, o);
280 ir->t.irt = (uint8_t)t; 285 ir->t.irt = (uint8_t)t;
281 ir->o = IR_KGC; 286 ir->o = IR_KGC;
282 ir->prev = J->chain[IR_KGC]; 287 ir->prev = J->chain[IR_KGC];
@@ -288,33 +293,39 @@ found:
288/* Allocate GCtrace constant placeholder (no interning). */ 293/* Allocate GCtrace constant placeholder (no interning). */
289TRef lj_ir_ktrace(jit_State *J) 294TRef lj_ir_ktrace(jit_State *J)
290{ 295{
291 IRRef ref = ir_nextk(J); 296 IRRef ref = ir_nextkgc(J);
292 IRIns *ir = IR(ref); 297 IRIns *ir = IR(ref);
293 lua_assert(irt_toitype_(IRT_P64) == LJ_TTRACE); 298 lua_assert(irt_toitype_(IRT_P64) == LJ_TTRACE);
294 ir->t.irt = IRT_P64; 299 ir->t.irt = IRT_P64;
295 ir->o = IR_KNULL; /* Not IR_KGC yet, but same size. */ 300 ir->o = LJ_GC64 ? IR_KNUM : IR_KNULL; /* Not IR_KGC yet, but same size. */
296 ir->prev = 0; 301 ir->prev = 0;
297 return TREF(ref, IRT_P64); 302 return TREF(ref, IRT_P64);
298} 303}
299 304
300/* Intern 32 bit pointer constant. */ 305/* Intern pointer constant. */
301TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr) 306TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr)
302{ 307{
303 IRIns *ir, *cir = J->cur.ir; 308 IRIns *ir, *cir = J->cur.ir;
304 IRRef ref; 309 IRRef ref;
310#if LJ_64 && !LJ_GC64
305 lua_assert((void *)(uintptr_t)u32ptr(ptr) == ptr); 311 lua_assert((void *)(uintptr_t)u32ptr(ptr) == ptr);
312#endif
306 for (ref = J->chain[op]; ref; ref = cir[ref].prev) 313 for (ref = J->chain[op]; ref; ref = cir[ref].prev)
307 if (ir_kptr(&cir[ref]) == ptr) 314 if (ir_kptr(&cir[ref]) == ptr)
308 goto found; 315 goto found;
316#if LJ_GC64
317 ref = ir_nextk64(J);
318#else
309 ref = ir_nextk(J); 319 ref = ir_nextk(J);
320#endif
310 ir = IR(ref); 321 ir = IR(ref);
311 setmref(ir->ptr, ptr); 322 setmref(ir[LJ_GC64].ptr, ptr);
312 ir->t.irt = IRT_P32; 323 ir->t.irt = IRT_PGC;
313 ir->o = op; 324 ir->o = op;
314 ir->prev = J->chain[op]; 325 ir->prev = J->chain[op];
315 J->chain[op] = (IRRef1)ref; 326 J->chain[op] = (IRRef1)ref;
316found: 327found:
317 return TREF(ref, IRT_P32); 328 return TREF(ref, IRT_PGC);
318} 329}
319 330
320/* Intern typed NULL constant. */ 331/* Intern typed NULL constant. */