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: Tue, 26 Feb 2013 05:24:40 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Hi William,

William ML Leslie <address@hidden> writes:
> On 23 February 2013 18:49, Mark H Weaver <address@hidden> wrote:
>> William ML Leslie <address@hidden> writes:
>>> 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.
>
> Not each let body, the let body in the example code.

Ah, sorry, I misunderstood you.

> Specifically, a guard needs to be placed whenever code with
> undetermined effect happens-before a 'call' to an inlined function.

Yes.  Thank you for expressing it much more clearly than I had.  I would
further refine it to "a guard needs to be placed whenever code that
might mutate an inlined variable happens-before the inlined variable
would have been referenced."

> That we are talking about happens-before means the possibility of
> runtime invalidation of code is limited not only by calls to functions
> of unknown effect, but also by usages of the variable.

You bring up an important point: that a happens-before relation can be
composed of an arbitrarily long chain of other relations.  This requires
more careful study.

>> Therefore, I repeat my initial assertion that this is a can of worms.
>
> Except that most dynamic compilers for imperative languages already do
> this (because it's a pretty common thing to need to do).

I didn't realize that this technique was so commonly implemented.
Nonetheless, I worry that this technique may not perform as well for
Scheme as for other languages.  The reason is that in Scheme, calls to
procedures of unknown effect are vastly more common than in other
languages, at least for Schemes that allow arbitrary variables such as
'+' to be mutated.

Thanks for your insights.

     Regards,
       Mark



reply via email to

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