Undo change in the handling of 'L->top' (commit b80077b8f3)
With MMBIN instructions, there are fewer opcodes that need to update 'L->top', so that change does not seem to pay for the increased complexity.
This commit is contained in:
2
lapi.c
2
lapi.c
@@ -329,14 +329,12 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
|
|||||||
o1 = index2value(L, index1);
|
o1 = index2value(L, index1);
|
||||||
o2 = index2value(L, index2);
|
o2 = index2value(L, index2);
|
||||||
if (isvalid(L, o1) && isvalid(L, o2)) {
|
if (isvalid(L, o1) && isvalid(L, o2)) {
|
||||||
ptrdiff_t top = savestack(L, L->top);
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break;
|
case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break;
|
||||||
case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
|
case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
|
||||||
case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
|
case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
|
||||||
default: api_check(L, 0, "invalid option");
|
default: api_check(L, 0, "invalid option");
|
||||||
}
|
}
|
||||||
L->top = restorestack(L, top);
|
|
||||||
}
|
}
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
@@ -127,9 +127,7 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,
|
|||||||
StkId res) {
|
StkId res) {
|
||||||
if (!luaO_rawarith(L, op, p1, p2, s2v(res))) {
|
if (!luaO_rawarith(L, op, p1, p2, s2v(res))) {
|
||||||
/* could not perform raw operation; try metamethod */
|
/* could not perform raw operation; try metamethod */
|
||||||
ptrdiff_t top = savestack(L, L->top);
|
|
||||||
luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD));
|
luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD));
|
||||||
L->top = restorestack(L, top);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
ltm.c
2
ltm.c
@@ -147,7 +147,6 @@ static int callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
|
|||||||
|
|
||||||
void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
|
void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
|
||||||
StkId res, TMS event) {
|
StkId res, TMS event) {
|
||||||
L->top = L->ci->top;
|
|
||||||
if (!callbinTM(L, p1, p2, res, event)) {
|
if (!callbinTM(L, p1, p2, res, event)) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case TM_BAND: case TM_BOR: case TM_BXOR:
|
case TM_BAND: case TM_BOR: case TM_BXOR:
|
||||||
@@ -191,7 +190,6 @@ void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2,
|
|||||||
|
|
||||||
int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
|
int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
|
||||||
TMS event) {
|
TMS event) {
|
||||||
L->top = L->ci->top;
|
|
||||||
if (callbinTM(L, p1, p2, L->top, event)) /* try original event */
|
if (callbinTM(L, p1, p2, L->top, event)) /* try original event */
|
||||||
return !l_isfalse(s2v(L->top));
|
return !l_isfalse(s2v(L->top));
|
||||||
#if defined(LUA_COMPAT_LT_LE)
|
#if defined(LUA_COMPAT_LT_LE)
|
||||||
|
|||||||
19
lvm.c
19
lvm.c
@@ -516,7 +516,6 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
|
|||||||
if (tm == NULL) /* no TM? */
|
if (tm == NULL) /* no TM? */
|
||||||
return 0; /* objects are different */
|
return 0; /* objects are different */
|
||||||
else {
|
else {
|
||||||
L->top = L->ci->top;
|
|
||||||
luaT_callTMres(L, tm, t1, t2, L->top); /* call TM */
|
luaT_callTMres(L, tm, t1, t2, L->top); /* call TM */
|
||||||
return !l_isfalse(s2v(L->top));
|
return !l_isfalse(s2v(L->top));
|
||||||
}
|
}
|
||||||
@@ -925,7 +924,7 @@ void luaV_finishOp (lua_State *L) {
|
|||||||
else if (ttisnumber(s2v(ra)) && ttisnumber(rb)) \
|
else if (ttisnumber(s2v(ra)) && ttisnumber(rb)) \
|
||||||
cond = opf(s2v(ra), rb); \
|
cond = opf(s2v(ra), rb); \
|
||||||
else \
|
else \
|
||||||
ProtectNT(cond = other(L, s2v(ra), rb)); \
|
Protect(cond = other(L, s2v(ra), rb)); \
|
||||||
docondjump(); }
|
docondjump(); }
|
||||||
|
|
||||||
|
|
||||||
@@ -944,7 +943,7 @@ void luaV_finishOp (lua_State *L) {
|
|||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
int isf = GETARG_C(i); \
|
int isf = GETARG_C(i); \
|
||||||
ProtectNT(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm)); \
|
Protect(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm)); \
|
||||||
} \
|
} \
|
||||||
docondjump(); }
|
docondjump(); }
|
||||||
|
|
||||||
@@ -989,7 +988,7 @@ void luaV_finishOp (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
/* for test instructions, execute the jump instruction that follows it */
|
/* for test instructions, execute the jump instruction that follows it */
|
||||||
#define donextjump(ci) { i = *pc; dojump(ci, i, 1); }
|
#define donextjump(ci) { Instruction ni = *pc; dojump(ci, ni, 1); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** do a conditional jump: skip next instruction if 'cond' is not what
|
** do a conditional jump: skip next instruction if 'cond' is not what
|
||||||
@@ -1408,7 +1407,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
|||||||
TMS tm = (TMS)GETARG_C(i);
|
TMS tm = (TMS)GETARG_C(i);
|
||||||
StkId result = RA(pi);
|
StkId result = RA(pi);
|
||||||
lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR);
|
lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR);
|
||||||
ProtectNT(luaT_trybinTM(L, s2v(ra), rb, result, tm));
|
Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm));
|
||||||
vmbreak;
|
vmbreak;
|
||||||
}
|
}
|
||||||
vmcase(OP_MMBINI) {
|
vmcase(OP_MMBINI) {
|
||||||
@@ -1417,7 +1416,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
|||||||
TMS tm = (TMS)GETARG_C(i);
|
TMS tm = (TMS)GETARG_C(i);
|
||||||
int flip = GETARG_k(i);
|
int flip = GETARG_k(i);
|
||||||
StkId result = RA(pi);
|
StkId result = RA(pi);
|
||||||
ProtectNT(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
|
Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
|
||||||
vmbreak;
|
vmbreak;
|
||||||
}
|
}
|
||||||
vmcase(OP_MMBINK) {
|
vmcase(OP_MMBINK) {
|
||||||
@@ -1426,7 +1425,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
|||||||
TMS tm = (TMS)GETARG_C(i);
|
TMS tm = (TMS)GETARG_C(i);
|
||||||
int flip = GETARG_k(i);
|
int flip = GETARG_k(i);
|
||||||
StkId result = RA(pi);
|
StkId result = RA(pi);
|
||||||
ProtectNT(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
|
Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
|
||||||
vmbreak;
|
vmbreak;
|
||||||
}
|
}
|
||||||
vmcase(OP_UNM) {
|
vmcase(OP_UNM) {
|
||||||
@@ -1440,7 +1439,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
|||||||
setfltvalue(s2v(ra), luai_numunm(L, nb));
|
setfltvalue(s2v(ra), luai_numunm(L, nb));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ProtectNT(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
|
Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
|
||||||
vmbreak;
|
vmbreak;
|
||||||
}
|
}
|
||||||
vmcase(OP_BNOT) {
|
vmcase(OP_BNOT) {
|
||||||
@@ -1450,7 +1449,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
|||||||
setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
|
setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ProtectNT(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
|
Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
|
||||||
vmbreak;
|
vmbreak;
|
||||||
}
|
}
|
||||||
vmcase(OP_NOT) {
|
vmcase(OP_NOT) {
|
||||||
@@ -1486,7 +1485,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
|||||||
vmcase(OP_EQ) {
|
vmcase(OP_EQ) {
|
||||||
int cond;
|
int cond;
|
||||||
TValue *rb = vRB(i);
|
TValue *rb = vRB(i);
|
||||||
ProtectNT(cond = luaV_equalobj(L, s2v(ra), rb));
|
Protect(cond = luaV_equalobj(L, s2v(ra), rb));
|
||||||
docondjump();
|
docondjump();
|
||||||
vmbreak;
|
vmbreak;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user