issue #128 added setupval

gccjit-ravi534
Dibyendu Majumdar 7 years ago
parent 35ae4cc567
commit 35cb6dc47f

@ -560,6 +560,12 @@ static const char Lua_header[] = ""
"extern void raviV_op_vararg(lua_State *L, CallInfo *ci, LClosure *cl, int a, int b);\n"
"extern void luaV_objlen (lua_State *L, StkId ra, const TValue *rb);\n"
"extern int luaV_forlimit(const TValue *obj, lua_Integer *p, lua_Integer step, int *stopnow);\n"
"extern void raviV_op_setupval(lua_State *L, LClosure *cl, TValue *ra, int b);\n"
"extern void raviV_op_setupvali(lua_State *L, LClosure *cl, TValue *ra, int b);\n"
"extern void raviV_op_setupvalf(lua_State *L, LClosure *cl, TValue *ra, int b);\n"
"extern void raviV_op_setupvalai(lua_State *L, LClosure *cl, TValue *ra, int b);\n"
"extern void raviV_op_setupvalaf(lua_State *L, LClosure *cl, TValue *ra, int b);\n"
"extern void raviV_op_setupvalt(lua_State *L, LClosure *cl, TValue *ra, int b);\n"
"extern void raise_error(lua_State *L, int errorcode);\n"
"#define R(i) (base + i)\n"
"#define K(i) (k + i)\n"
@ -605,6 +611,12 @@ bool raviJ_cancompile(Proto *p) {
case OP_GETTABUP:
case OP_RAVI_GETTABUP_SK:
case OP_GETUPVAL:
case OP_SETUPVAL:
case OP_RAVI_SETUPVALI:
case OP_RAVI_SETUPVALF:
case OP_RAVI_SETUPVALAI:
case OP_RAVI_SETUPVALAF:
case OP_RAVI_SETUPVALT:
case OP_RAVI_GETTABLE_S:
case OP_RAVI_GETTABLE_AI:
case OP_RAVI_GETTABLE_AF:
@ -674,7 +686,6 @@ bool raviJ_cancompile(Proto *p) {
case OP_NOT:
case OP_TFORCALL:
case OP_TFORLOOP:
case OP_SETUPVAL:
case OP_UNM:
#endif
default: {
@ -1304,6 +1315,10 @@ static void emit_op_vararg(struct function *fn, int A, int B, int pc) {
membuff_add_fstring(&fn->body, "raviV_op_vararg(L, ci, cl, %d, %d);\n", A, B);
}
static void emit_op_setupval(struct function *fn, int A, int B, int pc, const char *suffix) {
emit_reg(fn, "ra", A);
membuff_add_fstring(&fn->body, "raviV_op_setupval%s(L, cl, ra, %d);\n", suffix, B);
}
static void emit_op_forprep(struct function *fn, int A, int pc,
int pc1)
{
@ -1543,6 +1558,30 @@ bool raviJ_codegen(struct lua_State *L, struct Proto *p,
int B = GETARG_B(i);
emit_op_getupval(&fn, A, B, pc);
} break;
case OP_SETUPVAL: {
int B = GETARG_B(i);
emit_op_setupval(&fn, A, B, pc, "");
} break;
case OP_RAVI_SETUPVALI: {
int B = GETARG_B(i);
emit_op_setupval(&fn, A, B, pc, "i");
} break;
case OP_RAVI_SETUPVALF: {
int B = GETARG_B(i);
emit_op_setupval(&fn, A, B, pc, "f");
} break;
case OP_RAVI_SETUPVALAI: {
int B = GETARG_B(i);
emit_op_setupval(&fn, A, B, pc, "ai");
} break;
case OP_RAVI_SETUPVALAF: {
int B = GETARG_B(i);
emit_op_setupval(&fn, A, B, pc, "af");
} break;
case OP_RAVI_SETUPVALT: {
int B = GETARG_B(i);
emit_op_setupval(&fn, A, B, pc, "t");
} break;
case OP_NEWTABLE: {
int B = GETARG_B(i);
int C = GETARG_C(i);

@ -176,6 +176,13 @@ int raviV_initjit(struct lua_State *L) {
register_builtin_arg3(jit->jit, "luaV_objlen", luaV_objlen, NJXValueKind_V, NJXValueKind_P, NJXValueKind_P, NJXValueKind_P);
//int luaV_forlimit(const TValue *obj, lua_Integer *p, lua_Integer step, int *stopnow);
register_builtin_arg4(jit->jit, "luaV_forlimit", luaV_forlimit, NJXValueKind_I, NJXValueKind_P, NJXValueKind_P, NJXValueKind_Q, NJXValueKind_P);
// void raviV_op_setupval(lua_State *L, LClosure *cl, TValue *ra, int b);
register_builtin_arg4(jit->jit, "raviV_op_setupval", raviV_op_setupval, NJXValueKind_V, NJXValueKind_P, NJXValueKind_P, NJXValueKind_P, NJXValueKind_I);
register_builtin_arg4(jit->jit, "raviV_op_setupvali", raviV_op_setupvali, NJXValueKind_V, NJXValueKind_P, NJXValueKind_P, NJXValueKind_P, NJXValueKind_I);
register_builtin_arg4(jit->jit, "raviV_op_setupvalf", raviV_op_setupvalf, NJXValueKind_V, NJXValueKind_P, NJXValueKind_P, NJXValueKind_P, NJXValueKind_I);
register_builtin_arg4(jit->jit, "raviV_op_setupvalai", raviV_op_setupvalai, NJXValueKind_V, NJXValueKind_P, NJXValueKind_P, NJXValueKind_P, NJXValueKind_I);
register_builtin_arg4(jit->jit, "raviV_op_setupvalaf", raviV_op_setupvalaf, NJXValueKind_V, NJXValueKind_P, NJXValueKind_P, NJXValueKind_P, NJXValueKind_I);
register_builtin_arg4(jit->jit, "raviV_op_setupvalt", raviV_op_setupvalt, NJXValueKind_V, NJXValueKind_P, NJXValueKind_P, NJXValueKind_P, NJXValueKind_I);
G->ravi_state = jit;
return 0;

Loading…
Cancel
Save