issue #157 more renaming of bytecodes

pull/159/head
Dibyendu Majumdar 6 years ago
parent b65c595e05
commit 489e118012

@ -274,8 +274,8 @@ OP_RAVI_SELF_S,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)], string key, known t
/* Following opcodes are specialized for indexing where the
key is known to be string but the variable may or may not be
a table */
OP_RAVI_GETTABLE_I,/* A B C R(A) := R(B)[RK(C)], integer key, known table */
OP_RAVI_SETTABLE_I,/* A B C R(A)[RK(B)] := RK(C), integer key, known table */
OP_RAVI_GETI,/* A B C R(A) := R(B)[RK(C)], integer key, known table */
OP_RAVI_SETI,/* A B C R(A)[RK(B)] := RK(C), integer key, known table */
OP_RAVI_GETFIELD, /* A B C R(A) := R(B)[RK(C)], string key */
OP_RAVI_SELF_SK, /* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)], string key */
OP_RAVI_SETFIELD, /* A B C R(A)[RK(B)] := RK(C), string key */

@ -1242,7 +1242,7 @@ class RaviCodeGenerator {
void emit_SETTABLE(RaviFunctionDef *def, int A, int B, int C, int pc);
void emit_SETTABLE_I(RaviFunctionDef *def, int A, int B, int C, int pc);
void emit_SETI(RaviFunctionDef *def, int A, int B, int C, int pc);
void emit_SETFIELD(RaviFunctionDef *def, int A, int B, int C, int pc);
@ -1254,7 +1254,7 @@ class RaviCodeGenerator {
void emit_GETFIELD(RaviFunctionDef *def, int A, int B, int C, int pc,
TString *key);
void emit_GETTABLE_I(RaviFunctionDef *def, int A, int B, int C, int pc);
void emit_GETI(RaviFunctionDef *def, int A, int B, int C, int pc);
void emit_finish_GETTABLE(RaviFunctionDef *def, llvm::Value *phi,
llvm::Value *t, llvm::Value *ra, llvm::Value *rb,

@ -122,7 +122,7 @@ end,
'LOADNIL',
'MUL',
'DIV', 'ADD', 'GETTABLE', 'SUB', 'GETFIELD', 'POW',
'UNM', 'SETTABLE', 'SETTABLE_I', 'RETURN')
'UNM', 'SETTABLE', 'SETI', 'RETURN')
-- direct access to constants

@ -107,9 +107,9 @@ opcodes_coverage.LT_II = 0
opcodes_coverage.LT_FF = 0
opcodes_coverage.LE_II = 0
opcodes_coverage.LE_FF = 0
opcodes_coverage.GETTABLE_I = 0
opcodes_coverage.GETI = 0
opcodes_coverage.GETTABLE_S = 0
opcodes_coverage.SETTABLE_I = 0
opcodes_coverage.SETI = 0
opcodes_coverage.SETTABLE_S = 0
opcodes_coverage.SETFIELD = 0
opcodes_coverage.GETFIELD = 0
@ -216,7 +216,7 @@ end,
'LOADNIL',
'MUL',
'DIV', 'ADD', 'GETTABLE', 'SUB', 'GETFIELD', 'POW',
'UNM', 'SETTABLE', 'SETTABLE_I', 'RETURN')
'UNM', 'SETTABLE', 'SETI', 'RETURN')
-- direct access to constants
check(function ()
@ -564,7 +564,7 @@ function tabtest(x)
return x[1]
end
assert(tabtest({}) == 5)
check(tabtest, 'SETTABLE_I', 'GETTABLE_I', 'RETURN', 'RETURN')
check(tabtest, 'SETI', 'GETI', 'RETURN', 'RETURN')
compile(tabtest)
assert(tabtest({}) == 5)
print("test 16 OK")
@ -665,11 +665,11 @@ z = function()
assert(x() == "SundayMondayTuesdayWednesdayThursdayFridaySaturday")
end
check(z, 'NEWTABLE', 'LOADK', 'LOADK', 'LOADK', 'LOADK',
'LOADK', 'LOADK', 'LOADK', 'SETLIST', 'GETTABUP_SK', 'GETTABLE_I',
'LOADK', 'LOADK', 'LOADK', 'SETLIST', 'GETTABUP_SK', 'GETI',
'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'GETTABUP_SK', 'LEN', 'TOINT',
'EQ_II', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'GETTABUP_SK', 'GETTABLE_I',
'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'GETTABLE_I', 'LOADK',
'CONCAT', 'SETTABLE_I', 'CLOSURE', 'SETUPVAL', 'GETTABUP_SK', 'GETUPVAL',
'EQ_II', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'GETTABUP_SK', 'GETI',
'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'GETI', 'LOADK',
'CONCAT', 'SETI', 'CLOSURE', 'SETUPVAL', 'GETTABUP_SK', 'GETUPVAL',
'GETUPVAL', 'CALL', 'CALL', 'GETTABUP_SK', 'GETUPVAL', 'CALL', 'EQ',
'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'RETURN')
z()
@ -1127,9 +1127,9 @@ function test_tableaccess()
t[2][1] = 'london'
return t[1], t[2][1]
end
check(f, 'NEWTABLE', 'SETTABLE_I', 'NEWTABLE',
'SETTABLE_I', 'GETTABLE_I', 'SETTABLE_I',
'GETTABLE_I', 'GETTABLE_I' , 'GETTABLE_I',
check(f, 'NEWTABLE', 'SETI', 'NEWTABLE',
'SETI', 'GETI', 'SETI',
'GETI', 'GETI' , 'GETI',
'RETURN', 'RETURN')
local a,b = f()
assert(a == 'dibyendu')
@ -1584,7 +1584,7 @@ function x()
:find'not contain __ prefix')
end
check(x, 'GETTABUP_SK', 'NEWTABLE', 'GETTABUP_SK', 'CLOSURE',
'CALL', 'SETLIST', 'GETTABLE_I', 'SELF_SK', 'LOADK',
'CALL', 'SETLIST', 'GETI', 'SELF_SK', 'LOADK',
'CALL', 'CALL', 'RETURN')
print 'Test 64 OK'

@ -109,9 +109,9 @@ opcodes_coverage.LT_II = 0
opcodes_coverage.LT_FF = 0
opcodes_coverage.LE_II = 0
opcodes_coverage.LE_FF = 0
opcodes_coverage.GETTABLE_I = 0
opcodes_coverage.GETI = 0
opcodes_coverage.GETTABLE_S = 0
opcodes_coverage.SETTABLE_I = 0
opcodes_coverage.SETI = 0
opcodes_coverage.SETTABLE_S = 0
opcodes_coverage.SETFIELD = 0
opcodes_coverage.GETFIELD = 0
@ -175,8 +175,8 @@ end
check(x, {'LOADK', 'LOADK', 'GETTABUP_SK', 'EQ_II',
'JMP', 'EQ_FF', 'JMP', 'LOADBOOL', 'LOADBOOL',
'CALL', 'NEWTABLE', 'LOADK', 'LOADK', 'LOADK',
'LOADK', 'LOADK', 'SETLIST', 'GETTABLE_I', 'TOINT',
'MOVEI', 'GETTABLE_I', 'TOFLT', 'MOVEF', 'GETTABUP_SK',
'LOADK', 'LOADK', 'SETLIST', 'GETI', 'TOINT',
'MOVEI', 'GETI', 'TOFLT', 'MOVEF', 'GETTABUP_SK',
'EQ_II', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL',
'GETTABUP_SK', 'EQ_FF', 'JMP', 'LOADBOOL', 'LOADBOOL',
'CALL', 'RETURN'})
@ -214,8 +214,8 @@ compile(x)
y,z = x()
assert(y == 61 and math.abs(z - 19.9) < 1e-10)
check(x, {'LOADK', 'LOADK', 'LOADK', 'GETTABUP_SK',
'GETTABLE_I', 'TOINT', 'GETTABUP', 'TOINT', 'TOINT',
'MULII', 'ADDII', 'LOADK', 'GETTABUP_SK', 'GETTABLE_I',
'GETI', 'TOINT', 'GETTABUP', 'TOINT', 'TOINT',
'MULII', 'ADDII', 'LOADK', 'GETTABUP_SK', 'GETI',
'TOFLT', 'GETTABUP', 'TOFLT', 'MULFF', 'TOFLT',
'SUBFF', 'MOVE', 'MOVE', 'RETURN', 'RETURN'})

@ -272,13 +272,13 @@ Note that if a Lua functions contains a bytecode that cannot be be JITed then th
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_LE_FF | YES | if ((RK(B) <= RK(C)) ~= A) then pc++ |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_GETTABLE_I | YES | R(A) := R(B)[RK(C)], integer key |
| OP_RAVI_GETI | YES | R(A) := R(B)[RK(C)], integer key |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_GETTABLE_S | YES | R(A) := R(B)[RK(C)], string key |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_GETFIELD | YES | R(A) := R(B)[RK(C)], string key |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_SETTABLE_I | YES (4) | R(A)[RK(B)] := RK(C), integer key |
| OP_RAVI_SETI | YES (4) | R(A)[RK(B)] := RK(C), integer key |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_SETTABLE_S | YES (3) | R(A)[RK(B)] := RK(C), string key |
+-------------------------+----------+--------------------------------------------------+

@ -608,7 +608,7 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
else if (e->ravi_type == RAVI_TTABLE && e->u.ind.key_ravi_type == RAVI_TSTRING && isshortstr(fs, e->u.ind.idx))
op = OP_RAVI_GETTABLE_S;
else if (/* e->ravi_type == RAVI_TTABLE &&*/ e->u.ind.key_ravi_type == RAVI_TNUMINT)
op = OP_RAVI_GETTABLE_I;
op = OP_RAVI_GETI;
else if (e->u.ind.key_ravi_type == RAVI_TSTRING && isshortstr(fs, e->u.ind.idx))
op = OP_RAVI_GETFIELD;
else
@ -1012,7 +1012,7 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
op = OP_RAVI_IARRAY_SETI;
} else if (/* var->ravi_type == RAVI_TTABLE &&*/ var->u.ind.key_ravi_type == RAVI_TNUMINT) {
/* table with integer key */
op = OP_RAVI_SETTABLE_I;
op = OP_RAVI_SETI;
} else if (var->ravi_type == RAVI_TTABLE && var->u.ind.key_ravi_type == RAVI_TSTRING && isshortstr(fs, var->u.ind.idx)) {
/* table with string key */
op = OP_RAVI_SETTABLE_S;

@ -477,7 +477,7 @@ static const char *getobjname (Proto *p, int lastpc, int reg,
return getobjname(p, pc, b, name); /* get name for 'b' */
break;
}
case OP_RAVI_GETTABLE_I:
case OP_RAVI_GETI:
case OP_RAVI_GETTABLE_S:
case OP_RAVI_GETFIELD:
case OP_RAVI_IARRAY_GET:
@ -548,10 +548,10 @@ static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
/* all other instructions can call only through metamethods */
/* Ravi: added GETFIELD and SELF_SK because the call may be through metamethod rather than table */
case OP_SELF: case OP_GETTABUP: case OP_GETTABLE:
case OP_RAVI_SELF_SK: case OP_RAVI_GETTABUP_SK: case OP_RAVI_GETFIELD: case OP_RAVI_GETTABLE_I:
case OP_RAVI_SELF_SK: case OP_RAVI_GETTABUP_SK: case OP_RAVI_GETFIELD: case OP_RAVI_GETI:
tm = TM_INDEX;
break;
case OP_SETTABUP: case OP_SETTABLE: case OP_RAVI_SETFIELD: case OP_RAVI_SETTABLE_I:
case OP_SETTABUP: case OP_SETTABLE: case OP_RAVI_SETFIELD: case OP_RAVI_SETI:
tm = TM_NEWINDEX;
break;
case OP_ADD: case OP_SUB: case OP_MUL: case OP_MOD:

@ -157,8 +157,8 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
"SETTABLE_S", /* A B C R(A)[RK(B)] := RK(C), string key */
"SELF_S", /* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
"GETTABLE_I", /* A B C R(A) := R(B)[RK(C)], integer key */
"SETTABLE_I", /* A B C R(A)[RK(B)] := RK(C), integer key */
"GETI", /* A B C R(A) := R(B)[RK(C)], integer key */
"SETI", /* A B C R(A)[RK(B)] := RK(C), integer key */
"GETFIELD", /* _SK */ /* A B C R(A) := R(B)[RK(C)], string key */
"SELF_SK", /* _SK*/ /* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
"SETFIELD", /*_SK */ /* A B C R(A)[RK(B)] := RK(C), string key */
@ -298,8 +298,8 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_SETTABLE_S */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_SELF_S */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_GETTABLE_I */
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_SETTABLE_I */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_GETI */
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_SETI */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_GETFIELD */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_SELF_SK */
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_SETFIELD */
@ -466,7 +466,7 @@ static void PrintCode(const Proto* f)
if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }
break;
case OP_GETTABLE:
case OP_RAVI_GETTABLE_I:
case OP_RAVI_GETI:
case OP_RAVI_GETTABLE_S:
case OP_RAVI_FARRAY_GET:
case OP_RAVI_IARRAY_GET:
@ -477,7 +477,7 @@ static void PrintCode(const Proto* f)
if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); }
break;
case OP_SETTABLE:
case OP_RAVI_SETTABLE_I:
case OP_RAVI_SETI:
case OP_RAVI_SETTABLE_S:
case OP_RAVI_SETFIELD:
case OP_RAVI_FARRAY_SET:

@ -946,7 +946,7 @@ void luaV_finishOp (lua_State *L) {
case OP_MOD: case OP_POW:
case OP_UNM: case OP_BNOT: case OP_LEN:
case OP_RAVI_GETTABUP_SK:
case OP_RAVI_GETFIELD: case OP_RAVI_GETTABLE_I: case OP_RAVI_GETTABLE_S:
case OP_RAVI_GETFIELD: case OP_RAVI_GETI: case OP_RAVI_GETTABLE_S:
case OP_RAVI_SELF_SK: case OP_RAVI_SELF_S:
case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: {
setobjs2s(L, base + GETARG_A(inst), --L->top);
@ -989,7 +989,7 @@ void luaV_finishOp (lua_State *L) {
L->top = ci->top; /* adjust results */
break;
}
case OP_RAVI_SETTABLE_I: case OP_RAVI_SETTABLE_S: case OP_RAVI_SETFIELD:
case OP_RAVI_SETI: case OP_RAVI_SETTABLE_S: case OP_RAVI_SETFIELD:
case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE:
break;
default: lua_assert(0);
@ -1264,8 +1264,8 @@ int luaV_execute (lua_State *L) {
&&vmlabel(OP_RAVI_GETTABLE_S),
&&vmlabel(OP_RAVI_SETTABLE_S),
&&vmlabel(OP_RAVI_SELF_S),
&&vmlabel(OP_RAVI_GETTABLE_I),
&&vmlabel(OP_RAVI_SETTABLE_I),
&&vmlabel(OP_RAVI_GETI),
&&vmlabel(OP_RAVI_SETI),
&&vmlabel(OP_RAVI_GETFIELD),
&&vmlabel(OP_RAVI_SELF_SK),
&&vmlabel(OP_RAVI_SETFIELD),
@ -1362,7 +1362,7 @@ int luaV_execute (lua_State *L) {
SETTABLE_INLINE_PROTECTED(L, ra, rb, rc);
vmbreak;
}
vmcase(OP_RAVI_SETTABLE_I) {
vmcase(OP_RAVI_SETI) {
TValue *rb = RKB(i);
TValue *rc = RKC(i);
SETTABLE_INLINE_PROTECTED_I(L, ra, rb, rc);
@ -2096,7 +2096,7 @@ int luaV_execute (lua_State *L) {
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_RAVI_GETTABLE_I) {
vmcase(OP_RAVI_GETI) {
TValue *rb = RB(i);
TValue *rc = RKC(i);
GETTABLE_INLINE_PROTECTED_I(L, rb, rc, ra);

@ -631,14 +631,14 @@ bool raviJ_cancompile(Proto *p) {
case OP_RAVI_IARRAY_GET:
case OP_RAVI_FARRAY_GET:
case OP_RAVI_GETFIELD:
case OP_RAVI_GETTABLE_I:
case OP_RAVI_GETI:
case OP_GETTABLE:
case OP_SELF:
case OP_RAVI_SELF_S:
case OP_RAVI_SELF_SK:
case OP_RAVI_SETFIELD:
case OP_RAVI_SETTABLE_S:
case OP_RAVI_SETTABLE_I:
case OP_RAVI_SETI:
case OP_RAVI_IARRAY_SETI:
case OP_RAVI_IARRAY_SET:
case OP_RAVI_FARRAY_SETF:
@ -1196,7 +1196,7 @@ static void emit_op_gettable(struct function *fn, int A, int B, int C, int pc, O
emit_reg_or_k(fn, "rc", C);
if (op == OP_RAVI_GETFIELD) {
membuff_add_string(&fn->body, "raviV_gettable_sskey(L, rb, rc, ra);\n"); }
else if (op == OP_RAVI_GETTABLE_I) {
else if (op == OP_RAVI_GETI) {
membuff_add_string(&fn->body, "raviV_gettable_i(L, rb, rc, ra);\n");
}
else {
@ -1235,7 +1235,7 @@ static void emit_op_settable(struct function *fn, int A, int B, int C, int pc, O
emit_reg_or_k(fn, "rc", C);
if (op == OP_RAVI_SETFIELD) {
membuff_add_string(&fn->body, "raviV_settable_sskey(L, ra, rb, rc);\n"); }
else if (op == OP_RAVI_SETTABLE_I) {
else if (op == OP_RAVI_SETI) {
membuff_add_string(&fn->body, "raviV_settable_i(L, ra, rb, rc);\n");
}
else {
@ -1885,7 +1885,7 @@ bool raviJ_codegen(struct lua_State *L, struct Proto *p,
} break;
case OP_RAVI_GETTABLE_S:
case OP_RAVI_GETFIELD:
case OP_RAVI_GETTABLE_I:
case OP_RAVI_GETI:
case OP_GETTABLE: {
int B = GETARG_B(i);
int C = GETARG_C(i);
@ -1903,7 +1903,7 @@ bool raviJ_codegen(struct lua_State *L, struct Proto *p,
} break;
case OP_RAVI_SETFIELD:
case OP_RAVI_SETTABLE_S:
case OP_RAVI_SETTABLE_I:
case OP_RAVI_SETI:
case OP_SETTABLE: {
int B = GETARG_B(i);
int C = GETARG_C(i);

@ -1634,10 +1634,10 @@ bool RaviCodeGenerator::compile(lua_State *L, Proto *p,
int C = GETARG_C(i);
emit_SETFIELD(def, A, B, C, pc);
} break;
case OP_RAVI_SETTABLE_I: {
case OP_RAVI_SETI: {
int B = GETARG_B(i);
int C = GETARG_C(i);
emit_SETTABLE_I(def, A, B, C, pc);
emit_SETI(def, A, B, C, pc);
} break;
case OP_SETTABLE: {
int B = GETARG_B(i);
@ -1663,10 +1663,10 @@ bool RaviCodeGenerator::compile(lua_State *L, Proto *p,
lua_assert(key->tt == LUA_TSHRSTR);
emit_SELF_S(def, A, B, C, pc, key);
} break;
case OP_RAVI_GETTABLE_I: {
case OP_RAVI_GETI: {
int B = GETARG_B(i);
int C = GETARG_C(i);
emit_GETTABLE_I(def, A, B, C, pc);
emit_GETI(def, A, B, C, pc);
} break;
case OP_RAVI_GETFIELD: {
int B = GETARG_B(i);

@ -95,9 +95,9 @@ void RaviCodeGenerator::emit_LEN(RaviFunctionDef *def, int A, int B, int pc) {
// This relies on two things:
// a) we know we have a table
// b) we know the key is an integer
void RaviCodeGenerator::emit_SETTABLE_I(RaviFunctionDef *def, int A, int B,
void RaviCodeGenerator::emit_SETI(RaviFunctionDef *def, int A, int B,
int C, int pc) {
bool traced = emit_debug_trace(def, OP_RAVI_SETTABLE_I, pc);
bool traced = emit_debug_trace(def, OP_RAVI_SETI, pc);
if (!traced) emit_update_savedpc(def, pc);
emit_load_base(def);
llvm::Value *ra = emit_gep_register(def, A);
@ -201,10 +201,10 @@ void RaviCodeGenerator::emit_GETFIELD(RaviFunctionDef *def, int A, int B,
// luaH_getint(). This relies on two things:
// a) we know we have a table
// b) we know the key is an integer
void RaviCodeGenerator::emit_GETTABLE_I(RaviFunctionDef *def, int A, int B,
void RaviCodeGenerator::emit_GETI(RaviFunctionDef *def, int A, int B,
int C, int pc) {
// changed to that target may not be a table
bool traced = emit_debug_trace(def, OP_RAVI_GETTABLE_I, pc);
bool traced = emit_debug_trace(def, OP_RAVI_GETI, pc);
if (!traced) emit_update_savedpc(def, pc);
emit_load_base(def);
llvm::Value *ra = emit_gep_register(def, A);

@ -541,8 +541,8 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES + 1] =
"SETTABLE_S", /* A B C R(A)[RK(B)] := RK(C), string key */
"SELF_S", /* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
"GETTABLE_I", /* A B C R(A) := R(B)[RK(C)], integer key */
"SETTABLE_I", /* A B C R(A)[RK(B)] := RK(C), integer key */
"GETI", /* A B C R(A) := R(B)[RK(C)], integer key */
"SETI", /* A B C R(A)[RK(B)] := RK(C), integer key */
"GETFIELD",
/* _SK */ /* A B C R(A) := R(B)[RK(C)], string key */
"SELF_SK",

Loading…
Cancel
Save