From 1fa5375d28472730752d9d4df33bce21a766ac53 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Tue, 19 Dec 2017 11:32:59 +0000 Subject: [PATCH 1/2] Fix compiler warning & reusevm generated code --- src/lj_trace.c | 5 -- src/reusevm/lj_vm.S | 211 ++++++++++++++++---------------------------- 2 files changed, 74 insertions(+), 142 deletions(-) diff --git a/src/lj_trace.c b/src/lj_trace.c index 5be350ad17..e49f048609 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c @@ -347,7 +347,6 @@ static void penalty_pc(jit_State *J, GCproto *pt, BCIns *pc, TraceError e) /* Start tracing. */ static void trace_start(jit_State *J) { - lua_State *L; TraceNo traceno; if ((J->pt->flags & PROTO_NOJIT)) { /* JIT disabled for this proto? */ @@ -390,7 +389,6 @@ static void trace_start(jit_State *J) J->ktrace = 0; setgcref(J->cur.startpt, obj2gco(J->pt)); - L = J->L; lj_record_setup(J); } @@ -402,7 +400,6 @@ static void trace_stop(jit_State *J) GCproto *pt = &gcref(J->cur.startpt)->pt; TraceNo traceno = J->cur.traceno; GCtrace *T = J->curfinal; - lua_State *L; int i; switch (op) { @@ -459,8 +456,6 @@ static void trace_stop(jit_State *J) for (i = 0; i < PENALTY_SLOTS; i++) if (mref(J->penalty[i].pc, const BCIns) == pc) J->penalty[i].val = PENALTY_MIN; - - L = J->L; } /* Start a new root trace for down-recursion. */ diff --git a/src/reusevm/lj_vm.S b/src/reusevm/lj_vm.S index 9e4405c3f2..c0abc094f8 100644 --- a/src/reusevm/lj_vm.S +++ b/src/reusevm/lj_vm.S @@ -502,7 +502,7 @@ lj_BC_USETV: .byte 232,72,131,195,4,193,232,16,65,255,36,238,72,137,200,72 .byte 193,248,47,131,232,252,131,248,246,118,222,72,193,225,17,72 .byte 193,233,17,246,65,8,3,116,208,72,137,238,72,137,213,73 - .byte 141,190,192,240,255,255 + .byte 141,190,168,240,255,255 call lj_gc_barrieruv .byte 72,137,234,235,185 @@ -516,7 +516,7 @@ lj_BC_USETS: .byte 0,0,0,128,253,255,73,9,203,76,137,24,246,69,8,4 .byte 117,19,139,3,15,182,204,15,182,232,72,131,195,4,193,232 .byte 16,65,255,36,238,246,65,8,3,116,231,128,125,10,0,116 - .byte 225,72,137,213,72,137,198,73,141,190,192,240,255,255 + .byte 225,72,137,213,72,137,198,73,141,190,168,240,255,255 call lj_gc_barrieruv .byte 72,137,234,235,202 @@ -569,8 +569,8 @@ lj_BC_FNEW: .type lj_BC_TNEW, @function .size lj_BC_TNEW, 122 lj_BC_TNEW: - .byte 72,139,108,36,16,72,137,85,32,73,139,142,224,240,255,255 - .byte 73,59,142,232,240,255,255,72,137,92,36,24,115,78,137,194 + .byte 72,139,108,36,16,72,137,85,32,73,139,142,200,240,255,255 + .byte 73,59,142,208,240,255,255,72,137,92,36,24,115,78,137,194 .byte 37,255,7,0,0,193,234,11,61,255,7,0,0,116,54,72 .byte 137,239,137,198 call lj_tab_new @@ -586,8 +586,8 @@ lj_BC_TNEW: .type lj_BC_TDUP, @function .size lj_BC_TDUP, 106 lj_BC_TDUP: - .byte 72,247,208,72,139,108,36,16,73,139,142,224,240,255,255,72 - .byte 137,92,36,24,73,59,142,232,240,255,255,72,137,85,32,115 + .byte 72,247,208,72,139,108,36,16,73,139,142,200,240,255,255,72 + .byte 137,92,36,24,73,59,142,208,240,255,255,72,137,85,32,115 .byte 56,73,139,52,199,72,137,239 call lj_tab_dup .byte 72,139,85,32,15,182,75,253,73,187,0,0,0,0,0,0 @@ -685,7 +685,7 @@ lj_BC_TSETV: .byte 238,76,139,85,32,77,133,210,116,215,65,246,66,10,2,15 .byte 132,73,17,0,0,235,202,65,131,251,251,15,133,61,17,0 .byte 0,72,193,224,17,72,193,232,17,235,66,128,101,8,251,77 - .byte 139,150,16,241,255,255,73,137,174,16,241,255,255,76,137,85 + .byte 139,150,248,240,255,255,73,137,174,248,240,255,255,76,137,85 .byte 24,235,164 .globl lj_BC_TSETS @@ -708,8 +708,8 @@ lj_BC_TSETS: .byte 137,238,72,137,92,36,24 call lj_tab_newkey .byte 72,139,124,36,16,72,139,87,32,73,137,194,15,182,75,253 - .byte 233,118,255,255,255,128,101,8,251,77,139,158,16,241,255,255 - .byte 73,137,174,16,241,255,255,76,137,93,24,233,101,255,255,255 + .byte 233,118,255,255,255,128,101,8,251,77,139,158,248,240,255,255 + .byte 73,137,174,248,240,255,255,76,137,93,24,233,101,255,255,255 .globl lj_BC_TSETB .hidden lj_BC_TSETB @@ -723,7 +723,7 @@ lj_BC_TSETB: .byte 139,28,202,76,137,24,139,3,15,182,204,15,182,232,72,131 .byte 195,4,193,232,16,65,255,36,238,76,139,85,32,77,133,210 .byte 116,215,65,246,66,10,2,15,132,159,15,0,0,235,202,128 - .byte 101,8,251,77,139,150,16,241,255,255,73,137,174,16,241,255 + .byte 101,8,251,77,139,150,248,240,255,255,73,137,174,248,240,255 .byte 255,76,137,85,24,235,184 .globl lj_BC_TSETM @@ -741,8 +741,8 @@ lj_BC_TSETM: .byte 24 call lj_tab_reasize .byte 72,139,85,32,15,182,75,253,15,183,67,254,233,121,255,255 - .byte 255,128,101,8,251,73,139,134,16,241,255,255,73,137,174,16 - .byte 241,255,255,72,137,69,24,233,120,255,255,255 + .byte 255,128,101,8,251,73,139,134,248,240,255,255,73,137,174,248 + .byte 240,255,255,72,137,69,24,233,120,255,255,255 .globl lj_BC_TSETR .hidden lj_BC_TSETR @@ -753,8 +753,8 @@ lj_BC_TSETR: .byte 237,17,242,15,44,4,194,246,69,8,4,117,42,59,69,48 .byte 15,131,84,15,0,0,193,224,3,72,3,69,16,76,139,28 .byte 202,76,137,24,139,3,15,182,204,15,182,232,72,131,195,4 - .byte 193,232,16,65,255,36,238,128,101,8,251,77,139,150,16,241 - .byte 255,255,73,137,174,16,241,255,255,76,137,85,24,235,190 + .byte 193,232,16,65,255,36,238,128,101,8,251,77,139,150,248,240 + .byte 255,255,73,137,174,248,240,255,255,76,137,85,24,235,190 .globl lj_BC_CALLM .hidden lj_BC_CALLM @@ -1020,7 +1020,7 @@ lj_BC_ILOOP: .size lj_BC_JLOOP, 50 lj_BC_JLOOP: .byte 73,139,142,240,244,255,255,72,139,4,193,72,139,64,88,72 - .byte 139,108,36,16,73,137,150,32,242,255,255,73,137,174,96,241 + .byte 139,108,36,16,73,137,150,16,242,255,255,73,137,174,80,241 .byte 255,255,72,131,236,16,76,137,100,36,16,76,137,108,36,8 .byte 255,224 @@ -1097,13 +1097,9 @@ lj_BC_FUNCC: .byte 72,139,106,240,72,193,229,17,72,193,237,17,76,139,125,40 .byte 72,139,108,36,16,72,141,68,194,248,72,137,85,32,72,141 .byte 136,160,0,0,0,72,59,77,48,72,137,69,40,72,137,239 - .byte 15,135,31,2,0,0,65,199,134,64,241,255,255,254,255,255 -<<<<<<< HEAD - .byte 255,65,255,215,72,139,85,32,73,137,174,32,242,255,255,65 -======= - .byte 255,65,255,215,72,139,85,32,73,137,174,24,242,255,255,65 ->>>>>>> fix-alloc - .byte 199,134,64,241,255,255,255,255,255,255,72,141,12,194,72,247 + .byte 15,135,31,2,0,0,65,199,134,40,241,255,255,254,255,255 + .byte 255,65,255,215,72,139,85,32,73,137,174,8,242,255,255,65 + .byte 199,134,40,241,255,255,255,255,255,255,72,141,12,194,72,247 .byte 217,72,3,77,40,72,139,90,248,233,156,0,0,0 .globl lj_BC_FUNCCW @@ -1114,14 +1110,9 @@ lj_BC_FUNCCW: .byte 72,139,106,240,72,193,229,17,72,193,237,17,76,139,125,40 .byte 72,139,108,36,16,72,141,68,194,248,72,137,85,32,72,141 .byte 136,160,0,0,0,72,59,77,48,72,137,69,40,76,137,254 - .byte 72,137,239,15,135,174,1,0,0,65,199,134,64,241,255,255 -<<<<<<< HEAD - .byte 254,255,255,255,65,255,150,8,242,255,255,72,139,85,32,73 - .byte 137,174,32,242,255,255,65,199,134,64,241,255,255,255,255,255 -======= - .byte 254,255,255,255,65,255,150,0,242,255,255,72,139,85,32,73 - .byte 137,174,24,242,255,255,65,199,134,64,241,255,255,255,255,255 ->>>>>>> fix-alloc + .byte 72,137,239,15,135,174,1,0,0,65,199,134,40,241,255,255 + .byte 254,255,255,255,65,255,150,240,241,255,255,72,139,85,32,73 + .byte 137,174,8,242,255,255,65,199,134,40,241,255,255,255,255,255 .byte 255,72,141,12,194,72,247,217,72,3,77,40,72,139,90,248 .byte 235,42 @@ -1147,7 +1138,7 @@ lj_vm_returnc: .type lj_vm_return, @function .size lj_vm_return, 83 lj_vm_return: - .byte 72,131,243,1,247,195,3,0,0,0,117,177,65,199,134,64 + .byte 72,131,243,1,247,195,3,0,0,0,117,177,65,199,134,40 .byte 241,255,255,254,255,255,255,72,131,227,248,72,41,211,72,247 .byte 219,131,232,1,116,17,72,139,44,10,72,137,106,240,72,131 .byte 194,8,131,232,1,117,239,72,139,108,36,16,72,137,93,32 @@ -1218,9 +1209,9 @@ lj_vm_unwind_ff: .size lj_vm_unwind_ff_eh, 73 lj_vm_unwind_ff_eh: .byte 72,139,108,36,16,184,2,0,0,0,72,139,85,32,76,139 - .byte 117,16,73,129,198,64,15,0,0,72,139,90,248,72,185,255 + .byte 117,16,73,129,198,88,15,0,0,72,139,90,248,72,185,255 .byte 255,255,255,255,127,255,255,72,139,42,72,137,74,240,72,137 - .byte 106,248,72,199,193,240,255,255,255,65,199,134,64,241,255,255 + .byte 106,248,72,199,193,240,255,255,255,65,199,134,40,241,255,255 .byte 255,255,255,255,233,181,254,255,255 .globl lj_vm_growstack_c @@ -1257,14 +1248,10 @@ lj_vm_growstack_f: lj_vm_resume: .byte 85,83,65,87,65,86,65,85,65,84,72,131,236,40,72,137 .byte 253,72,137,124,36,16,72,137,241,187,5,0,0,0,49,192 - .byte 76,141,124,36,1,76,139,117,16,73,129,198,64,15,0,0 + .byte 76,141,124,36,1,76,139,117,16,73,129,198,88,15,0,0 .byte 72,137,68,36,24,72,137,68,36,32,137,68,36,8,137,68 .byte 36,12,76,137,125,80,56,69,11,15,132,153,0,0,0,73 -<<<<<<< HEAD - .byte 137,174,32,242,255,255,65,199,134,64,241,255,255,255,255,255 -======= - .byte 137,174,24,242,255,255,65,199,134,64,241,255,255,255,255,255 ->>>>>>> fix-alloc + .byte 137,174,8,242,255,255,65,199,134,40,241,255,255,255,255,255 .byte 255,136,69,11,72,139,85,32,72,139,69,40,72,41,200,193 .byte 232,3,131,192,1,72,41,209,72,139,90,248,137,4,36,247 .byte 195,3,0,0,0,15,132,205,247,255,255,233,219,253,255,255 @@ -1285,12 +1272,8 @@ lj_vm_call: .byte 85,83,65,87,65,86,65,85,65,84,72,131,236,40,187,1 .byte 0,0,0,137,84,36,8,72,137,253,72,137,124,36,16,72 .byte 137,241,76,139,117,16,76,139,125,80,76,137,124,36,32,72 - .byte 137,108,36,24,73,129,198,64,15,0,0,72,137,101,80,73 -<<<<<<< HEAD - .byte 137,174,32,242,255,255,65,199,134,64,241,255,255,255,255,255 -======= - .byte 137,174,24,242,255,255,65,199,134,64,241,255,255,255,255,255 ->>>>>>> fix-alloc + .byte 137,108,36,24,73,129,198,88,15,0,0,72,137,101,80,73 + .byte 137,174,8,242,255,255,65,199,134,40,241,255,255,255,255,255 .byte 255,72,139,85,32,72,1,203,72,41,211,72,139,69,40,72 .byte 41,200,193,232,3,131,192,1 @@ -1318,12 +1301,8 @@ lj_vm_cpcall: .byte 85,83,65,87,65,86,65,85,65,84,72,131,236,40,72,137 .byte 253,72,137,124,36,16,72,137,108,36,24,76,139,125,56,76 .byte 43,125,40,76,139,117,16,199,68,36,12,0,0,0,0,68 - .byte 137,124,36,8,73,129,198,64,15,0,0,76,139,125,80,76 -<<<<<<< HEAD - .byte 137,124,36,32,72,137,101,80,73,137,174,32,242,255,255,255 -======= - .byte 137,124,36,32,72,137,101,80,73,137,174,24,242,255,255,255 ->>>>>>> fix-alloc + .byte 137,124,36,8,73,129,198,88,15,0,0,76,139,125,80,76 + .byte 137,124,36,32,72,137,101,80,73,137,174,8,242,255,255,255 .byte 209,72,133,192,15,132,27,253,255,255,72,137,193,187,5,0 .byte 0,0,233,56,255,255,255 @@ -1356,7 +1335,7 @@ lj_cont_cat: lj_vmeta_tgets: .byte 73,187,0,0,0,0,0,128,253,255,76,9,216,72,137,4 .byte 36,72,141,4,36,128,123,252,54,117,53,72,185,0,0,0 - .byte 0,0,0,250,255,72,9,233,73,141,174,152,241,255,255,72 + .byte 0,0,0,250,255,72,9,233,73,141,174,136,241,255,255,72 .byte 137,77,0,235,35 .globl lj_vmeta_tgetb @@ -1406,7 +1385,7 @@ lj_vmeta_tgetr: lj_vmeta_tsets: .byte 73,187,0,0,0,0,0,128,253,255,76,9,216,72,137,4 .byte 36,72,141,4,36,128,123,252,55,117,53,72,185,0,0,0 - .byte 0,0,0,250,255,72,9,233,73,141,174,152,241,255,255,72 + .byte 0,0,0,250,255,72,9,233,73,141,174,136,241,255,255,72 .byte 137,77,0,235,35 .globl lj_vmeta_tsetb @@ -1641,13 +1620,13 @@ lj_ff_getmetatable: .byte 73,137,235,72,193,229,17,72,193,237,17,73,193,251,47,65 .byte 131,251,244,117,113,72,139,109,32,72,133,237,72,199,66,240 .byte 255,255,255,255,15,132,144,7,0,0,72,184,0,0,0,0 - .byte 0,0,250,255,72,9,232,72,137,66,240,73,139,134,184,242 + .byte 0,0,250,255,72,9,232,72,137,66,240,73,139,134,168,242 .byte 255,255,139,77,52,35,72,12,73,187,0,0,0,0,0,128 .byte 253,255,76,9,216,107,201,24,72,3,77,40,72,57,65,8 .byte 116,14,72,139,73,16,72,133,201,117,241,233,74,7,0,0 .byte 72,139,41,72,131,253,255,15,132,61,7,0,0,72,137,106 .byte 240,233,52,7,0,0,65,131,251,243,116,137,65,131,251,242 - .byte 119,6,65,187,242,255,255,255,65,247,211,75,139,172,222,224 + .byte 119,6,65,187,242,255,255,255,65,247,211,75,139,172,222,208 .byte 242,255,255,233,113,255,255,255 .globl lj_ff_setmetatable @@ -1661,8 +1640,8 @@ lj_ff_setmetatable: .byte 18,0,0,72,139,74,8,73,137,203,72,193,225,17,72,193 .byte 233,17,73,193,251,47,65,131,251,244,15,133,21,18,0,0 .byte 72,137,77,32,72,139,90,248,76,137,82,240,246,69,8,4 - .byte 116,22,128,101,8,251,73,139,134,16,241,255,255,73,137,174 - .byte 16,241,255,255,72,137,69,24,233,149,6,0,0 + .byte 116,22,128,101,8,251,73,139,134,248,240,255,255,73,137,174 + .byte 248,240,255,255,72,137,69,24,233,149,6,0,0 .globl lj_ff_rawget .hidden lj_ff_rawget @@ -1694,12 +1673,8 @@ lj_ff_tostring: .byte 131,248,2,15,130,108,17,0,0,72,139,90,248,72,139,42 .byte 73,137,235,73,193,251,47,65,131,251,251,117,9,72,137,106 .byte 240,233,252,5,0,0,65,131,251,242,15,135,64,17,0,0 -<<<<<<< HEAD - .byte 73,131,190,80,243,255,255,0,15,133,55,17,0,0,73,139 -======= - .byte 73,131,190,72,243,255,255,0,15,133,55,17,0,0,73,139 ->>>>>>> fix-alloc - .byte 174,224,240,255,255,73,59,174,232,240,255,255,114,5,232,217 + .byte 73,131,190,56,243,255,255,0,15,133,55,17,0,0,73,139 + .byte 174,200,240,255,255,73,59,174,208,240,255,255,114,5,232,217 .byte 17,0,0,72,139,108,36,16,72,137,85,32,72,137,92,36 .byte 24,72,137,214,72,137,239 call lj_strfmt_num @@ -1785,7 +1760,7 @@ lj_ff_ipairs: .size lj_ff_pcall, 64 lj_ff_pcall: .byte 131,248,2,15,130,7,15,0,0,72,141,74,16,131,232,1 - .byte 187,22,0,0,0,65,15,182,174,129,241,255,255,72,193,237 + .byte 187,22,0,0,0,65,15,182,174,113,241,255,255,72,193,237 .byte 4,72,131,229,1,72,1,235,73,137,199,74,139,108,249,232 .byte 74,137,108,249,240,73,131,239,1,119,240,233,3,246,255,255 @@ -1816,11 +1791,7 @@ lj_ff_coroutine_resume: .byte 203,116,17,72,139,4,43,72,137,67,248,72,131,235,8,72 .byte 57,203,117,239,72,137,206,72,139,60,36,232,12,244,255,255 .byte 72,139,108,36,16,72,139,28,36,72,139,85,32,73,137,174 -<<<<<<< HEAD - .byte 32,242,255,255,65,199,134,64,241,255,255,255,255,255,255,131 -======= - .byte 24,242,255,255,65,199,134,64,241,255,255,255,255,255,255,131 ->>>>>>> fix-alloc + .byte 8,242,255,255,65,199,134,40,241,255,255,255,255,255,255,131 .byte 248,1,119,104,72,139,75,32,76,139,123,40,72,137,75,40 .byte 76,137,251,72,41,203,116,35,72,141,4,26,193,235,3,72 .byte 59,69,48,119,110,72,137,213,72,41,205,72,139,1,72,137 @@ -1850,12 +1821,8 @@ lj_ff_coroutine_wrap_aux: .byte 32,72,137,85,40,72,141,108,194,240,72,41,221,72,57,203 .byte 116,17,72,139,4,43,72,137,67,248,72,131,235,8,72,57 .byte 203,117,239,72,137,206,72,139,60,36,232,154,242,255,255,72 -<<<<<<< HEAD - .byte 139,108,36,16,72,139,28,36,72,139,85,32,73,137,174,32 -======= - .byte 139,108,36,16,72,139,28,36,72,139,85,32,73,137,174,24 ->>>>>>> fix-alloc - .byte 242,255,255,65,199,134,64,241,255,255,255,255,255,255,131,248 + .byte 139,108,36,16,72,139,28,36,72,139,85,32,73,137,174,8 + .byte 242,255,255,65,199,134,40,241,255,255,255,255,255,255,131,248 .byte 1,119,85,72,139,75,32,76,139,123,40,72,137,75,40,76 .byte 137,251,72,41,203,116,35,72,141,4,26,193,235,3,72,59 .byte 69,48,119,63,72,137,213,72,41,205,72,139,1,72,137,4 @@ -2182,7 +2149,7 @@ lj_ff_string_byte: .type lj_ff_string_char, @function .size lj_ff_string_char, 76 lj_ff_string_char: - .byte 73,139,174,224,240,255,255,73,59,174,232,240,255,255,114,5 + .byte 73,139,174,200,240,255,255,73,59,174,208,240,255,255,114,5 .byte 232,223,6,0,0,131,248,2,15,133,31,6,0,0,76,139 .byte 26,73,193,251,47,65,131,251,242,15,131,14,6,0,0,242 .byte 15,44,42,129,253,255,0,0,0,15,135,254,5,0,0,137 @@ -2210,7 +2177,7 @@ lj_fff_resstr: .type lj_ff_string_sub, @function .size lj_ff_string_sub, 174 lj_ff_string_sub: - .byte 73,139,174,224,240,255,255,73,59,174,232,240,255,255,114,5 + .byte 73,139,174,200,240,255,255,73,59,174,208,240,255,255,114,5 .byte 232,89,6,0,0,65,186,255,255,255,255,131,248,3,15,130 .byte 147,5,0,0,118,24,76,139,90,16,73,193,251,47,65,131 .byte 251,242,15,131,127,5,0,0,242,68,15,44,82,16,72,139 @@ -2234,11 +2201,11 @@ lj_fff_emptystr: .type lj_ff_string_reverse, @function .size lj_ff_string_reverse, 108 lj_ff_string_reverse: - .byte 131,248,2,15,130,251,4,0,0,73,139,174,224,240,255,255 - .byte 73,59,174,232,240,255,255,114,5,232,157,5,0,0,72,139 + .byte 131,248,2,15,130,251,4,0,0,73,139,174,200,240,255,255 + .byte 73,59,174,208,240,255,255,114,5,232,157,5,0,0,72,139 .byte 50,73,137,243,72,193,230,17,72,193,238,17,73,193,251,47 .byte 65,131,251,251,15,133,202,4,0,0,72,139,108,36,16,73 - .byte 141,190,72,241,255,255,72,137,85,32,72,139,71,16,72,137 + .byte 141,190,56,241,255,255,72,137,85,32,72,139,71,16,72,137 .byte 111,24,72,137,7,72,137,92,36,24 call lj_buf_putstr_reverse .byte 72,137,199 @@ -2250,11 +2217,11 @@ lj_ff_string_reverse: .type lj_ff_string_lower, @function .size lj_ff_string_lower, 108 lj_ff_string_lower: - .byte 131,248,2,15,130,143,4,0,0,73,139,174,224,240,255,255 - .byte 73,59,174,232,240,255,255,114,5,232,49,5,0,0,72,139 + .byte 131,248,2,15,130,143,4,0,0,73,139,174,200,240,255,255 + .byte 73,59,174,208,240,255,255,114,5,232,49,5,0,0,72,139 .byte 50,73,137,243,72,193,230,17,72,193,238,17,73,193,251,47 .byte 65,131,251,251,15,133,94,4,0,0,72,139,108,36,16,73 - .byte 141,190,72,241,255,255,72,137,85,32,72,139,71,16,72,137 + .byte 141,190,56,241,255,255,72,137,85,32,72,139,71,16,72,137 .byte 111,24,72,137,7,72,137,92,36,24 call lj_buf_putstr_lower .byte 72,137,199 @@ -2266,11 +2233,11 @@ lj_ff_string_lower: .type lj_ff_string_upper, @function .size lj_ff_string_upper, 108 lj_ff_string_upper: - .byte 131,248,2,15,130,35,4,0,0,73,139,174,224,240,255,255 - .byte 73,59,174,232,240,255,255,114,5,232,197,4,0,0,72,139 + .byte 131,248,2,15,130,35,4,0,0,73,139,174,200,240,255,255 + .byte 73,59,174,208,240,255,255,114,5,232,197,4,0,0,72,139 .byte 50,73,137,243,72,193,230,17,72,193,238,17,73,193,251,47 .byte 65,131,251,251,15,133,242,3,0,0,72,139,108,36,16,73 - .byte 141,190,72,241,255,255,72,137,85,32,72,139,71,16,72,137 + .byte 141,190,56,241,255,255,72,137,85,32,72,139,71,16,72,137 .byte 111,24,72,137,7,72,137,92,36,24 call lj_buf_putstr_upper .byte 72,137,199 @@ -2475,7 +2442,7 @@ lj_fff_gcstep: .type lj_vm_record, @function .size lj_vm_record, 17 lj_vm_record: - .byte 168,16,117,56,168,12,116,52,65,255,142,240,241,255,255,235 + .byte 168,16,117,56,168,12,116,52,65,255,142,224,241,255,255,235 .byte 43 .globl lj_vm_rethook @@ -2483,15 +2450,15 @@ lj_vm_record: .type lj_vm_rethook, @function .size lj_vm_rethook, 14 lj_vm_rethook: - .byte 65,15,182,134,129,241,255,255,168,16,117,59,235,29 + .byte 65,15,182,134,113,241,255,255,168,16,117,59,235,29 .globl lj_vm_inshook .hidden lj_vm_inshook .type lj_vm_inshook, @function .size lj_vm_inshook, 73 lj_vm_inshook: - .byte 65,15,182,134,129,241,255,255,168,16,117,45,168,12,116,41 - .byte 65,255,142,240,241,255,255,116,4,168,4,116,28,72,139,108 + .byte 65,15,182,134,113,241,255,255,168,16,117,45,168,12,116,41 + .byte 65,255,142,224,241,255,255,116,4,168,4,116,28,72,139,108 .byte 36,16,72,137,85,32,72,137,222,72,137,239 call lj_dispatch_ins .byte 72,139,85,32,15,182,75,253,15,182,107,252,15,183,67,254 @@ -2511,7 +2478,7 @@ lj_cont_hook: lj_vm_hotloop: .byte 72,139,106,240,72,193,229,17,72,193,237,17,72,139,109,32 .byte 15,182,69,163,72,141,4,194,72,139,108,36,16,72,137,85 - .byte 32,72,137,69,40,72,137,222,73,141,190,96,243,255,255,73 + .byte 32,72,137,69,40,72,137,222,73,141,190,80,243,255,255,73 .byte 137,174,224,243,255,255,72,137,92,36,24 call lj_trace_hot .byte 235,153 @@ -2546,10 +2513,10 @@ lj_cont_stitch: .byte 40,72,137,41,72,131,192,8,72,131,193,8,65,131,234,1 .byte 117,236,15,182,67,253,15,182,107,255,72,1,232,72,141,68 .byte 194,248,72,57,200,119,82,77,133,219,15,132,121,231,255,255 - .byte 65,15,183,107,104,65,15,183,67,106,57,232,15,132,103,231 + .byte 65,15,183,107,116,65,15,183,67,118,57,232,15,132,103,231 .byte 255,255,133,192,15,133,153,223,255,255,73,137,174,60,255,255 .byte 255,72,139,108,36,16,72,137,85,32,72,137,222,73,141,190 - .byte 96,243,255,255,73,137,174,224,243,255,255 + .byte 80,243,255,255,73,137,174,224,243,255,255 call lj_dispatch_stitch .byte 72,139,85,32,233,48,231,255,255,72,199,1,255,255,255,255 .byte 72,131,193,8,235,156 @@ -2561,31 +2528,18 @@ lj_cont_stitch: lj_vm_exit_handler: .byte 65,85,65,84,65,83,65,82,65,81,65,80,87,86,85,72 .byte 141,108,36,88,85,83,82,81,80,15,182,69,248,138,101,240 - .byte 76,137,125,248,76,137,117,240,65,139,142,64,241,255,255,65 - .byte 199,134,64,241,255,255,252,255,255,255,65,137,134,60,255,255 -<<<<<<< HEAD - .byte 255,65,137,142,56,255,255,255,65,137,142,72,241,255,255,72 + .byte 76,137,125,248,76,137,117,240,65,139,142,40,241,255,255,65 + .byte 199,134,40,241,255,255,252,255,255,255,65,137,134,60,255,255 + .byte 255,65,137,142,56,255,255,255,65,137,142,48,241,255,255,72 .byte 129,236,128,0,0,0,72,131,197,128,242,68,15,17,125,248 .byte 242,68,15,17,117,240,242,68,15,17,109,232,242,68,15,17 .byte 101,224,242,68,15,17,93,216,242,68,15,17,85,208,242,68 .byte 15,17,77,200,242,68,15,17,69,192,242,15,17,125,184,242 .byte 15,17,117,176,242,15,17,109,168,242,15,17,101,160,242,15 .byte 17,93,152,242,15,17,85,144,242,15,17,77,136,242,15,17 - .byte 69,128,73,139,174,32,242,255,255,73,139,150,40,242,255,255 - .byte 73,137,174,232,243,255,255,72,137,85,32,72,137,230,73,141 - .byte 190,104,243,255,255,73,199,134,40,242,255,255,0,0,0,0 -======= - .byte 255,65,137,142,56,255,255,255,72,129,236,128,0,0,0,72 - .byte 131,197,128,242,68,15,17,125,248,242,68,15,17,117,240,242 - .byte 68,15,17,109,232,242,68,15,17,101,224,242,68,15,17,93 - .byte 216,242,68,15,17,85,208,242,68,15,17,77,200,242,68,15 - .byte 17,69,192,242,15,17,125,184,242,15,17,117,176,242,15,17 - .byte 109,168,242,15,17,101,160,242,15,17,93,152,242,15,17,85 - .byte 144,242,15,17,77,136,242,15,17,69,128,73,139,174,24,242 - .byte 255,255,73,139,150,32,242,255,255,73,137,174,224,243,255,255 - .byte 72,137,85,32,72,137,230,73,141,190,96,243,255,255,73,199 - .byte 134,32,242,255,255,0,0,0,0 ->>>>>>> fix-alloc + .byte 69,128,73,139,174,8,242,255,255,73,139,150,16,242,255,255 + .byte 73,137,174,224,243,255,255,72,137,85,32,72,137,230,73,141 + .byte 190,80,243,255,255,73,199,134,16,242,255,255,0,0,0,0 call lj_trace_exit .byte 72,139,77,80,72,131,225,252,72,137,105,16,72,139,85,32 .byte 72,139,89,24,235,25 @@ -2595,31 +2549,18 @@ lj_vm_exit_handler: .type lj_vm_exit_interp, @function .size lj_vm_exit_interp, 191 lj_vm_exit_interp: -<<<<<<< HEAD - .byte 72,141,76,36,16,69,139,150,64,241,255,255,65,131,250,1 - .byte 114,7,69,137,150,72,241,255,255,76,139,105,248,76,139,33 + .byte 72,141,76,36,16,69,139,150,40,241,255,255,65,131,250,1 + .byte 114,7,69,137,150,48,241,255,255,76,139,105,248,76,139,33 .byte 72,137,204,133,192,15,136,134,0,0,0,72,139,108,36,16 .byte 137,4,36,76,139,122,240,73,193,231,17,73,193,239,17,77 - .byte 139,127,32,77,139,127,184,72,137,85,32,73,199,134,40,242 - .byte 255,255,0,0,0,0,69,139,150,64,241,255,255,65,199,134 - .byte 64,241,255,255,255,255,255,255,139,3,15,182,204,15,182,232 + .byte 139,127,32,77,139,127,184,72,137,85,32,73,199,134,16,242 + .byte 255,255,0,0,0,0,69,139,150,40,241,255,255,65,199,134 + .byte 40,241,255,255,255,255,255,255,139,3,15,182,204,15,182,232 .byte 72,131,195,4,193,232,16,131,253,89,114,8,131,253,97,115 .byte 7,139,4,36,65,255,36,238,72,139,66,248,169,3,0,0 .byte 0,117,238,15,182,64,253,72,247,216,76,139,124,194,224,73 .byte 193,231,17,73,193,239,17,77,139,127,32,77,139,127,184,235 .byte 208,72,247,216,72,137,239,72,137,198 -======= - .byte 72,141,76,36,16,76,139,105,248,76,139,33,72,137,204,133 - .byte 192,15,136,127,0,0,0,72,139,108,36,16,137,4,36,76 - .byte 139,122,240,73,193,231,17,73,193,239,17,77,139,127,32,77 - .byte 139,127,184,72,137,85,32,73,199,134,32,242,255,255,0,0 - .byte 0,0,65,199,134,64,241,255,255,255,255,255,255,139,3,15 - .byte 182,204,15,182,232,72,131,195,4,193,232,16,131,253,89,114 - .byte 8,131,253,97,115,7,139,4,36,65,255,36,238,72,139,66 - .byte 248,169,3,0,0,0,117,238,15,182,64,253,72,247,216,76 - .byte 139,124,194,224,73,193,231,17,73,193,239,17,77,139,127,32 - .byte 77,139,127,184,235,208,72,247,216,72,137,239,72,137,198 ->>>>>>> fix-alloc call lj_err_throw .globl lj_vm_floor_sse @@ -2724,11 +2665,7 @@ lj_assert_bad_for_arg_type: .size lj_vm_ffi_callback, 202 lj_vm_ffi_callback: .byte 83,65,87,65,86,65,85,65,84,72,131,236,40,76,141,181 -<<<<<<< HEAD - .byte 64,15,0,0,72,139,157,112,1,0,0,15,183,192,137,131 -======= - .byte 64,15,0,0,72,139,157,104,1,0,0,15,183,192,137,131 ->>>>>>> fix-alloc + .byte 88,15,0,0,72,139,157,112,1,0,0,15,183,192,137,131 .byte 208,0,0,0,72,137,123,112,72,137,115,120,72,137,147,128 .byte 0,0,0,72,137,139,136,0,0,0,242,15,17,67,48,242 .byte 15,17,75,56,242,15,17,83,64,242,15,17,91,72,72,141 @@ -2737,7 +2674,7 @@ lj_vm_ffi_callback: .byte 242,15,17,123,104,72,137,131,176,0,0,0,72,137,230,72 .byte 137,92,36,24,72,137,223 call lj_ccallback_enter - .byte 65,199,134,64,241,255,255,255,255,255,255,72,139,80,32,72 + .byte 65,199,134,40,241,255,255,255,255,255,255,72,139,80,32,72 .byte 139,64,40,72,41,208,72,139,106,240,72,193,229,17,72,193 .byte 237,17,72,193,232,3,72,131,192,1,72,139,93,32,139,11 .byte 15,182,233,15,182,205,72,131,195,4,65,255,36,238 @@ -2747,7 +2684,7 @@ lj_vm_ffi_callback: .type lj_cont_ffi_callback, @function .size lj_cont_ffi_callback, 49 lj_cont_ffi_callback: - .byte 72,139,76,36,16,73,139,158,40,242,255,255,72,137,75,16 + .byte 72,139,76,36,16,73,139,158,24,242,255,255,72,137,75,16 .byte 72,137,81,32,72,137,105,40,72,137,223,72,137,198 call lj_ccallback_leave .byte 72,139,67,112,242,15,16,67,48,233,143,221,255,255 From 7844c5f525172aa8b193aa5c00328880dc05e94a Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Tue, 19 Dec 2017 15:56:55 +0000 Subject: [PATCH 2/2] Add '-p file' command line syntax for VMProfile Now it is possible to enable VMProfile trace profiling to a file from the command line. --- src/lj_vmprofile.c | 25 ++++++++++++++++--------- src/lj_vmprofile.h | 4 ++++ src/luajit.c | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/lj_vmprofile.c b/src/lj_vmprofile.c index eb2ef48792..2d614ea62d 100644 --- a/src/lj_vmprofile.c +++ b/src/lj_vmprofile.c @@ -41,6 +41,21 @@ int vmprofile_get_profile_size() { return sizeof(VMProfile); } +/* Open a counter file on disk and returned the mmapped data structure. */ +void *vmprofile_open_file(const char *filename) +{ + int fd; + void *ptr = MAP_FAILED; + if (((fd = open(filename, O_RDWR|O_CREAT, 0666)) != -1) && + ((ftruncate(fd, sizeof(VMProfile))) != -1) && + ((ptr = mmap(NULL, sizeof(VMProfile), PROT_READ|PROT_WRITE, + MAP_SHARED, fd, 0)) != MAP_FAILED)) { + memset(ptr, 0, sizeof(VMProfile)); + } + if (fd != -1) close(fd); + return ptr == MAP_FAILED ? NULL : ptr; +} + /* Set the memory where the next samples will be counted. Size of the memory must match vmprofile_get_profile_size(). */ void vmprofile_set_profile(void *counters) { @@ -122,20 +137,12 @@ static void stop_timer() LUA_API int luaJIT_vmprofile_open(lua_State *L, const char *str) { - int fd; void *ptr; - if (((fd = open(str, O_RDWR|O_CREAT, 0666)) != -1) && - ((ftruncate(fd, sizeof(VMProfile))) != -1) && - ((ptr = mmap(NULL, sizeof(VMProfile), PROT_READ|PROT_WRITE, - MAP_SHARED, fd, 0)) != MAP_FAILED)) { - memset(ptr, 0, sizeof(VMProfile)); + if ((ptr = vmprofile_open_file(str)) != NULL) { setlightudV(L->base, checklightudptr(L, ptr)); } else { setnilV(L->base); } - if (fd != -1) { - close(fd); - } return 1; } diff --git a/src/lj_vmprofile.h b/src/lj_vmprofile.h index 2cdce69640..c9d023a072 100644 --- a/src/lj_vmprofile.h +++ b/src/lj_vmprofile.h @@ -6,6 +6,9 @@ #ifndef _LJ_VMPROFILE_H #define _LJ_VMPROFILE_H +#include +#include "lj_obj.h" + /* Counters are 64-bit to avoid overflow even in long running processes. */ typedef uint64_t VMProfileCount; @@ -30,6 +33,7 @@ typedef struct VMProfile { /* Functions that should be accessed via FFI. */ +void *vmprofile_open_file(const char *filename); void vmprofile_set_profile(void *counters); int vmprofile_get_profile_size(); diff --git a/src/luajit.c b/src/luajit.c index 2f45fa02f5..9fb96f5d09 100644 --- a/src/luajit.c +++ b/src/luajit.c @@ -16,6 +16,7 @@ #include "lauxlib.h" #include "lualib.h" #include "luajit.h" +#include "lj_vmprofile.h" #include "lj_arch.h" @@ -56,6 +57,7 @@ static void print_usage(void) " -j cmd Perform LuaJIT control command.\n" " -O[opt] Control LuaJIT optimizations.\n" " -i Enter interactive mode after executing " LUA_QL("script") ".\n" + " -p file Enable trace profiling to a VMProfile file.\n" " -v Show version information.\n" " -E Ignore environment variables.\n" " -- Stop handling options.\n" @@ -404,6 +406,7 @@ static int collectargs(char **argv, int *flags) *flags |= FLAGS_EXEC; case 'j': /* LuaJIT extension */ case 'l': + case 'p': /* RaptorJIT extension */ *flags |= FLAGS_OPTION; if (argv[i][2] == '\0') { i++; @@ -461,6 +464,17 @@ static int runargs(lua_State *L, char **argv, int argn) break; case 'b': /* LuaJIT extension. */ return dobytecode(L, argv+i); + case 'p': { + void *ptr; + if ((ptr = vmprofile_open_file(argv[++i])) != NULL) { + vmprofile_set_profile(ptr); + luaJIT_vmprofile_start(L); + } else { + fprintf(stderr, "unable to open vmprofile\n"); + fflush(stderr); + } + break; + } default: break; } }