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

David T. Lewis lewis at mail.msen.com
Wed Jan 20 01:16:04 UTC 2010


On Tue, Jan 19, 2010 at 02:30:43PM -0800, Andreas Raab wrote:
> 
> What I'm proposing is an additional VM entry point, called
> 
>   Interpreter>>readImageFromHeap: heapStart size: heapSize
> 
> which takes to arguments: The pointer to the beginning of the
> (pre-allocated) memory portion where the image file has been loaded or
> mapped and a size for the allocated memory portion. The VM then assumes
> that beginning at heapStart there is an image provided that it needs to
> properly prepare (i.e., perform byte-reversal, pointer adjustment etc).

A suggestion:

  Interpreter>>installImage: address size: imageSize header: header

Where header is the address of the image file header, and address is
the address of the uninitialized image beginning after the file header.

Rationale:

- "Install" is more appropriate that "read", since the contents of the
  image file have already been read.

- "Heap" is not relevant.

- The file header is logically distinct from from the contents of the
  image proper, and since someone else did the reading, it seems better
  to pass them as two distinct things (*). The pointer to header is
  presumed to be a memory block of at least 64 bytes, so in the usual
  case of a 32 bit image read into a block of malloc'ed space, we expect
  that address == header + 64.

My opinion: Adding the entry point is easy to do and has a clear benefit
for at least one platform of interest, so we should do this. Removing
the existing entry point is debatable and can be done at a later time.

Dave

(*) I've noticed that the format of the file header for 64-bit images
is not optimal, so a logical separation of the file header from the
image proper just seems like the right thing to do.



More information about the Vm-dev mailing list