[Vm-dev] headerTypeBytes oddity

Igor Stasenko siguctua at gmail.com
Wed Feb 18 13:09:22 UTC 2009


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.

It maybe not worth much attention for Squeak VM, but for Hydra, i
found that this ivar placed into Interpreter struct (which means that
each instance of interpreter will having separate  headerTypeBytes).
There are tons of ivars in ObjectMemory and Interpreter and its hard
to track all, which worth keeping on a per-interpreter basis :)

-- 
Best regards,
Igor Stasenko AKA sig.


More information about the Vm-dev mailing list