[Vm-dev] Why primitive new have unexpected temp affectation

Mathieu Suen mathk.sue at gmail.com
Sun Aug 12 23:46:01 UTC 2007


I have look at the code of the primitiveNew and it seems that the  
temporaries is affect twice which don't make sense:

	"Allocate a new indexable instance. Fail if the allocation would  
leave less than lowSpaceThreshold bytes free."
	| size class spaceOkay |
	size := self positive32BitValueOf: self stackTop.
	class := self stackValue: 1.
	self success: size >= 0.
		ifTrue: ["The following may cause GC!"
			spaceOkay := self sufficientSpaceToInstantiate: class  
indexableSize: size.
			self success: spaceOkay.
			class := self stackValue: 1].
	successFlag ifTrue: [self pop: 2 thenPush: (self instantiateClass:  
class indexableSize: size)]

The first affectation is not necessary. Isn't it?


More information about the Vm-dev mailing list