Universal VM for 32/64 bit images (was: [Vm-dev] 64bit FFI?)
David T. Lewis
lewis at mail.msen.com
Fri Feb 13 14:42:10 UTC 2009
On Thu, Feb 12, 2009 at 09:47:44PM -0800, Eliot Miranda wrote:
> On Thu, Feb 12, 2009 at 7:38 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> > On Thu, Feb 12, 2009 at 11:18:02AM -0800, Eliot Miranda wrote:
> > >
> > > AFAICT you can produce a 64-bit VM that runs a 32-bit image with this
> > > technique, but you can't get a VM that runs both.
> > Actually, I think that it probably *is* possible to make a Squeak
> > VM that will run both 32 and 64 bit images, although performance may
> > be poor and the plugins would be problematic. The basic idea is to
> > move BytesPerWord and BaseHeaderSize into run time variables rather
> > than compile time macros (i.e. move them from class variables in
> > ObjectMemory to instance variables in ObjectMemory), and set the
> > values at image load time. Everything else should just work.
> You'll have to change oopForPointer/pointerForOop to account for the
> different widths of an oop. e.g. if the heap is origined at 0 then in a
> 64-bit image the oop 4 maps to byte address 8, but in a 32-bit image it maps
> to byte address 4.
> You'll have to change the readers and writers
> (e.g. oopAtPointer/oopAtPointerPut) to test BytesPerWord and fetch/store 64
> or 32 bits as required.
Piece o' cake. I bet you a virtual beer I can get it working without touching
any of these ;)
> It won't be particularly sprightly :)
No wagers on that one. It would be interesting to see just how much slower
it is though. Just to hazard a guess, I would expect about a 30% hit. If
I get it working, I'll report back on results.
More information about the Vm-dev