diff options
author | Andy Wingo <wingo@pobox.com> | 2013-02-15 12:11:29 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-02-15 12:11:29 +0100 |
commit | d21537efb4a0edea30a7ab801909207d4bb69030 (patch) | |
tree | 73ba8df2aa0360a9742b8d8af796042c04a32a84 /test-suite/tests/peval.test | |
parent | 564f5e70543f771e1e7c5aa57cee6f8b8d20c9ed (diff) | |
download | guile-d21537efb4a0edea30a7ab801909207d4bb69030.tar.gz |
better inlining of `apply' with rest arguments
* module/language/tree-il/peval.scm (peval): Move up the find-definition
helper. Use it to speculatively destructure conses and lists into the
tail position of an `apply' form.
* test-suite/tests/peval.test ("partial evaluation"): Add tests.
Diffstat (limited to 'test-suite/tests/peval.test')
-rw-r--r-- | test-suite/tests/peval.test | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test-suite/tests/peval.test b/test-suite/tests/peval.test index fdae7b10a..01164e4cf 100644 --- a/test-suite/tests/peval.test +++ b/test-suite/tests/peval.test @@ -850,6 +850,35 @@ (let (z) (_) ((apply (primitive list) (const 3) (const 4))) (apply (primitive list) (const 1) (const 2) (lexical z _)))) + (pass-if-peval resolve-primitives + ;; Unmutated lists can get inlined. + (let ((args (list 2 3))) + (apply (lambda (x y z w) + (list x y z w)) + 0 1 args)) + (apply (primitive list) (const 0) (const 1) (const 2) (const 3))) + + (pass-if-peval resolve-primitives + ;; However if the list might have been mutated, it doesn't propagate. + (let ((args (list 2 3))) + (foo! args) + (apply (lambda (x y z w) + (list x y z w)) + 0 1 args)) + (let (args) (_) ((apply (primitive list) (const 2) (const 3))) + (begin + (apply (toplevel foo!) (lexical args _)) + (apply (primitive @apply) + (lambda () + (lambda-case + (((x y z w) #f #f #f () (_ _ _ _)) + (apply (primitive list) + (lexical x _) (lexical y _) + (lexical z _) (lexical w _))))) + (const 0) + (const 1) + (lexical args _))))) + (pass-if-peval ;; Constant folding: cons of #nil does not make list (cons 1 #nil) |