[Vm-dev] mmap,
changes to co-ordinate mapping to particular address to avoid oops
address remapping at startup time.
John M McIntosh
johnmci at smalltalkconsulting.com
Fri Oct 24 01:52:25 UTC 2008
Well it's not quite a straight forward
(a) you need to disable the image read logic I guess this could be in
the #define
So in readImageFromFile: f HeapSize: desiredHeapSize StartingAt:
imageOffset
we have
"read in the image in bulk, then swap the bytes if necessary"
bytesRead := self cCode: 'sqImageFileRead(pointerForOop(memory),
sizeof(unsigned char), dataSize, f)'.
bytesRead ~= dataSize ifTrue: [self unableToReadImageError].
That I think needs to become
bytesRead := self cCode:
'sqImageFileReadEntireImage(pointerForOop(memory), sizeof(unsigned
char), dataSize, f)'.
bytesRead ~= dataSize ifTrue: [self unableToReadImageError].
so that you can say
#define s#define sqImageFileRead(ptr, sz, count, f) count
which then nulls out what sqImageFileReadEntireImage does since the
image reading is really done via the mmap which was done in the
allocateMemoryminimumimageFileheaderSize
otherwise by default it would be
#define sqImageFileReadEntireImage(ptr, sz, count, f)
sqImageFileRead(ptr, sz, count, f)
(b) free?
Actually I'm not sure who if anyone ummaps memory on exit, however in
this case one does need to remember that memory points to the start of
file, not 0+headerSize
For testing I've just remember the mmap for the file, and mmap for the
anonymous section. However I'd guess a Hydra VM would have to do a
bit more to remember those
two memory locations somewhere since I suspect the ability to startup
and shutdown an image is more likely without terminating the process
space.
On Oct 23, 2008, at 6:16 PM, David T. Lewis wrote:
> On Fri, Oct 10, 2008 at 09:36:51PM -0700, John M McIntosh wrote:
>>
>> In the past year or so there has been discussion of using mmap to set
>> a start address for the offset of object memory so that memory
>> address
>> swizzling does not occur.
>> Also various operating systems vendors say using mmap to page in
>> large
>> files is faster than using fread, this in fact is true and noticeable
>> on the iPhone.
>>
>> This requires a change to VMMaker so that sqAllocateMemory can pass
>> the file pointer and the header size, since in the
>> sqAllocateMemory we need to figure out the file (image size) and also
>> understand the headersize of the image file to return a proper
>> address
>> to work with.
>
> John,
>
> If I understand correctly, the change in
> #readImageFromFile:HeapSize:StartingAt:
> might look like this:
>
> "allocate a contiguous block of memory for the Squeak heap"
> memory := self
> allocateMemory: heapSize
> minimum: minimumMemory
> imageFile: f
> headerSize: headerSize.
>
> For backward compatibility in the support code (e.g. for the
> existing unix
> platform code), a define could be provided like this:
>
> #define allocateMemoryminimumimageFileheaderSize(heapSize,
> minimumMemory, f, headerSize) \
> sqAllocateMemory(minimumMemory, heapSize)
>
> And for the iPhone VM, you could have a macro like this:
>
> #define allocateMemoryminimumimageFileheaderSize(heapSize,
> minimumMemory, f, headerSize) \
> sqAllocateMemoryMac(minimumMemory, heapSize, f, headerSize) {
>
> Does that sound right? Change set attached for the VMMaker part.
>
> - Dave
>
> <Interpreter-readImageFromFile-jmm-dtl.1.cs>
--
=
=
=
========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
=
=
=
========================================================================
More information about the Vm-dev
mailing list