[antlr-interest] Got GCJ to compile antlr and java parser/tree parser :)
Terence Parr
parrt at antlr.org
Sat Sep 13 16:32:23 PDT 2003
Ok, it was a pain in the ass, but with the knowledge that Ric Klaren
had gotten antlr to compile, I spent a few hours today trying things
out myself.
First, get ANTLR to compile. Got it to compile out of the box:
for each package dir in antlr:
$ gcj --CLASSPATH=/home/parrt/org.antlr -c -g -O *.java
then link:
gcj -o /usr/local/bin/antlr --main=antlr.Tool -g *.o */*.o */*/*.o
After running strip on executable, it's like 1.3M. :) Nice.
Getting antlr to run over a .g file is now easy:
$ antlr file.g
Hooray! Now, to compile the resulting parser took me a while to get
working.
I tried to make a library and all that, but couldn't make it work so I
resorted to telling it to compile antlr each time along with the parser
from file.g. No biggie.
GCJ does not have swing so I had to yank out anything related to that
like debug/misc/ASTFrame.* etc... Then I jar'd it up (put in
/tmp/antlr.jar) and then did this:
$ antlr java.g
$ antlr java.tree.g
$ gcj -c -g -O --classpath=/tmp/antlr.jar:. *.java
$ gcj -o jparse --main=Main -g *.o /tmp/antlr.jar
Lots of things like this come out:
warning: exception handler inside code that is being protected
but I ignored it and gave it the old smoke test.
ENVIRONMENT
My test box is a dual 1Ghz linux 9.x (can't remember which) with 1G RAM.
$ cat /proc/version
Linux version 2.4.20-6smp (bhcompile at porky.devel.redhat.com) (gcc
version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 SMP Thu Feb 27
09:59:40 EST 2003
$ gcj --version
gcj (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
TIMING
Java VM parsing jdk 1.4 source using time program:
$ java Main /usr/local/java/java
real 0m28.868s
user 0m24.990s
sys 0m0.420s
GCJ compiled parser doing same thing:
$ ./jparse /usr/local/java/java
real 0m40.004s
user 0m38.870s
sys 0m0.470s
[Note there are some problems parsing the source, but I haven't checked
what the error in my grammar is]
Yes, the GCJ version is SLOWER! Could this be the garbage collector or
slow IO library or something?
Ok, let's try on something smaller. How about the antlr source.
$ time java Main /home/parrt/org.antlr/antlr
real 0m7.226s
user 0m4.750s
sys 0m0.090s
$ time ./jparse /home/parrt/org.antlr/antlr
real 0m5.794s
user 0m5.700s
sys 0m0.080s
In this case, GCJ wins.
When parsing 1.4 source, GCJ version needs 10M resident and java VM
version needs 25M.
Well, that's all I have to report at the moment. Can anybody comment,
speculate?
Terence
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com pure link sharing
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list