[squeak-dev] oldBaseAddr

Eliot Miranda eliot.miranda at gmail.com
Mon Aug 24 19:02:18 UTC 2009


Hi Ang,
    when a snapshot is written the heap is simply written to the file, so
all the object addresses in the file are those the objects had in the
address space of the process that wrote the snapshot.  The start address of
the heap is written to the snapshot file's header in the oldBaseAddr field.
 So nil, which is the first object in the heap, has address oldBaseAddr.  So
nil's address - oldBaseAddr is zero.  i.e. subtracting oldBaseAddr converts
an absolute heap address into a releative one where the heap starts at 0.

When a snapshot is loaded, the VM asks the OS to allocate memory for the
heap and assigns the start of this memory to memStart.  Therefore to load a
snapshot file at the new address, memStart, all pointers in the heap must be
adjusted by memStart - oldBaseAddr.

HTH

On Mon, Aug 24, 2009 at 11:13 AM, Ang Beepeng <beepeng86 at yahoo.com> wrote:

>
> Hi all.
>
> I do not understand the usage of oldBaseAddr. In VM source,
>
>
> oldBaseAddr = getLongFromFileswap(f, swapBytes);
> ...
> bytesToShift = memStart - oldBaseAddr;
>
>
> Thanks.
>
> Ang Beepeng
> --
> View this message in context:
> http://www.nabble.com/oldBaseAddr-tp25120957p25120957.html
> Sent from the Squeak - Dev mailing list archive at Nabble.com.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090824/481086b5/attachment.htm


More information about the Squeak-dev mailing list