issue #169 add op_defer support in JIT backend

asmvm
Dibyendu Majumdar 4 years ago
parent da64639ef1
commit 31824e2a9b

@ -581,6 +581,7 @@ static const char Lua_header[] = ""
"extern void raviV_settable_sskey(lua_State *L, const TValue *t, TValue *key, TValue *val);\n"
"extern void raviV_gettable_i(lua_State *L, const TValue *t, TValue *key, TValue *val);\n"
"extern void raviV_settable_i(lua_State *L, const TValue *t, TValue *key, TValue *val);\n"
"extern void raviV_op_defer(lua_State *L, TValue *ra);\n"
"#define R(i) (base + i)\n"
"#define K(i) (k + i)\n"
"#define tonumberns(o,n) \\\n"
@ -704,7 +705,8 @@ bool raviJ_cancompile(Proto *p) {
case OP_RAVI_TOCLOSURE:
case OP_RAVI_TOSTRING:
case OP_RAVI_TOTYPE:
case OP_LOADKX: break;
case OP_LOADKX:
case OP_RAVI_DEFER: break;
#if 0
case OP_UNM:
case OP_BNOT:
@ -1352,6 +1354,12 @@ static void emit_op_divii(struct function *fn, int A, int B, int C, int pc) {
"(lua_Number)(ivalue(rc)));\n");
}
static void emit_op_defer(struct function *fn, int A, int pc) {
(void)pc;
emit_reg(fn, "ra", A);
membuff_add_string(&fn->body, "raviV_op_defer(L, ra);\n");
}
static void emit_op_loadfz(struct function *fn, int A, int pc) {
(void)pc;
emit_reg(fn, "ra", A);
@ -2257,6 +2265,9 @@ bool raviJ_codegen(struct lua_State *L, struct Proto *p,
int B = GETARG_B(i);
emit_op_len(&fn, A, B, pc);
} break;
case OP_RAVI_DEFER: {
emit_op_defer(&fn, A, pc);
} break;
default: abort();
}
}

@ -104,6 +104,7 @@ static LuaFunc Lua_functions[] = {
{ "raviV_settable_sskey", raviV_settable_sskey },
{ "raviV_gettable_i", raviV_gettable_i },
{ "raviV_settable_i", raviV_settable_i },
{ "raviV_op_defer", raviV_op_defer },
{ "lua_absindex", lua_absindex },
{ "lua_gettop", lua_gettop },

@ -313,6 +313,8 @@ int raviV_initjit(struct lua_State *L) {
register_builtin_arg2(jit->jit, "lua_setmetatable", lua_setmetatable, JIT_Int32, JIT_Address, JIT_Int32);
//LUA_API void (lua_setuservalue)(lua_State *L, int idx);
register_builtin_arg2(jit->jit, "lua_setuservalue", lua_setuservalue, JIT_NoType, JIT_Address, JIT_Int32);
//LUA_API void raviV_op_defer(lua_State *L, TValue *ra);
register_builtin_arg2(jit->jit, "raviV_op_defer", raviV_op_defer, JIT_NoType, JIT_Address, JIT_Address);
G->ravi_state = jit;
return 0;

Loading…
Cancel
Save