guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CPS Update


From: Mark H Weaver
Subject: Re: CPS Update
Date: Sat, 23 Feb 2013 02:49:30 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

William ML Leslie <address@hidden> writes:

> On 20 February 2013 03:21, Mark H Weaver <address@hidden> wrote:
>> (define (func x)
>>   (let ((r (my-special-function x)))
>>     (+ x 2 r)))
>>
>> Here, (my-special-function x) must be evaluated before evaluating '+'.
>> Evaluating '+' means to fetch the value stored in the location denoted
>> by '+'.  Therefore, if '+' is rebound during the call to
>> 'my-special-function', then the new binding for '+' must be used.
>>
>> This is a case where on-stack-replacement is needed to implement the
>> correct semantics.
>>
>> To summarize, when you rebind a function 'foo', it is not the existing
>> activation records for 'foo' that you need to worry about.  Instead, you
>> need to worry about existing activation records for all compiled
>> procedures 'bar' that incorporated assumptions about 'foo'.
>
> Recompiling every procedure that uses + when somebody binds it means
> compiling a lot of code that probably isn't going to be used.  More
> likely, if + has been inlined here, the compiler will have to emit a
> guard that checks inlining assumptions as the start of the let body.

I'm afraid this isn't good enough.  Even if one ignores the possibility
of multiple threads, checks would have to be added not just at the start
of each let body, but also upon return from every procedure that might
rebind '+' or capture its continuation.  This includes all procedures
accessed through toplevel/module bindings.

Therefore, I repeat my initial assertion that this is a can of worms.
I'd like to see it implemented in Guile some day, but it's a big job.

     Regards,
       Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]