aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-12-05 12:59:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-12-05 12:59:42 -0300
commit490ecfcaa1f25fcc17f9dcb0ed7216da54a391e3 (patch)
tree0f6c221c65ddad7b73a223c40cb6cd3e4f324102 /lopcodes.h
parente174f43807d46a7c0a9ab5eeb3fc4434bcb0091f (diff)
downloadlua-490ecfcaa1f25fcc17f9dcb0ed7216da54a391e3.tar.gz
lua-490ecfcaa1f25fcc17f9dcb0ed7216da54a391e3.tar.bz2
lua-490ecfcaa1f25fcc17f9dcb0ed7216da54a391e3.zip
Better comments about the use of 'k' in opcodes
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h42
1 files changed, 23 insertions, 19 deletions
diff --git a/lopcodes.h b/lopcodes.h
index 382dec05..aec9dcbc 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -217,7 +217,7 @@ OP_SETTABLE,/* A B C R[A][R[B]] := RK(C) */
217OP_SETI,/* A B C R[A][B] := RK(C) */ 217OP_SETI,/* A B C R[A][B] := RK(C) */
218OP_SETFIELD,/* A B C R[A][K[B]:string] := RK(C) */ 218OP_SETFIELD,/* A B C R[A][K[B]:string] := RK(C) */
219 219
220OP_NEWTABLE,/* A B C R[A] := {} */ 220OP_NEWTABLE,/* A B C k R[A] := {} */
221 221
222OP_SELF,/* A B C R[A+1] := R[B]; R[A] := R[B][RK(C):string] */ 222OP_SELF,/* A B C R[A+1] := R[B]; R[A] := R[B][RK(C):string] */
223 223
@@ -253,8 +253,8 @@ OP_SHL,/* A B C R[A] := R[B] << R[C] */
253OP_SHR,/* A B C R[A] := R[B] >> R[C] */ 253OP_SHR,/* A B C R[A] := R[B] >> R[C] */
254 254
255OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] */ 255OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] */
256OP_MMBINI,/* A sB C call C metamethod over R[A] and sB */ 256OP_MMBINI,/* A sB C k call C metamethod over R[A] and sB */
257OP_MMBINK,/* A B C call C metamethod over R[A] and K[B] */ 257OP_MMBINK,/* A B C k call C metamethod over R[A] and K[B] */
258 258
259OP_UNM,/* A B R[A] := -R[B] */ 259OP_UNM,/* A B R[A] := -R[B] */
260OP_BNOT,/* A B R[A] := ~R[B] */ 260OP_BNOT,/* A B R[A] := ~R[B] */
@@ -266,24 +266,24 @@ OP_CONCAT,/* A B R[A] := R[A].. ... ..R[A + B - 1] */
266OP_CLOSE,/* A close all upvalues >= R[A] */ 266OP_CLOSE,/* A close all upvalues >= R[A] */
267OP_TBC,/* A mark variable A "to be closed" */ 267OP_TBC,/* A mark variable A "to be closed" */
268OP_JMP,/* sJ pc += sJ */ 268OP_JMP,/* sJ pc += sJ */
269OP_EQ,/* A B if ((R[A] == R[B]) ~= k) then pc++ */ 269OP_EQ,/* A B k if ((R[A] == R[B]) ~= k) then pc++ */
270OP_LT,/* A B if ((R[A] < R[B]) ~= k) then pc++ */ 270OP_LT,/* A B k if ((R[A] < R[B]) ~= k) then pc++ */
271OP_LE,/* A B if ((R[A] <= R[B]) ~= k) then pc++ */ 271OP_LE,/* A B k if ((R[A] <= R[B]) ~= k) then pc++ */
272 272
273OP_EQK,/* A B if ((R[A] == K[B]) ~= k) then pc++ */ 273OP_EQK,/* A B k if ((R[A] == K[B]) ~= k) then pc++ */
274OP_EQI,/* A sB if ((R[A] == sB) ~= k) then pc++ */ 274OP_EQI,/* A sB k if ((R[A] == sB) ~= k) then pc++ */
275OP_LTI,/* A sB if ((R[A] < sB) ~= k) then pc++ */ 275OP_LTI,/* A sB k if ((R[A] < sB) ~= k) then pc++ */
276OP_LEI,/* A sB if ((R[A] <= sB) ~= k) then pc++ */ 276OP_LEI,/* A sB k if ((R[A] <= sB) ~= k) then pc++ */
277OP_GTI,/* A sB if ((R[A] > sB) ~= k) then pc++ */ 277OP_GTI,/* A sB k if ((R[A] > sB) ~= k) then pc++ */
278OP_GEI,/* A sB if ((R[A] >= sB) ~= k) then pc++ */ 278OP_GEI,/* A sB k if ((R[A] >= sB) ~= k) then pc++ */
279 279
280OP_TEST,/* A if (not R[A] == k) then pc++ */ 280OP_TEST,/* A k if (not R[A] == k) then pc++ */
281OP_TESTSET,/* A B if (not R[B] == k) then pc++ else R[A] := R[B] */ 281OP_TESTSET,/* A B k if (not R[B] == k) then pc++ else R[A] := R[B] */
282 282
283OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */ 283OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */
284OP_TAILCALL,/* A B C return R[A](R[A+1], ... ,R[A+B-1]) */ 284OP_TAILCALL,/* A B C k return R[A](R[A+1], ... ,R[A+B-1]) */
285 285
286OP_RETURN,/* A B C return R[A], ... ,R[A+B-2] (see note) */ 286OP_RETURN,/* A B C k return R[A], ... ,R[A+B-2] (see note) */
287OP_RETURN0,/* return */ 287OP_RETURN0,/* return */
288OP_RETURN1,/* A return R[A] */ 288OP_RETURN1,/* A return R[A] */
289 289
@@ -295,7 +295,7 @@ OP_TFORPREP,/* A Bx create upvalue for R[A + 3]; pc+=Bx */
295OP_TFORCALL,/* A C R[A+4], ... ,R[A+3+C] := R[A](R[A+1], R[A+2]); */ 295OP_TFORCALL,/* A C R[A+4], ... ,R[A+3+C] := R[A](R[A+1], R[A+2]); */
296OP_TFORLOOP,/* A Bx if R[A+2] ~= nil then { R[A]=R[A+2]; pc -= Bx } */ 296OP_TFORLOOP,/* A Bx if R[A+2] ~= nil then { R[A]=R[A+2]; pc -= Bx } */
297 297
298OP_SETLIST,/* A B C R[A][(C-1)*FPF+i] := R[A+i], 1 <= i <= B */ 298OP_SETLIST,/* A B C k R[A][(C-1)*FPF+i] := R[A+i], 1 <= i <= B */
299 299
300OP_CLOSURE,/* A Bx R[A] := closure(KPROTO[Bx]) */ 300OP_CLOSURE,/* A Bx R[A] := closure(KPROTO[Bx]) */
301 301
@@ -323,7 +323,7 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
323 (*) In OP_RETURN, if (B == 0) then return up to 'top'. 323 (*) In OP_RETURN, if (B == 0) then return up to 'top'.
324 324
325 (*) In OP_LOADKX and OP_NEWTABLE, the next instruction is always 325 (*) In OP_LOADKX and OP_NEWTABLE, the next instruction is always
326 EXTRAARG. 326 OP_EXTRAARG.
327 327
328 (*) In OP_SETLIST, if (B == 0) then real B = 'top'; if k, then 328 (*) In OP_SETLIST, if (B == 0) then real B = 'top'; if k, then
329 real C = EXTRAARG _ C (the bits of EXTRAARG concatenated with the 329 real C = EXTRAARG _ C (the bits of EXTRAARG concatenated with the
@@ -336,6 +336,9 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
336 (*) For comparisons, k specifies what condition the test should accept 336 (*) For comparisons, k specifies what condition the test should accept
337 (true or false). 337 (true or false).
338 338
339 (*) In OP_MMBINI/OP_MMBINK, k means the arguments were flipped
340 (the constant is the first operand).
341
339 (*) All 'skips' (pc++) assume that next instruction is a jump. 342 (*) All 'skips' (pc++) assume that next instruction is a jump.
340 343
341 (*) In instructions OP_RETURN/OP_TAILCALL, 'k' specifies that the 344 (*) In instructions OP_RETURN/OP_TAILCALL, 'k' specifies that the
@@ -344,7 +347,8 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
344 returning; in this case, (C - 1) is its number of fixed parameters. 347 returning; in this case, (C - 1) is its number of fixed parameters.
345 348
346 (*) In comparisons with an immediate operand, C signals whether the 349 (*) In comparisons with an immediate operand, C signals whether the
347 original operand was a float. 350 original operand was a float. (It must be corrected in case of
351 metamethods.)
348 352
349===========================================================================*/ 353===========================================================================*/
350 354