DUALNUM: Add integer type to core VM.

This commit is contained in:
Mike Pall
2011-02-17 00:44:14 +01:00
parent 963f05c7e1
commit 03946ac978
23 changed files with 403 additions and 189 deletions

View File

@@ -70,7 +70,7 @@ LJLIB_CF(jit_off)
LJLIB_CF(jit_flush)
{
#if LJ_HASJIT
if (L->base < L->top && (tvisnum(L->base) || tvisstr(L->base))) {
if (L->base < L->top && !tvisnil(L->base)) {
int traceno = lj_lib_checkint(L, 1);
luaJIT_setmode(L, traceno, LUAJIT_MODE_FLUSH|LUAJIT_MODE_TRACE);
return 0;
@@ -202,8 +202,8 @@ LJLIB_CF(jit_util_funcinfo)
t = tabV(L->top-1);
if (!iscfunc(fn))
setintfield(L, t, "ffid", fn->c.ffid);
setnumV(lj_tab_setstr(L, t, lj_str_newlit(L, "addr")),
cast_num((intptr_t)fn->c.f));
setintptrV(lj_tab_setstr(L, t, lj_str_newlit(L, "addr")),
(intptr_t)(void *)fn->c.f);
setintfield(L, t, "upvalues", fn->c.nupvalues);
}
return 1;
@@ -233,7 +233,7 @@ LJLIB_CF(jit_util_funck)
ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2);
if (idx >= 0) {
if (idx < (ptrdiff_t)pt->sizekn) {
setnumV(L->top-1, proto_knum(pt, idx));
copyTV(L, L->top-1, proto_knumtv(pt, idx));
return 1;
}
} else {
@@ -358,7 +358,7 @@ LJLIB_CF(jit_util_tracemc)
GCtrace *T = jit_checktrace(L);
if (T && T->mcode != NULL) {
setstrV(L, L->top-1, lj_str_new(L, (const char *)T->mcode, T->szmcode));
setnumV(L->top++, cast_num((intptr_t)T->mcode));
setintptrV(L->top++, (intptr_t)(void *)T->mcode);
setintV(L->top++, T->mcloop);
return 3;
}
@@ -371,7 +371,7 @@ LJLIB_CF(jit_util_traceexitstub)
ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1);
jit_State *J = L2J(L);
if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) {
setnumV(L->top-1, cast_num((intptr_t)exitstub_addr(J, exitno)));
setintptrV(L->top-1, (intptr_t)(void *)exitstub_addr(J, exitno));
return 1;
}
return 0;
@@ -382,7 +382,7 @@ LJLIB_CF(jit_util_ircalladdr)
{
uint32_t idx = (uint32_t)lj_lib_checkint(L, 1);
if (idx < IRCALL__MAX) {
setnumV(L->top-1, cast_num((uintptr_t)(void *)lj_ir_callinfo[idx].func));
setintptrV(L->top-1, (intptr_t)(void *)lj_ir_callinfo[idx].func);
return 1;
}
return 0;
@@ -462,11 +462,14 @@ static int jitopt_param(jit_State *J, const char *str)
int i;
for (i = 0; i < JIT_P__MAX; i++) {
size_t len = *(const uint8_t *)lst;
TValue tv;
lua_assert(len != 0);
if (strncmp(str, lst+1, len) == 0 && str[len] == '=' &&
lj_str_numconv(&str[len+1], &tv)) {
J->param[i] = lj_num2int(tv.n);
if (strncmp(str, lst+1, len) == 0 && str[len] == '=') {
int32_t n = 0;
const char *p = &str[len+1];
while (*p >= '0' && *p <= '9')
n = n*10 + (*p++ - '0');
if (*p) return 0; /* Malformed number. */
J->param[i] = n;
if (i == JIT_P_hotloop)
lj_dispatch_init_hotcount(J2G(J));
return 1; /* Ok. */