This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: java.lang.Character
Eric Blake wrote:
> Yes, I will look at retooling Character.java and chartables.pl to use
> the same algorithms as the Classpath counterparts, but using
> java-chartables.h for storing the table as C arrays. The Classpath
> implementation DOES have the algorithmic advantages: it is fully
> compliant with the 1.4 specs (gcj is currently broken in several
> methods, such as isJavaLetter()), and its concept of a direct 2-level
> fixed-block-size lookup is better than gcj's binary search (maximum 10
> comparisons for Unicode 3.0) followed by a 1-level variable-block-size
> lookup. Besides, Classpath has Javadoc, which gcj lacks.
Great! Thanks.
> So, my end target is to have the end algorithms and behavior match,
> although the database interface will differ between the two projects.
> Merging is definately a chore ;)
Sorry. Would it make sense to write a little Java application that
implements CharData.java, and writes out java-chartables.h? That
should be simple - and it might be useful for other tasks. The other
part of the task - reacpling the Character methods by native methods
and moving them to natCharacter.cc should be easy if tedious.
> Actually, I do have one more question on efficiency:
> In the Classpath version, the 2nd level lookup occupies up 5800+
> characters, although there are about only 350 unique character
> attributes (so 9 bits are required to index into a 3rd level). As a
> result, there are four 3rd level tables for the attributes that did not
> fit in the 7 otherwise unused bits of the 2nd level lookup.
I haven't looked at hwo the tables work, so I can't say. If you're
talking about just a few kilobytes extra space then it may be worth it
to save an extra lookup. But if it is more than that, I'd say do the
extra lookup. While spped of character parsing is often important, one
extra non-bounds-checked lookup is probably a price worth paying, given
our goal to make GCJ suitable for limited -memory environments. Where
the cur-off point is between time and space is harder to say.
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/