[racket] disable inlining for recursive functions

From: Denys Rtveliashvili (rtvd at mac.com)
Date: Thu Dec 6 01:27:58 EST 2012

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


Posted on the users mailing list.