1
Fork 0
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:
Andy Wingo 2015-03-12 14:48:03 +01:00
parent 7fee63b947
commit fe7ecee820

View file

@ -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)
(lazy (cenv)
(let ((var (%resolve-variable loc (env-toplevel cenv)))) (let ((var (%resolve-variable loc (env-toplevel cenv))))
(lambda (env) (variable-ref var)))) (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)))