[racket] disable inlining for recursive functions

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Dec 6 20:56:38 EST 2012

In addition to what Sam mentioned, if you use state in your function,
then the optimizer tends to give up early, so you can often stick a
set! that isn't doing anything to make it give up.

Robby

On Thu, Dec 6, 2012 at 12:27 AM, Denys Rtveliashvili <rtvd at mac.com> wrote:
> Hello,
>
> Is there a way of disabling the inlining for recursive functions?
>
> This code:
>
> (define (do_loop i)
>     (when (< i 1000000)
>         (do_loop (add1 i))))
>
> Is compiled into this:
>
> (begin
>   (module test3 ....
>     (require (lib "racket/main.rkt"))
>     (define-values
>      (_do_loop)
>      (lambda (arg0-12)
>        '#(do_loop
>           #<path:/home/rtvd/src/rtvd-racket/test/compiled/test3.rkt>
>           3
>           0
>           15
>           72
>           #f)
>        '(flags: preserves-marks single-result)
>        '(captures: #%modvars (_do_loop))
>        (if (#%in < arg0-12 '1000000)
>          (let ((local15 (#%in add1 arg0-12)))
>            (if (#%in < local15 '1000000)
>              (let ((local19 (#%in add1 local15)))
>                (if (#%in < local19 '1000000)
>                  (let ((local23 (#%in add1 local19)))
>                    (if (#%in < local23 '1000000)
>                      (let ((local27 (#%in add1 local23)))
>                        (if (#%in < local27 '1000000)
>                          (_do_loop (#%in add1 local27))
>                          '#<void>))
>                      '#<void>))
>                  '#<void>))
>              '#<void>))
>          '#<void>)))))
>
> I wonder if it would make any difference had the code been kept simple.
>
> With kind regards,
> Denys
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.