aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2016-05-22 23:40:37 +0200
committerMike Pall <mike>2016-05-22 23:40:37 +0200
commit3152ed98ea3d99579940eb5e72da687ce66792de (patch)
treedcd8b8dec22f0d1d0a9ad3e30fcaefc4f288e3f2
parenta657fa01869e63508afce88cc8088c3d2e2fb47c (diff)
downloadluajit-3152ed98ea3d99579940eb5e72da687ce66792de.tar.gz
luajit-3152ed98ea3d99579940eb5e72da687ce66792de.tar.bz2
luajit-3152ed98ea3d99579940eb5e72da687ce66792de.zip
Simplify GCtrace * reference embedding for trace stitching.
This is now possible due to the immovable IR. Contributed by Peter Cawley.
-rw-r--r--src/lj_asm.c5
-rw-r--r--src/lj_ffrecord.c5
-rw-r--r--src/lj_ir.c12
-rw-r--r--src/lj_iropt.h1
-rw-r--r--src/lj_jit.h2
-rw-r--r--src/lj_trace.c5
6 files changed, 22 insertions, 8 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 5235dd00..9b394beb 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -1933,6 +1933,11 @@ static void asm_tail_link(ASMState *as)
1933 } 1933 }
1934 emit_addptr(as, RID_BASE, 8*(int32_t)baseslot); 1934 emit_addptr(as, RID_BASE, 8*(int32_t)baseslot);
1935 1935
1936 if (as->J->ktrace) { /* Patch ktrace slot with the final GCtrace pointer. */
1937 setgcref(IR(as->J->ktrace)->gcr, obj2gco(as->J->curfinal));
1938 IR(as->J->ktrace)->o = IR_KGC;
1939 }
1940
1936 /* Sync the interpreter state with the on-trace state. */ 1941 /* Sync the interpreter state with the on-trace state. */
1937 asm_stack_restore(as, snap); 1942 asm_stack_restore(as, snap);
1938 1943
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index 14fde4d9..ae567622 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -118,9 +118,8 @@ static void recff_stitch(jit_State *J)
118 /* Ditto for the IR. */ 118 /* Ditto for the IR. */
119 memmove(&J->base[1], &J->base[-1], sizeof(TRef)*(J->maxslot+1)); 119 memmove(&J->base[1], &J->base[-1], sizeof(TRef)*(J->maxslot+1));
120 J->base[0] = lj_ir_kptr(J, contptr(cont)) | TREF_CONT; 120 J->base[0] = lj_ir_kptr(J, contptr(cont)) | TREF_CONT;
121 J->ktracep = lj_ir_k64_reserve(J); 121 J->base[-1] = lj_ir_ktrace(J);
122 lua_assert(irt_toitype_(IRT_P64) == LJ_TTRACE); 122 J->ktrace = tref_ref(J->base[-1]);
123 J->base[-1] = emitir(IRT(IR_XLOAD, IRT_P64), lj_ir_kptr(J, &J->ktracep->gcr), 0);
124 J->base += 2; 123 J->base += 2;
125 J->baseslot += 2; 124 J->baseslot += 2;
126 J->framedepth++; 125 J->framedepth++;
diff --git a/src/lj_ir.c b/src/lj_ir.c
index 593b4127..acb39463 100644
--- a/src/lj_ir.c
+++ b/src/lj_ir.c
@@ -348,6 +348,18 @@ found:
348 return TREF(ref, t); 348 return TREF(ref, t);
349} 349}
350 350
351/* Allocate GCtrace constant placeholder (no interning). */
352TRef lj_ir_ktrace(jit_State *J)
353{
354 IRRef ref = ir_nextk(J);
355 IRIns *ir = IR(ref);
356 lua_assert(irt_toitype_(IRT_P64) == LJ_TTRACE);
357 ir->t.irt = IRT_P64;
358 ir->o = IR_KNULL; /* Not IR_KGC yet, but same size. */
359 ir->prev = 0;
360 return TREF(ref, IRT_P64);
361}
362
351/* Intern 32 bit pointer constant. */ 363/* Intern 32 bit pointer constant. */
352TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr) 364TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr)
353{ 365{
diff --git a/src/lj_iropt.h b/src/lj_iropt.h
index 46933671..fdc5f0d2 100644
--- a/src/lj_iropt.h
+++ b/src/lj_iropt.h
@@ -51,6 +51,7 @@ LJ_FUNC TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t);
51LJ_FUNC TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr); 51LJ_FUNC TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr);
52LJ_FUNC TRef lj_ir_knull(jit_State *J, IRType t); 52LJ_FUNC TRef lj_ir_knull(jit_State *J, IRType t);
53LJ_FUNC TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot); 53LJ_FUNC TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot);
54LJ_FUNC TRef lj_ir_ktrace(jit_State *J);
54 55
55#if LJ_64 56#if LJ_64
56#define lj_ir_kintp(J, k) lj_ir_kint64(J, (uint64_t)(k)) 57#define lj_ir_kintp(J, k) lj_ir_kint64(J, (uint64_t)(k))
diff --git a/src/lj_jit.h b/src/lj_jit.h
index ad9d62af..eafbc327 100644
--- a/src/lj_jit.h
+++ b/src/lj_jit.h
@@ -416,7 +416,7 @@ typedef struct jit_State {
416 GCRef *trace; /* Array of traces. */ 416 GCRef *trace; /* Array of traces. */
417 TraceNo freetrace; /* Start of scan for next free trace. */ 417 TraceNo freetrace; /* Start of scan for next free trace. */
418 MSize sizetrace; /* Size of trace array. */ 418 MSize sizetrace; /* Size of trace array. */
419 TValue *ktracep; /* Pointer to K64Array slot with GCtrace pointer. */ 419 IRRef1 ktrace; /* Reference to KGC with GCtrace. */
420 420
421 IRRef1 chain[IR__MAX]; /* IR instruction skip-list chain anchors. */ 421 IRRef1 chain[IR__MAX]; /* IR instruction skip-list chain anchors. */
422 TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA]; /* Stack slot map. */ 422 TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA]; /* Stack slot map. */
diff --git a/src/lj_trace.c b/src/lj_trace.c
index 19ddba41..eaf9365c 100644
--- a/src/lj_trace.c
+++ b/src/lj_trace.c
@@ -436,7 +436,7 @@ static void trace_start(jit_State *J)
436 J->postproc = LJ_POST_NONE; 436 J->postproc = LJ_POST_NONE;
437 lj_resetsplit(J); 437 lj_resetsplit(J);
438 J->retryrec = 0; 438 J->retryrec = 0;
439 J->ktracep = NULL; 439 J->ktrace = 0;
440 setgcref(J->cur.startpt, obj2gco(J->pt)); 440 setgcref(J->cur.startpt, obj2gco(J->pt));
441 441
442 L = J->L; 442 L = J->L;
@@ -512,9 +512,6 @@ static void trace_stop(jit_State *J)
512 lj_mcode_commit(J, J->cur.mcode); 512 lj_mcode_commit(J, J->cur.mcode);
513 J->postproc = LJ_POST_NONE; 513 J->postproc = LJ_POST_NONE;
514 trace_save(J, T); 514 trace_save(J, T);
515 if (J->ktracep) { /* Patch K64Array slot with the final GCtrace pointer. */
516 setgcV(J->L, J->ktracep, obj2gco(T), LJ_TTRACE);
517 }
518 515
519 L = J->L; 516 L = J->L;
520 lj_vmevent_send(L, TRACE, 517 lj_vmevent_send(L, TRACE,