aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lcode.c4
-rw-r--r--ldebug.c2
-rw-r--r--lopcodes.c28
-rw-r--r--lopcodes.h12
-rw-r--r--ltable.c2
-rw-r--r--lvm.c4
6 files changed, 38 insertions, 14 deletions
diff --git a/lcode.c b/lcode.c
index a74c2a16..e120f0db 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1844,7 +1844,9 @@ void luaK_finish (FuncState *fs) {
1844 Proto *p = fs->f; 1844 Proto *p = fs->f;
1845 for (i = 0; i < fs->pc; i++) { 1845 for (i = 0; i < fs->pc; i++) {
1846 Instruction *pc = &p->code[i]; 1846 Instruction *pc = &p->code[i];
1847 lua_assert(i == 0 || isOT(*(pc - 1)) == isIT(*pc)); 1847 /* avoid "not used" warnings when assert is off (for 'onelua.c') */
1848 (void)luaP_isOT; (void)luaP_isIT;
1849 lua_assert(i == 0 || luaP_isOT(*(pc - 1)) == luaP_isIT(*pc));
1848 switch (GET_OPCODE(*pc)) { 1850 switch (GET_OPCODE(*pc)) {
1849 case OP_RETURN0: case OP_RETURN1: { 1851 case OP_RETURN0: case OP_RETURN1: {
1850 if (!(fs->needclose || (p->flag & PF_ISVARARG))) 1852 if (!(fs->needclose || (p->flag & PF_ISVARARG)))
diff --git a/ldebug.c b/ldebug.c
index e199decf..202d6417 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -939,7 +939,7 @@ int luaG_traceexec (lua_State *L, const Instruction *pc) {
939 ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ 939 ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */
940 return 1; /* do not call hook again (VM yielded, so it did not move) */ 940 return 1; /* do not call hook again (VM yielded, so it did not move) */
941 } 941 }
942 if (!isIT(*(ci->u.l.savedpc - 1))) /* top not being used? */ 942 if (!luaP_isIT(*(ci->u.l.savedpc - 1))) /* top not being used? */
943 L->top.p = ci->top.p; /* correct top */ 943 L->top.p = ci->top.p; /* correct top */
944 if (counthook) 944 if (counthook)
945 luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */ 945 luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */
diff --git a/lopcodes.c b/lopcodes.c
index c67aa227..2f9d55c5 100644
--- a/lopcodes.c
+++ b/lopcodes.c
@@ -13,6 +13,10 @@
13#include "lopcodes.h" 13#include "lopcodes.h"
14 14
15 15
16#define opmode(mm,ot,it,t,a,m) \
17 (((mm) << 7) | ((ot) << 6) | ((it) << 5) | ((t) << 4) | ((a) << 3) | (m))
18
19
16/* ORDER OP */ 20/* ORDER OP */
17 21
18LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { 22LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
@@ -102,3 +106,27 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
102 ,opmode(0, 0, 0, 0, 0, iAx) /* OP_EXTRAARG */ 106 ,opmode(0, 0, 0, 0, 0, iAx) /* OP_EXTRAARG */
103}; 107};
104 108
109
110
111/*
112** Check whether instruction sets top for next instruction, that is,
113** it results in multiple values.
114*/
115int luaP_isOT (Instruction i) {
116 OpCode op = GET_OPCODE(i);
117 switch (op) {
118 case OP_TAILCALL: return 1;
119 default:
120 return testOTMode(op) && GETARG_C(i) == 0;
121 }
122}
123
124
125/*
126** Check whether instruction uses top from previous instruction, that is,
127** it accepts multiple results.
128*/
129int luaP_isIT (Instruction i) {
130 return testITMode(GET_OPCODE(i)) && GETARG_B(i) == 0;
131}
132
diff --git a/lopcodes.h b/lopcodes.h
index 1d31e7c5..63918be1 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -8,6 +8,7 @@
8#define lopcodes_h 8#define lopcodes_h
9 9
10#include "llimits.h" 10#include "llimits.h"
11#include "lobject.h"
11 12
12 13
13/*=========================================================================== 14/*===========================================================================
@@ -394,16 +395,9 @@ LUAI_DDEC(const lu_byte luaP_opmodes[NUM_OPCODES];)
394#define testOTMode(m) (luaP_opmodes[m] & (1 << 6)) 395#define testOTMode(m) (luaP_opmodes[m] & (1 << 6))
395#define testMMMode(m) (luaP_opmodes[m] & (1 << 7)) 396#define testMMMode(m) (luaP_opmodes[m] & (1 << 7))
396 397
397/* "out top" (set top for next instruction) */
398#define isOT(i) \
399 ((testOTMode(GET_OPCODE(i)) && GETARG_C(i) == 0) || \
400 GET_OPCODE(i) == OP_TAILCALL)
401 398
402/* "in top" (uses top from previous instruction) */ 399LUAI_FUNC int luaP_isOT (Instruction i);
403#define isIT(i) (testITMode(GET_OPCODE(i)) && GETARG_B(i) == 0) 400LUAI_FUNC int luaP_isIT (Instruction i);
404
405#define opmode(mm,ot,it,t,a,m) \
406 (((mm) << 7) | ((ot) << 6) | ((it) << 5) | ((t) << 4) | ((a) << 3) | (m))
407 401
408 402
409#endif 403#endif
diff --git a/ltable.c b/ltable.c
index 40a4683f..1be291c7 100644
--- a/ltable.c
+++ b/ltable.c
@@ -278,7 +278,7 @@ static int equalkey (const TValue *k1, const Node *n2, int deadok) {
278/* 278/*
279** Returns the real size of the 'array' array 279** Returns the real size of the 'array' array
280*/ 280*/
281LUAI_FUNC unsigned int luaH_realasize (const Table *t) { 281unsigned int luaH_realasize (const Table *t) {
282 if (limitequalsasize(t)) 282 if (limitequalsasize(t))
283 return t->alimit; /* this is the size */ 283 return t->alimit; /* this is the size */
284 else { 284 else {
diff --git a/lvm.c b/lvm.c
index 940a15e6..4bc8ee81 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1180,8 +1180,8 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1180 #endif 1180 #endif
1181 lua_assert(base == ci->func.p + 1); 1181 lua_assert(base == ci->func.p + 1);
1182 lua_assert(base <= L->top.p && L->top.p <= L->stack_last.p); 1182 lua_assert(base <= L->top.p && L->top.p <= L->stack_last.p);
1183 /* invalidate top for instructions not expecting it */ 1183 /* for tests, invalidate top for instructions not expecting it */
1184 lua_assert(isIT(i) || (cast_void(L->top.p = base), 1)); 1184 lua_assert(luaP_isIT(i) || (cast_void(L->top.p = base), 1));
1185 vmdispatch (GET_OPCODE(i)) { 1185 vmdispatch (GET_OPCODE(i)) {
1186 vmcase(OP_MOVE) { 1186 vmcase(OP_MOVE) {
1187 StkId ra = RA(i); 1187 StkId ra = RA(i);