3 ms·
Interesting. The TXR Lisp VM uses displays, and has a similar concept with keeping track of levels. We can see that with code. We disable optimization so the co
by kazinator 3y ago
Interesting. The TXR Lisp VM uses displays, and has a similar concept with keeping track of levels. We can see that with code. We disable optimization so the compiler doesn't eliminate frames:
1> (let ((*opt-level* 0))
(compile-toplevel '(let (a) (let (b) (let (c) (list a b c))))))
#<sys:vm-desc: 9fb6870>
2> (disassemble *1)
data:
syms:
0: list
code:
0: 04020001 frame 2 1
1: 04030001 frame 3 1
2: 04040001 frame 4 1
3: 20030002 gcall t2 0 v00000 v01000 v02000
4: 08000000
5: 10000C00
6: 10000002 end t2
7: 10000002 end t2
8: 10000002 end t2
9: 10000002 end t2
instruction count:
8
#<sys:vm-desc: 9fb6870>
The frame 4 1 instruction means we are at depth 4, and there is 1 variable here.