javac: ending positions generation and DiagnosticListener

Per Bothner per.bothner at oracle.com
Fri Dec 6 13:41:19 PST 2013


It is of course possible to implement the 'end-pos-table' much
more compactly.  Currently, it uses a Map<JCTree, Integer> (see
class SimpleEndPosTable in JavacParser.java).  This is of course
very space-inefficient, as it requires an Integer object and
a Map.Entry object for each entry.

Kawa has a class IntHashTable which maps Object to int in an
optimized fashion, with no per-entry allocation:
https://sourceware.org/viewvc/kawa/trunk/gnu/kawa/util/IntHashTable.java?view=co&revision=7567&content-type=text%2Fplain

This code was written by Charles Turner (as a Google Summer of Code 
student),
based on my design/suggestions.  The Kawa project (led by me) would be happy
to donate this class as a much-more efficient re-implementation of
SimpleEndPosTable.  (If there is interest, as a courtesy I'll check with 
Charles.)

The code could probably be simplified a bit, as long as we don't
care about general deletions, though replaceTree needs special handling.
-- 
	--Per Bothner
per.bothner at oracle.com   per at bothner.com   http://per.bothner.com/


More information about the compiler-dev mailing list