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

Igor Stasenko siguctua at gmail.com
Wed Jan 20 01:34:52 UTC 2010


2010/1/20 Andreas Raab <andreas.raab at gmx.de>:
>
> John M McIntosh wrote:
>>
>> For anonymous mmap I need  fread(imageFile, memStart, fsize(imageFile));
>> to mmap allocate and read the file into the anonymous mmap
>>
>> readImageFromHeapSize does nothing.
>> or for file based mmap I need  fread(imageFile, memStart,
>> fsize(imageFile));
>> to mmap the image file.
>> So I need the readImageFromHeapSize for?
>
> To tell the VM where your memory is located (replacement of sqAlloc*), and
> how much you've pre-allocated. Like I wrote in the original post:
>
> "The VMs would generally use this along the lines of:
>
>  memStart = malloc(heapSize);
>  fread(imageFile, memStart, fsize(imageFile));
>  readImageFromHeapSize(memStart, heapSize);
>
> etc."
>
RIGHT! Who said that image could be read only from file?
It could be a memory location, it could be a socket stream, it could
be anything.

So, i very like your idea with replacing an entry point by abstract

readImageFromObject: object size: heapSize

which could be just a 2-liner:

  memStart := self sqMalloc: heapSize.
  self ioReadFrom: object Into: memStart Size: heapSize.

(and object is of type 'void *', which leaves a platform code to
decide its meaning)

sqMalloc() and ioReadFromIntoSize(), also provided by platform-specific code)..

This makes an interpreter completely agnostic from data source, where
actual image is stored.


> Cheers,
>  - Andreas
>




-- 
Best regards,
Igor Stasenko AKA sig.


More information about the Vm-dev mailing list