Update: No so good news, my idea of yesterday was slightly wrong. I
think it causes no errors, but it makes the compiler pessimistic and
it avoid some optimizations. I found another fix, but I want to test
it more before submitting the patch.

More details:

In some cases, the optimizer reoptimize an expression with fuel=0, to
get the correct values of some internal flags. So some code in
optimize_for_inline must run even when fuel=0.

The idea is that when fuel=0 there should be no inlining, but the
compiler tries to inline the functions that are used only once even
when there is not enough fuel, so the original copy disappear and only
the inlined code survives. (When the function is used more than one
time this may increase the size of the bytecode. But this is a good
idea for single used functions.)

So this modified version hangs:
#lang racket
(define dup (lambda (f) (f f)))
(lambda ()
  (let ([rep (lambda (f) (f f))])
    (list
     (dup rep)
     dup))) ; <-- look here

But this modified version is ok
#lang racket
(define dup (lambda (f) (f f)))
(lambda ()
  (let ([rep (lambda (f) (f f))])
    (list
     (dup rep)
     rep))) ; <-- look here

This also explains why only '(dup rep)' caused problems.

Todays fix is in line 1900 of optimize.c
-      if ((sz >= 0) && (single_use || (sz <= threshold))) {
+      if ((sz >= 0) && (single_use || (sz <= threshold)) &&
(info->inline_fuel > 0)) {

But perhaps the problem is in the code that tracks the single_use
value. After 'dup' is applied, 'rep' is not long a singled used
function.  ... I must test this a little more ...

Gustavo



On Wed, Jul 15, 2015 at 4:14 AM, Ryan Davis <zenspi...@gmail.com> wrote:
>
>> On Jul 14, 2015, at 20:19, Gustavo Massaccesi <gust...@oma.org.ar> wrote:
>>
>> Replacing the line 1758 of optimize.c
>>
>> -  if ((info->inline_fuel < 0) && info->has_nonleaf && !noapp)
>> +  if ((info->inline_fuel <= 0) && info->has_nonleaf && !noapp)
>>
>> make the problem disappear, but I still don't understand why "(dup
>> rep)" is the only combination that creates a problem.
>>
>> I also want to think about the "(info->inline_fuel >= 0)" in line 1872
>> and how that interacts with the "if (noapp)" in line 1876 ...
>
> Thanks! I can test against my whole suite in tomorrow's daily if you'd like.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to