[Vm-dev] headerTypeBytes oddity
Igor Stasenko
siguctua at gmail.com
Thu Feb 19 01:44:52 UTC 2009
2009/2/19 David T. Lewis <lewis at mail.msen.com>:
>
> On Wed, Feb 18, 2009 at 03:09:22PM +0200, Igor Stasenko wrote:
>>
>> A headerTypeBytes ivar used in Interpreter, but initialized only once
>> during its lifetime - in readImageFromFile: f HeapSize:
>> desiredHeapSize StartingAt: imageOffset),
>> and with same constants:
>>
>> headerTypeBytes at: 0 put: BytesPerWord * 2. "3-word header (type 0)"
>> headerTypeBytes at: 1 put: BytesPerWord. "2-word header (type 1)"
>> headerTypeBytes at: 2 put: 0. "free chunk (type 2)"
>> headerTypeBytes at: 3 put: 0. "1-word header (type 3)"
>>
>> I think this initialization could be put into static var declaration,
>> in #declareCVarsIn:
>> aCCodeGenerator
>> var: #headerTypeBytes
>> declareC: 'static sqInt headerTypeBytes[4] = { blablabla}'.
>>
>> then we don't have to pollute already complex #readImageFromFile:...
>> method with odd stuff like this.
>
> Igor,
>
> Can you make a Mantis entry for this? It looks like an easy and harmless
> change, but it would be good to have a record of it on Mantis so the
> various VM projects can keep in sync.
>
i found one reason why it initialized there - because of simulation.
If you remove that code and try to run VM simulated, this ivar will
not be properly initialized.
Anyway, i think it would be better to place this code somewhere else
that in #readImageFromFile:
In Hydra, i having #initializeVM method where i can place it and
forget about it.
In Squeak VM, this could be difficult - the main issue is to get it
properly initialized in simulation.
> Dave
>
>
--
Best regards,
Igor Stasenko AKA sig.
More information about the Vm-dev
mailing list