diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-12-05 12:59:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-12-05 12:59:42 -0300 |
commit | 490ecfcaa1f25fcc17f9dcb0ed7216da54a391e3 (patch) | |
tree | 0f6c221c65ddad7b73a223c40cb6cd3e4f324102 /lopcodes.h | |
parent | e174f43807d46a7c0a9ab5eeb3fc4434bcb0091f (diff) | |
download | lua-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.h | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -217,7 +217,7 @@ OP_SETTABLE,/* A B C R[A][R[B]] := RK(C) */ | |||
217 | OP_SETI,/* A B C R[A][B] := RK(C) */ | 217 | OP_SETI,/* A B C R[A][B] := RK(C) */ |
218 | OP_SETFIELD,/* A B C R[A][K[B]:string] := RK(C) */ | 218 | OP_SETFIELD,/* A B C R[A][K[B]:string] := RK(C) */ |
219 | 219 | ||
220 | OP_NEWTABLE,/* A B C R[A] := {} */ | 220 | OP_NEWTABLE,/* A B C k R[A] := {} */ |
221 | 221 | ||
222 | OP_SELF,/* A B C R[A+1] := R[B]; R[A] := R[B][RK(C):string] */ | 222 | OP_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] */ | |||
253 | OP_SHR,/* A B C R[A] := R[B] >> R[C] */ | 253 | OP_SHR,/* A B C R[A] := R[B] >> R[C] */ |
254 | 254 | ||
255 | OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] */ | 255 | OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] */ |
256 | OP_MMBINI,/* A sB C call C metamethod over R[A] and sB */ | 256 | OP_MMBINI,/* A sB C k call C metamethod over R[A] and sB */ |
257 | OP_MMBINK,/* A B C call C metamethod over R[A] and K[B] */ | 257 | OP_MMBINK,/* A B C k call C metamethod over R[A] and K[B] */ |
258 | 258 | ||
259 | OP_UNM,/* A B R[A] := -R[B] */ | 259 | OP_UNM,/* A B R[A] := -R[B] */ |
260 | OP_BNOT,/* A B R[A] := ~R[B] */ | 260 | OP_BNOT,/* A B R[A] := ~R[B] */ |
@@ -266,24 +266,24 @@ OP_CONCAT,/* A B R[A] := R[A].. ... ..R[A + B - 1] */ | |||
266 | OP_CLOSE,/* A close all upvalues >= R[A] */ | 266 | OP_CLOSE,/* A close all upvalues >= R[A] */ |
267 | OP_TBC,/* A mark variable A "to be closed" */ | 267 | OP_TBC,/* A mark variable A "to be closed" */ |
268 | OP_JMP,/* sJ pc += sJ */ | 268 | OP_JMP,/* sJ pc += sJ */ |
269 | OP_EQ,/* A B if ((R[A] == R[B]) ~= k) then pc++ */ | 269 | OP_EQ,/* A B k if ((R[A] == R[B]) ~= k) then pc++ */ |
270 | OP_LT,/* A B if ((R[A] < R[B]) ~= k) then pc++ */ | 270 | OP_LT,/* A B k if ((R[A] < R[B]) ~= k) then pc++ */ |
271 | OP_LE,/* A B if ((R[A] <= R[B]) ~= k) then pc++ */ | 271 | OP_LE,/* A B k if ((R[A] <= R[B]) ~= k) then pc++ */ |
272 | 272 | ||
273 | OP_EQK,/* A B if ((R[A] == K[B]) ~= k) then pc++ */ | 273 | OP_EQK,/* A B k if ((R[A] == K[B]) ~= k) then pc++ */ |
274 | OP_EQI,/* A sB if ((R[A] == sB) ~= k) then pc++ */ | 274 | OP_EQI,/* A sB k if ((R[A] == sB) ~= k) then pc++ */ |
275 | OP_LTI,/* A sB if ((R[A] < sB) ~= k) then pc++ */ | 275 | OP_LTI,/* A sB k if ((R[A] < sB) ~= k) then pc++ */ |
276 | OP_LEI,/* A sB if ((R[A] <= sB) ~= k) then pc++ */ | 276 | OP_LEI,/* A sB k if ((R[A] <= sB) ~= k) then pc++ */ |
277 | OP_GTI,/* A sB if ((R[A] > sB) ~= k) then pc++ */ | 277 | OP_GTI,/* A sB k if ((R[A] > sB) ~= k) then pc++ */ |
278 | OP_GEI,/* A sB if ((R[A] >= sB) ~= k) then pc++ */ | 278 | OP_GEI,/* A sB k if ((R[A] >= sB) ~= k) then pc++ */ |
279 | 279 | ||
280 | OP_TEST,/* A if (not R[A] == k) then pc++ */ | 280 | OP_TEST,/* A k if (not R[A] == k) then pc++ */ |
281 | OP_TESTSET,/* A B if (not R[B] == k) then pc++ else R[A] := R[B] */ | 281 | OP_TESTSET,/* A B k if (not R[B] == k) then pc++ else R[A] := R[B] */ |
282 | 282 | ||
283 | OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */ | 283 | OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */ |
284 | OP_TAILCALL,/* A B C return R[A](R[A+1], ... ,R[A+B-1]) */ | 284 | OP_TAILCALL,/* A B C k return R[A](R[A+1], ... ,R[A+B-1]) */ |
285 | 285 | ||
286 | OP_RETURN,/* A B C return R[A], ... ,R[A+B-2] (see note) */ | 286 | OP_RETURN,/* A B C k return R[A], ... ,R[A+B-2] (see note) */ |
287 | OP_RETURN0,/* return */ | 287 | OP_RETURN0,/* return */ |
288 | OP_RETURN1,/* A return R[A] */ | 288 | OP_RETURN1,/* A return R[A] */ |
289 | 289 | ||
@@ -295,7 +295,7 @@ OP_TFORPREP,/* A Bx create upvalue for R[A + 3]; pc+=Bx */ | |||
295 | OP_TFORCALL,/* A C R[A+4], ... ,R[A+3+C] := R[A](R[A+1], R[A+2]); */ | 295 | OP_TFORCALL,/* A C R[A+4], ... ,R[A+3+C] := R[A](R[A+1], R[A+2]); */ |
296 | OP_TFORLOOP,/* A Bx if R[A+2] ~= nil then { R[A]=R[A+2]; pc -= Bx } */ | 296 | OP_TFORLOOP,/* A Bx if R[A+2] ~= nil then { R[A]=R[A+2]; pc -= Bx } */ |
297 | 297 | ||
298 | OP_SETLIST,/* A B C R[A][(C-1)*FPF+i] := R[A+i], 1 <= i <= B */ | 298 | OP_SETLIST,/* A B C k R[A][(C-1)*FPF+i] := R[A+i], 1 <= i <= B */ |
299 | 299 | ||
300 | OP_CLOSURE,/* A Bx R[A] := closure(KPROTO[Bx]) */ | 300 | OP_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 | ||