diff options
author | Andy Wingo <wingo@pobox.com> | 2013-11-03 12:28:47 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-11-03 12:28:47 +0100 |
commit | 92afe25d5c162c29d971c2c36bd04a5b9d0b29c5 (patch) | |
tree | a8d3a9acc409ad0a96acb492b6eedfc58928a689 | |
parent | be6e40a1df4cc97d1bf3d4567e980b92454d5180 (diff) | |
download | guile-92afe25d5c162c29d971c2c36bd04a5b9d0b29c5.tar.gz |
Correctness fix for vector constructor inlining.
* module/language/tree-il/compile-cps.scm (convert): Don't inline the
vector constructor if any arg could capture the current continuation.
-rw-r--r-- | module/language/tree-il/compile-cps.scm | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/module/language/tree-il/compile-cps.scm b/module/language/tree-il/compile-cps.scm index 9d190620c..67f1ec15c 100644 --- a/module/language/tree-il/compile-cps.scm +++ b/module/language/tree-il/compile-cps.scm @@ -337,13 +337,24 @@ (convert (make-conditional src exp (make-const #f #t) (make-const #f #f)) k subst)) - ((eq? name 'vector) + ((and (eq? name 'vector) + (and-map (match-lambda + ((or ($ <const>) + ($ <void>) + ($ <lambda>) + ($ <lexical-ref>)) #t) + (_ #f)) + args)) ;; Some macros generate calls to "vector" with like 300 ;; arguments. Since we eventually compile to make-vector and ;; vector-set!, it reduces live variable pressure to allocate the - ;; vector first, then set values as they are produced. Normally - ;; we would do this transformation in the compiler, but it's - ;; quite tricky there and quite easy here, so hold your nose + ;; vector first, then set values as they are produced, if we can + ;; prove that no value can capture the continuation. (More on + ;; that caveat here: + ;; http://wingolog.org/archives/2013/11/02/scheme-quiz-time). + ;; + ;; Normally we would do this transformation in the compiler, but + ;; it's quite tricky there and quite easy here, so hold your nose ;; while we drop some smelly code. (convert (let ((len (length args))) (let-gensyms (v) |