[Vm-dev] VM Maker: Fix VMMaker.oscog-eem.787.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Jun 29 02:22:33 UTC 2014


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/Fix VMMaker.oscog-eem.787.mcz

==================== Summary ====================

Name: Fix VMMaker.oscog-eem.787
Author: eem
Time: 28 June 2014, 7:19:54.984 pm
UUID: a9fe951c-7914-49b0-a008-20c39417cae0
Ancestors: VMMaker.oscog-eem.786

Fix return types for positive[64/32]BitValueOf: in InterpreterProxy
(& hence in sqVirtualMachine.[ch] soon).

Use positiveMachineIntegerValueOf: to decode arg in
primitiveNewWithArg and ensure positiveMachineIntegerValueOf:
is inlined there-in.

=============== Diff against VMMaker.oscog-eem.786 ===============

Item was changed:
  ----- Method: InterpreterPrimitives>>positiveMachineIntegerValueOf: (in category 'primitive support') -----
  positiveMachineIntegerValueOf: oop
  	"Answer a value of an integer in address range, i.e up to the size of a machine word.
  	The object may be either a positive SmallInteger or a LargePositiveInteger of size <= word size."
  	<returnTypeC: #'unsigned long'>
+ 	<inline: true> "only two callers & one is primitiveNewWithArg"
  	| value bs ok |
  	(objectMemory isIntegerObject: oop) ifTrue:
  		[value := objectMemory integerValueOf: oop.
  		 value < 0 ifTrue: [^self primitiveFail].
  		^value].
  
  	ok := objectMemory
  			isClassOfNonImm: oop
  			equalTo: (objectMemory splObj: ClassLargePositiveInteger)
  			compactClassIndex: ClassLargePositiveIntegerCompactIndex.
  	(ok and: [(bs := objectMemory lengthOf: oop) <= (self sizeof: #'unsigned long')]) ifFalse:
  		[^self primitiveFail].
  
  	((self sizeof: #'unsigned long') = 8
  	and: [bs > 4]) ifTrue:
  		[^  (objectMemory fetchByte: 0 ofObject: oop)
  		 + ((objectMemory fetchByte: 1 ofObject: oop) <<  8)
  		 + ((objectMemory fetchByte: 2 ofObject: oop) << 16)
  		 + ((objectMemory fetchByte: 3 ofObject: oop) << 24)
  		 + ((objectMemory fetchByte: 4 ofObject: oop) << 32)
  		 + ((objectMemory fetchByte: 5 ofObject: oop) << 40)
  		 + ((objectMemory fetchByte: 6 ofObject: oop) << 48)
  		 + ((objectMemory fetchByte: 7 ofObject: oop) << 56)].
  
  	^  (objectMemory fetchByte: 0 ofObject: oop)
  	+ ((objectMemory fetchByte: 1 ofObject: oop) <<  8)
  	+ ((objectMemory fetchByte: 2 ofObject: oop) << 16)
  	+ ((objectMemory fetchByte: 3 ofObject: oop) << 24)!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveNewWithArg (in category 'object access primitives') -----
  primitiveNewWithArg
  	"Allocate a new indexable instance. Fail if the allocation would leave less than lowSpaceThreshold bytes free. May cause a GC."
  	| size spaceOkay |
+ 	size := self positiveMachineIntegerValueOf: self stackTop.
- 	size := self positive32BitValueOf: self stackTop.
  	self cppIf: NewspeakVM
  		ifTrue: "For the mirror prims check that the class obj is actually a valid class."
  			[(argumentCount < 2
  			  or: [self addressCouldBeClassObj: (self stackValue: 1)]) ifFalse:
  				[self primitiveFailFor: PrimErrBadArgument]].
+ 	self successful "positiveMachineIntegerValueOf: succeeds only for non-negative integers."
- 	self successful "positive32BitValueOf: succeds only for non-negative integers < 2^32"
  		ifTrue:
  			[objectMemory hasSpurMemoryManagerAPI
  				ifTrue:
  					[(objectMemory instantiateClass: (self stackValue: 1) indexableSize: size)
  						ifNotNil: [:obj| self pop: argumentCount + 1 thenPush: obj]
  						ifNil: [self primitiveFailFor: PrimErrNoMemory]]
  				ifFalse:
  					[spaceOkay := objectMemory sufficientSpaceToInstantiate: (self stackValue: 1) indexableSize: size.
  					 spaceOkay
  						ifTrue:
  							[self
  								pop: argumentCount + 1
  								thenPush: (objectMemory instantiateClass: (self stackValue: 1) indexableSize: size)]
  						ifFalse:
  							[self primitiveFailFor: PrimErrNoMemory]]]
  		ifFalse:
  			[self primitiveFailFor: PrimErrBadArgument]!

Item was changed:
  ----- Method: InterpreterProxy>>positive32BitValueOf: (in category 'converting') -----
  positive32BitValueOf: oop
+ 	<returnTypeC: #usqInt>
  	oop isInteger ifFalse:[self error:'Not an integer object'].
  	oop < 0 
  		ifTrue:[self primitiveFail. ^0]
  		ifFalse:[^oop]!

Item was changed:
  ----- Method: InterpreterProxy>>positive64BitValueOf: (in category 'converting') -----
  positive64BitValueOf: oop
+ 	<returnTypeC: #usqLong>
- 	<returnTypeC: #sqLong>
  	oop isInteger ifFalse:[self error:'Not an integer object'].
  	oop < 0 
  		ifTrue:[self primitiveFail. ^0]
  		ifFalse:[^oop]!



More information about the Vm-dev mailing list