--20cf3079bf42dde73904b02761cc
Content-Type: text/plain; charset=ISO-8859-1

Hi Charlie,

I guess the difficulty I do have with certain modern bytecode systems is
that on some level there do not match that well with the backends and IL
structure of modern compilers (for example LLVM is heavily SSA based since
this simplifies dataflow analysis due to lack of symbol replication).
 Concerning your point wrt to abstract versus more concrete bytecode systems
do you know of any references here where one can find discussion of the
pro/cons of one of these versus the other. It would seem to me if the JIT
systems can in principle deduce (infer) thinks based on the abstract IL or
get some kind of "metadata" from the compiler frontend this would imply that
the frontend information is not needed.

Regards,

Carter.


On Wed, Oct 26, 2011 at 9:30 AM, Charles Oliver Nutter
<headius / headius.com>wrote:

> On Tue, Oct 25, 2011 at 11:35 AM, Carter Cheng <cartercheng / gmail.com>
> wrote:
> >
> > Hello Charlie,
> > I did notice reading through some of the papers on the current efforts to
> JIT javascript (v8, spider monkey and squirrelfish) are quite similar to
> Ruby in some ways but that it offers unique challenges. Are there some
> descriptions out there of the JRuby effort and the internals?
>
> There's an oldish description here, but it could use some refreshing:
> https://github.com/jruby/jruby/wiki/JRubyInternalDesign
>
> Basically, there's two phases to JRuby's JITing. First there's the
> JRuby compiler, which compiles from the AST (which we interpret
> against) into JVM bytecode. The primary goal of the bytecode compiler
> is to map Ruby language constructs as closely to JVM constructs as
> possible. For example, mapping local variables to JVM local variables
> whenever possible by detecting the use of closures, methods like
> 'eval', and so on. The set of optimizations that compiler does is
> fairly limited.
>
> Then after the bytecode runs for a while, the JVM will take over. The
> different JVMs all have their own optimization strategies, but in
> general they're extremely good at it. I won't go into the details
> here; there's papers on each of the JVMs, and lots of information
> about how Hotspot/OpenJDK optimizes publicly available.
>
> We do also have a third compiler that will be in use soon, which
> produces a CFG-based intermediate representation (so called "IR
> Compiler"). This new compiler will give us the opportunity to apply
> more traditional compiler optimization techniques, improving the
> quality of the JVM bytecode we produce so that JVMs have better
> visibility to take things from there. I'm not the expert on that
> compiler, but I can point you toward folks who are.
>
> > My sense is that there are opportunities here for further improvement
> though with MRI I would
> > ideally like to restructure the byte code IL format (though I am
> uncertain if this is a good idea given the direction it looks like 2.0 may
> be going.
>
> My understanding of optimizing bytecode compilers tells me that having
> a good IL is very important. You want enough visibility into the
> fine-grained operations (so you can optimize well) but you don't want
> such a massive instruction set that the optimizer becomes gigantic. I
> don't hink MRI's current bytecode set is "too big" but they've started
> to add "superinstructions" which are a clear sign (to me) of premature
> optimization.
>
> - Charlie
>
>

--20cf3079bf42dde73904b02761cc
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Charlie,<div><br></div><div>I guess the difficulty I do have with certain modern bytecode systems is that on some level there do not match that well with the backends and IL structure of modern compilers (for example LLVM is heavily SSA based since this simplifies dataflow analysis due to lack ofymbol replication).                                             䮼<div><br></div><div>Regards,</div><div><br></div><div>Carter.</div><div><br><br><div class="gmail_quote">On Wed, Oct 26, 2011 at 9:30 AM, Charles Oliver Nutter <span dir="ltr">&lt;<a href="mailto:headius / headius.com" target="_blank">headius / headius.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Tue, Oct 25, 2011 at 11:35 AM, Carter Cheng &lt;<a href="mailto:cartercheng / gmail.com" target="_blank">cartercheng / gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hello Charlie,<br>
&gt; I did notice reading through some of the papers on the current effortso JIT javascript (v8, spider monkey and squirrelfish) are quite similar to Ruby in some ways but that it offers unique challenges. Are there some descriptions out there of the JRuby effort and the internals?<br>


<br>
</div>There&#39;s an oldish description here, but it could use some refreshing:<br>
<a href="https://github.com/jruby/jruby/wiki/JRubyInternalDesign" target="_blank">https://github.com/jruby/jruby/wiki/JRubyInternalDesign</a><br>
<br>
Basically, there&#39;s two phases to JRuby&#39;s JITing. First there&#39;s the<br>
JRuby compiler, which compiles from the AST (which we interpret<br>
against) into JVM bytecode. The primary goal of the bytecode compiler<br>
is to map Ruby language constructs as closely to JVM constructs as<br>
possible. For example, mapping local variables to JVM local variables<br>
whenever possible by detecting the use of closures, methods like<br>
&#39;eval&#39;, and so on. The set of optimizations that compiler does is<br>
fairly limited.<br>
<br>
Then after the bytecode runs for a while, the JVM will take over. The<br>
different JVMs all have their own optimization strategies, but in<br>
general they&#39;re extremely good at it. I won&#39;t go into the details<br>
here; there&#39;s papers on each of the JVMs, and lots of information<br>
about how Hotspot/OpenJDK optimizes publicly available.<br>
<br>
We do also have a third compiler that will be in use soon, which<br>
produces a CFG-based intermediate representation (so called &quot;IR<br>
Compiler&quot;). This new compiler will give us the opportunity to apply<br>
more traditional compiler optimization techniques, improving the<br>
quality of the JVM bytecode we produce so that JVMs have better<br>
visibility to take things from there. I&#39;m not the expert on that<br>
compiler, but I can point you toward folks who are.<br>
<div><br>
&gt; My sense is that there are opportunities here for further improvement though with MRI I would<br>
&gt; ideally like to restructure the byte code IL format (though I am uncertain if this is a good idea given the direction it looks like 2.0 may be going.<br>
<br>
</div>My understanding of optimizing bytecode compilers tells me that having<br>
a good IL is very important. You want enough visibility into the<br>
fine-grained operations (so you can optimize well) but you don&#39;t want<br>
such a massive instruction set that the optimizer becomes gigantic. I<br>
don&#39;t hink MRI&#39;s current bytecode set is &quot;too big&quot; but they&#39;ve started<br>
to add &quot;superinstructions&quot; which are a clear sign (to me) of premature<br>
optimization.<br>
<br>
- Charlie<br>
<br>
</blockquote></div><br></div>

--20cf3079bf42dde73904b02761cc--