Answer 5.32
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
(load "util.scm")
|
(load "util.scm")
|
||||||
|
|
||||||
(display "\nex-5.31\n")
|
(display "\nex-5.31 - save-and-restore-for-apply\n")
|
||||||
|
|
||||||
; 1. save and restore env around operator
|
; 1. save and restore env around operator
|
||||||
; 2. save and restore env around each operand (except last)
|
; 2. save and restore env around each operand (except last)
|
||||||
@@ -28,7 +28,43 @@
|
|||||||
|
|
||||||
(display "[answered]\n")
|
(display "[answered]\n")
|
||||||
|
|
||||||
(display "\nex-5.32\n")
|
(display "\nex-5.32 - optimize-eceval-application\n")
|
||||||
|
|
||||||
|
'(
|
||||||
|
ev-application
|
||||||
|
(save continue)
|
||||||
|
(assign unev (op operands) (reg exp))
|
||||||
|
(assign exp (op operator) (reg exp))
|
||||||
|
(assign continue (label ev-appl-did-operator-no-restore))
|
||||||
|
(test (op variable?) (reg exp))
|
||||||
|
(branch (label ev-variable))
|
||||||
|
(save env)
|
||||||
|
(save unev)
|
||||||
|
(assign continue (label ev-appl-did-operator))
|
||||||
|
(goto (label eval-dispatch))
|
||||||
|
ev-appl-did-operator
|
||||||
|
(restore unev)
|
||||||
|
(restore env)
|
||||||
|
ev-appl-did-operator-no-restore
|
||||||
|
(assign argl (op empty-arglist))
|
||||||
|
(assign proc (reg val))
|
||||||
|
(test (op no-operands?) (reg unev))
|
||||||
|
(branch (label apply-dispatch))
|
||||||
|
(save proc)
|
||||||
|
)
|
||||||
|
|
||||||
|
(display "[ok]\n")
|
||||||
|
|
||||||
|
; b. Applying all the optimizations make sense, but the compiled code will
|
||||||
|
; still run faster because the interpreter has to analyze the code every time
|
||||||
|
; it executes and the analysis itself adds overhead that the compiler can do
|
||||||
|
; before runtime
|
||||||
|
(display "[answered]\n")
|
||||||
|
|
||||||
(display "\nex-5.33\n")
|
(display "\nex-5.33\n")
|
||||||
|
|
||||||
|
(display "CONTINUE at 5.5.3\n")
|
||||||
|
|
||||||
|
(display "\nex-5.34\n")
|
||||||
|
;(display "\nex-5.35\n")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user