VM Maker: VMMaker.oscog-ul.2756.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-ul.2756.mcz

commits-2
 
Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2756.mcz

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

Name: VMMaker.oscog-ul.2756
Author: ul
Time: 25 May 2020, 9:54:24.664084 pm
UUID: b5df77c0-0837-4f41-89e0-d9c656e94d50
Ancestors: VMMaker.oscog-eem.2755

- don't let primitive 145 (#primitiveConstantFillSpur) modify immutable obejcts
- provide custom error codes from the same primitive

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

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveConstantFillSpur (in category 'sound primitives') -----
  primitiveConstantFillSpur
  "Fill the receiver, which must be an indexable non-pointer object, with the given integer value."
  <inline: true>
  | fillValue rcvr format end i oddBytes |
  <var: #fillValue type: #usqLong>
  <var: #end type: #usqInt>
  <var: #i type: #usqInt>
+ argumentCount ~= 1 ifTrue:
+ [^self primitiveFailFor: PrimErrBadNumArgs].
- fillValue := self positive64BitValueOf: self stackTop.
  rcvr := self stackValue: 1.
+ ((objectMemory isNonImmediate: rcvr)
+ and: [(format := objectMemory formatOf: rcvr) >= objectMemory sixtyFourBitIndexableFormat]) ifFalse:
+ [^self primitiveFailFor: PrimErrBadReceiver].
+ (objectMemory isObjImmutable: rcvr) ifTrue:
+ [^self primitiveFailFor: PrimErrNoModification].
+ fillValue := self positive64BitValueOf: self stackTop.
+ self successful ifFalse:
+ [^self primitiveFailFor: PrimErrBadArgument].
- (self successful
- and: [(objectMemory isNonImmediate: rcvr)
- and: [(format := objectMemory formatOf: rcvr) >= objectMemory sixtyFourBitIndexableFormat]]) ifFalse:
- [^self primitiveFail].
  format >= objectMemory firstShortFormat
  ifTrue:
  [format >= objectMemory firstByteFormat
  ifTrue:
  [(fillValue > 16rFF or: [format >= objectMemory firstCompiledMethodFormat]) ifTrue:
  [^self primitiveFail].
  fillValue := fillValue + (fillValue << 8) + (fillValue << 16) + (fillValue << 24).
  oddBytes := format bitAnd: 7]
  ifFalse:
  [fillValue > 16rFFFF ifTrue:
  [^self primitiveFail].
  fillValue := fillValue + (fillValue << 16).
  oddBytes := (format bitAnd: 3) << 1].
  fillValue := fillValue + (fillValue << 32)]
  ifFalse:
  [format = objectMemory sixtyFourBitIndexableFormat
  ifTrue:
  [oddBytes := 0]
  ifFalse:
  [fillValue > 16rFFFFFFFF ifTrue:
  [^self primitiveFail].
  fillValue := fillValue + (fillValue << 32).
  oddBytes := (format bitAnd: 1) << 2]].
  end := objectMemory addressAfter: rcvr.
  i := rcvr + objectMemory baseHeaderSize.
  [i < end] whileTrue:
  [objectMemory long64At: i put: fillValue.
  i := i + 8].
  "now ensure trailing bytes are zero"
  oddBytes > 0 ifTrue:
  [self flag: #endianness.
  fillValue := fillValue >> (8 * oddBytes).
  objectMemory long64At: i - 8 put: fillValue].
  self pop: 1!