Re: Compiling pointer arithmetic targeting JVM

bonzini@gnu.org (Paolo Bonzini)
3 Dec 2003 20:32:47 -0500

          From comp.compilers

Related articles
Compiling pointer arithmetic targeting JVM napi@cs.indiana.edu (2003-11-21)
Re: Compiling pointer arithmetic targeting JVM gah@ugcs.caltech.edu (glen herrmannsfeldt) (2003-12-03)
Re: Compiling pointer arithmetic targeting JVM bonzini@gnu.org (2003-12-03)
Re: Compiling pointer arithmetic targeting JVM joachim.durchholz@web.de (Joachim Durchholz) (2003-12-08)
Re: Compiling pointer arithmetic targeting JVM fjh@cs.mu.oz.au (Fergus Henderson) (2003-12-13)
| List of all articles for this month |

From: bonzini@gnu.org (Paolo Bonzini)
Newsgroups: comp.compilers
Date: 3 Dec 2003 20:32:47 -0500
Organization: http://groups.google.com
References: 03-11-098
Keywords: Java
Posted-Date: 03 Dec 2003 20:32:47 EST

> Is there any literature that explains how to mimic memory architecture in
> JVM so that we could compile pointer arithmetic inherent in languages like
> C and Pascal. Thanks for any tips.


You may try converting a pointer to a "fat format" that includes the
base and the offset. Then


      ptr2 - ptr1 == ptr2.ofs - ptr1.ofs


(it works only if the base is the same, but otherwise it is not valid
ANSI C)


      ptr1 < ptr2 == ptr1.ofs < ptr2.ofs


(likewise)


      ptr1 + delta == (ptr1.base, ptr1.ofs + delta)
      *ptr == ptr.base[ptr.ofs]


Array <-> pointer conversion goes on like this:


      array == (array, 0)
      &array[element] == (array, element)


You may experiment with boxing vs. keeping the two parts in separate
variables.


Hope this helps,


Paolo


Post a followup to this message

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