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

commits at source.squeak.org commits at source.squeak.org
Thu Apr 7 01:33:14 UTC 2016


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

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

Name: VMMaker.oscog-eem.1777
Author: eem
Time: 6 April 2016, 6:31:28.51167 pm
UUID: a1efdb25-0231-43f2-bf60-5e6eb78dbf3a
Ancestors: VMMaker.oscog-eem.1776

Simulator:
Rationalize cCoerce:to:.  Put one implementation in VMClass and override only in the Cogit (which defers to objectMemory) and InterpreterPlugin which simply answers the value.

N.B.  This means that in the InterpreterPlugin hierarchy if you want null coercion (as for example in BalloonEngineBase>>initColorTransform) you sent cCoerce:to: to self, but if you want the proper coercion of oops you /must/ send cCoerce:to: to interpreterProxy.

Fix just such a coercion slip in LargeIntegersPlugin>>digitAddLarge:with:

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

Item was removed:
- ----- Method: CogVMSimulator>>cCoerce:to: (in category 'memory access') -----
- cCoerce: value to: cTypeString
- 	"Type coercion for translation only; just return the value when running in Smalltalk."
- 
- 	^value == nil
- 		ifTrue: [value]
- 		ifFalse: [value coerceTo: cTypeString sim: self]!

Item was added:
+ ----- Method: InterpreterPlugin>>cCoerce:to: (in category 'simulation') -----
+ cCoerce: value to: cType
+ 	"Type coercion for translation only; just return the value when running in Smalltalk.
+ 	 This overrides the generic coercion method in VMClass.  For some reason we are the exception.
+ 	 If we want that style of coercion we can send cCoerce:to: to interpreterProxy, not self."
+ 
+ 	^value!

Item was removed:
- ----- Method: InterpreterSimulator>>cCoerce:to: (in category 'memory access') -----
- cCoerce: value to: cTypeString
- 	"Type coercion for translation only; just return the value when running in Smalltalk."
- 
- 	^value == nil
- 		ifTrue: [value]
- 		ifFalse: [value coerceTo: cTypeString sim: self]!

Item was changed:
  ----- Method: LargeIntegersPlugin>>digitAddLarge:with: (in category 'oop functions') -----
  digitAddLarge: firstInteger with: secondInteger 
  	"Does not need to normalize!!"
  	| over firstDigitLen secondDigitLen shortInt shortDigitLen longInt longDigitLen sum newSum neg |
  	<var: #over type: #'unsigned int'>
  	firstDigitLen := self digitSizeOfLargeInt: firstInteger.
  	secondDigitLen := self digitSizeOfLargeInt: secondInteger.
  	neg := (interpreterProxy fetchClassOf: firstInteger)
  		= interpreterProxy classLargeNegativeInteger.
  	firstDigitLen <= secondDigitLen
  		ifTrue: 
  			[shortInt := firstInteger.
  			shortDigitLen := firstDigitLen.
  			longInt := secondInteger.
  			longDigitLen := secondDigitLen]
  		ifFalse: 
  			[shortInt := secondInteger.
  			shortDigitLen := secondDigitLen.
  			longInt := firstInteger.
  			longDigitLen := firstDigitLen].
  	"	sum := Integer new: len neg: firstInteger negative."
  	self remapOop: #(shortInt longInt ) in: [sum := self createLargeIntegerNeg: neg digitLength: longDigitLen].
  	over := self
  				cDigitAdd: (interpreterProxy firstIndexableField: shortInt)
  				len: shortDigitLen
  				with: (interpreterProxy firstIndexableField: longInt)
  				len: longDigitLen
  				into: (interpreterProxy firstIndexableField: sum).
  	over > 0
  		ifTrue: 
  			["sum := sum growby: 1."
  			self remapOop: sum in: [newSum := self createLargeIntegerNeg: neg byteLength: longDigitLen * 4 + 1].
  			self
  				cDigitCopyFrom: (interpreterProxy firstIndexableField: sum)
  				to: (interpreterProxy firstIndexableField: newSum)
  				len: longDigitLen.
  			sum := newSum.
  			"C index!!"
+ 			self cDigitOf: (interpreterProxy cCoerce: (interpreterProxy firstIndexableField: sum) to: 'unsigned int *')
- 			self cDigitOf: (self cCoerce: (interpreterProxy firstIndexableField: sum) to: 'unsigned int *')
  				at: longDigitLen put: over]
  		ifFalse:
  			[sum := neg 
  				ifTrue: [self normalizeNegative: sum]
  				ifFalse: [self normalizePositive: sum]].
  	^ sum!

Item was removed:
- ----- Method: NewCoObjectMemorySimulator>>cCoerce:to: (in category 'memory access') -----
- cCoerce: value to: cTypeString
- 	"Type coercion for translation only; just return the value when running in Smalltalk."
- 
- 	^value == nil
- 		ifTrue: [value]
- 		ifFalse: [value coerceTo: cTypeString sim: self]!

Item was removed:
- ----- Method: NewObjectMemorySimulator>>cCoerce:to: (in category 'memory access') -----
- cCoerce: value to: cTypeString
- 	"Type coercion for translation only; just return the value when running in Smalltalk."
- 
- 	^value == nil
- 		ifTrue: [value]
- 		ifFalse: [value coerceTo: cTypeString sim: self]!

Item was removed:
- ----- Method: SpurMemoryManager>>cCoerce:to: (in category 'memory access') -----
- cCoerce: value to: cTypeString
- 	"Type coercion. For translation a cast will be emmitted. When running in Smalltalk
- 	  answer a suitable wrapper for correct indexing."
- 	<doNotGenerate>
- 	^value
- 		ifNil: [value]
- 		ifNotNil: [value coerceTo: cTypeString sim: self]!

Item was removed:
- ----- Method: StackInterpreterSimulator>>cCoerce:to: (in category 'memory access') -----
- cCoerce: value to: cTypeString
- 	"Type coercion for translation only; just return the value when running in Smalltalk."
- 
- 	^value == nil
- 		ifTrue: [value]
- 		ifFalse: [value coerceTo: cTypeString sim: self]!

Item was added:
+ ----- Method: VMClass>>cCoerce:to: (in category 'memory access') -----
+ cCoerce: value to: cTypeString
+ 	"Type coercion. For translation a cast will be emmitted. When running in Smalltalk
+ 	  answer a suitable wrapper for correct indexing."
+ 	<doNotGenerate>
+ 	^value
+ 		ifNil: [value]
+ 		ifNotNil: [value coerceTo: cTypeString sim: self]!



More information about the Vm-dev mailing list