Parsing Scheme + (+ (* 2 3) 1) * 1 2 3
Compiling Scheme frame + frame halt * 1 3 2 3 2 refer 1 apply * refer apply +
Compiling Scheme make-return START make-test make-close make-assign make- pair? yes yes yes yes yes no no no if? lambda? define? quote? no no symbol? yes make-refer 0 1 2 make-frame no make-apply make- make-
Interpreting Bytecode frame frame halt 3 pc = halt acc = 7 2 refer 1 apply * refer apply +
bytecode frame 3 frame halt registers pc accumulator s environment frames val val... val 2 stack refer apply * refer apply + 1 pc arg env pc arg env...... pc arg env environment frame stack
Frame Bytecode Set program counter to second continuation Push registers onto frame stack Set program counter to first continuation
Constant Bytecode Set accumulator to value of operand Set program counter to continuation
Argument Bytecode Push accumulator onto stack Set program counter to continuation
Refer Bytecode Lookup value of operand in environment and store it in accumulator Set program counter to continuation
Apply Bytecode (primitive) Apply primitive to vals on stack Pop frame stack
Apply Bytecode (closure) Make application frame using closure's list (vars) and stack (vals) Push application frame onto environment Set program counter to body of closure
Pop frame stack Return Bytecode
Test Bytecode If accumulator is not #f then set program counter to first continuation else set program counter to second continuation
Assign Bytecode Make definition using operand and accumulator Add definition to top frame of environment Set program counter to continuation
Close Bytecode Make closure using operands and environment Set program counter to continuation
halt Halt Bytecode
Parsing Scheme + (+ (* 2 3) 1) * 1 2 3 1
Compiling Scheme frame + frame halt * 1 3 2 3 2 refer 1 apply * refer apply + 2
Compiling Scheme make-return START pair? yes make-test make-close make-assign make- yes yes yes yes no no no if? lambda? define? quote? no no symbol? yes make-refer 0 1 2 make-frame no make-apply make- make- 3
Interpreting Bytecode frame frame halt 3 pc = halt acc = 7 2 refer 1 apply * refer apply + 4
bytecode frame 3 frame halt registers pc accumulator s environment frames val val... val 2 stack refer apply * refer apply + 1 pc arg env pc arg env...... environment pc arg env frame stack 5
Frame Bytecode Set program counter to second continuation Push registers onto frame stack Set program counter to first continuation 6
Constant Bytecode Set accumulator to value of operand Set program counter to continuation 7
Argument Bytecode Push accumulator onto stack Set program counter to continuation 8
Refer Bytecode Lookup value of operand in environment and store it in accumulator Set program counter to continuation 9
Apply Bytecode (primitive) Apply primitive to vals on stack Pop frame stack 10
Apply Bytecode (closure) Make application frame using closure's list (vars) and stack (vals) Push application frame onto environment Set program counter to body of closure 11
Pop frame stack Return Bytecode 12
Test Bytecode If accumulator is not #f then set program counter to first continuation else set program counter to second continuation 13
Assign Bytecode Make definition using operand and accumulator Add definition to top frame of environment Set program counter to continuation 14
Close Bytecode Make closure using operands and environment Set program counter to continuation 15
Halt Bytecode halt 16