[Vm-dev] Byte addressing

John McIntosh johnmci at smalltalkconsulting.com
Thu Jun 16 23:12:04 UTC 2011

Casey, go look at sqMemoryAccess.h

you'll find all memory access is abstracted out, either as a macro or
a C subroutine (you choose). So you can grind thru what is needed to
get bytes in or out.  I have used that in the past to run sanity
checks on oops addressing.

Pay attention to sqMemoryBase which is added (or not) to the oops
reference to get a memory address, this has behaviour differences
between 32 and 64 bit machines, when you run a 32bit image on a 64bit
Alas some plugins incorrectly assume the oops pointer is a memory
address. This *works* on 32bit machines, but is death when you run a
32 bit image with a 64bit VM, cross checking and fixing is boring ugly
task, still I did that for the freetype plugin (which was broken) a
year back (or was it two?)

The other key issue is swizzling oops pointers to match the base
memory address where the image is loaded.
And then dealing with big or little endian, where one marchs thru the
image flipping bytes.
This is all done at the point where the image is loaded into memory
from the storage sub system.

>From an optimization viewpoint you will find that on OS-X and IOS via
magic in mmap we attempt to use the same start memory address to avoid
walking the image to re-swizzle oops references to the real memory
address. Thus avoiding touching image memory on IOS.

On Thu, Jun 16, 2011 at 6:31 PM, Casey Ransberger
<casey.obrien.r at gmail.com> wrote:
> The VM depends upon the availability of byte addressing in the underlying hardware, is this correct?
> My somewhat-educated guess is yes, what with things like ByteString, etc.
> If I wanted to build it on a platform that didn't support byte addressing, e.g. Chuck Thacker's TinyComputer, what work would need to be done?
> For now, I'm asking about the interpreter VM. I'll worry about Cog later.
> I suppose a supporting question, given that GCC expects byte addressing, might be: what other C compilers can I use currently to build the Squeak VM? I'm aware that the Microsoft compiler will of course work, but I can't use that. I ask because it will be easier to modify just the VM than it will be to modify both the VM and the C compiler.
> If the right answer, amongst the experience here, is "don't even try," that will likely be useful advice, so don't be shy:)

John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com

More information about the Vm-dev mailing list