VM Maker: VMMaker.oscog-eem.2663.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: VMMaker.oscog-eem.2663.mcz

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

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

Name: VMMaker.oscog-eem.2663
Author: eem
Time: 18 January 2020, 2:32:34.562874 pm
UUID: 0dd0f212-66eb-4a18-8da6-5e84a5cbc1ed
Ancestors: VMMaker.oscog-eem.2662

Implement 238 primitiveFloatArrayAt & 239 primitiveFloatArrayAtPut for Spur WordArray and DoubleWordArray as higher performance versions of the FloatArrayPlugin.  No JIT implementation yet.

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

Item was added:
+ ----- Method: InterpreterPrimitives>>primitiveFloatArrayAt (in category 'indexing primitives') -----
+ primitiveFloatArrayAt
+ "Index the receiver, which must be an indexable non-pointer
+ object, and yield a float."
+ objectMemory hasSpurMemoryManagerAPI
+ ifTrue: [self primitiveFloatArrayAtSpur]
+ ifFalse: [self primitiveFailFor: PrimErrUnsupported]!

Item was added:
+ ----- Method: InterpreterPrimitives>>primitiveFloatArrayAtPut (in category 'indexing primitives') -----
+ primitiveFloatArrayAtPut
+ "Index the receiver, which must be an indexable non-pointer
+ object, and store a float."
+ objectMemory hasSpurMemoryManagerAPI
+ ifTrue: [self primitiveFloatArrayAtPutSpur]
+ ifFalse: [self primitiveFailFor: PrimErrUnsupported]!

Item was added:
+ ----- Method: InterpreterPrimitives>>primitiveFloatArrayAtPutSpur (in category 'indexing primitives') -----
+ primitiveFloatArrayAtPutSpur
+ "Index the receiver, which must be an indexable non-pointer
+ object, and store a float. In Spur, if the receiver is a WordArray the float is
+ stored in IEEE single precision (if possible), and if a DoubleWordArray in
+ IEEE double precision."
+
+ <inline: true>
+ | index rcvr valueOop fmt numSlots |
+ valueOop := self stackValue: 0.
+ index := self stackValue: 1.
+ rcvr := self stackValue: 2.
+ ((objectMemory isFloatInstance: valueOop)
+ and: [objectMemory isIntegerObject: index]) ifFalse:
+ [^self primitiveFailFor: PrimErrBadArgument].
+ (objectMemory isImmediate: rcvr) ifTrue:
+ [^self primitiveFailFor: PrimErrBadReceiver].
+ (objectMemory isObjImmutable: rcvr) ifTrue:
+ [^self primitiveFailFor: PrimErrNoModification].
+ fmt := objectMemory formatOf: rcvr.
+ index := (objectMemory integerValueOf: index) - 1.
+
+ fmt = objectMemory sixtyFourBitIndexableFormat ifTrue:
+ ["Note that a high-quality implementation would not move bits to/from the double data type,
+  but simply move bits. We leave this sophistication to the JIT implementation."
+ numSlots := objectMemory num64BitUnitsOf: rcvr.
+ (self asUnsigned: index) < numSlots ifTrue:
+ [objectMemory storeFloat64: index ofObject: rcvr withValue: (objectMemory floatValueOf: valueOop).
+ self methodReturnValue: valueOop.
+ ^0].
+ ^self primitiveFailFor: PrimErrBadIndex].
+
+ "N.B. Currently we simply truncate to 32-bits, which matches the behavior of the FloatArrayPlugin.
+ Maybe we should validate and range check."
+ (fmt >= objectMemory firstLongFormat
+ and: [fmt <= (objectMemory firstLongFormat + 1)]) ifTrue:
+ [numSlots := objectMemory num32BitUnitsOf: rcvr.
+ (self asUnsigned: index) < numSlots ifTrue:
+ [objectMemory storeFloat32: index ofObject: rcvr withValue: (objectMemory floatValueOf: valueOop).
+ self methodReturnValue: valueOop.
+ ^0].
+ ^self primitiveFailFor: PrimErrBadIndex].
+
+ ^self primitiveFailFor: PrimErrBadReceiver!

Item was added:
+ ----- Method: InterpreterPrimitives>>primitiveFloatArrayAtSpur (in category 'indexing primitives') -----
+ primitiveFloatArrayAtSpur
+ "Index the receiver, which must be an indexable non-pointer object,
+ and yield a float. In Spur, if the receiver is a WordArray the float is
+ interpreted as IEEE single precision, and if a DoubleWordArray as
+ IEEE double precision."
+
+ <inline: true>
+ | index rcvr fmt numSlots aDouble aFloat |
+ index := self stackTop.
+ rcvr := self stackValue: 1.
+ (objectMemory isIntegerObject: index) ifFalse:
+ [^self primitiveFailFor: PrimErrBadArgument].
+ (objectMemory isImmediate: rcvr) ifTrue:
+ [^self primitiveFailFor: PrimErrBadReceiver].
+ fmt := objectMemory formatOf: rcvr.
+ index := (objectMemory integerValueOf: index) - 1.
+
+ fmt = objectMemory sixtyFourBitIndexableFormat ifTrue:
+ ["Note that a high-quality implementation would not move bits to/from the double data type,
+  but simply move bits. We leave this sophistication to the JIT implementation."
+ numSlots := objectMemory num64BitUnitsOf: rcvr.
+ (self asUnsigned: index) < numSlots ifTrue:
+ [aDouble := objectMemory fetchFloat64: index ofObject: rcvr.
+ self methodReturnValue: (objectMemory floatObjectOf: aDouble).
+ ^0].
+ ^self primitiveFailFor: PrimErrBadIndex].
+
+ (fmt >= objectMemory firstLongFormat
+ and: [fmt <= (objectMemory firstLongFormat + 1)]) ifTrue:
+ [numSlots := objectMemory num32BitUnitsOf: rcvr.
+ (self asUnsigned: index) < numSlots ifTrue:
+ [aFloat := objectMemory fetchFloat32: index ofObject: rcvr.
+ self methodReturnValue: (objectMemory floatObjectOf: aFloat).
+ ^0].
+ ^self primitiveFailFor: PrimErrBadIndex].
+
+ ^self primitiveFailFor: PrimErrBadReceiver!

Item was added:
+ ----- Method: SpurMemoryManager>>fetchFloat32:ofObject: (in category 'object access') -----
+ fetchFloat32: wordIndex ofObject: objOop
+ <returnTypeC: #float>
+ ^self singleFloatAtPointer: objOop + self baseHeaderSize + (wordIndex << 2)!

Item was added:
+ ----- Method: SpurMemoryManager>>fetchFloat64:ofObject: (in category 'object access') -----
+ fetchFloat64: longIndex ofObject: objOop
+ <returnTypeC: #double>
+ ^self floatAtPointer: objOop + self baseHeaderSize + (longIndex << 3)!

Item was added:
+ ----- Method: SpurMemoryManager>>floatAtPointer: (in category 'simulation only') -----
+ floatAtPointer: ptr
+ "See platforms/Cross/vm/sqMemoryAccess.h for the production implementation."
+ <doNotGenerate>
+ ^Float fromIEEE64BitWord: (self long64At: ptr)!

Item was added:
+ ----- Method: SpurMemoryManager>>floatAtPointer:put: (in category 'simulation only') -----
+ floatAtPointer: ptr put: aDouble
+ "See platforms/Cross/vm/sqMemoryAccess.h for the production implementation."
+ <doNotGenerate>
+ self long64At: ptr put: aDouble asIEEE64BitWord.
+ ^aDouble!

Item was added:
+ ----- Method: SpurMemoryManager>>singleFloatAtPointer: (in category 'simulation only') -----
+ singleFloatAtPointer: ptr
+ "See platforms/Cross/vm/sqMemoryAccess.h for the production implementation."
+ <doNotGenerate>
+ ^Float fromIEEE32Bit: (self long32At: ptr)!

Item was added:
+ ----- Method: SpurMemoryManager>>singleFloatAtPointer:put: (in category 'simulation only') -----
+ singleFloatAtPointer: ptr put: aFloat
+ "See platforms/Cross/vm/sqMemoryAccess.h for the production implementation."
+ <doNotGenerate>
+ self long32At: ptr put: aFloat asIEEE32BitWord.
+ ^aFloat!

Item was added:
+ ----- Method: SpurMemoryManager>>storeFloat32:ofObject:withValue: (in category 'object access') -----
+ storeFloat32: wordIndex ofObject: objOop withValue: aFloat
+ <returnTypeC: #float>
+ <var: 'aFloat' type: #float>
+ ^self singleFloatAtPointer: objOop + self baseHeaderSize + (wordIndex << 2) put: aFloat!

Item was added:
+ ----- Method: SpurMemoryManager>>storeFloat64:ofObject:withValue: (in category 'object access') -----
+ storeFloat64: longIndex ofObject: objOop withValue: aDouble
+ <returnTypeC: #double>
+ <var: 'aDouble' type: #double>
+ ^self floatAtPointer: objOop + self baseHeaderSize + (longIndex << 3) put: aDouble!