[racket-dev] how to disable intra-module constant inlining?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jan 19 12:40:47 EST 2012

When I wrote "inlining", I should have written "function inlining".

The `compile-context-preservation-enabled' parameter doesn't affect
propagation of non-function constants (which I incorrectly called
"folding" in my previous message); it affects only function inlining.

At Thu, 19 Jan 2012 10:49:22 -0500, Danny Yoo wrote:
> > If you compile "a.rkt" normally and set
> > `compile-context-preservation-enabled' to #f for"b.rkt", then `f' will
> > not be inlined (because inlining is disabled), but `c' will still be
> > replaced with 10.
> 
> 
> This is odd then, because I thought I had tried this yesterday and
> still observed inlining.  Let me try again...
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> #lang racket/base
> (require compiler/zo-parse
>          compiler/decompile)
> 
> (define (test b)
>   (parameterize ([current-namespace (make-base-namespace)]
>                  (compile-enforce-module-constants b))
> 
>     (eval (compile '(module foo-1 '#%kernel
>                       (#%provide a)
>                       (define-values (a) 'hello))))
> 
>     (define bytecode (compile '(module foo-2 '#%kernel
>                                  (#%require 'foo-1)
>                                  (display a)
>                                  (newline))))
>     (define op (open-output-bytes))
>     (write bytecode op)
>     (decompile (zo-parse (open-input-bytes (get-output-bytes op))))))
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > (test #t)
> '(begin (module foo-2 .... (display 'hello) (newline)))
> > (test #f)
> '(begin (module foo-2 .... (display |[email protected](quote foo-1)|) (newline)))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> 
> So maybe I'm hallucinating (again).  I confirm that
> compile-enforce-module-constants is working here.  I'll need to look
> at why it didn't appear as effective in the context of Whalesong;
> perhaps I'd set up the parameterization incorrectly.
> 
> 
> Thanks!

Posted on the dev mailing list.