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

commits at source.squeak.org commits at source.squeak.org
Thu Dec 11 22:59:55 UTC 2014


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

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

Name: VMMaker.oscog-eem.978
Author: eem
Time: 11 December 2014, 2:56:59.634 pm
UUID: 1af5bc4f-0f74-4dcb-bebb-24e2d2265a05
Ancestors: VMMaker.oscog-eem.977

Generate the right casts for left shift beyond the int
range.
Generate the right error code for negative arguments
to primitiveSizeInBytesOfInstance

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

Item was changed:
  ----- Method: CCodeGenerator>>generateShiftLeft:on:indent: (in category 'C translation') -----
  generateShiftLeft: msgNode on: aStream indent: level
  	"Generate a C bitShift.  If we can determine the result
  	 would overflow the word size, cast to a long integer."
+ 	| rcvr arg valueBeyondInt castToLong |
- 	| rcvr arg bitSizeOfInt |
- 	bitSizeOfInt := 1 bitShift: BytesPerWord * 4. "The default type of const << N is int."
  	rcvr := msgNode receiver.
  	arg := msgNode args first.
+ 	valueBeyondInt := 1 bitShift: BytesPerWord * 4. "The default type of const << N is int."
+ 	castToLong := false.
+ 	rcvr constantNumbericValueOrNil ifNotNil:
+ 		[:rcvrVal|
+ 		arg constantNumbericValueOrNil ifNotNil:
+ 			[:argVal|
+ 			 castToLong := rcvrVal < valueBeyondInt
+ 							  and: [(rcvrVal bitShift: argVal) >= valueBeyondInt]]].
+ 	castToLong
+ 		ifTrue:
+ 			[rcvr isConstant
+ 				ifTrue:
+ 					[self emitCExpression: rcvr on: aStream.
+ 					 aStream nextPutAll: 'LL']
+ 				ifFalse:
+ 					[aStream nextPutAll: '((unsigned long)'.
+ 					 self emitCExpression: rcvr on: aStream.
+ 					 aStream nextPut: $)]]
+ 		ifFalse:
+ 			[self emitCExpression: rcvr on: aStream].
- 	self emitCExpression: rcvr on: aStream.
- 	(rcvr isConstant and: [arg isConstant
- 	 and: [rcvr value isInteger and: [arg value isInteger
- 	 and: [rcvr value < (1 bitShift: BytesPerWord * 8)
- 	 and: [(rcvr value bitShift: arg value) >= bitSizeOfInt]]]]]) ifTrue:
- 		[aStream nextPutAll: 'LL'].
  	aStream nextPutAll: ' << '.
  	self emitCExpression: arg on: aStream!

Item was changed:
  ----- Method: SpurMemoryManager>>byteSizeOfInstanceOf:withIndexableSlots:errInto: (in category 'indexing primitive support') -----
  byteSizeOfInstanceOf: classObj withIndexableSlots: nElements errInto: errorBlock
  	| instSpec classFormat numSlots |
  	<var: 'numSlots' type: #usqInt>
  	classFormat := self formatOfClass: classObj.
  	instSpec := self instSpecOfClassFormat: classFormat.
  	instSpec caseOf: {
  		[self arrayFormat]	->
  			[numSlots := nElements].
  		[self indexablePointersFormat]	->
  			[numSlots := (self fixedFieldsOfClassFormat: classFormat) + nElements].
  		[self weakArrayFormat]	->
  			[numSlots := (self fixedFieldsOfClassFormat: classFormat) + nElements].
  		[self sixtyFourBitIndexableFormat]	->
  			[numSlots := self bytesPerOop = 4 ifTrue: [nElements * 2] ifFalse: [nElements]].
  		[self firstLongFormat]	->
  			[numSlots := self bytesPerOop = 4 ifTrue: [nElements] ifFalse: [nElements + 1 // 2]].
  		[self firstShortFormat]	->
  			[numSlots := self bytesPerOop = 4 ifTrue: [nElements + 1 // 2] ifFalse: [nElements + 3 // 4]].
  		[self firstByteFormat]	->
  			[numSlots := nElements + (self bytesPerOop - 1) // self bytesPerOop].
  		[self firstCompiledMethodFormat]	-> "Assume nElements is derived from CompiledMethod>>basicSize."
  			[numSlots := nElements + (self bytesPerOop - 1) // self bytesPerOop] }
  		otherwise: [^errorBlock value: PrimErrBadReceiver negated]. "non-indexable"
+ 	numSlots >= (1 asLong << (self bytesPerOop * 8 - self logBytesPerOop)) ifTrue:
+ 		[^errorBlock value: (nElements < 0 ifTrue: [PrimErrBadArgument] ifFalse: [PrimErrLimitExceeded])].
- 	numSlots >= (1 << (self bytesPerOop * 8 - self logBytesPerOop)) ifTrue:
- 		[^errorBlock value: PrimErrLimitExceeded].
  	^self objectBytesForSlots: numSlots!



More information about the Vm-dev mailing list