[Vm-dev] VM Maker: ImageFormat-dtl.49.mcz

David T. Lewis lewis at mail.msen.com
Sun Jan 10 16:32:15 UTC 2021


On Sun, Jan 10, 2021 at 11:11:30AM -0500, David T. Lewis wrote:
>  
> On Sun, Jan 10, 2021 at 11:30:50AM +0530, K K Subbu wrote:
> > 
> > On 10/01/21 5:39 am, commits at source.squeak.org wrote:
> > >+ ----- Method: CogImageFileHeader>>readFieldsFrom:littleEndian:into: (in 
> > >category 'reading') -----
> > >+ readFieldsFrom: aStream littleEndian: littleEndian into: aCollection
> > 
> > Passing endian flag to every read looks like an overkill, doesn't it?
> > 
> > >+ 			[ 16r00001966 "6502" ] -> [ imageFormat := 
> > >ImageFormat fromInteger: 6502. littleEndian := false ] .
> > 
> > The endianness is fixed when the imageFormat is instantiated. If it 
> > could be encapsulated as part of this instance, then there is no need to 
> > pass it as an argument for every read from the store associated with 
> > this image instance.
> > 
> > Ideally, the image store type (little/big endian) should be separated 
> > from the image encoding format (32-bit, 64-bit, ....). But I guess this 
> > separation can evolve over time.
> > 
> > Regards .. Subbu
> 
> Hi Subbu,
> 
> It is an interesting question and I'm glad you spotted it. In the VM,
> the logic for reading and writing the snapshot header is buried in the
> code where most people will never see or think about it. So I am trying
> to make it more accessible.
> 

I should add one more thing - I did not really answer your question of
whether the image file endianness should be saved as an instance variable
somewhere, as opposed to passing it around as a flag. I don't really have
a good answer right now. For the case of simply reading and writing an
ImageFileHeader, I think it's better to leave at as a flag used only in
the process of reading. But I can imagine other use cases where it might
be useful to keep it as an instance variable.

Dave


More information about the Vm-dev mailing list