On Mon, Sep 15, 2003 at 11:49:52AM -0400, Gordon Henriksen wrote:
> Austin Hastings wrote:
> 
> > Given that threads are present, and given the continuation based
> > nature of the interpreter, I assume that code blocks can be closured.
> > So why not allocate JITed methods on the heap and manage them as first
> > class closures, so that the stackref will hold them until the stack
> > exits?
> 
> 
> Austin,
> 
> That's a fine and dandy way to do some things, like progressive
> optimization ala HotSpot. (e.g., "Oh! I've been called 10,000 times.
> Maybe you should bother to run a peephole analyzer over me?") But when
> an assumption made by the already-executing routine is actually
> violated, it causes incorrect behavior. Here's an example:
> 
>     class My::PluginBase;
>     
>     method say_hi() {
>         # Default implementation.
>         print "Hello, world.\n";
>     }
> 
> 
>     package main;
>     
>     load_plugin($filepath) { ... }
> 
>     my $plugin is My::PluginBase;
>     $plugin = load_plugin($ARGV[0]);
>     $plugin.SayHi();
> 
> Now, while it would obviously seem a bad idea to you, it would be
> reasonable for perl to initially optimize the method call
> $plugin.say_hi() to the function call My::PluginBase::say_hi($plugin).
> But when load_plugin loads a subclass of My::PluginBase from the file
> specified in $ARGV[0], then that assumption is violated. Now, the
> optimization has to be backed out, or the program will never call the
> subclass's say_hi. Letting the GC clean up the old version of main when
> the notification is received isn't enough--the existing stack frame must
> actually be rewritten to use the newly-compiled version.


This discussion seems to contain two separate problems, and I'm not
always sure which one is being addressed.  The components I see are:

1) Detecting when the assumptions have been violated and the code has
   to be changed; and,

2) Actually making the change after we know that we need to.


I have at least a vague idea of why #1 would be difficult.  As to
#2...assuming that the original source is available (or can be
recovered), then regenerating the expression does not seem difficult.
Or am I missing something?


--Dks

Reply via email to