mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 15:34:09 +00:00
Implement LOOP.
Allows for while and repeat loops, for example: x = 0 while x < 5 do print(x) x = x + 1 end -- prints: -- 0 -- 1 -- 2 -- 3 -- 4
This commit is contained in:
parent
6673652fd9
commit
5dc644ad89
@ -2844,14 +2844,22 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
|
||||
| stg r0, 0(r0)
|
||||
| stg r0, 0(r0)
|
||||
break;
|
||||
|
||||
case BC_LOOP:
|
||||
| stg r0, 0(r0)
|
||||
| stg r0, 0(r0)
|
||||
| ins_A // RA = base, RD = target (loop extent)
|
||||
| // Note: RA/RD is only used by trace recorder to determine scope/extent
|
||||
| // This opcode does NOT jump, it's only purpose is to detect a hot loop.
|
||||
|.if JIT
|
||||
| hotloop RBd
|
||||
|.endif
|
||||
| // Fall through. Assumes BC_ILOOP follows and ins_A is a no-op.
|
||||
break;
|
||||
|
||||
case BC_ILOOP:
|
||||
| stg r0, 0(r0)
|
||||
| stg r0, 0(r0)
|
||||
| ins_A // RA = base, RD = target (loop extent)
|
||||
| ins_next
|
||||
break;
|
||||
|
||||
case BC_JLOOP:
|
||||
| stg r0, 0(r0)
|
||||
| stg r0, 0(r0)
|
||||
|
Loading…
Reference in New Issue
Block a user