diff options
author | Mike Pall <mike> | 2011-02-17 00:44:14 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-02-17 00:44:14 +0100 |
commit | 03946ac978d9a1a3230619e3da048002e5fda2d1 (patch) | |
tree | c0a7b8edaccf789f128468320d451d9a1fee1495 /src/lib_jit.c | |
parent | 963f05c7e153714921484e0de71a7cb6bab338d9 (diff) | |
download | luajit-03946ac978d9a1a3230619e3da048002e5fda2d1.tar.gz luajit-03946ac978d9a1a3230619e3da048002e5fda2d1.tar.bz2 luajit-03946ac978d9a1a3230619e3da048002e5fda2d1.zip |
DUALNUM: Add integer type to core VM.
Diffstat (limited to 'src/lib_jit.c')
-rw-r--r-- | src/lib_jit.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c index 66a00523..8f809875 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -70,7 +70,7 @@ LJLIB_CF(jit_off) | |||
70 | LJLIB_CF(jit_flush) | 70 | LJLIB_CF(jit_flush) |
71 | { | 71 | { |
72 | #if LJ_HASJIT | 72 | #if LJ_HASJIT |
73 | if (L->base < L->top && (tvisnum(L->base) || tvisstr(L->base))) { | 73 | if (L->base < L->top && !tvisnil(L->base)) { |
74 | int traceno = lj_lib_checkint(L, 1); | 74 | int traceno = lj_lib_checkint(L, 1); |
75 | luaJIT_setmode(L, traceno, LUAJIT_MODE_FLUSH|LUAJIT_MODE_TRACE); | 75 | luaJIT_setmode(L, traceno, LUAJIT_MODE_FLUSH|LUAJIT_MODE_TRACE); |
76 | return 0; | 76 | return 0; |
@@ -202,8 +202,8 @@ LJLIB_CF(jit_util_funcinfo) | |||
202 | t = tabV(L->top-1); | 202 | t = tabV(L->top-1); |
203 | if (!iscfunc(fn)) | 203 | if (!iscfunc(fn)) |
204 | setintfield(L, t, "ffid", fn->c.ffid); | 204 | setintfield(L, t, "ffid", fn->c.ffid); |
205 | setnumV(lj_tab_setstr(L, t, lj_str_newlit(L, "addr")), | 205 | setintptrV(lj_tab_setstr(L, t, lj_str_newlit(L, "addr")), |
206 | cast_num((intptr_t)fn->c.f)); | 206 | (intptr_t)(void *)fn->c.f); |
207 | setintfield(L, t, "upvalues", fn->c.nupvalues); | 207 | setintfield(L, t, "upvalues", fn->c.nupvalues); |
208 | } | 208 | } |
209 | return 1; | 209 | return 1; |
@@ -233,7 +233,7 @@ LJLIB_CF(jit_util_funck) | |||
233 | ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2); | 233 | ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2); |
234 | if (idx >= 0) { | 234 | if (idx >= 0) { |
235 | if (idx < (ptrdiff_t)pt->sizekn) { | 235 | if (idx < (ptrdiff_t)pt->sizekn) { |
236 | setnumV(L->top-1, proto_knum(pt, idx)); | 236 | copyTV(L, L->top-1, proto_knumtv(pt, idx)); |
237 | return 1; | 237 | return 1; |
238 | } | 238 | } |
239 | } else { | 239 | } else { |
@@ -358,7 +358,7 @@ LJLIB_CF(jit_util_tracemc) | |||
358 | GCtrace *T = jit_checktrace(L); | 358 | GCtrace *T = jit_checktrace(L); |
359 | if (T && T->mcode != NULL) { | 359 | if (T && T->mcode != NULL) { |
360 | setstrV(L, L->top-1, lj_str_new(L, (const char *)T->mcode, T->szmcode)); | 360 | setstrV(L, L->top-1, lj_str_new(L, (const char *)T->mcode, T->szmcode)); |
361 | setnumV(L->top++, cast_num((intptr_t)T->mcode)); | 361 | setintptrV(L->top++, (intptr_t)(void *)T->mcode); |
362 | setintV(L->top++, T->mcloop); | 362 | setintV(L->top++, T->mcloop); |
363 | return 3; | 363 | return 3; |
364 | } | 364 | } |
@@ -371,7 +371,7 @@ LJLIB_CF(jit_util_traceexitstub) | |||
371 | ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1); | 371 | ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1); |
372 | jit_State *J = L2J(L); | 372 | jit_State *J = L2J(L); |
373 | if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) { | 373 | if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) { |
374 | setnumV(L->top-1, cast_num((intptr_t)exitstub_addr(J, exitno))); | 374 | setintptrV(L->top-1, (intptr_t)(void *)exitstub_addr(J, exitno)); |
375 | return 1; | 375 | return 1; |
376 | } | 376 | } |
377 | return 0; | 377 | return 0; |
@@ -382,7 +382,7 @@ LJLIB_CF(jit_util_ircalladdr) | |||
382 | { | 382 | { |
383 | uint32_t idx = (uint32_t)lj_lib_checkint(L, 1); | 383 | uint32_t idx = (uint32_t)lj_lib_checkint(L, 1); |
384 | if (idx < IRCALL__MAX) { | 384 | if (idx < IRCALL__MAX) { |
385 | setnumV(L->top-1, cast_num((uintptr_t)(void *)lj_ir_callinfo[idx].func)); | 385 | setintptrV(L->top-1, (intptr_t)(void *)lj_ir_callinfo[idx].func); |
386 | return 1; | 386 | return 1; |
387 | } | 387 | } |
388 | return 0; | 388 | return 0; |
@@ -462,11 +462,14 @@ static int jitopt_param(jit_State *J, const char *str) | |||
462 | int i; | 462 | int i; |
463 | for (i = 0; i < JIT_P__MAX; i++) { | 463 | for (i = 0; i < JIT_P__MAX; i++) { |
464 | size_t len = *(const uint8_t *)lst; | 464 | size_t len = *(const uint8_t *)lst; |
465 | TValue tv; | ||
466 | lua_assert(len != 0); | 465 | lua_assert(len != 0); |
467 | if (strncmp(str, lst+1, len) == 0 && str[len] == '=' && | 466 | if (strncmp(str, lst+1, len) == 0 && str[len] == '=') { |
468 | lj_str_numconv(&str[len+1], &tv)) { | 467 | int32_t n = 0; |
469 | J->param[i] = lj_num2int(tv.n); | 468 | const char *p = &str[len+1]; |
469 | while (*p >= '0' && *p <= '9') | ||
470 | n = n*10 + (*p++ - '0'); | ||
471 | if (*p) return 0; /* Malformed number. */ | ||
472 | J->param[i] = n; | ||
470 | if (i == JIT_P_hotloop) | 473 | if (i == JIT_P_hotloop) |
471 | lj_dispatch_init_hotcount(J2G(J)); | 474 | lj_dispatch_init_hotcount(J2G(J)); |
472 | return 1; /* Ok. */ | 475 | return 1; /* Ok. */ |