Navigation

RSS 2.0 New Entries Syndication Feed Atom 0.3 New Entries Syndication Feed

Show blog menu v

 

General

Use it

Documentation

Support

Sibling projects

RIFE powered

Valid XHTML 1.0 Transitional

Valid CSS!

Blogs : Archives

< RIFE v0.7.1 has been released   Bidirectional template engine >
Bytecode generation rocks

Initially, RIFE templates were first converted to real Java source files and then compiled on-the-fly with a regular Java compiler. Since I started using ASM for the Java continuations engine of the web framework, I quickly throught that it would be a good idea to use it for generating bytecode directly from the template engine.

Since yesterday I got rather fed up with the wait everytime I modified a template file, I decided that I'd give it a shot. In less than half a day I got all the old code disabled and replaced by suitable ASM visitors. It truly is a great bytecode generation and manipulation library. A nice side effect is that if you don't precompile the templates for distribution (ie. only let them be generated at runtime) no disc access is performed at all. The bytecode is generated in memory and passed directly as a byte array to a dedicated classloader.

The speed benefits that I hoped this would offer definately made the effort worth-while. The pre-compilation of all templates of our latest project now takes 44 seconds instead of 8 minutes 33 seconds, that's almost 12 times faster!!!

posted by Geert Bevin in RIFE on May 8, 2004 9:16 AM : 2 comments [permalink]
 

Comments

Re: Bytecode generation rocks

Does code generation on-the-fly reduce debuggability? What if there is a bug with the code generator? How do you debug?

Re: Bytecode generation rocks

You're basically reduced to regular debug print statements. What I do is first write the code in java anyway and test that thoroughly. Then I feed the bytecode through some simple analysis classes which convert the bytecode to the Java code that I would need to write for ASM to generate the same result. I can then optionally have debugging output logged with the exact bytecode location that's executed. If I need more, I insert a logger call somewhere in the bytecode generation logic.

Add a new comment

Comments on this blog entry have been closed.

< RIFE v0.7.1 has been released   Bidirectional template engine >
 
 
 
Google
rifers.org web