UNPKG

microvium

Version:

A compact, embeddable scripting engine for microcontrollers for executing small scripts written in a subset of JavaScript.

154 lines (139 loc) 5.22 kB
Test popScope -> 01ac Closure in loop -> 0226 # ROM ``` 01ac 2 Header [Size: 117, Type: TC_REF_FUNCTION] 01ae 75 - # Function popScope 01ae 1 maxStackDepth: 6 01af 21 - # Block entry 01af 2 ScopePush(count 2) 01b1 3 Literal(deleted) 01b4 3 Literal(deleted) 01b7 3 LoadGlobal [0] 01ba 1 Literal(lit undefined) 01bb 3 Literal(&0070) 01be 2 Call(count 2) 01c0 1 Pop(count 1) 01c1 3 Literal(&0082) 01c4 1 StoreScoped [0] 01c5 3 Literal(&008a) 01c8 1 StoreScoped [1] 01c9 2 ArrayNew() [capacity=0] 01cb 1 StoreVar(index 0) 01cc 2 ScopePush(count 1) 01ce 1 Literal(lit 0) 01cf 1 StoreScoped [0] 01d0 0 <implicit fallthrough> 01d0 5 - # Block block13 01d0 1 LoadScoped [0] 01d1 1 Literal(lit 5) 01d2 1 BinOp(op '<') 01d3 2 Branch &01f3 01d5 10 - # Block block15 01d5 1 ScopePop 01d6 3 Literal(&0242) 01d9 1 ClosureNew() 01da 1 StoreVar(index 1) 01db 1 LoadVar(index 1) 01dc 1 Literal(lit undefined) 01dd 2 Call(count 1) 01df 1 Pop(count 1) 01e0 3 Literal(deleted) 01e3 1 Literal(lit 0) 01e4 1 StoreVar(index 2) 01e5 0 <implicit fallthrough> 01e5 9 - # Block block16 01e5 1 LoadVar(index 2) 01e6 1 LoadVar(index 0) 01e7 3 Literal('length') 01ea 1 ObjectGet() 01eb 1 BinOp(op '<') 01ec 2 Branch &0212 01ee 5 - # Block block18 01ee 1 Pop(count 1) 01ef 2 Pop(count 2) 01f1 1 Literal(lit undefined) 01f2 1 Return() 01f3 1f - # Block block14 01f3 2 ScopePush(count 1) 01f5 1 LoadScoped [1] 01f6 1 StoreScoped [0] 01f7 1 LoadVar(index 0) 01f8 1 LoadVar(index 2) 01f9 3 Literal(&002c) 01fc 1 ObjectGet() 01fd 1 LoadVar(index 2) 01fe 3 Literal(&0226) 0201 1 ClosureNew() 0202 2 Call(count 2) 0204 1 StoreVar(index 2) 0205 1 Pop(count 1) 0206 1 ScopePop 0207 1 ScopeClone 0208 1 LoadScoped [0] 0209 1 LoadVar(index 2) 020a 1 Literal(lit 1) 020b 1 BinOp(op '+') 020c 1 LoadVar(index 3) 020d 1 StoreScoped [0] 020e 1 Pop(count 1) 020f 1 Pop(count 1\ ) 0210 2 Jump &01d0 0212 11 - # Block block17 0212 1 LoadVar(index 0) 0213 1 LoadVar(index 2) 0214 1 ObjectGet() 0215 1 Literal(lit undefined) 0216 2 Call(count 1) 0218 1 Pop(count 1) 0219 1 LoadVar(index 2) 021a 1 LoadVar(index 3) 021b 1 Literal(lit 1) 021c 1 BinOp(op '+') 021d 1 LoadVar(index 4) 021e 1 StoreVar(index 2) 021f 1 Pop(count 1) 0220 1 Pop(count 1) 0221 2 Jump &01e5 ``` ``` 0224 2 Header [Size: 25, Type: TC_REF_FUNCTION] 0226 19 - # Function anonymous2 0226 1 maxStackDepth: 4 0227 18 - # Block entry 0227 3 LoadGlobal [0] 022a 1 Literal(lit undefined) 022b 3 Literal(&004a) 022e 1 LoadScoped [1] 022f 1 BinOp(op '+') 0230 3 Literal(&004e) 0233 1 BinOp(op '+') 0234 1 LoadScoped [0] 0235 1 BinOp(op '+') 0236 3 Literal(&004e) 0239 1 BinOp(op '+') 023a 1 LoadScoped [3] 023b 1 BinOp(op '+') 023c 2 Call(count 2) 023e 1 Return() ``` # RAM Scopes: - Root scope (x, z) -> RAM 021e from PC 01af - Loop outer (x) -> RAM 022c from PC 01cc - Loop inner (y) -> RAM 0232 from PC 01f3 - Loop inner (y) -> RAM 0248 from PC 0207 Closures: - RAM 0238 from PC 0202: - Scope: RAM 0232 - Target: PC 0226 - from 01d9 Other allocations: - RAM 0226 may be `arr` - RAM 0218 may be `foo` Closure calls: - Calling RAM 0238 at 0216 # GC Collection - 0226 -> 0016 (`arr`) - 0248 -> 005a