mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
Only lazily compile where profitable
* module/ice-9/eval.scm (primitive-eval): Only lazily compile box-ref on toplevel variables; otherwise compile eagerly to avoid the indirection.
This commit is contained in:
parent
7fee63b947
commit
fe7ecee820
1 changed files with 5 additions and 4 deletions
|
@ -213,11 +213,12 @@
|
||||||
'()
|
'()
|
||||||
(cons ((car args) env) (lp (cdr args)))))))))))))
|
(cons ((car args) env) (lp (cdr args)))))))))))))
|
||||||
|
|
||||||
(define (compile-box-ref cenv box)
|
(define (compile-box-ref box)
|
||||||
(match box
|
(match box
|
||||||
((,(typecode resolve) . loc)
|
((,(typecode resolve) . loc)
|
||||||
(let ((var (%resolve-variable loc (env-toplevel cenv))))
|
(lazy (cenv)
|
||||||
(lambda (env) (variable-ref var))))
|
(let ((var (%resolve-variable loc (env-toplevel cenv))))
|
||||||
|
(lambda (env) (variable-ref var)))))
|
||||||
((,(typecode lexical-ref) depth . width)
|
((,(typecode lexical-ref) depth . width)
|
||||||
(lambda (env)
|
(lambda (env)
|
||||||
(variable-ref (env-ref env depth width))))
|
(variable-ref (env-ref env depth width))))
|
||||||
|
@ -655,7 +656,7 @@
|
||||||
(compile-call f args))
|
(compile-call f args))
|
||||||
|
|
||||||
((,(typecode box-ref) . box)
|
((,(typecode box-ref) . box)
|
||||||
(lazy (env) (compile-box-ref env box)))
|
(compile-box-ref box))
|
||||||
|
|
||||||
((,(typecode resolve) . loc)
|
((,(typecode resolve) . loc)
|
||||||
(lazy (env) (compile-resolve env loc)))
|
(lazy (env) (compile-resolve env loc)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue