From d5a46621f9d1299a7e5c06c59dfc02d61dc04a79 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 8 Feb 2010 20:17:34 +0100 Subject: [PATCH] Drop bc field in GCproto since the bytecode is colocated. --- src/buildvm_x64.h | 12 ++++++------ src/buildvm_x64win.h | 12 ++++++------ src/buildvm_x86.dasc | 6 +++--- src/buildvm_x86.h | 12 ++++++------ src/lib_jit.c | 2 +- src/lj_obj.h | 7 +------ src/lj_parse.c | 1 - 7 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/buildvm_x64.h b/src/buildvm_x64.h index 615b9b82..9ce79dd7 100644 --- a/src/buildvm_x64.h +++ b/src/buildvm_x64.h @@ -13,7 +13,7 @@ #define DASM_SECTION_CODE_SUB 1 #define DASM_MAXSECTION 2 static const unsigned char build_actionlist[13633] = { - 254,1,248,10,137,202,139,173,233,137,90,252,252,15,182,141,233,139,157,233, + 254,1,248,10,137,202,139,173,233,137,90,252,252,15,182,141,233,141,157,233, 68,139,189,233,139,108,36,16,141,12,202,141,68,194,252,252,59,141,233,15, 135,244,11,248,9,189,237,248,1,137,40,137,104,8,131,192,16,57,200,15,130, 244,1,255,139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36, @@ -22,7 +22,7 @@ static const unsigned char build_actionlist[13633] = { 141,66,4,68,59,187,233,15,135,244,13,15,182,157,233,133,219,15,132,244,248, 248,1,131,193,8,57,209,15,131,244,248,68,139,121,252,248,68,137,120,252,252, 68,139,121,252,252,68,137,56,131,192,8,199,65,252,252,237,131,252,235,1,15, - 133,244,1,248,2,15,182,141,233,139,157,233,255,68,139,189,233,141,12,202, + 133,244,1,248,2,15,182,141,233,141,157,233,255,68,139,189,233,141,12,202, 252,233,244,9,248,14,137,89,252,252,76,139,189,233,139,108,36,16,141,68,193, 252,248,137,141,233,141,136,233,137,133,233,59,141,233,76,137,252,254,137, 252,239,15,135,244,15,65,199,134,233,237,65,252,255,150,233,65,199,134,233, @@ -47,7 +47,7 @@ static const unsigned char build_actionlist[13633] = { 198,239,139,90,252,252,199,66,252,252,237,65,199,134,233,237,255,252,233, 244,16,248,20,252,247,195,237,15,132,244,27,131,227,252,248,41,218,72,141, 76,25,252,248,139,90,252,252,199,68,10,4,237,252,233,244,16,248,15,190,237, - 252,233,244,247,248,13,131,232,8,137,202,68,137,252,249,139,157,233,139,108, + 252,233,244,247,248,13,131,232,8,137,202,68,137,252,249,141,157,233,139,108, 36,16,248,11,131,232,4,41,209,193,252,233,3,131,195,4,137,149,233,137,133, 233,137,92,36,20,137,206,248,1,137,252,239,232,251,1,0,139,141,233,255,139, 133,233,139,105,252,248,139,89,252,252,41,200,193,232,3,131,192,1,252,255, @@ -1032,16 +1032,16 @@ static const char *const extnames[] = { static void build_subroutines(BuildCtx *ctx, int cmov, int sse) { dasm_put(Dst, 0); - dasm_put(Dst, 2, Dt7(->pt), Dt9(->framesize), Dt9(->bc), Dt9(->k), Dt1(->maxstack), LJ_TNIL); + dasm_put(Dst, 2, Dt7(->pt), Dt9(->framesize), sizeof(GCproto), Dt9(->k), Dt1(->maxstack), LJ_TNIL); #if LJ_HASJIT #endif - dasm_put(Dst, 64, FRAME_VARG, -FRAME_VARG, Dt7(->pt), Dt9(->framesize), Dt1(->maxstack), Dt9(->numparams), LJ_TNIL, Dt9(->framesize), Dt9(->bc)); + dasm_put(Dst, 64, FRAME_VARG, -FRAME_VARG, Dt7(->pt), Dt9(->framesize), Dt1(->maxstack), Dt9(->numparams), LJ_TNIL, Dt9(->framesize), sizeof(GCproto)); dasm_put(Dst, 198, Dt9(->k), Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->top), Dt1(->maxstack), DISPATCH_GL(vmstate), ~LJ_VMST_C, DISPATCH_GL(wrapf), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), FRAME_TYPE); dasm_put(Dst, 292, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->top), Dt1(->maxstack), DISPATCH_GL(vmstate), ~LJ_VMST_C, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), FRAME_TYPE); dasm_put(Dst, 378, FRAME_C, DISPATCH_GL(vmstate), ~LJ_VMST_C, Dt1(->base)); dasm_put(Dst, 470, Dt1(->top), Dt1(->cframe), Dt1(->maxstack), LJ_TNIL, Dt1(->top)); dasm_put(Dst, 554, Dt1(->top), Dt1(->glref), Dt2(->vmstate), ~LJ_VMST_C, CFRAME_RAWMASK, 1+1, Dt1(->base), Dt1(->glref), GG_G2DISP, LJ_TFALSE, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP); - dasm_put(Dst, 655, FRAME_P, LJ_TTRUE, LUA_MINSTACK, Dt9(->bc), Dt1(->base), Dt1(->top), Dt1(->base)); + dasm_put(Dst, 655, FRAME_P, LJ_TTRUE, LUA_MINSTACK, sizeof(GCproto), Dt1(->base), Dt1(->top), Dt1(->base)); dasm_put(Dst, 759, Dt1(->top), Dt7(->gate), FRAME_CP, CFRAME_RESUME, Dt1(->glref), GG_G2DISP, Dt1(->cframe), Dt1(->status), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->status), Dt1(->base), Dt1(->top), FRAME_TYPE); dasm_put(Dst, 898, FRAME_CP, FRAME_C, Dt1(->cframe), Dt1(->cframe), Dt1(->glref), GG_G2DISP, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), LJ_TFUNC, Dt7(->gate)); dasm_put(Dst, 1023, Dt1(->stack), Dt1(->top), Dt1(->cframe), Dt1(->cframe), FRAME_CP, LJ_TNIL, 0, Dt7(->pt), Dt9(->k), Dt1(->base)); diff --git a/src/buildvm_x64win.h b/src/buildvm_x64win.h index 2ea21bb8..797acba3 100644 --- a/src/buildvm_x64win.h +++ b/src/buildvm_x64win.h @@ -13,7 +13,7 @@ #define DASM_SECTION_CODE_SUB 1 #define DASM_MAXSECTION 2 static const unsigned char build_actionlist[13481] = { - 254,1,248,10,137,202,139,173,233,137,114,252,252,15,182,141,233,139,181,233, + 254,1,248,10,137,202,139,173,233,137,114,252,252,15,182,141,233,141,181,233, 139,189,233,139,108,36,96,141,12,202,141,68,194,252,252,59,141,233,15,135, 244,11,248,9,189,237,248,1,137,40,137,104,8,131,192,16,57,200,15,130,244, 1,255,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235, @@ -22,7 +22,7 @@ static const unsigned char build_actionlist[13481] = { 66,4,59,190,233,15,135,244,13,15,182,181,233,133,252,246,15,132,244,248,248, 1,131,193,8,57,209,15,131,244,248,139,121,252,248,137,120,252,252,139,121, 252,252,137,56,131,192,8,199,65,252,252,237,131,252,238,1,15,133,244,1,248, - 2,15,182,141,233,139,181,233,255,139,189,233,141,12,202,252,233,244,9,248, + 2,15,182,141,233,141,181,233,255,139,189,233,141,12,202,252,233,244,9,248, 14,137,113,252,252,72,139,189,233,139,108,36,96,141,68,193,252,248,137,141, 233,141,136,233,137,133,233,59,141,233,72,137,252,250,137,252,233,15,135, 244,15,199,131,233,237,252,255,147,233,199,131,233,237,139,149,233,141,12, @@ -47,7 +47,7 @@ static const unsigned char build_actionlist[13481] = { 131,233,237,255,252,233,244,16,248,20,252,247,198,237,15,132,244,27,131,230, 252,248,41,252,242,72,141,76,49,252,248,139,114,252,252,199,68,10,4,237,252, 233,244,16,248,15,186,237,252,233,244,247,248,13,131,232,8,137,202,137,252, - 249,139,181,233,139,108,36,96,248,11,131,232,4,41,209,193,252,233,3,131,198, + 249,141,181,233,139,108,36,96,248,11,131,232,4,41,209,193,252,233,3,131,198, 4,137,149,233,137,133,233,137,116,36,100,137,202,248,1,137,252,233,232,251, 1,0,139,141,233,255,139,133,233,139,105,252,248,139,113,252,252,41,200,193, 232,3,131,192,1,252,255,165,233,248,28,85,87,86,83,72,131,252,236,40,137, @@ -1028,16 +1028,16 @@ static const char *const extnames[] = { static void build_subroutines(BuildCtx *ctx, int cmov, int sse) { dasm_put(Dst, 0); - dasm_put(Dst, 2, Dt7(->pt), Dt9(->framesize), Dt9(->bc), Dt9(->k), Dt1(->maxstack), LJ_TNIL); + dasm_put(Dst, 2, Dt7(->pt), Dt9(->framesize), sizeof(GCproto), Dt9(->k), Dt1(->maxstack), LJ_TNIL); #if LJ_HASJIT #endif - dasm_put(Dst, 63, FRAME_VARG, -FRAME_VARG, Dt7(->pt), Dt9(->framesize), Dt1(->maxstack), Dt9(->numparams), LJ_TNIL, Dt9(->framesize), Dt9(->bc)); + dasm_put(Dst, 63, FRAME_VARG, -FRAME_VARG, Dt7(->pt), Dt9(->framesize), Dt1(->maxstack), Dt9(->numparams), LJ_TNIL, Dt9(->framesize), sizeof(GCproto)); dasm_put(Dst, 192, Dt9(->k), Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->top), Dt1(->maxstack), DISPATCH_GL(vmstate), ~LJ_VMST_C, DISPATCH_GL(wrapf), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), FRAME_TYPE); dasm_put(Dst, 282, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->top), Dt1(->maxstack), DISPATCH_GL(vmstate), ~LJ_VMST_C, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), FRAME_TYPE); dasm_put(Dst, 365, FRAME_C, DISPATCH_GL(vmstate), ~LJ_VMST_C, Dt1(->base)); dasm_put(Dst, 456, Dt1(->top), Dt1(->cframe), Dt1(->maxstack), LJ_TNIL, Dt1(->top)); dasm_put(Dst, 538, Dt1(->top), Dt1(->glref), Dt2(->vmstate), ~LJ_VMST_C, CFRAME_RAWMASK, 1+1, Dt1(->base), Dt1(->glref), GG_G2DISP, LJ_TFALSE, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP); - dasm_put(Dst, 633, FRAME_P, LJ_TTRUE, LUA_MINSTACK, Dt9(->bc), Dt1(->base), Dt1(->top), Dt1(->base)); + dasm_put(Dst, 633, FRAME_P, LJ_TTRUE, LUA_MINSTACK, sizeof(GCproto), Dt1(->base), Dt1(->top), Dt1(->base)); dasm_put(Dst, 737, Dt1(->top), Dt7(->gate), FRAME_CP, CFRAME_RESUME, Dt1(->glref), GG_G2DISP, Dt1(->cframe), Dt1(->status), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->status), Dt1(->base), Dt1(->top), FRAME_TYPE); dasm_put(Dst, 869, FRAME_CP, FRAME_C, Dt1(->cframe), Dt1(->cframe), Dt1(->glref), GG_G2DISP, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), LJ_TFUNC, Dt7(->gate)); dasm_put(Dst, 987, Dt1(->stack), Dt1(->top), Dt1(->cframe), Dt1(->cframe), FRAME_CP, LJ_TNIL, 0, Dt7(->pt), Dt9(->k), Dt1(->base)); diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index 4e4ccc49..e09c37e9 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc @@ -409,7 +409,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | mov PROTO:RB, LFUNC:RB->pt | mov [BASE-4], PC // Store caller PC. | movzx RA, byte PROTO:RB->framesize - | mov PC, PROTO:RB->bc + | lea PC, [PROTO:RB+sizeof(GCproto)] | mov KBASE, PROTO:RB->k | mov L:RB, SAVE_L | lea RA, [BASE+RA*8] // Top of frame. @@ -462,7 +462,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | jnz <1 |2: | movzx RA, byte PROTO:RB->framesize - | mov PC, PROTO:RB->bc + | lea PC, [PROTO:RB+sizeof(GCproto)] | mov KBASE, PROTO:RB->k | lea RA, [BASE+RA*8] | jmp <9 @@ -666,7 +666,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | sub RC, 8 | mov BASE, RA | mov RA, KBASE - | mov PC, PROTO:RB->bc + | lea PC, [PROTO:RB+sizeof(GCproto)] | mov L:RB, SAVE_L | |->gate_lf_growstack: // Grow stack for fixarg Lua function. diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h index e98d2622..a562361c 100644 --- a/src/buildvm_x86.h +++ b/src/buildvm_x86.h @@ -13,7 +13,7 @@ #define DASM_SECTION_CODE_SUB 1 #define DASM_MAXSECTION 2 static const unsigned char build_actionlist[15185] = { - 254,1,248,10,137,202,139,173,233,137,114,252,252,15,182,141,233,139,181,233, + 254,1,248,10,137,202,139,173,233,137,114,252,252,15,182,141,233,141,181,233, 139,189,233,139,108,36,48,141,12,202,141,68,194,252,252,59,141,233,15,135, 244,11,248,9,189,237,248,1,137,40,137,104,8,131,192,16,57,200,15,130,244, 1,255,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248, @@ -22,7 +22,7 @@ static const unsigned char build_actionlist[15185] = { 4,59,190,233,15,135,244,13,15,182,181,233,133,252,246,15,132,244,248,248, 1,131,193,8,57,209,15,131,244,248,139,121,252,248,137,120,252,252,139,121, 252,252,137,56,131,192,8,199,65,252,252,237,131,252,238,1,15,133,244,1,248, - 2,15,182,141,233,139,181,233,255,139,189,233,141,12,202,252,233,244,9,248, + 2,15,182,141,233,141,181,233,255,139,189,233,141,12,202,252,233,244,9,248, 14,137,113,252,252,139,189,233,139,108,36,48,141,68,193,252,248,137,141,233, 141,136,233,137,133,233,59,141,233,137,124,36,4,137,44,36,15,135,244,15,199, 131,233,237,252,255,147,233,199,131,233,237,139,149,233,141,12,194,252,247, @@ -46,7 +46,7 @@ static const unsigned char build_actionlist[15185] = { 199,66,252,252,237,199,131,233,237,255,252,233,244,16,248,20,252,247,198, 237,15,132,244,27,131,230,252,248,41,252,242,141,76,49,252,248,139,114,252, 252,199,68,10,4,237,252,233,244,16,248,15,186,237,252,233,244,247,248,13, - 131,232,8,137,202,137,252,249,139,181,233,139,108,36,48,248,11,131,232,4, + 131,232,8,137,202,137,252,249,141,181,233,139,108,36,48,248,11,131,232,4, 41,209,193,252,233,3,131,198,4,137,149,233,137,133,233,137,116,36,24,137, 202,248,1,137,252,233,232,251,1,0,139,141,233,255,139,133,233,139,105,252, 248,139,113,252,252,41,200,193,232,3,131,192,1,252,255,165,233,248,28,85, @@ -1107,16 +1107,16 @@ static const char *const extnames[] = { static void build_subroutines(BuildCtx *ctx, int cmov, int sse) { dasm_put(Dst, 0); - dasm_put(Dst, 2, Dt7(->pt), Dt9(->framesize), Dt9(->bc), Dt9(->k), Dt1(->maxstack), LJ_TNIL); + dasm_put(Dst, 2, Dt7(->pt), Dt9(->framesize), sizeof(GCproto), Dt9(->k), Dt1(->maxstack), LJ_TNIL); #if LJ_HASJIT #endif - dasm_put(Dst, 63, FRAME_VARG, -FRAME_VARG, Dt7(->pt), Dt9(->framesize), Dt1(->maxstack), Dt9(->numparams), LJ_TNIL, Dt9(->framesize), Dt9(->bc)); + dasm_put(Dst, 63, FRAME_VARG, -FRAME_VARG, Dt7(->pt), Dt9(->framesize), Dt1(->maxstack), Dt9(->numparams), LJ_TNIL, Dt9(->framesize), sizeof(GCproto)); dasm_put(Dst, 191, Dt9(->k), Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->top), Dt1(->maxstack), DISPATCH_GL(vmstate), ~LJ_VMST_C, DISPATCH_GL(wrapf), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), FRAME_TYPE); dasm_put(Dst, 280, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->top), Dt1(->maxstack), DISPATCH_GL(vmstate), ~LJ_VMST_C, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), FRAME_TYPE); dasm_put(Dst, 362, FRAME_C, DISPATCH_GL(vmstate), ~LJ_VMST_C, Dt1(->base)); dasm_put(Dst, 453, Dt1(->top), Dt1(->cframe), Dt1(->maxstack), LJ_TNIL, Dt1(->top)); dasm_put(Dst, 532, Dt1(->top), Dt1(->glref), Dt2(->vmstate), ~LJ_VMST_C, CFRAME_RAWMASK, 1+1, Dt1(->base), Dt1(->glref), GG_G2DISP, LJ_TFALSE, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP); - dasm_put(Dst, 622, FRAME_P, LJ_TTRUE, LUA_MINSTACK, Dt9(->bc), Dt1(->base), Dt1(->top), Dt1(->base)); + dasm_put(Dst, 622, FRAME_P, LJ_TTRUE, LUA_MINSTACK, sizeof(GCproto), Dt1(->base), Dt1(->top), Dt1(->base)); dasm_put(Dst, 725, Dt1(->top), Dt7(->gate), FRAME_CP, CFRAME_RESUME, Dt1(->glref), GG_G2DISP, Dt1(->cframe), Dt1(->status), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->status), Dt1(->base), Dt1(->top), FRAME_TYPE); dasm_put(Dst, 845, FRAME_CP, FRAME_C, Dt1(->cframe), Dt1(->cframe), Dt1(->glref), GG_G2DISP, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), LJ_TFUNC, Dt7(->gate)); dasm_put(Dst, 948, Dt1(->stack), Dt1(->top), Dt1(->cframe), Dt1(->cframe), FRAME_CP, LJ_TNIL, Dt7(->pt), Dt9(->k), LJ_TSTR); diff --git a/src/lib_jit.c b/src/lib_jit.c index 33571b17..fb551315 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c @@ -210,7 +210,7 @@ LJLIB_CF(jit_util_funcbc) GCproto *pt = check_Lproto(L, 0); BCPos pc = (BCPos)lj_lib_checkint(L, 2) - 1; if (pc < pt->sizebc) { - BCIns ins = proto_ins(pt, pc); + BCIns ins = proto_bc(pt)[pc]; BCOp op = bc_op(ins); lua_assert(op < BC__MAX); setintV(L->top, ins); diff --git a/src/lj_obj.h b/src/lj_obj.h index d8aab90a..f243a75b 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h @@ -351,7 +351,6 @@ typedef struct GCproto { MSize sizebc; /* Number of bytecode instructions. */ GCRef gclist; MRef k; /* Split constant array (points to the middle). */ - MRef bc; /* Array of bytecode instructions. */ MRef uv; /* Upvalue list. local slot|0x8000 or parent uv idx. */ MSize sizekgc; /* Number of collectable constants. */ MSize sizekn; /* Number of lua_Number constants. */ @@ -381,11 +380,7 @@ typedef struct GCproto { gcref(mref((pt)->k, GCRef)[(idx)])) #define proto_knum(pt, idx) \ check_exp((uintptr_t)(idx) < (pt)->sizekn, mref((pt)->k, lua_Number)[(idx)]) -#define proto_bc(pt) (mref((pt)->bc, BCIns)) -#define proto_ins(pt, pos) \ - check_exp((uintptr_t)(pos) < (pt)->sizebc, proto_bc(pt)[(pos)]) -#define proto_insptr(pt, pos) \ - check_exp((uintptr_t)(pos) < (pt)->sizebc, &proto_bc(pt)[(pos)]) +#define proto_bc(pt) ((BCIns *)((char *)(pt) + sizeof(GCproto))) #define proto_bcpos(pt, pc) ((BCPos)((pc) - proto_bc(pt))) #define proto_uv(pt) (mref((pt)->uv, uint16_t)) diff --git a/src/lj_parse.c b/src/lj_parse.c index 5cb3ac3b..ed695e19 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c @@ -1033,7 +1033,6 @@ static void fs_fixup_bc(FuncState *fs, GCproto *pt, BCIns *bc, BCLine *lineinfo) { MSize i, n = fs->pc; BCInsLine *base = fs->bcbase; - setmref(pt->bc, bc); setmref(pt->lineinfo, lineinfo); pt->sizebc = n; bc[n] = ~0u; /* Close potentially uninitialized gap between bc and kgc. */