issue #157 more renaming of bytecodes

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

@ -267,8 +267,8 @@ OP_RAVI_LE_FF,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
/* Following op codes are specialised when it is known that indexing is being
done on a table and the key is known type */
OP_RAVI_GETTABLE_S,/* A B C R(A) := R(B)[RK(C)], string key, known table */
OP_RAVI_SETTABLE_S,/* A B C R(A)[RK(B)] := RK(C), string key, known table */
OP_RAVI_TABLE_GETFIELD,/* A B C R(A) := R(B)[RK(C)], string key, known table */
OP_RAVI_TABLE_SETFIELD,/* A B C R(A)[RK(B)] := RK(C), string key, known table */
OP_RAVI_SELF_S,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)], string key, known table */
/* Following opcodes are specialized for indexing where the

@ -108,9 +108,9 @@ opcodes_coverage.LT_FF = 0
opcodes_coverage.LE_II = 0
opcodes_coverage.LE_FF = 0
opcodes_coverage.GETI = 0
opcodes_coverage.GETTABLE_S = 0
opcodes_coverage.TABLE_GETFIELD = 0
opcodes_coverage.SETI = 0
opcodes_coverage.SETTABLE_S = 0
opcodes_coverage.TABLE_SETFIELD = 0
opcodes_coverage.SETFIELD = 0
opcodes_coverage.GETFIELD = 0
opcodes_coverage.TOTAB = 0
@ -1105,9 +1105,9 @@ function test_tableaccess()
t.data.city = 'london'
return t.name, t.data.city
end
check(f, 'NEWTABLE', 'SETTABLE_S', 'NEWTABLE',
'SETTABLE_S', 'GETTABLE_S', 'SETFIELD',
'GETTABLE_S', 'GETTABLE_S' , 'GETFIELD',
check(f, 'NEWTABLE', 'TABLE_SETFIELD', 'NEWTABLE',
'TABLE_SETFIELD', 'TABLE_GETFIELD', 'SETFIELD',
'TABLE_GETFIELD', 'TABLE_GETFIELD' , 'GETFIELD',
'RETURN', 'RETURN')
local a,b = f()
assert(a == 'dibyendu')
@ -1149,8 +1149,8 @@ function test_self_s()
assert(t:name())
return t:name()
end
check(test_self_s, 'NEWTABLE', 'SETTABLE_S', 'CLOSURE',
'SETTABLE_S', 'GETTABUP_SK', 'SELF_S', 'CALL', 'CALL', 'SELF_S', 'TAILCALL',
check(test_self_s, 'NEWTABLE', 'TABLE_SETFIELD', 'CLOSURE',
'TABLE_SETFIELD', 'GETTABUP_SK', 'SELF_S', 'CALL', 'CALL', 'SELF_S', 'TAILCALL',
'RETURN')
assert(test_self_s() == 'dibyendu majumdar')
compile(test_self_s)
@ -1252,11 +1252,11 @@ function test_longkey()
assert(t.s == nil)
end
check(test_longkey, 'NEWTABLE', 'SETTABLE', 'GETTABUP_SK', 'GETTABLE',
'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'SETTABLE_S', 'GETTABUP_SK',
'GETTABLE_S', 'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'SETTABLE_S',
'GETTABUP_SK', 'GETTABLE_S', 'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL',
'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'TABLE_SETFIELD', 'GETTABUP_SK',
'TABLE_GETFIELD', 'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL', 'TABLE_SETFIELD',
'GETTABUP_SK', 'TABLE_GETFIELD', 'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL',
'LOADK', 'GETTABUP_SK', 'GETTABLE', 'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL',
'GETTABUP_SK', 'GETTABLE_S', 'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL',
'GETTABUP_SK', 'TABLE_GETFIELD', 'EQ', 'JMP', 'LOADBOOL', 'LOADBOOL', 'CALL',
'RETURN')
assert(pcall(test_longkey));
compile(test_longkey);

@ -110,9 +110,9 @@ opcodes_coverage.LT_FF = 0
opcodes_coverage.LE_II = 0
opcodes_coverage.LE_FF = 0
opcodes_coverage.GETI = 0
opcodes_coverage.GETTABLE_S = 0
opcodes_coverage.TABLE_GETFIELD = 0
opcodes_coverage.SETI = 0
opcodes_coverage.SETTABLE_S = 0
opcodes_coverage.TABLE_SETFIELD = 0
opcodes_coverage.SETFIELD = 0
opcodes_coverage.GETFIELD = 0
opcodes_coverage.TOTAB = 0

@ -274,13 +274,13 @@ Note that if a Lua functions contains a bytecode that cannot be be JITed then th
+-------------------------+----------+--------------------------------------------------+
| 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_TABLE_GETFIELD | YES | R(A) := R(B)[RK(C)], string key |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_GETFIELD | YES | R(A) := R(B)[RK(C)], string 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 |
| OP_RAVI_TABLE_SETFIELD | YES (3) | R(A)[RK(B)] := RK(C), string key |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_SETFIELD | YES | R(A)[RK(B)] := RK(C), string key |
+-------------------------+----------+--------------------------------------------------+

@ -606,8 +606,8 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
op = OP_RAVI_IARRAY_GET;
/* Check that we have a short string constant */
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_TABLE_GETFIELD;
else if (e->u.ind.key_ravi_type == RAVI_TNUMINT)
op = OP_RAVI_GETI;
else if (e->u.ind.key_ravi_type == RAVI_TSTRING && isshortstr(fs, e->u.ind.idx))
op = OP_RAVI_GETFIELD;
@ -1010,15 +1010,15 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
else
/* input value is known to be integer */
op = OP_RAVI_IARRAY_SETI;
} else if (/* var->ravi_type == RAVI_TTABLE &&*/ var->u.ind.key_ravi_type == RAVI_TNUMINT) {
/* table with integer key */
} else if (var->u.ind.key_ravi_type == RAVI_TNUMINT) {
/* index op with integer key, target may not be a table */
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;
op = OP_RAVI_TABLE_SETFIELD;
}
else if (var->u.ind.key_ravi_type == RAVI_TSTRING && isshortstr(fs, var->u.ind.idx)) {
/* table with string key */
/* index op with string key, target may not be a table */
op = OP_RAVI_SETFIELD;
}
}
@ -1058,7 +1058,9 @@ void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
e->u.info = fs->freereg; /* base register for op_self */
e->k = VNONRELOC; /* self expression has a fixed register */
luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */
luaK_codeABC(fs, table_and_string ? OP_RAVI_SELF_S : (is_string_constant_key ? OP_RAVI_SELF_SK : OP_SELF), e->u.info, ereg, luaK_exp2RK(fs, key));
luaK_codeABC(fs, table_and_string ? OP_RAVI_SELF_S :
(is_string_constant_key ? OP_RAVI_SELF_SK : OP_SELF),
e->u.info, ereg, luaK_exp2RK(fs, key));
freeexp(fs, key);
}

@ -478,7 +478,7 @@ static const char *getobjname (Proto *p, int lastpc, int reg,
break;
}
case OP_RAVI_GETI:
case OP_RAVI_GETTABLE_S:
case OP_RAVI_TABLE_GETFIELD:
case OP_RAVI_GETFIELD:
case OP_RAVI_IARRAY_GET:
case OP_RAVI_FARRAY_GET:

@ -153,8 +153,8 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
"LE_II", /* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
"LE_FF", /* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
"GETTABLE_S", /* A B C R(A) := R(B)[RK(C)], string key */
"SETTABLE_S", /* A B C R(A)[RK(B)] := RK(C), string key */
"TABLE_GETFIELD", /* A B C R(A) := R(B)[RK(C)], string key */
"TABLE_SETFIELD", /* 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)] */
"GETI", /* A B C R(A) := R(B)[RK(C)], integer key */
@ -294,8 +294,8 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_LE_II */
,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_LE_FF */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_GETTABLE_S */
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_SETTABLE_S */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_TABLE_GETFIELD */
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_TABLE_SETFIELD */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_SELF_S */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_GETI */
@ -467,7 +467,7 @@ static void PrintCode(const Proto* f)
break;
case OP_GETTABLE:
case OP_RAVI_GETI:
case OP_RAVI_GETTABLE_S:
case OP_RAVI_TABLE_GETFIELD:
case OP_RAVI_FARRAY_GET:
case OP_RAVI_IARRAY_GET:
case OP_SELF:
@ -478,7 +478,7 @@ static void PrintCode(const Proto* f)
break;
case OP_SETTABLE:
case OP_RAVI_SETI:
case OP_RAVI_SETTABLE_S:
case OP_RAVI_TABLE_SETFIELD:
case OP_RAVI_SETFIELD:
case OP_RAVI_FARRAY_SET:
case OP_RAVI_FARRAY_SETF:

@ -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_GETI: case OP_RAVI_GETTABLE_S:
case OP_RAVI_GETFIELD: case OP_RAVI_GETI: case OP_RAVI_TABLE_GETFIELD:
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_SETI: case OP_RAVI_SETTABLE_S: case OP_RAVI_SETFIELD:
case OP_RAVI_SETI: case OP_RAVI_TABLE_SETFIELD: case OP_RAVI_SETFIELD:
case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE:
break;
default: lua_assert(0);
@ -1261,8 +1261,8 @@ int luaV_execute (lua_State *L) {
&&vmlabel(OP_RAVI_LT_FF),
&&vmlabel(OP_RAVI_LE_II),
&&vmlabel(OP_RAVI_LE_FF),
&&vmlabel(OP_RAVI_GETTABLE_S),
&&vmlabel(OP_RAVI_SETTABLE_S),
&&vmlabel(OP_RAVI_TABLE_GETFIELD),
&&vmlabel(OP_RAVI_TABLE_SETFIELD),
&&vmlabel(OP_RAVI_SELF_S),
&&vmlabel(OP_RAVI_GETI),
&&vmlabel(OP_RAVI_SETI),
@ -1369,7 +1369,7 @@ int luaV_execute (lua_State *L) {
vmbreak;
}
vmcase(OP_RAVI_SETFIELD)
vmcase(OP_RAVI_SETTABLE_S) {
vmcase(OP_RAVI_TABLE_SETFIELD) {
TValue *rb = RKB(i);
TValue *rc = RKC(i);
SETTABLE_INLINE_SSKEY_PROTECTED(L, ra, rb, rc);
@ -2123,7 +2123,7 @@ int luaV_execute (lua_State *L) {
vmbreak;
}
vmcase(OP_RAVI_SELF_S)
vmcase(OP_RAVI_GETTABLE_S) {
vmcase(OP_RAVI_TABLE_GETFIELD) {
/* This opcode is used when the key is known to be
short string and the variable is known to be
a table

@ -627,7 +627,7 @@ bool raviJ_cancompile(Proto *p) {
case OP_RAVI_SETUPVAL_IARRAY:
case OP_RAVI_SETUPVAL_FARRAY:
case OP_RAVI_SETUPVALT:
case OP_RAVI_GETTABLE_S:
case OP_RAVI_TABLE_GETFIELD:
case OP_RAVI_IARRAY_GET:
case OP_RAVI_FARRAY_GET:
case OP_RAVI_GETFIELD:
@ -637,7 +637,7 @@ bool raviJ_cancompile(Proto *p) {
case OP_RAVI_SELF_S:
case OP_RAVI_SELF_SK:
case OP_RAVI_SETFIELD:
case OP_RAVI_SETTABLE_S:
case OP_RAVI_TABLE_SETFIELD:
case OP_RAVI_SETI:
case OP_RAVI_IARRAY_SETI:
case OP_RAVI_IARRAY_SET:
@ -1883,7 +1883,7 @@ bool raviJ_codegen(struct lua_State *L, struct Proto *p,
int j = sbx + pc + 1;
emit_op_testset(&fn, A, B, C, j, GETARG_A(i), pc - 1);
} break;
case OP_RAVI_GETTABLE_S:
case OP_RAVI_TABLE_GETFIELD:
case OP_RAVI_GETFIELD:
case OP_RAVI_GETI:
case OP_GETTABLE: {
@ -1902,7 +1902,7 @@ bool raviJ_codegen(struct lua_State *L, struct Proto *p,
emit_FARRAY_GET(&fn, A, B, C, options->omit_array_get_range_check, pc);
} break;
case OP_RAVI_SETFIELD:
case OP_RAVI_SETTABLE_S:
case OP_RAVI_TABLE_SETFIELD:
case OP_RAVI_SETI:
case OP_SETTABLE: {
int B = GETARG_B(i);

@ -1629,7 +1629,7 @@ bool RaviCodeGenerator::compile(lua_State *L, Proto *p,
} break;
case OP_RAVI_SETFIELD:
case OP_RAVI_SETTABLE_S: {
case OP_RAVI_TABLE_SETFIELD: {
int B = GETARG_B(i);
int C = GETARG_C(i);
emit_SETFIELD(def, A, B, C, pc);
@ -1644,7 +1644,7 @@ bool RaviCodeGenerator::compile(lua_State *L, Proto *p,
int C = GETARG_C(i);
emit_SETTABLE(def, A, B, C, pc);
} break;
case OP_RAVI_GETTABLE_S: {
case OP_RAVI_TABLE_GETFIELD: {
int C = GETARG_C(i);
int B = GETARG_B(i);
lua_assert(ISK(C));

@ -467,7 +467,7 @@ void RaviCodeGenerator::emit_GETTABLE_S(RaviFunctionDef *def, int A, int B,
// return gval(n);
// return luaH_getstr(t, key);
emit_debug_trace(def, OP_RAVI_GETTABLE_S, pc);
emit_debug_trace(def, OP_RAVI_TABLE_GETFIELD, pc);
emit_load_base(def);
emit_common_GETTABLE_S(def, A, B, C, key);
}

@ -537,17 +537,14 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES + 1] =
"LE_II", /* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
"LE_FF", /* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
"GETTABLE_S", /* A B C R(A) := R(B)[RK(C)], string key */
"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)] */
"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 */
"TABLE_GETFIELD", /* A B C R(A) := R(B)[RK(C)], string key */
"TABLE_SETFIELD", /* 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)] */
"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", /* A B C R(A) := R(B)[RK(C)], string key */
"SELF_SK", /* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
"SETFIELD", /* A B C R(A)[RK(B)] := RK(C), string key */
"GETTABUP_SK",
NULL};

Loading…
Cancel
Save