[Vm-dev] [Fwd: Image file loading]

Andreas Raab andreas.raab at gmx.de
Tue Jan 19 23:09:05 UTC 2010


John M McIntosh wrote:
> On 2010-01-19, at 2:30 PM, Andreas Raab wrote:
> 
>> b) It trivially allows mmap()ing the entire image into memory (I think
>> John does that on the iPhone).
> 
> So how is this different that what happens now? 

That it removes hundreds of lines of completely unnecessary code. Yes, 
one can implement the same logic with the current interfaces, I just did 
that on Android :-) But at some point one must question the approach if 
the end result is only adding additional complexity.

That's why I'm saying move all of this out so that the interpreter 
doesn't have to deal with it. The task of allocating the initial amount 
of memory and loading the image into said memory should be done by 
support code *before* calling the interpreter the first time. Then, give 
the interpreter one entry point and then remove all the extra 
complexity. Which means:

> #ifndef allocateMemoryMinimumImageFileHeaderSize

Gets removed.

>  /* Called by Interpreter>>allocateMemory:minimum:imageFile:headerSize: */
>  #define allocateMemoryMinimumImageFileHeaderSize(heapSize, minimumMemory, fileStream, headerSize)  sqAllocateMemory(minimumMemory, heapSize)

Gets removed.

> #ifndef sqImageFileReadEntireImage

Gets removed.

>  #define sqImageFileReadEntireImage(memoryAddress, elementSize,  length, fileStream)  sqImageFileRead(memoryAddress, elementSize,  length, fileStream)

Gets removed.

> In platform specfic I change that 
> 
> usqInt sqAllocateMemoryMac(sqInt minHeapSize, sqInt *desiredHeapSize, FILE * f,usqInt headersize);

Gets removed.

> #ifdef BUILD_FOR_OSX
> size_t sqImageFileReadEntireImage(void *ptr, size_t elementSize, size_t count, FILE * f);
> #define sqImageFileReadEntireImage(memoryAddress, elementSize,  length, fileStream)  sqImageFileReadEntireImage(memoryAddress, elementSize, length, fileStream)
> #else
> #define sqImageFileReadEntireImage(memoryAddress, elementSize,  length, fileStream) length 
> #endif

Gets removed.

Some more things that get removed is in 
CCodeGenerator>>writeDefaultMacrosOn: a whole bunch of sqImageFile* 
definitions in sq.h and more.

Cheers,
   - Andreas


More information about the Vm-dev mailing list