Re: Wonder about design of a Java compiler

sgganesh@gmail.com
3 Jan 2005 00:53:51 -0500

          From comp.compilers

Related articles
Wonder about design of a Java compiler malinda.fernando@gmail.com (malinda) (2004-12-29)
Re: Wonder about design of a Java compiler vbdis@aol.com (2004-12-30)
Re: Wonder about design of a Java compiler sgganesh@gmail.com (2005-01-03)
| List of all articles for this month |
From: sgganesh@gmail.com
Newsgroups: comp.compilers
Date: 3 Jan 2005 00:53:51 -0500
Organization: http://groups.google.com
References: 04-12-150
Keywords: Java
Posted-Date: 03 Jan 2005 00:53:51 EST

Writing a Java compiler is not a very difficult: Java is a
considerably simple language (compared to, say, C++), and can be
written following traditional compilation techniques.


In past, I've written a Java compiler when I was a college grad, to
expriment compiler implementation techniques I learned in our college
course: it took around 6 months to write a reasonably robust
implementation. The conventional lex->syntax->semantics->code-gen was
followed. You would need to refer the books The Java Language
Specification and The Java Virtual Machine Specification by the
original designers of Java from Sun.


Two main differences I noticed from conventional compilers and Java
compilers:


The native code generation techniques (like register allocation) are
not useful in Java (but for a VM, and the file format is .class file,
with bytecodes; bytecode level is something like a (stack-based)
intermediate language you would use in a traditional compiler
implementation from which you would proceed to generate native code;
in Java compiler, you stop there).


Traditional, simple optimizations (like constant folding) can be done
in the compiler, but sophisticated optimizations cannot be done in
Java because of the restrictions imposed by the .class file format and
its close interaction/depenency with JVM.


-Ganesh


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.