diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-22 12:16:46 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-22 12:16:46 -0200 |
commit | 4676f6599e04d4eaa78c050616e94994e6a36396 (patch) | |
tree | 94ef87b23d9008bee2fd34df7703c77181b4d655 /lopcodes.h | |
parent | 1d5b885437286a307a77b5d12756d73d374efd54 (diff) | |
download | lua-4676f6599e04d4eaa78c050616e94994e6a36396.tar.gz lua-4676f6599e04d4eaa78c050616e94994e6a36396.tar.bz2 lua-4676f6599e04d4eaa78c050616e94994e6a36396.zip |
new macros 'isOT'/'isIT'
(plus exchanged parameters of OP_VARARG to make it similar to other
'isOT' instructions)
Diffstat (limited to 'lopcodes.h')
-rw-r--r-- | lopcodes.h | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.h,v 1.179 2017/12/15 18:53:48 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.180 2017/12/18 17:49:31 roberto Exp roberto $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -282,7 +282,7 @@ OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */ | |||
282 | 282 | ||
283 | OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */ | 283 | OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */ |
284 | 284 | ||
285 | OP_VARARG,/* A B C R(A), R(A+1), ..., R(A+B-2) = vararg(C) */ | 285 | OP_VARARG,/* A B C R(A), R(A+1), ..., R(A+C-2) = vararg(B) */ |
286 | 286 | ||
287 | OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | 287 | OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ |
288 | } OpCode; | 288 | } OpCode; |
@@ -298,8 +298,8 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | |||
298 | set to last_result+1, so next open instruction (OP_CALL, OP_RETURN, | 298 | set to last_result+1, so next open instruction (OP_CALL, OP_RETURN, |
299 | OP_SETLIST) may use 'top'. | 299 | OP_SETLIST) may use 'top'. |
300 | 300 | ||
301 | (*) In OP_VARARG, if (B == 0) then use actual number of varargs and | 301 | (*) In OP_VARARG, if (C == 0) then use actual number of varargs and |
302 | set top (like in OP_CALL with C == 0). C is the vararg parameter. | 302 | set top (like in OP_CALL with C == 0). B is the vararg parameter. |
303 | 303 | ||
304 | (*) In OP_RETURN, if (B == 0) then return up to 'top'. | 304 | (*) In OP_RETURN, if (B == 0) then return up to 'top'. |
305 | 305 | ||
@@ -330,6 +330,8 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | |||
330 | ** bits 0-2: op mode | 330 | ** bits 0-2: op mode |
331 | ** bit 3: instruction set register A | 331 | ** bit 3: instruction set register A |
332 | ** bit 4: operator is a test (next instruction must be a jump) | 332 | ** bit 4: operator is a test (next instruction must be a jump) |
333 | ** bit 5: instruction sets 'L->top' for next instruction (when C == 0) | ||
334 | ** bit 6: instruction uses 'L->top' set by previous instruction (when B == 0) | ||
333 | */ | 335 | */ |
334 | 336 | ||
335 | LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]; | 337 | LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]; |
@@ -337,8 +339,16 @@ LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]; | |||
337 | #define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 7)) | 339 | #define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 7)) |
338 | #define testAMode(m) (luaP_opmodes[m] & (1 << 3)) | 340 | #define testAMode(m) (luaP_opmodes[m] & (1 << 3)) |
339 | #define testTMode(m) (luaP_opmodes[m] & (1 << 4)) | 341 | #define testTMode(m) (luaP_opmodes[m] & (1 << 4)) |
342 | #define testOTMode(m) (luaP_opmodes[m] & (1 << 5)) | ||
343 | #define testITMode(m) (luaP_opmodes[m] & (1 << 6)) | ||
340 | 344 | ||
341 | #define opmode(t,a,m) (((t)<<4) | ((a)<<3) | (m)) | 345 | /* "out top" (set top for next instruction) */ |
346 | #define isOT(i) (testOTMode(GET_OPCODE(i)) && GETARG_C(i) == 0) | ||
347 | |||
348 | /* "in top" (uses top from previous instruction) */ | ||
349 | #define isIT(i) (testITMode(GET_OPCODE(i)) && GETARG_B(i) == 0) | ||
350 | |||
351 | #define opmode(ot,it,t,a,m) (((ot)<<5) | ((it)<<6) | ((t)<<4) | ((a)<<3) | (m)) | ||
342 | 352 | ||
343 | 353 | ||
344 | LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ | 354 | LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ |