Prefer recording loops over calls.

Hotcounts are decremented by 2 for loops and by 1 for calls.
This commit is contained in:
Mike Pall 2011-06-29 01:51:39 +02:00
parent deeb8196c4
commit 82eca898db
10 changed files with 151 additions and 141 deletions

View File

@ -185,23 +185,23 @@
| |
#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto))
| |
|.macro hotcheck |.macro hotcheck, delta
| lsr CARG1, PC, #1 | lsr CARG1, PC, #1
| and CARG1, CARG1, #126 | and CARG1, CARG1, #126
| sub CARG1, CARG1, #-GG_DISP2HOT | sub CARG1, CARG1, #-GG_DISP2HOT
| ldrh CARG2, [DISPATCH, CARG1] | ldrh CARG2, [DISPATCH, CARG1]
| subs CARG2, CARG2, #1 | subs CARG2, CARG2, #delta
| strh CARG2, [DISPATCH, CARG1] | strh CARG2, [DISPATCH, CARG1]
|.endmacro |.endmacro
| |
|.macro hotloop |.macro hotloop
| hotcheck | hotcheck HOTCOUNT_LOOP
| beq ->vm_hotloop | blo ->vm_hotloop
|.endmacro |.endmacro
| |
|.macro hotcall |.macro hotcall
| hotcheck | hotcheck HOTCOUNT_CALL
| beq ->vm_hotcall | blo ->vm_hotcall
|.endmacro |.endmacro
| |
|// Set current VM state. |// Set current VM state.

View File

@ -12,7 +12,7 @@
#define DASM_SECTION_CODE_OP 0 #define DASM_SECTION_CODE_OP 0
#define DASM_SECTION_CODE_SUB 1 #define DASM_SECTION_CODE_SUB 1
#define DASM_MAXSECTION 2 #define DASM_MAXSECTION 2
static const unsigned int build_actionlist[5702] = { static const unsigned int build_actionlist[5706] = {
0x00010001, 0x00010001,
0x00060014, 0x00060014,
0xe3160000, 0xe3160000,
@ -5381,9 +5381,10 @@ static const unsigned int build_actionlist[5702] = {
0xe2400000, 0xe2400000,
0x000a0000, 0x000a0000,
0xe19710b0, 0xe19710b0,
0xe2511001, 0xe2511000,
0x000a0000,
0xe18710b0, 0xe18710b0,
0x0a000000, 0x3a000000,
0x00050091, 0x00050091,
0x00000000, 0x00000000,
0xe1aa00d9, 0xe1aa00d9,
@ -5519,9 +5520,10 @@ static const unsigned int build_actionlist[5702] = {
0xe2400000, 0xe2400000,
0x000a0000, 0x000a0000,
0xe19710b0, 0xe19710b0,
0xe2511001, 0xe2511000,
0x000a0000,
0xe18710b0, 0xe18710b0,
0x0a000000, 0x3a000000,
0x00050091, 0x00050091,
0x00000000, 0x00000000,
0xe1aa00d9, 0xe1aa00d9,
@ -5550,9 +5552,10 @@ static const unsigned int build_actionlist[5702] = {
0xe2400000, 0xe2400000,
0x000a0000, 0x000a0000,
0xe19710b0, 0xe19710b0,
0xe2511001, 0xe2511000,
0x000a0000,
0xe18710b0, 0xe18710b0,
0x0a000000, 0x3a000000,
0x00050091, 0x00050091,
0x00000000, 0x00000000,
0xe5d6c000, 0xe5d6c000,
@ -5590,9 +5593,10 @@ static const unsigned int build_actionlist[5702] = {
0xe2400000, 0xe2400000,
0x000a0000, 0x000a0000,
0xe19710b0, 0xe19710b0,
0xe2511001, 0xe2511000,
0x000a0000,
0xe18710b0, 0xe18710b0,
0x0a000000, 0x3a000000,
0x00050093, 0x00050093,
0x00000000, 0x00000000,
0xe5180000, 0xe5180000,
@ -7138,7 +7142,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
case BC_FORL: case BC_FORL:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 5363, -GG_DISP2HOT); dasm_put(Dst, 5363, -GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -7150,68 +7154,68 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
case BC_FORI: case BC_FORI:
case BC_IFORL: case BC_IFORL:
vk = (op == BC_IFORL || op == BC_JFORL); vk = (op == BC_IFORL || op == BC_JFORL);
dasm_put(Dst, 5373); dasm_put(Dst, 5374);
if (op != BC_JFORL) { if (op != BC_JFORL) {
dasm_put(Dst, 5375); dasm_put(Dst, 5376);
} }
if (!vk) { if (!vk) {
dasm_put(Dst, 5377, -LJ_TISNUM, -LJ_TISNUM, -LJ_TISNUM); dasm_put(Dst, 5378, -LJ_TISNUM, -LJ_TISNUM, -LJ_TISNUM);
} else { } else {
dasm_put(Dst, 5395, -LJ_TISNUM); dasm_put(Dst, 5396, -LJ_TISNUM);
if (op == BC_IFORL) { if (op == BC_IFORL) {
dasm_put(Dst, 5403); dasm_put(Dst, 5404);
} else { } else {
dasm_put(Dst, 5405); dasm_put(Dst, 5406);
} }
dasm_put(Dst, 5408); dasm_put(Dst, 5409);
} }
dasm_put(Dst, 5413); dasm_put(Dst, 5414);
if (op == BC_FORI) { if (op == BC_FORI) {
dasm_put(Dst, 5415); dasm_put(Dst, 5416);
} else if (op == BC_JFORI) { } else if (op == BC_JFORI) {
dasm_put(Dst, 5417); dasm_put(Dst, 5418);
} else if (op == BC_IFORL) { } else if (op == BC_IFORL) {
dasm_put(Dst, 5420); dasm_put(Dst, 5421);
} }
if (vk) { if (vk) {
dasm_put(Dst, 5422); dasm_put(Dst, 5423);
} }
dasm_put(Dst, 5424); dasm_put(Dst, 5425);
if (op == BC_JFORI || op == BC_JFORL) { if (op == BC_JFORI || op == BC_JFORL) {
dasm_put(Dst, 5429, BC_JLOOP); dasm_put(Dst, 5430, BC_JLOOP);
} }
dasm_put(Dst, 5432); dasm_put(Dst, 5433);
if (!vk) { if (!vk) {
dasm_put(Dst, 5439); dasm_put(Dst, 5440);
} else { } else {
dasm_put(Dst, 5441); dasm_put(Dst, 5442);
} }
dasm_put(Dst, 5443); dasm_put(Dst, 5444);
if (!vk) { if (!vk) {
dasm_put(Dst, 5447, -LJ_TISNUM, -LJ_TISNUM); dasm_put(Dst, 5448, -LJ_TISNUM, -LJ_TISNUM);
} else { } else {
dasm_put(Dst, 5459); dasm_put(Dst, 5460);
} }
dasm_put(Dst, 5468); dasm_put(Dst, 5469);
if (op == BC_FORI) { if (op == BC_FORI) {
dasm_put(Dst, 5472); dasm_put(Dst, 5473);
} else if (op == BC_JFORI) { } else if (op == BC_JFORI) {
dasm_put(Dst, 5474, BC_JLOOP); dasm_put(Dst, 5475, BC_JLOOP);
} else if (op == BC_IFORL) { } else if (op == BC_IFORL) {
dasm_put(Dst, 5479); dasm_put(Dst, 5480);
} else { } else {
dasm_put(Dst, 5481, BC_JLOOP); dasm_put(Dst, 5482, BC_JLOOP);
} }
dasm_put(Dst, 5484); dasm_put(Dst, 5485);
if (vk) { if (vk) {
dasm_put(Dst, 5490); dasm_put(Dst, 5491);
} }
dasm_put(Dst, 5495); dasm_put(Dst, 5496);
break; break;
case BC_ITERL: case BC_ITERL:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 5501, -GG_DISP2HOT); dasm_put(Dst, 5502, -GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -7220,40 +7224,40 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
break; break;
#endif #endif
case BC_IITERL: case BC_IITERL:
dasm_put(Dst, 5511); dasm_put(Dst, 5513);
if (op == BC_JITERL) { if (op == BC_JITERL) {
dasm_put(Dst, 5513, -LJ_TNIL, BC_JLOOP); dasm_put(Dst, 5515, -LJ_TNIL, BC_JLOOP);
} else { } else {
dasm_put(Dst, 5519, -LJ_TNIL); dasm_put(Dst, 5521, -LJ_TNIL);
} }
dasm_put(Dst, 5525); dasm_put(Dst, 5527);
break; break;
case BC_LOOP: case BC_LOOP:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 5532, -GG_DISP2HOT); dasm_put(Dst, 5534, -GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
case BC_ILOOP: case BC_ILOOP:
dasm_put(Dst, 5542); dasm_put(Dst, 5545);
break; break;
case BC_JLOOP: case BC_JLOOP:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 5549, DISPATCH_J(trace), DISPATCH_GL(vmstate), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L)); dasm_put(Dst, 5552, DISPATCH_J(trace), DISPATCH_GL(vmstate), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L));
#endif #endif
break; break;
case BC_JMP: case BC_JMP:
dasm_put(Dst, 5563); dasm_put(Dst, 5566);
break; break;
/* -- Function headers -------------------------------------------------- */ /* -- Function headers -------------------------------------------------- */
case BC_FUNCF: case BC_FUNCF:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 5572, -GG_DISP2HOT); dasm_put(Dst, 5575, -GG_DISP2HOT, HOTCOUNT_CALL);
#endif #endif
case BC_FUNCV: /* NYI: compiled vararg functions. */ case BC_FUNCV: /* NYI: compiled vararg functions. */
break; break;
@ -7263,42 +7267,42 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
break; break;
#endif #endif
case BC_IFUNCF: case BC_IFUNCF:
dasm_put(Dst, 5582, Dt1(->maxstack), -4+PC2PROTO(numparams), -4+PC2PROTO(k)); dasm_put(Dst, 5586, Dt1(->maxstack), -4+PC2PROTO(numparams), -4+PC2PROTO(k));
if (op != BC_JFUNCF) { if (op != BC_JFUNCF) {
dasm_put(Dst, 5592); dasm_put(Dst, 5596);
} }
dasm_put(Dst, 5595, ~LJ_TNIL); dasm_put(Dst, 5599, ~LJ_TNIL);
if (op == BC_JFUNCF) { if (op == BC_JFUNCF) {
dasm_put(Dst, 5602, BC_JLOOP); dasm_put(Dst, 5606, BC_JLOOP);
} else { } else {
dasm_put(Dst, 5606); dasm_put(Dst, 5610);
} }
dasm_put(Dst, 5611); dasm_put(Dst, 5615);
break; break;
case BC_JFUNCV: case BC_JFUNCV:
#if !LJ_HASJIT #if !LJ_HASJIT
break; break;
#endif #endif
dasm_put(Dst, 5617); dasm_put(Dst, 5621);
break; /* NYI: compiled vararg functions. */ break; /* NYI: compiled vararg functions. */
case BC_IFUNCV: case BC_IFUNCV:
dasm_put(Dst, 5619, Dt1(->maxstack), 8+FRAME_VARG, -4+PC2PROTO(k), -4+PC2PROTO(numparams), ~LJ_TNIL); dasm_put(Dst, 5623, Dt1(->maxstack), 8+FRAME_VARG, -4+PC2PROTO(k), -4+PC2PROTO(numparams), ~LJ_TNIL);
break; break;
case BC_FUNCC: case BC_FUNCC:
case BC_FUNCCW: case BC_FUNCCW:
if (op == BC_FUNCC) { if (op == BC_FUNCC) {
dasm_put(Dst, 5660, Dt8(->f)); dasm_put(Dst, 5664, Dt8(->f));
} else { } else {
dasm_put(Dst, 5663, DISPATCH_GL(wrapf)); dasm_put(Dst, 5667, DISPATCH_GL(wrapf));
} }
dasm_put(Dst, 5666, Dt1(->maxstack), Dt1(->base), Dt1(->top)); dasm_put(Dst, 5670, Dt1(->maxstack), Dt1(->base), Dt1(->top));
if (op == BC_FUNCCW) { if (op == BC_FUNCCW) {
dasm_put(Dst, 5676, Dt8(->f)); dasm_put(Dst, 5680, Dt8(->f));
} }
dasm_put(Dst, 5679, LJ_VMST_C, DISPATCH_GL(vmstate), Dt1(->base), LJ_VMST_INTERP, Dt1(->top), DISPATCH_GL(vmstate)); dasm_put(Dst, 5683, LJ_VMST_C, DISPATCH_GL(vmstate), Dt1(->base), LJ_VMST_INTERP, Dt1(->top), DISPATCH_GL(vmstate));
break; break;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -7318,7 +7322,7 @@ static int build_backend(BuildCtx *ctx)
build_subroutines(ctx); build_subroutines(ctx);
dasm_put(Dst, 5701); dasm_put(Dst, 5705);
for (op = 0; op < BC__MAX; op++) for (op = 0; op < BC__MAX; op++)
build_ins(ctx, (BCOp)op, op); build_ins(ctx, (BCOp)op, op);

View File

@ -751,16 +751,16 @@ static const unsigned char build_actionlist[16156] = {
182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,6,255,65,199,71,252, 182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,6,255,65,199,71,252,
252,237,65,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244, 252,237,65,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,
5,248,7,141,171,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233, 5,248,7,141,171,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,
255,137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1,15,132,244, 255,137,221,209,252,237,129,229,239,102,65,129,172,253,46,233,238,15,130,
148,255,141,12,202,255,129,121,253,4,239,15,133,244,255,255,129,121,253,12, 244,148,255,141,12,202,255,129,121,253,4,239,15,133,244,255,255,129,121,253,
239,15,133,244,60,129,121,253,20,239,15,133,244,60,139,41,131,121,16,0,15, 12,239,15,133,244,60,129,121,253,20,239,15,133,244,60,139,41,131,121,16,0,
140,244,251,255,129,121,253,12,239,15,133,244,165,129,121,253,20,239,15,133, 15,140,244,251,255,129,121,253,12,239,15,133,244,165,129,121,253,20,239,15,
244,165,255,139,105,16,133,252,237,15,136,244,251,3,41,15,128,244,247,137, 133,244,165,255,139,105,16,133,252,237,15,136,244,251,3,41,15,128,244,247,
41,255,59,105,8,199,65,28,237,137,105,24,255,15,142,244,253,248,1,248,6,141, 137,41,255,59,105,8,199,65,28,237,137,105,24,255,15,142,244,253,248,1,248,
156,253,131,233,255,141,156,253,131,233,15,183,67,252,254,15,142,245,248, 6,141,156,253,131,233,255,141,156,253,131,233,15,183,67,252,254,15,142,245,
1,248,6,255,15,143,244,253,248,6,141,156,253,131,233,248,1,255,248,7,139, 248,1,248,6,255,15,143,244,253,248,6,141,156,253,131,233,248,1,255,248,7,
3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,5, 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,
255,3,41,15,128,244,1,137,41,255,15,141,244,7,255,141,156,253,131,233,15, 5,255,3,41,15,128,244,1,137,41,255,15,141,244,7,255,141,156,253,131,233,15,
183,67,252,254,15,141,245,255,15,140,244,7,255,252,233,244,6,248,9,255,129, 183,67,252,254,15,141,245,255,15,140,244,7,255,252,233,244,6,248,9,255,129,
121,253,4,239,255,15,131,244,60,129,121,253,12,239,15,131,244,60,255,129, 121,253,4,239,255,15,131,244,60,129,121,253,12,239,15,131,244,60,255,129,
121,253,12,239,15,131,244,165,129,121,253,20,239,15,131,244,165,255,139,105, 121,253,12,239,15,131,244,165,129,121,253,20,239,15,131,244,165,255,139,105,
@ -777,22 +777,22 @@ static const unsigned char build_actionlist[16156] = {
139,4,129,72,139,128,233,139,108,36,24,65,137,150,233,65,137,174,233,76,137, 139,4,129,72,139,128,233,139,108,36,24,65,137,150,233,65,137,174,233,76,137,
36,36,76,137,108,36,8,72,131,252,236,16,252,255,224,255,141,156,253,131,233, 36,36,76,137,108,36,8,72,131,252,236,16,252,255,224,255,141,156,253,131,233,
139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255, 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255,
137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1,15,132,244,150, 137,221,209,252,237,129,229,239,102,65,129,172,253,46,233,238,15,130,244,
255,68,139,187,233,139,108,36,24,141,12,202,59,141,233,15,135,244,24,15,182, 150,255,68,139,187,233,139,108,36,24,141,12,202,59,141,233,15,135,244,24,
139,233,57,200,15,134,244,249,248,2,255,15,183,67,252,254,252,233,245,255, 15,182,139,233,57,200,15,134,244,249,248,2,255,15,183,67,252,254,252,233,
248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2, 245,255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,
255,141,44,197,237,141,4,194,68,139,122,252,248,137,104,252,252,68,137,120, 244,2,255,141,44,197,237,141,4,194,68,139,122,252,248,137,104,252,252,68,
252,248,139,108,36,24,141,12,200,59,141,233,15,135,244,23,137,209,137,194, 137,120,252,248,139,108,36,24,141,12,200,59,141,233,15,135,244,23,137,209,
15,182,171,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244, 137,194,15,182,171,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,
249,68,139,121,252,248,68,137,56,68,139,121,252,252,68,137,120,4,131,192, 15,131,244,249,68,139,121,252,248,68,137,56,68,139,121,252,252,68,137,120,
8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,68,139,187,233, 4,131,192,8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,68,139,
139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255, 187,233,139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,
248,3,199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244,2,255, 238,255,248,3,199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244,
139,106,252,248,76,139,189,233,139,108,36,24,141,68,194,252,248,137,149,233, 2,255,139,106,252,248,76,139,189,233,139,108,36,24,141,68,194,252,248,137,
141,136,233,59,141,233,137,133,233,255,76,137,252,254,137,252,239,255,15, 149,233,141,136,233,59,141,233,137,133,233,255,76,137,252,254,137,252,239,
135,244,22,65,199,134,233,237,255,65,252,255,215,255,65,252,255,150,233,255, 255,15,135,244,22,65,199,134,233,237,255,65,252,255,215,255,65,252,255,150,
65,199,134,233,237,139,149,233,141,12,194,252,247,217,3,141,233,139,90,252, 233,255,65,199,134,233,237,139,149,233,141,12,194,252,247,217,3,141,233,139,
252,252,233,244,12,255,254,0 90,252,252,252,233,244,12,255,254,0
}; };
enum { enum {
@ -2777,7 +2777,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_FORL: case BC_FORL:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -2893,7 +2893,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_ITERL: case BC_ITERL:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -2913,7 +2913,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_LOOP: case BC_LOOP:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -2942,7 +2942,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_FUNCF: case BC_FUNCF:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 15842, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 15842, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_CALL);
#endif #endif
case BC_FUNCV: /* NYI: compiled vararg functions. */ case BC_FUNCV: /* NYI: compiled vararg functions. */
break; break;

View File

@ -746,7 +746,7 @@ static const unsigned char build_actionlist[16011] = {
36,252,235,248,6,255,199,71,252,252,237,131,199,8,255,199,68,194,252,244, 36,252,235,248,6,255,199,71,252,252,237,131,199,8,255,199,68,194,252,244,
237,255,131,192,1,252,233,244,5,248,7,141,174,233,252,247,197,237,15,133, 237,255,131,192,1,252,233,244,5,248,7,141,174,233,252,247,197,237,15,133,
244,14,41,252,234,255,1,252,233,255,137,252,245,209,252,237,129,229,239,102, 244,14,41,252,234,255,1,252,233,255,137,252,245,209,252,237,129,229,239,102,
131,172,253,43,233,1,15,132,244,148,255,141,12,202,255,129,121,253,4,239, 129,172,253,43,233,238,15,130,244,148,255,141,12,202,255,129,121,253,4,239,
15,133,244,255,255,129,121,253,12,239,15,133,244,60,129,121,253,20,239,15, 15,133,244,255,255,129,121,253,12,239,15,133,244,60,129,121,253,20,239,15,
133,244,60,139,41,131,121,16,0,15,140,244,251,255,129,121,253,12,239,15,133, 133,244,60,139,41,131,121,16,0,15,140,244,251,255,129,121,253,12,239,15,133,
244,165,129,121,253,20,239,15,133,244,165,255,139,105,16,133,252,237,15,136, 244,165,129,121,253,20,239,15,133,244,165,255,139,105,16,133,252,237,15,136,
@ -775,21 +775,21 @@ static const unsigned char build_actionlist[16011] = {
15,127,153,233,102,68,15,127,161,233,102,68,15,127,169,233,102,68,15,127, 15,127,153,233,102,68,15,127,161,233,102,68,15,127,169,233,102,68,15,127,
177,233,102,68,15,127,185,233,252,255,224,255,141,180,253,134,233,139,6,15, 177,233,102,68,15,127,185,233,252,255,224,255,141,180,253,134,233,139,6,15,
182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235,255,137,252,245, 182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235,255,137,252,245,
209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,150,255,139,190, 209,252,237,129,229,239,102,129,172,253,43,233,238,15,130,244,150,255,139,
233,139,108,36,96,141,12,202,59,141,233,15,135,244,24,15,182,142,233,57,200, 190,233,139,108,36,96,141,12,202,59,141,233,15,135,244,24,15,182,142,233,
15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,255,248,3,199,68,194, 57,200,15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,255,248,3,199,
252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2,255,141,44,197,237, 68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2,255,141,44,
141,4,194,139,122,252,248,137,104,252,252,137,120,252,248,139,108,36,96,141, 197,237,141,4,194,139,122,252,248,137,104,252,252,137,120,252,248,139,108,
12,200,59,141,233,15,135,244,23,137,209,137,194,15,182,174,233,133,252,237, 36,96,141,12,200,59,141,233,15,135,244,23,137,209,137,194,15,182,174,233,
15,132,244,248,248,1,131,193,8,57,209,15,131,244,249,139,121,252,248,137, 133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244,249,139,121,
56,139,121,252,252,137,120,4,131,192,8,199,65,252,252,237,131,252,237,1,15, 252,248,137,56,139,121,252,252,137,120,4,131,192,8,199,65,252,252,237,131,
133,244,1,248,2,255,139,190,233,139,6,15,182,204,15,182,232,131,198,4,193, 252,237,1,15,133,244,1,248,2,255,139,190,233,139,6,15,182,204,15,182,232,
232,16,252,255,36,252,235,255,248,3,199,64,4,237,131,192,8,131,252,237,1, 131,198,4,193,232,16,252,255,36,252,235,255,248,3,199,64,4,237,131,192,8,
15,133,244,3,252,233,244,2,255,139,106,252,248,72,139,189,233,139,108,36, 131,252,237,1,15,133,244,3,252,233,244,2,255,139,106,252,248,72,139,189,233,
96,141,68,194,252,248,137,149,233,141,136,233,59,141,233,137,133,233,255, 139,108,36,96,141,68,194,252,248,137,149,233,141,136,233,59,141,233,137,133,
72,137,252,250,137,252,233,255,15,135,244,22,199,131,233,237,255,252,255, 233,255,72,137,252,250,137,252,233,255,15,135,244,22,199,131,233,237,255,
215,255,252,255,147,233,255,199,131,233,237,139,149,233,141,12,194,252,247, 252,255,215,255,252,255,147,233,255,199,131,233,237,139,149,233,141,12,194,
217,3,141,233,139,114,252,252,252,233,244,12,255,254,0 252,247,217,3,141,233,139,114,252,252,252,233,244,12,255,254,0
}; };
enum { enum {
@ -2775,7 +2775,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_FORL: case BC_FORL:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -2891,7 +2891,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_ITERL: case BC_ITERL:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -2911,7 +2911,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_LOOP: case BC_LOOP:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -2940,7 +2940,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_FUNCF: case BC_FUNCF:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 15710, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 15710, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_CALL);
#endif #endif
case BC_FUNCV: /* NYI: compiled vararg functions. */ case BC_FUNCV: /* NYI: compiled vararg functions. */
break; break;

View File

@ -333,16 +333,16 @@
| mov reg, PC | mov reg, PC
| shr reg, 1 | shr reg, 1
| and reg, HOTCOUNT_PCMASK | and reg, HOTCOUNT_PCMASK
| sub word [DISPATCH+reg+GG_DISP2HOT], 1 | sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_LOOP
| jz ->vm_hotloop | jb ->vm_hotloop
|.endmacro |.endmacro
| |
|.macro hotcall, reg |.macro hotcall, reg
| mov reg, PC | mov reg, PC
| shr reg, 1 | shr reg, 1
| and reg, HOTCOUNT_PCMASK | and reg, HOTCOUNT_PCMASK
| sub word [DISPATCH+reg+GG_DISP2HOT], 1 | sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_CALL
| jz ->vm_hotcall | jb ->vm_hotcall
|.endmacro |.endmacro
| |
|// Set current VM state. |// Set current VM state.

View File

@ -798,12 +798,12 @@ static const unsigned char build_actionlist[17111] = {
204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,6,255,199,71,252,252, 204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,6,255,199,71,252,252,
237,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,5,248, 237,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,5,248,
7,141,174,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,255, 7,141,174,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,255,
137,252,245,209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,148, 137,252,245,209,252,237,129,229,239,102,129,172,253,43,233,238,15,130,244,
255,141,12,202,255,129,121,253,4,239,15,133,244,255,255,129,121,253,12,239, 148,255,141,12,202,255,129,121,253,4,239,15,133,244,255,255,129,121,253,12,
15,133,244,60,129,121,253,20,239,15,133,244,60,139,41,131,121,16,0,15,140, 239,15,133,244,60,129,121,253,20,239,15,133,244,60,139,41,131,121,16,0,15,
244,251,255,129,121,253,12,239,15,133,244,165,129,121,253,20,239,15,133,244, 140,244,251,255,129,121,253,12,239,15,133,244,165,129,121,253,20,239,15,133,
165,255,139,105,16,133,252,237,15,136,244,251,3,41,15,128,244,247,137,41, 244,165,255,139,105,16,133,252,237,15,136,244,251,3,41,15,128,244,247,137,
255,59,105,8,199,65,28,237,137,105,24,255,15,142,244,253,248,1,248,6,141, 41,255,59,105,8,199,65,28,237,137,105,24,255,15,142,244,253,248,1,248,6,141,
180,253,134,233,255,141,180,253,134,233,15,183,70,252,254,15,142,245,248, 180,253,134,233,255,141,180,253,134,233,15,183,70,252,254,15,142,245,248,
1,248,6,255,15,143,244,253,248,6,141,180,253,134,233,248,1,255,248,7,139, 1,248,6,255,15,143,244,253,248,6,141,180,253,134,233,248,1,255,248,7,139,
6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,5,255,3,41, 6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,5,255,3,41,
@ -823,11 +823,11 @@ static const unsigned char build_actionlist[17111] = {
134,233,139,1,137,105,252,252,137,65,252,248,255,139,139,233,139,4,129,139, 134,233,139,1,137,105,252,252,137,65,252,248,255,139,139,233,139,4,129,139,
128,233,139,108,36,48,137,147,233,137,171,233,252,255,224,255,141,180,253, 128,233,139,108,36,48,137,147,233,137,171,233,252,255,224,255,141,180,253,
134,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,255, 134,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,255,
137,252,245,209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,150, 137,252,245,209,252,237,129,229,239,102,129,172,253,43,233,238,15,130,244,
255,139,190,233,139,108,36,48,141,12,202,59,141,233,15,135,244,24,15,182, 150,255,139,190,233,139,108,36,48,141,12,202,59,141,233,15,135,244,24,15,
142,233,57,200,15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,255, 182,142,233,57,200,15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,
248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2, 255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,
255,141,44,197,237,141,4,194,139,122,252,248,137,104,252,252,137,120,252, 2,255,141,44,197,237,141,4,194,139,122,252,248,137,104,252,252,137,120,252,
248,139,108,36,48,141,12,200,59,141,233,15,135,244,23,137,209,137,194,15, 248,139,108,36,48,141,12,200,59,141,233,15,135,244,23,137,209,137,194,15,
182,174,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244, 182,174,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244,
249,139,121,252,248,137,56,139,121,252,252,137,120,4,131,192,8,199,65,252, 249,139,121,252,248,137,56,139,121,252,252,137,120,4,131,192,8,199,65,252,
@ -2933,7 +2933,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_FORL: case BC_FORL:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -3049,7 +3049,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_ITERL: case BC_ITERL:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -3069,7 +3069,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_LOOP: case BC_LOOP:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP);
#endif #endif
break; break;
@ -3098,7 +3098,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
case BC_FUNCF: case BC_FUNCF:
#if LJ_HASJIT #if LJ_HASJIT
dasm_put(Dst, 16808, HOTCOUNT_PCMASK, GG_DISP2HOT); dasm_put(Dst, 16808, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_CALL);
#endif #endif
case BC_FUNCV: /* NYI: compiled vararg functions. */ case BC_FUNCV: /* NYI: compiled vararg functions. */
break; break;

View File

@ -50,7 +50,8 @@ void lj_dispatch_init(GG_State *GG)
/* Initialize hotcount table. */ /* Initialize hotcount table. */
void lj_dispatch_init_hotcount(global_State *g) void lj_dispatch_init_hotcount(global_State *g)
{ {
HotCount start = (HotCount)G2J(g)->param[JIT_P_hotloop]; int32_t hotloop = G2J(g)->param[JIT_P_hotloop];
HotCount start = (HotCount)(hotloop*HOTCOUNT_LOOP - 1);
HotCount *hotcount = G2GG(g)->hotcount; HotCount *hotcount = G2GG(g)->hotcount;
uint32_t i; uint32_t i;
for (i = 0; i < HOTCOUNT_SIZE; i++) for (i = 0; i < HOTCOUNT_SIZE; i++)

View File

@ -20,6 +20,10 @@ typedef uint16_t HotCount;
#define HOTCOUNT_SIZE 64 #define HOTCOUNT_SIZE 64
#define HOTCOUNT_PCMASK ((HOTCOUNT_SIZE-1)*sizeof(HotCount)) #define HOTCOUNT_PCMASK ((HOTCOUNT_SIZE-1)*sizeof(HotCount))
/* Hotcount decrements. */
#define HOTCOUNT_LOOP 2
#define HOTCOUNT_CALL 1
/* This solves a circular dependency problem -- bump as needed. Sigh. */ /* This solves a circular dependency problem -- bump as needed. Sigh. */
#define GG_NUM_ASMFF 62 #define GG_NUM_ASMFF 62

View File

@ -232,7 +232,7 @@ typedef struct HotPenalty {
} HotPenalty; } HotPenalty;
#define PENALTY_SLOTS 64 /* Penalty cache slot. Must be a power of 2. */ #define PENALTY_SLOTS 64 /* Penalty cache slot. Must be a power of 2. */
#define PENALTY_MIN 36 /* Minimum penalty value. */ #define PENALTY_MIN (36*2) /* Minimum penalty value. */
#define PENALTY_MAX 60000 /* Maximum penalty value. */ #define PENALTY_MAX 60000 /* Maximum penalty value. */
#define PENALTY_RNDBITS 4 /* # of random bits to add to penalty value. */ #define PENALTY_RNDBITS 4 /* # of random bits to add to penalty value. */

View File

@ -643,9 +643,10 @@ void lj_trace_ins(jit_State *J, const BCIns *pc)
/* A hotcount triggered. Start recording a root trace. */ /* A hotcount triggered. Start recording a root trace. */
void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc) void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc)
{ {
ERRNO_SAVE
/* Note: pc is the interpreter bytecode PC here. It's offset by 1. */ /* Note: pc is the interpreter bytecode PC here. It's offset by 1. */
hotcount_set(J2GG(J), pc, J->param[JIT_P_hotloop]+1); /* Reset hotcount. */ ERRNO_SAVE
/* Reset hotcount. */
hotcount_set(J2GG(J), pc, J->param[JIT_P_hotloop]*HOTCOUNT_LOOP);
/* Only start a new trace if not recording or inside __gc call or vmevent. */ /* Only start a new trace if not recording or inside __gc call or vmevent. */
if (J->state == LJ_TRACE_IDLE && if (J->state == LJ_TRACE_IDLE &&
!(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT))) { !(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT))) {