[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    Re: Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS
From:       Per Bothner <per () bothner ! com>
Date:       2000-01-31 5:11:34
[Download RAW message or body]

Tom Tromey <tromey@cygnus.com> writes:

> Actually, I was referring to this:
> 
> http://archive.csee.uq.edu.au/~csmweb/uqbt.html#gcc-jvm
> 
> I don't know if this targets PicoJava or not.  It was written by
> different people than the PicoJava port from SAC.

I took a very quick look at this.  It looks like the basic idea
is to have represent memory as a global array of ints.
I.e.:
        public int[] memory;

A "pointer" is an index into "memory".  It looks like each element
of memory is only used to store an 8-bit byte.  My guess is this is
so one can address 8-bit bytes, which storing a point in a memory cell.

It definitely looks like a quick hack, but it might still be a
reasonable approach.  I can see that you have (at least) two basic
choices: You have a single global "memory", which means it has to be a
single type (char or int).  You then have to do explicit conversions
(e.g masks, shifts) to re-interpret the memory as some other data type.
Alternatively, you can have multiple memory objects, one for each "C
object" (variable or array).  Then you (mostly) don't have to do as
many conversions.  However, you have to represent a "C pointer" as a
pair of (reference to a C Object, offset), and casting between pointer
and integer may not be possible.  You have various tradeoffs for heap
allocation (with the global memory you have to implement your own
malloc/free, which allocate a chunk from the memory array, and
re-allocate it if it is too small).

In any case, you should start with a run-time model: How would I
represent the data types (integer, floats, arrays, maybe pointers and
structures) of my language using Java data types?  How would I represent
parameter passing?  How do I represent call-by-reference (in Fortran)
or taking the address of an object component (in C)?

Once you can *hand-translate* Fortran (or C) code to either Java
source or Java bytecodes, then you can write a Gcc back-end that
does the translation for you.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic