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

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

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

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

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

Name: VMMaker.oscog-eem.2254
Author: eem
Time: 18 July 2017, 3:02:56.421478 pm
UUID: 4f2c2cce-f4a2-469a-93f1-97ed941df0ad
Ancestors: VMMaker.oscog-eem.2253

Spur: Fail become if copyHash is true and target is immutable.

FloatArrayPlugin: Fix length & normalize to return at failure points instead of continuing.

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

Item was changed:
  ----- Method: FloatArrayPlugin>>primitiveLength (in category 'arithmetic primitives') -----
  primitiveLength
  "Primitive. Compute the length of the argument (sqrt of sum of component squares)."
  <export: true>
  | rcvr rcvrPtr length len |
  <var: #rcvrPtr type: #'float *'>
  <var: #len type: #double>
  rcvr := interpreterProxy stackValue: 0.
  (interpreterProxy isWords: rcvr) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadReceiver].
- [interpreterProxy primitiveFailFor: PrimErrBadReceiver].
  length := interpreterProxy stSizeOf: rcvr.
  rcvrPtr := self cCoerce: (interpreterProxy firstIndexableField: rcvr) to: #'float *'.
  len := 0.0.
+ 0 to: length-1 do:
+ [:i| len := len + ((self cCoerce: (rcvrPtr at: i) to: #double) * (self cCoerce: (rcvrPtr at: i) to: #double)) ].
- 0 to: length-1 do:[:i|
- len := len + ((self cCoerce: (rcvrPtr at: i) to: #double) * (self cCoerce: (rcvrPtr at: i) to: #double)).
- ].
  len > 0.0 ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadReceiver].
- [interpreterProxy primitiveFailFor: PrimErrBadReceiver].
  interpreterProxy pop: 1 thenPush: (interpreterProxy floatObjectOf: (self sqrt: len))!

Item was changed:
  ----- Method: FloatArrayPlugin>>primitiveNormalize (in category 'arithmetic primitives') -----
  primitiveNormalize
  "Primitive. Normalize the argument (A FloatArray) in place."
  <export: true>
  | rcvr rcvrPtr length len |
  <var: #rcvrPtr type: #'float *'>
  <var: #len type: #double>
  rcvr := interpreterProxy stackValue: 0.
  (interpreterProxy isWords: rcvr) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadReceiver].
- [interpreterProxy primitiveFailFor: PrimErrBadReceiver].
  length := interpreterProxy stSizeOf: rcvr.
  rcvrPtr := self cCoerce: (interpreterProxy firstIndexableField: rcvr) to: #'float *'.
  len := 0.0.
+ 0 to: length - 1 do:
+ [:i| len := len + ((self cCoerce: (rcvrPtr at: i) to: #double) * (self cCoerce: (rcvrPtr at: i) to: #double)) ].
- 0 to: length-1 do:[:i|
- len := len + ((self cCoerce: (rcvrPtr at: i) to: #double) * (self cCoerce: (rcvrPtr at: i) to: #double)).
- ].
  len > 0.0 ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadReceiver].
- [interpreterProxy primitiveFailFor: PrimErrBadReceiver].
 
  len := self sqrt: len.
+ 0 to: length - 1 do:
+ [:i| rcvrPtr at: i put: ((self cCoerce: (rcvrPtr at: i) to: #double) / len) ].
- 0 to: length-1 do:[:i|
- rcvrPtr at: i put: ((self cCoerce: (rcvrPtr at: i) to: #double) / len).
- ].
 
  "Leave receiver on the stack."!

Item was changed:
  ----- Method: SpurMemoryManager>>containsOnlyValidBecomeObjects:and:twoWay:copyHash: (in category 'become implementation') -----
  containsOnlyValidBecomeObjects: array1 and: array2 twoWay: isTwoWay copyHash: copyHash
  "Answer 0 if neither array contains an object inappropriate for the become operation.
  Otherwise answer an informative error code for the first offending object found:
  Can't become: immediates => PrimErrInappropriate
  Shouldn't become pinned objects => PrimErrObjectIsPinned.
  Shouldn't become immutable objects => PrimErrNoModification.
  Can't copy hash into immediates => PrimErrInappropriate.
  Two-way become may require memory to create copies => PrimErrNoMemory.
  As a side-effect unforward any forwarders in the two arrays if answering 0."
  <inline: true>
  | fieldOffset effectsFlags oop1 oop2 size |
  fieldOffset := self lastPointerOf: array1.
  effectsFlags := size := 0.
  "array1 is known to be the same size as array2"
  [fieldOffset >= self baseHeaderSize] whileTrue:
  [oop1 := self longAt: array1 + fieldOffset.
  (self isOopForwarded: oop1) ifTrue:
  [oop1 := self followForwarded: oop1.
  self longAt: array1 + fieldOffset put: oop1].
  self ifOopInvalidForBecome: oop1 errorCodeInto: [:errCode| ^errCode].
  effectsFlags := effectsFlags bitOr: (self becomeEffectFlagsFor: oop1).
  oop2 := self longAt: array2 + fieldOffset.
  (self isOopForwarded: oop2) ifTrue:
  [oop2 := self followForwarded: oop2.
  self longAt: array2 + fieldOffset put: oop2].
  isTwoWay
  ifTrue:
  [self ifOopInvalidForBecome: oop2 errorCodeInto: [:errCode| ^errCode].
  size := size + (self bytesInObject: oop1) + (self bytesInObject: oop2).
  effectsFlags := effectsFlags bitOr: (self becomeEffectFlagsFor: oop2)]
  ifFalse:
+ [(copyHash and: [(self isImmediate: oop2) or: [self isImmutable: oop2]]) ifTrue:
- [(copyHash and: [self isImmediate: oop2]) ifTrue:
  [^PrimErrInappropriate]].
  fieldOffset := fieldOffset - self bytesPerOop].
  size >= (totalFreeOldSpace + (scavengeThreshold - freeStart)) ifTrue:
  [^PrimErrNoMemory].
  "only set flags after checking all args."
  becomeEffectsFlags := effectsFlags.
  ^0!

Loading...