On 7/11/06, Nick Sieger <[EMAIL PROTECTED]> wrote:
This is really meant as a pseudo-Ruby-bytecode, to help settle my understanding of what's required for the compiler. FCALL will really translate into the code we currently run for an FCallNode. There's no ability to bind to a specific Java method so FCALL will not == INVOKE* (other than of course calling IRubyObject.callMethod).
Yeah, I actually started writing a simple compiler this morning on the way to work and it may work out well. Once I get completely away from the EvaluationState bit (which makes sense, since it's for interpretation) the variable, argument, and call semantics map fairly well to Java bytecodes. If all goes well I could have a simple compiler that can handle fib() by the end of the week...just for fun.
Yes, I was more or less abstracting that away with this pseudo bytecode. Local vars inside Ruby are actually in an array in the Scope class, associated with the current Frame. If there's any block usage in the method, that would have to stay the same (since a Block would need access to the same Scope when called). However if there's no block, no continuation, etc, a good optimization might be to make those local vars REALLY local vars in the Java sense, rather than looking them up from a remote array. We might also be able to eliminate Frame in those cases. Those combined with passing ThreadContext to every compiled method could start making it really stupid fast.
Please keep it going! :) I'm learning this stuff as I go anyway...I've never written a compiler or taken a course in same (but it doesn't seem to be as hard as it's made out to be).
Is FCALL supposed to be "call with self as receiver"? The JVM requires you to push "this" before every invocation -- or are you just doing this for a condensed pseodo-bytecode?
This is really meant as a pseudo-Ruby-bytecode, to help settle my understanding of what's required for the compiler. FCALL will really translate into the code we currently run for an FCallNode. There's no ability to bind to a specific Java method so FCALL will not == INVOKE* (other than of course calling IRubyObject.callMethod).
You'd be creating a ByteCompilerVisitor for traversing the AST without evaluating it right? I don't think that traversing calls to compile would be any more tricky than compiling them, it's pretty much the same process.
Yeah, I actually started writing a simple compiler this morning on the way to work and it may work out well. Once I get completely away from the EvaluationState bit (which makes sense, since it's for interpretation) the variable, argument, and call semantics map fairly well to Java bytecodes. If all goes well I could have a simple compiler that can handle fib() by the end of the week...just for fun.
Another thought, wouldn't you need a bytecode for "lookup local or call with current receiver" -- although I don't remember whether your fib example needed this.
Yes, I was more or less abstracting that away with this pseudo bytecode. Local vars inside Ruby are actually in an array in the Scope class, associated with the current Frame. If there's any block usage in the method, that would have to stay the same (since a Block would need access to the same Scope when called). However if there's no block, no continuation, etc, a good optimization might be to make those local vars REALLY local vars in the Java sense, rather than looking them up from a remote array. We might also be able to eliminate Frame in those cases. Those combined with passing ThreadContext to every compiled method could start making it really stupid fast.
Bear with me, I'm trying to hang onto a discussion that's a little over my head. Feel free to swat me down if I'm not adding any value :)
Please keep it going! :) I'm learning this stuff as I go anyway...I've never written a compiler or taken a course in same (but it doesn't seem to be as hard as it's made out to be).
--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ www.jruby.org
Application Architect @ www.ventera.com
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Jruby-devel mailing list Jruby-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jruby-devel