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

6
lvm.c
View File

@@ -1382,10 +1382,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
StkId ra = RA(i);
lu_byte tag;
TValue *rb = vRB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rc); /* key must be a string */
TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a short string */
setobj2s(L, ra + 1, rb);
luaV_fastget(rb, key, s2v(ra), luaH_getstr, tag);
luaV_fastget(rb, key, s2v(ra), luaH_getshortstr, tag);
if (tagisempty(tag))
Protect(luaV_finishget(L, rb, rc, ra, tag));
vmbreak;