OP_SELF restricted to constant short strings

Optimize this opcode for the common case. For long names or method
calls after too many constants, operation can be coded as a move
followed by 'gettable'.
This commit is contained in:
Roberto Ierusalimschy
2024-12-11 13:56:03 -03:00
parent b4b616bdf2
commit 25a491fe34
5 changed files with 35 additions and 34 deletions

View File

@@ -541,18 +541,6 @@ static void rname (const Proto *p, int pc, int c, const char **name) {
}
/*
** Find a "name" for a 'C' value in an RK instruction.
*/
static void rkname (const Proto *p, int pc, Instruction i, const char **name) {
int c = GETARG_C(i); /* key index */
if (GETARG_k(i)) /* is 'c' a constant? */
kname(p, c, name);
else /* 'c' is a register */
rname(p, pc, c, name);
}
/*
** Check whether table being indexed by instruction 'i' is the
** environment '_ENV'
@@ -600,7 +588,8 @@ static const char *getobjname (const Proto *p, int lastpc, int reg,
return isEnv(p, lastpc, i, 0);
}
case OP_SELF: {
rkname(p, lastpc, i, name);
int k = GETARG_C(i); /* key index */
kname(p, k, name);
return "method";
}
default: break; /* go through to return NULL */