From 985702f7131e11c7c13aa75db19d10525c34fecd Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 23 Apr 2012 17:56:28 +0200 Subject: avoid emitting degenerate aliases in peval * module/language/tree-il/peval.scm (, make-operand) (make-bound-operands, peval): Avoid emitting needless aliases in degenerate cases of let. (visit-operand): If we visit an operand with a fresh counter and have to abort, record that fact. * test-suite/tests/peval.test ("partial evaluation"): Add a test. --- test-suite/tests/peval.test | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test-suite/tests/peval.test') diff --git a/test-suite/tests/peval.test b/test-suite/tests/peval.test index 5305dea72..987b06cca 100644 --- a/test-suite/tests/peval.test +++ b/test-suite/tests/peval.test @@ -985,4 +985,18 @@ (pass-if-peval resolve-primitives (car '(1 2)) - (const 1))) + (const 1)) + + ;; If we bail out when inlining an identifier because it's too big, + ;; but the identifier simply aliases some other identifier, then avoid + ;; residualizing a reference to the leaf identifier. The bailout is + ;; driven by the recursive-effort-limit, which is currently 100. We + ;; make sure to trip it with this recursive sum thing. + (pass-if-peval resolve-primitives + (let ((x (let sum ((n 0) (out 0)) + (if (< n 10000) + (sum (1+ n) (+ out n)) + out)))) + ((lambda (y) (list y)) x)) + (let (x) (_) (_) + (apply (primitive list) (lexical x _))))) -- cgit v1.2.1