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

2012-01-19 Thread Matthew Flatt
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 forb.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

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


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

2012-01-19 Thread Danny Yoo
 If you compile a.rkt normally and set
 `compile-context-preservation-enabled' to #f forb.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 |_a@(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!
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


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

2012-01-19 Thread Matthew Flatt
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 forb.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 |_a@(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!
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


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

2012-01-18 Thread Danny Yoo
Hi everyone,

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.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


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

2012-01-18 Thread Danny Yoo
 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/6b8bcdaf767efe2294a7dd8d9a5580c5a64c20ff)


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