Blog Post

#382 Build 1.0.34

brian Fri 24 Oct 2008

I have posted the latest build for download. I did not update the online docs (no public APIs were changed).

This build really focuses on one feature - using primitives in the Java runtime:

sys::Bool   =>  boolean
sys::Int    =>  long
sys::Float  =>  double

Getting this all to work smoothly involved a lot of changes:

  • Ensuring the compiler correctly generates coercions everywhere necessary
  • Changing the fcode format to provide type arguments for comparison and stack opcodes. I also took this opportunity to cleanup the fcode definitions
  • Generate Java bytecode using primitives
  • Refactor Java emit code to keep track of locals for using correct opcodes
  • Refactor all the Java native code to use primitives
  • Tons of new tests

My basic design philosophy has been to keep the number of Fan opcodes fairly small, but provide type arguments to permit the Java and .NET runtime to optimize appropriately. This design seems to be working out well. Andy is busy refactoring the .NET runtime and we'll see how that turns out over the course of the next few weeks.

This build should be used as the bootstrap for compiling the Mercurial tip. The past few weeks it has been impossible to bootstrap off hg - sorry about that. I think from this point forward I should be able to keep the tip compilable using the released build.

I posted some performance numbers earlier. The performance boost for numeric computation is quite impressive. Computing Fibonacci to 40:

Fan 1.0.33 (old)    21.6sec
Fan 1.0.34 (new)     2.4sec
Java (using longs)   2.2sec

That test shows an order of magnitude improvement! The Fan performance gets pretty close to raw Java. Shortly I'll refactor the compiler's tokenizer to use non-nullable ints - I expect this will be a pretty big performance improvement since tokenizing is where we took a bit hit when I moved from the Java compiler to the Fan compiler.

The test suite fully passes and I'm using Flux full-time against this new build. However I expect it will take a little while to work out the bumps. If you notice a Java verification error, please let me know so I can dig into it.

tompalmer Sun 26 Oct 2008

Sweet performance happiness. Once there's some serious numeric array action, I think Fan will do nicely for algorithms.

katox Mon 27 Oct 2008

Using the tip these are the numbers I got for fib(48) naive implementation

Java (using ints)    0min 52.004s
Fan (mercurial tip)  1min 20.601s
Java (using longs)   1min 43.759s

now tell me why ;) (yes, the resulting number was the same)

alexlamsl Mon 27 Oct 2008

now tell me why ;)

Because HotSpot only expects professional implementations? ;P

Now that things seem to be settling in Fanland, I should start thinking again from where I've left off - about how I should implement RationalNumbers in Fan.

Login or Signup to reply.