[racket-dev] how to disable intra-module constant inlining?
Do you mean the situation with one module, like this one?
;; a.rkt
#lang racket
(provide f c)
(define (f x) x)
(f 3) ; call might be inlined
(define c 10)
(define use-c c) ; constant might be folded
Or are two modules involved, like this second one?
;; b.rkt
#lang racket
(require "a.rkt")
c ; constant from other module might be folded
(f 3) ; function from other module might be inlined
?
If you set `compile-enforce-module-constants' to #f while compiling
"a.rkt", then all folding and inlining of `c' and `f' will be disabled
in both "a.rkt" and "b.rkt", since mutation wil be allowed on `f' and
`c'.
If you compile "a.rkt" normally, then setting
`compile-enforce-module-constants' for "b.rkt" has no effect for `c'
and `f' (i.e., they will be folded away and inlined), because `c' and
`f' in "a.rkt" have been compiled as constants.
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.
All that said, adding `set!'s sounds like the way to go here, because
you want the exports of the module to always act as if they are
mutable.
At Wed, 18 Jan 2012 18:21:04 -0500, Danny Yoo wrote:
> > So Whalesong is actually breaking on a few of my test case examples
> > because 5.2.1 does some aggressive inlining. Specifically, it's doing
> > intra-module constant optimizations. Whalesong depends on the late
> > binding of module bindings in some special places (specifically, the
> > FFI), so I need a way of turning that constant inlining off. I tried
> > using (compile-enforce-module-constants #f), but that didn't seem to
> > do the trick.
>
>
> Followup: ok, whew. I can workaround it for the specific case where
> things are breaking by artificially injecting set!s in the affected
> modules.
> (https://github.com/dyoo/whalesong/commit/6b8bcdaf767efe2294a7dd8d9a5580c5a64c20
> ff)
>
>
> I'd still love to know how to disable the intra-module constant
> inlining, that is, if there's a parameter that controls inlining
> similar to compile-context-preservation-enabled. Sam suggested that
> whatever 'raco make --disable-inline' does might do the trick, but
> that option appears to only affect function calls inlining; what I'm
> running into is constant inlining.
>
> _________________________
> Racket Developers list:
> http://lists.racket-lang.org/dev