From 703edc46a05b3104967c24d2126f5abb4d0a895d Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Tue, 8 Mar 2011 04:05:52 -0500 Subject: [PATCH] optimization: when doing primitive application, the result value can be directly placed if targetted to a lexical reference. --- compile.rkt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/compile.rkt b/compile.rkt index d088531..9255156 100644 --- a/compile.rkt +++ b/compile.rkt @@ -384,10 +384,17 @@ cenv (make-instruction-sequence `(,(make-AssignPrimOpStatement - 'val + ;; optimization: we can put the result directly in the registers, or in + ;; the appropriate spot on the stack. + (cond [(eq? target 'val) + 'val] + [(eq? target 'proc) + 'proc] + [(EnvLexicalReference? target) + (make-EnvLexicalReference (+ (EnvLexicalReference-depth target) n))]) (make-ApplyPrimitiveProcedure n)) - ,(make-PopEnvironment n 0) - ,(make-AssignImmediateStatement target (make-Reg 'val))))) + ,(make-PopEnvironment n 0)))) + after-call))))