issue #157 rename bytecodes

pull/159/head
Dibyendu Majumdar 6 years ago
parent 5e552ab4a7
commit 08157b102c

@ -269,7 +269,7 @@ OP_RAVI_LE_FF,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
done on a table and the key is known type */
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 */
OP_RAVI_TABLE_SELF_SK,/* 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
key is known to be string but the variable may or may not be

@ -1262,7 +1262,7 @@ class RaviCodeGenerator {
void emit_SELF(RaviFunctionDef *def, int A, int B, int C, int pc);
void emit_SELF_S(RaviFunctionDef *def, int A, int B, int C, int pc,
void emit_TABLE_SELF_SK(RaviFunctionDef *def, int A, int B, int C, int pc,
TString *key);
void emit_SELF_SK(RaviFunctionDef *def, int A, int B, int C, int pc);

@ -116,7 +116,7 @@ opcodes_coverage.GETFIELD = 0
opcodes_coverage.TOTAB = 0
opcodes_coverage.MOVETAB = 0
opcodes_coverage.SETUPVALT = 0
opcodes_coverage.SELF_S = 0
opcodes_coverage.TABLE_SELF_SK = 0
opcodes_coverage.TOTYPE = 0
opcodes_coverage.TOSTRING = 0
opcodes_coverage.TOCLOSURE = 0
@ -1150,7 +1150,7 @@ function test_self_s()
return t:name()
end
check(test_self_s, 'NEWTABLE', 'TABLE_SETFIELD', 'CLOSURE',
'TABLE_SETFIELD', 'GETTABUP_SK', 'SELF_S', 'CALL', 'CALL', 'SELF_S', 'TAILCALL',
'TABLE_SETFIELD', 'GETTABUP_SK', 'TABLE_SELF_SK', 'CALL', 'CALL', 'TABLE_SELF_SK', 'TAILCALL',
'RETURN')
assert(test_self_s() == 'dibyendu majumdar')
compile(test_self_s)

@ -118,7 +118,7 @@ opcodes_coverage.GETFIELD = 0
opcodes_coverage.TOTAB = 0
opcodes_coverage.MOVETAB = 0
opcodes_coverage.SETUPVALT = 0
opcodes_coverage.SELF_S = 0
opcodes_coverage.TABLE_SELF_SK = 0
opcodes_coverage.TOTYPE = 0
opcodes_coverage.TOSTRING = 0
opcodes_coverage.TOCLOSURE = 0

@ -292,7 +292,7 @@ Note that if a Lua functions contains a bytecode that cannot be be JITed then th
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_SELF_SK | YES | R(A+1) := R(B); R(A) := R(B)[RK(C)] |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_SELF_S | YES | R(A+1) := R(B); R(A) := R(B)[RK(C)] |
| OP_RAVI_TABLE_SELF_SK | YES | R(A+1) := R(B); R(A) := R(B)[RK(C)] |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_GETTABUP_SK | YES | R(A) := UpValue[B][RK(C)] |
+-------------------------+----------+--------------------------------------------------+

@ -1041,7 +1041,7 @@ void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
If we only know the key is a string constant
we emit specialized bytecode OP_RAVI_SELF_SK
If we also know that the variable is a table
then we emit OP_RAVI_SELF_S
then we emit OP_RAVI_TABLE_SELF_SK
*/
int is_string_constant_key =
key->k == VK &&
@ -1058,7 +1058,7 @@ 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 :
luaK_codeABC(fs, table_and_string ? OP_RAVI_TABLE_SELF_SK :
(is_string_constant_key ? OP_RAVI_SELF_SK : OP_SELF),
e->u.info, ereg, luaK_exp2RK(fs, key));
freeexp(fs, key);

@ -508,7 +508,7 @@ static const char *getobjname (Proto *p, int lastpc, int reg,
break;
}
case OP_RAVI_SELF_SK:
case OP_RAVI_SELF_S:
case OP_RAVI_TABLE_SELF_SK:
case OP_SELF: {
int k = GETARG_C(i); /* key index */
kname(p, pc, k, name);

@ -155,7 +155,7 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
"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)] */
"TABLE_SELF_SK", /* 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 */
@ -296,7 +296,7 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
,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_TABLE_SELF_SK */
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_RAVI_GETI */
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_RAVI_SETI */
@ -472,7 +472,7 @@ static void PrintCode(const Proto* f)
case OP_RAVI_IARRAY_GET:
case OP_SELF:
case OP_RAVI_GETFIELD:
case OP_RAVI_SELF_S:
case OP_RAVI_TABLE_SELF_SK:
case OP_RAVI_SELF_SK:
if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); }
break;

@ -947,7 +947,7 @@ void luaV_finishOp (lua_State *L) {
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_TABLE_GETFIELD:
case OP_RAVI_SELF_SK: case OP_RAVI_SELF_S:
case OP_RAVI_SELF_SK: case OP_RAVI_TABLE_SELF_SK:
case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: {
setobjs2s(L, base + GETARG_A(inst), --L->top);
break;
@ -1263,7 +1263,7 @@ int luaV_execute (lua_State *L) {
&&vmlabel(OP_RAVI_LE_FF),
&&vmlabel(OP_RAVI_TABLE_GETFIELD),
&&vmlabel(OP_RAVI_TABLE_SETFIELD),
&&vmlabel(OP_RAVI_SELF_S),
&&vmlabel(OP_RAVI_TABLE_SELF_SK),
&&vmlabel(OP_RAVI_GETI),
&&vmlabel(OP_RAVI_SETI),
&&vmlabel(OP_RAVI_GETFIELD),
@ -2122,14 +2122,14 @@ int luaV_execute (lua_State *L) {
GETTABLE_INLINE_SSKEY_PROTECTED(L, rb, rc, ra);
vmbreak;
}
vmcase(OP_RAVI_SELF_S)
vmcase(OP_RAVI_TABLE_SELF_SK)
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
*/
StkId rb = RB(i);
if (op == OP_RAVI_SELF_S) { setobjs2s(L, ra + 1, rb); }
if (op == OP_RAVI_TABLE_SELF_SK) { setobjs2s(L, ra + 1, rb); }
{
lua_assert(ISK(GETARG_C(i)));
TValue *rc = k + INDEXK(GETARG_C(i));

@ -634,7 +634,7 @@ bool raviJ_cancompile(Proto *p) {
case OP_RAVI_GETI:
case OP_GETTABLE:
case OP_SELF:
case OP_RAVI_SELF_S:
case OP_RAVI_TABLE_SELF_SK:
case OP_RAVI_SELF_SK:
case OP_RAVI_SETFIELD:
case OP_RAVI_TABLE_SETFIELD:
@ -2186,7 +2186,7 @@ bool raviJ_codegen(struct lua_State *L, struct Proto *p,
emit_op_setlist(&fn, A, B, C, pc);
} break;
case OP_SELF:
case OP_RAVI_SELF_S:
case OP_RAVI_TABLE_SELF_SK:
case OP_RAVI_SELF_SK: {
int B = GETARG_B(i);
int C = GETARG_C(i);

@ -1654,14 +1654,14 @@ bool RaviCodeGenerator::compile(lua_State *L, Proto *p,
emit_GETTABLE_S(def, A, B, C, pc, key);
} break;
case OP_RAVI_SELF_S: {
case OP_RAVI_TABLE_SELF_SK: {
int C = GETARG_C(i);
int B = GETARG_B(i);
lua_assert(ISK(C));
TValue *kv = k + INDEXK(C);
TString *key = tsvalue(kv);
lua_assert(key->tt == LUA_TSHRSTR);
emit_SELF_S(def, A, B, C, pc, key);
emit_TABLE_SELF_SK(def, A, B, C, pc, key);
} break;
case OP_RAVI_GETI: {
int B = GETARG_B(i);

@ -61,7 +61,7 @@ void RaviCodeGenerator::emit_SELF_SK(RaviFunctionDef *def, int A, int B, int C,
}
// R(A+1) := R(B); R(A) := R(B)[RK(C)]
void RaviCodeGenerator::emit_SELF_S(RaviFunctionDef *def, int A, int B, int C,
void RaviCodeGenerator::emit_TABLE_SELF_SK(RaviFunctionDef *def, int A, int B, int C,
int pc, TString *key) {
// StkId rb = RB(i);
// setobjs2s(L, ra + 1, rb);
@ -69,7 +69,7 @@ void RaviCodeGenerator::emit_SELF_S(RaviFunctionDef *def, int A, int B, int C,
// TString *key = tsvalue(kv);
// const TValue *v = luaH_getstr(hvalue(rb), key);
// setobj2s(L, ra, v);
emit_debug_trace(def, OP_RAVI_SELF_S, pc);
emit_debug_trace(def, OP_RAVI_TABLE_SELF_SK, pc);
emit_load_base(def);
llvm::Value *rb = emit_gep_register(def, B);
llvm::Value *ra1 = emit_gep_register(def, A + 1);

@ -539,7 +539,7 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES + 1] =
"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)] */
"TABLE_SELF_SK", /* 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 */

Loading…
Cancel
Save