Discussion:
[jruby-dev] Keyword arguments and the compiler
(too old to reply)
Jon Zeppieri
2013-10-01 20:41:29 UTC
Permalink
[Apologies to the list admin who probably received a couple of these
already, as I've been fighting with the mailer daemon.]

I'm attempting to add keyword argument support to the compiler, but
since I'm completely new to the codebase, I have a few questions. I
really appreciate any help you can give me.

First, I wrote a very simple program that (1) defines a method that
takes a keyword argument, and (2) calls it in a loop. I thought that,
if I called the method a sufficient number of times (50?), then the
JIT would kick in and the behavior would change. However, that didn't
happen. When I looked through the code base, I found the line at
ASTCompiler19#compileMethodArgs() that throws a
NotCompilableException. So my first question is:

- Are NotCompilableExceptions caught somewhere, allowing the
interpreter to carry on? (I did a simple grep for this, but didn't
find it.) Or was that code path not taken, at all?

Nest, I AOT-compiled the program and ran it. This time, the program
ran and produced incorrect results. Which leads me to my second
question:

- Does AOT compilation not go through that code path that would throw
the NotCompilableException?

And finally:

- What is the state of the IR? My brief look suggests that currently
the production compiler translates directly from the AST but that
there is a separate, newer compiler pipeline that goes through the IR,
and that pipeline can be turned on with a command-line switch but
which is off by default.

Thanks,
Jon

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

http://xircles.codehaus.org/manage_email
Charles Oliver Nutter
2013-10-01 21:20:45 UTC
Permalink
Many questions!
Post by Jon Zeppieri
- Are NotCompilableExceptions caught somewhere, allowing the
interpreter to carry on? (I did a simple grep for this, but didn't
find it.) Or was that code path not taken, at all?
NotCompileableException is caught by the JIT and used to leave a given
method in the interpreter. They can be logged with
-Xjit.logging.verbose=true (and -Xjit.logging=true will log
successes).

If you do not see the method fail to JIT, then the code path in
question was probably not taken.

I will say that the compiler size of keyword args is a little hacky
right now and probably well behind the interpreter. 2.0 has not been a
priority for us during the 1.7.x cycle.
Post by Jon Zeppieri
- Does AOT compilation not go through that code path that would throw
the NotCompilableException?
AOT compilation should follow the same paths as JIT but fail hard when
NotCompilableException is thrown.
Post by Jon Zeppieri
- What is the state of the IR? My brief look suggests that currently
the production compiler translates directly from the AST but that
there is a separate, newer compiler pipeline that goes through the IR,
and that pipeline can be turned on with a command-line switch but
which is off by default.
The IR is produced by a compiler from the current AST. We have a fully
functional interpreter (unsure about 2.0 features) and a very partial
JIT from IR to JVM bytecode.

The current plan is that the IR will form the basis of JRuby 9000's runtime.

- Charlie

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

http://xircles.codehaus.org/manage_email
Jon Zeppieri
2013-10-02 15:52:16 UTC
Permalink
Thanks for your help, Charles.

It seems that when I run the interpreter, RUBY_VERSION is set to 2.0,
based on my .jrubyrc (which has "compat.version=2.0"), but when I run
the compiler, it's set to 1.9.3. So, I suppose that setting isn't
being used by the compiler -- at least, not when run with the jrubyc
script. I'm not sure where compiler configuration takes place.

-Jon


On Tue, Oct 1, 2013 at 5:20 PM, Charles Oliver Nutter
Post by Charles Oliver Nutter
Many questions!
Post by Jon Zeppieri
- Are NotCompilableExceptions caught somewhere, allowing the
interpreter to carry on? (I did a simple grep for this, but didn't
find it.) Or was that code path not taken, at all?
NotCompileableException is caught by the JIT and used to leave a given
method in the interpreter. They can be logged with
-Xjit.logging.verbose=true (and -Xjit.logging=true will log
successes).
If you do not see the method fail to JIT, then the code path in
question was probably not taken.
I will say that the compiler size of keyword args is a little hacky
right now and probably well behind the interpreter. 2.0 has not been a
priority for us during the 1.7.x cycle.
Post by Jon Zeppieri
- Does AOT compilation not go through that code path that would throw
the NotCompilableException?
AOT compilation should follow the same paths as JIT but fail hard when
NotCompilableException is thrown.
Post by Jon Zeppieri
- What is the state of the IR? My brief look suggests that currently
the production compiler translates directly from the AST but that
there is a separate, newer compiler pipeline that goes through the IR,
and that pipeline can be turned on with a command-line switch but
which is off by default.
The IR is produced by a compiler from the current AST. We have a fully
functional interpreter (unsure about 2.0 features) and a very partial
JIT from IR to JVM bytecode.
The current plan is that the IR will form the basis of JRuby 9000's runtime.
- Charlie
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Subramanya Sastry
2013-10-02 18:25:05 UTC
Permalink
On Tue, Oct 1, 2013 at 4:20 PM, Charles Oliver Nutter
Post by Charles Oliver Nutter
Many questions!
Post by Jon Zeppieri
- Are NotCompilableExceptions caught somewhere, allowing the
interpreter to carry on? (I did a simple grep for this, but didn't
find it.) Or was that code path not taken, at all?
- What is the state of the IR? My brief look suggests that currently
the production compiler translates directly from the AST but that
there is a separate, newer compiler pipeline that goes through the IR,
and that pipeline can be turned on with a command-line switch but
which is off by default.
The IR is produced by a compiler from the current AST. We have a fully
functional interpreter (unsure about 2.0 features) and a very partial
JIT from IR to JVM bytecode.
Full keyword arg support present in IR since July (
https://github.com/jruby/jruby/commit/27b02be084545a05e5259c0550d1048574d55e4e)


Subbu.

Loading...