Skip to content

Commit

Permalink
issue #169 add op_defer support in JIT backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Dibyendu Majumdar committed Dec 28, 2019
1 parent da64639 commit 31824e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/ravi_jitshared.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ravi_mirjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 2 additions & 0 deletions src/ravi_omrjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 31824e2

Please sign in to comment.