diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib_jit.c | 16 | ||||
| -rw-r--r-- | src/lj_dispatch.c | 16 | ||||
| -rw-r--r-- | src/lj_dispatch.h | 1 |
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. */ | ||
| 441 | static void jit_init_hotcount(jit_State *J); | ||
| 442 | |||
| 443 | /* Parse optimization parameter. */ | 440 | /* Parse optimization parameter. */ |
| 444 | static int jitopt_param(jit_State *J, const char *str) | 441 | static 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. */ | ||
| 503 | static 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. */ | ||
| 39 | void 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. */ |
| 38 | void lj_dispatch_update(global_State *g) | 50 | void 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. */ |
| 58 | LJ_FUNC void lj_dispatch_init(GG_State *GG); | 58 | LJ_FUNC void lj_dispatch_init(GG_State *GG); |
| 59 | LJ_FUNC void lj_dispatch_init_hotcount(global_State *g); | ||
| 59 | LJ_FUNC void lj_dispatch_update(global_State *g); | 60 | LJ_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. */ |
