[squeak-dev] oldBaseAddr

Eliot Miranda eliot.miranda at gmail.com
Mon Aug 24 20:09:57 UTC 2009


On Mon, Aug 24, 2009 at 12:48 PM, Ang Beepeng <beepeng86 at yahoo.com> wrote:

>
> Thank you very much.
>
> Do you mean that during squeak start-up, process of memory allocation
> somehow make memStart to have value according to the image loaded. And
> therefore the same as oldBaseAddr which is  from the same image.
> (I know very little about memory allocation in every aspect, sorry about
> that)
>

No.  The issue is that memStart is where the OS gives it to you.  It could
be anywhere.  It could also change between two slightly different VMs on the
same platform, because one VM might have more code and therefore memStart
would end up at a higher address.

So the problem is to load the image at the address that the OS gives you
memory in which to load the heap.  Writing oldBaseAddr to the image avoids
having to update the pointers when writing the image.


>
> The difference is only when one reload a snapshot, without restarting the
> VM. memStart remain the same, but oldBaseAddr (memStart of another snaphot)
> is different. Is that correct?


The other way around.  oldBaseAddr is the base of the heap at the time the
snapshot was written.  memStart is the start of the heap in the current
system that is trying to load the snapshot.


>
>
> Thanks.
>
> Ang Beepeng
>
>
> Eliot Miranda-2 wrote:
> >
> > 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
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/oldBaseAddr-tp25120957p25122722.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/a376b1a8/attachment.htm


More information about the Squeak-dev mailing list