aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2010-02-04 20:40:00 +0100
committerMike Pall <mike>2010-02-04 20:40:00 +0100
commit5d2690c6084d09ed6f5bb9cdb4fc5113bb4fa512 (patch)
tree8e18b1f103b3c8bd99c34d70cb678cc2772ca8c3 /src
parent7256690364a2c9a5e9269ffd89bc132ee188480d (diff)
downloadluajit-5d2690c6084d09ed6f5bb9cdb4fc5113bb4fa512.tar.gz
luajit-5d2690c6084d09ed6f5bb9cdb4fc5113bb4fa512.tar.bz2
luajit-5d2690c6084d09ed6f5bb9cdb4fc5113bb4fa512.zip
Reset the hotcount table after a JIT off to on transition.
Diffstat (limited to 'src')
-rw-r--r--src/lib_jit.c16
-rw-r--r--src/lj_dispatch.c16
-rw-r--r--src/lj_dispatch.h1
3 files changed, 18 insertions, 15 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c
index 4da079c8..0728fc3a 100644
--- a/src/lib_jit.c
+++ b/src/lib_jit.c
@@ -437,9 +437,6 @@ static int jitopt_flag(jit_State *J, const char *str)
437 return 0; /* No match. */ 437 return 0; /* No match. */
438} 438}
439 439
440/* Forward declaration. */
441static void jit_init_hotcount(jit_State *J);
442
443/* Parse optimization parameter. */ 440/* Parse optimization parameter. */
444static int jitopt_param(jit_State *J, const char *str) 441static int jitopt_param(jit_State *J, const char *str)
445{ 442{
@@ -453,7 +450,7 @@ static int jitopt_param(jit_State *J, const char *str)
453 lj_str_numconv(&str[len+1], &tv)) { 450 lj_str_numconv(&str[len+1], &tv)) {
454 J->param[i] = lj_num2int(tv.n); 451 J->param[i] = lj_num2int(tv.n);
455 if (i == JIT_P_hotloop) 452 if (i == JIT_P_hotloop)
456 jit_init_hotcount(J); 453 lj_dispatch_init_hotcount(J2G(J));
457 return 1; /* Ok. */ 454 return 1; /* Ok. */
458 } 455 }
459 lst += 1+len; 456 lst += 1+len;
@@ -498,16 +495,6 @@ JIT_PARAMDEF(JIT_PARAMINIT)
498#undef JIT_PARAMINIT 495#undef JIT_PARAMINIT
499 0 496 0
500}; 497};
501
502/* Initialize hotcount table. */
503static void jit_init_hotcount(jit_State *J)
504{
505 HotCount start = (HotCount)J->param[JIT_P_hotloop];
506 HotCount *hotcount = J2GG(J)->hotcount;
507 uint32_t i;
508 for (i = 0; i < HOTCOUNT_SIZE; i++)
509 hotcount[i] = start;
510}
511#endif 498#endif
512 499
513/* Arch-dependent CPU detection. */ 500/* Arch-dependent CPU detection. */
@@ -570,7 +557,6 @@ static void jit_init(lua_State *L)
570 jit_State *J = L2J(L); 557 jit_State *J = L2J(L);
571 J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT; 558 J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT;
572 memcpy(J->param, jit_param_default, sizeof(J->param)); 559 memcpy(J->param, jit_param_default, sizeof(J->param));
573 jit_init_hotcount(J);
574 lj_dispatch_update(G(L)); 560 lj_dispatch_update(G(L));
575#else 561#else
576 UNUSED(flags); 562 UNUSED(flags);
diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c
index 1e5b574c..a94afea9 100644
--- a/src/lj_dispatch.c
+++ b/src/lj_dispatch.c
@@ -34,6 +34,18 @@ void lj_dispatch_init(GG_State *GG)
34 disp[BC_LOOP] = disp[BC_ILOOP]; 34 disp[BC_LOOP] = disp[BC_ILOOP];
35} 35}
36 36
37#if LJ_HASJIT
38/* Initialize hotcount table. */
39void lj_dispatch_init_hotcount(global_State *g)
40{
41 HotCount start = (HotCount)G2J(g)->param[JIT_P_hotloop];
42 HotCount *hotcount = G2GG(g)->hotcount;
43 uint32_t i;
44 for (i = 0; i < HOTCOUNT_SIZE; i++)
45 hotcount[i] = start;
46}
47#endif
48
37/* Update dispatch table depending on various flags. */ 49/* Update dispatch table depending on various flags. */
38void lj_dispatch_update(global_State *g) 50void lj_dispatch_update(global_State *g)
39{ 51{
@@ -77,6 +89,10 @@ void lj_dispatch_update(global_State *g)
77 disp[BC_ITERL] = f_iterl; 89 disp[BC_ITERL] = f_iterl;
78 disp[BC_LOOP] = f_loop; 90 disp[BC_LOOP] = f_loop;
79 } 91 }
92#if LJ_HASJIT
93 if ((mode & 1) && !(oldmode & 1)) /* JIT off to on transition. */
94 lj_dispatch_init_hotcount(g);
95#endif
80 } 96 }
81} 97}
82 98
diff --git a/src/lj_dispatch.h b/src/lj_dispatch.h
index ce9d9e11..cb5e5f64 100644
--- a/src/lj_dispatch.h
+++ b/src/lj_dispatch.h
@@ -56,6 +56,7 @@ typedef struct GG_State {
56 56
57/* Dispatch table management. */ 57/* Dispatch table management. */
58LJ_FUNC void lj_dispatch_init(GG_State *GG); 58LJ_FUNC void lj_dispatch_init(GG_State *GG);
59LJ_FUNC void lj_dispatch_init_hotcount(global_State *g);
59LJ_FUNC void lj_dispatch_update(global_State *g); 60LJ_FUNC void lj_dispatch_update(global_State *g);
60 61
61/* Instruction dispatch callback for instr/line hooks or when recording. */ 62/* Instruction dispatch callback for instr/line hooks or when recording. */