On Wed, May 13, 2009 at 5:05 PM, Jecel Assumpcao Jr <jecel@merlintec.com> wrote:

Eliot,

> [JIT code uses call which pushes PC first]

Ok, so this can't be helped.

> So while one could I don't see that its worth-while.  Even if one did
> keep the arguments and temporaries together one would still have the
> stack contents separate from the arguments and temporaries and
> temporary access bytecodes can still access those so arguably one
> would still have to check the index against the temp count.

Really? I wouldn't expect the compiler to ever generate such bytecodes
and so wasn't too worried if the VM did the wrong thing in this
situation.

There's a tension between implementing what the current compiler produces and implementing what the instruction set defines.  For example should one assume arguments are never written to?  I lean on the side of implementing the instruction set.

> In the JIT the flag is a bit in the method reference's LSBs and is set for free
> on frame build.

That sounds like a neat trick. Are the stack formats for the interpreted
stack vm and the jit a little diffeent?

Yes.  In the JIT an interpreted frame needs an extra field to hold the saved bytecode instruction pointer when an interpreted frame calls a machine code frame because the return address is the "return to interpreter trampoline" pc.  There is no flag word in a machine code frame.  So machine code frames save one word w.r.t. the stack vm and interpreted frames gain a word.  But most frames are machine code ones so most of the time one is saving space.

Thanks for the explanations. I haven't figured out how to do this in
hardware in a reasonable way and so might have to go with a different design.

I guess that in hardware you can create an instruction that will load a descriptor register as part of the return sequence in parallel with restoring the frame pointer and method so one would never indirect through the frame pointer to fetch the flags word; instead it would be part of the register state.  But that's an extremely uneducated guess :)



-- Jecel