Chris Oliver's Weblog

Saturday Jul 14, 2007

First steps with the JavaFX Compiler

Thanks to the efforts of Robert Field, Lubo Litchev, and Jonathan Gibbons of the Javac team, as well as Per Bothner and Brian Goetz (and also thanks to the organizational efforts of Bob Brewin, James Gosling, and Tom Ball) we have the beginnings of a JavaFX to JVM-byte-code compiler built on the same infrastructure as Javac.

Of course, the compiler is still incomplete, but it turns out to be far enough along to try a first performance benchmark (Takeuchi function):

import java.lang.System;

public class Tak {
  operation tak(x:Number, y: Number, z:Number):Number;
}

operation Tak.tak(x, y, z) {
   return if (y >= x)
       then z
       else tak(tak(x-1, y, z),
                tak(y-1, z, x),
                tak(z-1, x, y));
}

var tak = new Tak();
System.out.println("tak(24,16,8)={tak.tak(24, 16, 8)}");

$ time java -cp ".;dist/JavaFX.jar" TakMod
tak(24,16,8)=9.0

real    0m1.333s
user    0m0.010s
sys     0m0.020s

Here's the interpreter:

$ time bin/javafx.sh TakMod.fx
compile thread: Thread[main,5,main]
compile 0.04
tak(24,16,8)=9.0
init: 69.48

real    1m10.422s
user    0m0.190s
sys     0m0.130s
Speed improvement for this particular example is a pretty awesome 54x.

Comments:

hi, sounds great! :) but how's compilation performance? is it faster than the current interpreter?

Posted by peter on July 14, 2007 at 07:18 PM PDT #

@Peter I'd say the answer to your question is something like "butterflies," which as an answer makes as much sense as your question.

Posted by Hans Uvstohn on July 15, 2007 at 08:48 AM PDT #

When can we download the compiler?

Posted by David Ford on July 15, 2007 at 11:42 AM PDT #

probably you misunderstood my question. the current javafx runtime needs a long time to check for syntax and semantical errors. so it would be great if this time will be shortened with the new compiler.

Posted by peter on July 17, 2007 at 10:48 AM PDT #

To Peter,
There is a figure for you.

JavaFX Interpreter (Class Loader) => Run-Time
JavaFX Compiler => Compiler-Time

Comparing compiler-time performance with run-time performance is meaningless.

Posted by Jerry Tsai on July 17, 2007 at 07:15 PM PDT #

again you misunderstood me. before the runtime (and I'm talking about the current javafx runtime without the upcoming compiler) can *execute* the application it has still to 'compile' the code before it can execute it. And I would like to have a comparison of exactly this time and the time the new compiler takes to compile.

Posted by peter on July 18, 2007 at 04:33 AM PDT #

So will Sun's heavy support of JavaFX finally lead to JVM support for tail recursion? That's the hope I just got while looking at this (though I'm not fresh on the details of proper tail recursion - not sure if this example applies - still, I understand that many functional folk are dying for it, and I understand why they want it).

Posted by Tom Palmer on July 19, 2007 at 12:33 PM PDT #

3

Posted by 61.8.226.148 on July 19, 2007 at 12:33 PM PDT #

[Trackback] An incubator project to build a compiler for the JavaFX Script language has been started. Not much there yet, but developers have a chance to get in on the bottom floor and help make it a killer tool.

Posted by Tom Ball's Blog on July 20, 2007 at 06:50 AM PDT #

If I understand well, Peter is referring to the interactive experience while writing JavaFX code that is immediately executed. Right? So he's asking whether the time needed for compiling the stuff will have a negative impact on that experience.

Posted by Fabrizio Giudici on July 20, 2007 at 04:28 PM PDT #

This benchmark is just too naive.
At least loop it a 1000 times to give some meaningful results.
Currently you are mostly measuring pure VM startup times vs JavaFX startup times, taking absolutely no advantage of HotSpot at all.
You also should include the timings for a pure java implementation as reference.
I just checked a C implementation, at about 12s/1000 loops on a 2Ghz core2.

Posted by Eike Dierks on July 21, 2007 at 08:50 PM PDT #

is it possible to include external libraries in JavaFX applications ? how ?? I just can find Swing libraries and Java API libraries.. and how about third party libraries.. ?

Posted by Felipe Gaucho on July 22, 2007 at 03:42 AM PDT #

So will Sun's heavy support of JavaFX finally lead to JVM support for tail recursion? That's the hope I just got while looking at this (though I'm not fresh on the details of proper tail recursion - not sure if this example applies - still, I understand that many functional folk are dying for it, and I understand why they want it).

Posted by Warhammer Online Gold on March 11, 2009 at 10:03 PM PDT #

http://www.smsmatbaa.com

Posted by matbaa on June 22, 2009 at 10:05 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Calendar

Feeds

Search

Links

Navigation

Referers