Ok, bug or something...

* The StoreLocalVariable and LoadLocalVariable seem to use a
zero-based offset for depth but a one-based offset for index into the
binding. Intentional? I will subtract one for now.

I am implementing this without context.push/pop and exception-handling
logic for the moment to test that it's working. May require me to
implement closures, too, but that will be a lot easier now that I
don't have to implement the pre/post logic in a wrapper.

- Charlie

On Tue, May 8, 2012 at 2:26 AM, Charles Oliver Nutter
<head...@headius.com> wrote:
> Looks good so far reading the ast --ir output. A few things on which I
> could use clarification:
>
> * Binding variable load/stores are unconditionally done before/after
> block calls, yes? Opportunity to optimize or failover to all binding
> variables if we see there's a lot of churn?
> * Are all variables bound regardless of usage in the block?
> (proc-as-binding, grrr)
> * I have not yet looked at the linearized code to see how the ensure
> logic fires. Judging by the output, the normal and exceptional paths
> are already encoded separately, which is how I'd hope to see it.
> * Depending on how we encode $~ and $_, they could be treated as
> binding locals too.
>
> At the moment I'm going to implement this with the method body
> allocating the DynamicScope *and* doing the push/pop. If we can
> eliminate the need for pushing the scopes onto an external
> thread-local structure (i.e. pass it along call stack, which indy will
> help with) the pushing, popping, and finally/ensure logic can
> disappear and we'll *just* have the scope allocation (i.e. pop will be
> a no-op). That would definitely be the ideal, since it would allow for
> bindings to eventually escape-analyze away (once we get the JVM to
> inline through to closures).
>
> - Charlie
>
> On Tue, May 8, 2012 at 2:14 AM, Charles Oliver Nutter
> <head...@headius.com> wrote:
>> I will look into this a bit tonight and see if I can get basic binding
>> logic implemented in IR2JVM. Thanks, Subbu!
>>
>> On Mon, May 7, 2012 at 8:48 PM, Subramanya Sastry <sss.li...@gmail.com> 
>> wrote:
>>> I started working on implementing an explicit call protocol last week.
>>> It required me to clean up a few other bits which I did over several commits
>>> since y'day.
>>>
>>> I now committed a first cut at AddExplicitCallProtocolInstructions compiler
>>> pass.
>>>
>>> I tested this with the interpreter and it seeks to run fine.  There may be
>>> bugs in corner cases ... but I haven't run into it running rubyspecs, gem
>>> list, and irb.
>>>
>>> To take full advantage of this, you need to run the following 2 passes:
>>> AddLocalVarLoadStoreInstructions, AddExplicitCallProtocolInstructions, and
>>> implement compiler code for PushBinding, PopBinding, LoadLocalVar and
>>> StoreLocalVar instructions.
>>>
>>> Ex: jruby  -X-CIR
>>> -Xir.passes=OptimizeTempVarsPass,LocalOptimizationPass,DeadCodeElimination,AddLocalVarLoadStoreInstructions,AddCallProtocolInstructions,LinearizeCFG
>>> bench/bench_fib_recursive.rb
>>>
>>> Subbu.
>>>
>>> PS: There is one private patch for operands/TemporaryVariable that I have
>>> not yet committed -- this has got to do with handling use-before-defs in
>>> Ruby.  This is normally not required for tmps but with explicit load/store
>>> of local-vars, this becomes necessary since all local vars are now pushed
>>> into temp vars (and java local vars in the compiler).  This patch is
>>> required for gem list and for getting "green" on rubyspecs, for ex.   This
>>> only affects the interpreter, not the compiler since I presume you have this
>>> logic there anyway.   The patch is trivial (enclosed below)
>>>
>>>      @Override
>>>      public Object retrieve(ThreadContext context, IRubyObject self,
>>> DynamicScope currDynScope, Object[] temp) {
>>> -                 return temp[offset];
>>> +                 Object o = temp[offset];
>>> +                 return o == null ? context.nil : o;
>>>      }
>>>
>>> I have not committed this because I was hoping that we could find a way to
>>> eliminate this (both here and in DynamicScope.java:getValueOrNil ) by
>>> canonicalizing the instr stream to eliminate use-before-defs in ruby code --
>>> I dont yet have a cheap fix for it, so haven't implemented yet, but maybe I
>>> should just commit this patch and forget about it for now.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to