Hi GWT team and contributors,

The GWT compiler currently does a good job of dead code elimination
and generating concise, efficient JavaScript.  However, the AST based
representation makes it difficult to perform data-flow based
optimizations.

I've been experimenting with a low-level, strongly-typed, SSA based
backend representation for the GWT backend.  The design of the IR is
heavily influenced by LLVM (http://llvm.org), a BSD-licensed compiler
infrastructure.  Some of the optimizations are adapted from LLVM.

The experimental backend works by flattening/linearizing all Java and
JavaScript code to a low-level IR, in which all non-memory operations
are in SSA form.  Nearly all optimizations occur on the IR, and not on
the Java or JavaScript ASTs.  The JavaScript AST is then generated
from the IR.  We may want to perform syntax based optimizations on the
JS AST, such as removing unnecessary labels or return statements.

This low-level IR has several advantages over GWT's current AST based
representation.  The SSA form makes advanced data flow analysis
easier.  The unified representation means compiler optimizations work
on both Java and JavaScript code.  Since it preserves type
information, we can still perform aggressive dead code elimination.

At this point, the experimental backend correctly compiles the
Showcase and Hello examples and passes most of the CompilerTest suite.
 Most compiler optimizations are not implemented and the generated
JavaScript is pretty verbose.  Long emulation, code-splitting, SOYC,
and probably a few of the other nifty GWT features don't work.

My code is at http://web.mit.edu/sgross/www/gwt/unified-r7422.patch .
For the most part, the only changes to existing classes are to make
some methods public to reduce copy-pasted code.  It also includes a
work around for issue 4512.

The backend is implemented using the x.compiler.class configuration
property.  To compile Showcase, add the following lines to
Showcase.gwt.xml:

  <define-configuration-property name="x.compiler.class"
is_multi_valued="false" />
  <set-configuration-property name="x.compiler.class"
value="com.google.gwt.dev.jjs.ir.gen.IrCompiler" />

Regards,
Sam
-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to