VM Maker: VMMaker.oscog-eem.2086.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.2086.mcz

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

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

Name: VMMaker.oscog-eem.2086
Author: eem
Time: 12 January 2017, 1:27:56.475431 pm
UUID: 23d04ad6-1b6f-4806-94ea-bfc77c5f9637
Ancestors: VMMaker.oscog-eem.2085

SpurPlanningCompactor:
Add a test for 10 repetitions of a repeatably random assortment of 1000 pinned, unpinned x live, dead or free objects.  This has found a bug :-(

Include rawNumSlotsand eliminate the hex prefix in printEntity:'s size info.

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

Item was changed:
  ----- Method: SpurMemoryManager>>printEntity: (in category 'debug printing') -----
  printEntity: oop
  <api>
  | isObj |
  isObj := false.
  coInterpreter printHex: oop; space.
  (self addressCouldBeObj: oop) ifFalse:
  [^coInterpreter print: ((self isImmediate: oop) ifTrue: ['immediate'] ifFalse: ['unknown'])].
  coInterpreter
  print: ((self isFreeObject: oop) ifTrue: ['free'] ifFalse:
  [(self isSegmentBridge: oop) ifTrue: ['bridge'] ifFalse:
  [(self isForwarded: oop) ifTrue: ['forwarder'] ifFalse:
  [(self classIndexOf: oop) <= self lastClassIndexPun ifTrue: ['pun/obj stack'] ifFalse:
  [isObj := true. 'object']]]]);
+ space; printHexnpnp: (self rawNumSlotsOf: oop); print: '/'; printHexnpnp: (self bytesInObject: oop); print: '/'; printNum: (self bytesInObject: oop).
- space; printHex: (self bytesInObject: oop); print: '/'; printNum: (self bytesInObject: oop).
  isObj ifTrue:
  [coInterpreter
  space;
  print: ((self formatOf: oop) <= 16rF ifTrue: ['f:0'] ifFalse: ['f:']);
  printHexnpnp: (self formatOf: oop);
  print: ((self isGrey: oop) ifTrue: [' g'] ifFalse: [' .']);
  print: ((self isImmutable: oop) ifTrue: ['i'] ifFalse: ['.']);
  print: ((self isMarked: oop) ifTrue: ['m'] ifFalse: ['.']);
  print: ((self isPinned: oop) ifTrue: ['p'] ifFalse: ['.']);
  print: ((self isRemembered: oop) ifTrue: ['r'] ifFalse: ['.'])].
  coInterpreter cr!

Item was added:
+ ----- Method: SpurPlanningCompactorTests>>testRandomAssortment: (in category 'private') -----
+ testRandomAssortment: random
+ "Test that the compactor can handle a random assortment of live, pinned, dead, and free chunks."
+ | om lastObj obj expectedFreeSpace liveFill pinFill liveCounter pinCounter totalLive totalPinned |
+ random reset. "random is a read stream on 3000 random numbers; for repeatability"
+ om := self initializedVM objectMemory.
+ om allOldSpaceObjectsDo: [:o| om setIsMarkedOf: o to: true. lastObj := o].
+ pinFill := 16r99999900.
+ liveFill := 16r55AA0000.
+ liveCounter := pinCounter := expectedFreeSpace := 0.
+ 1000 timesRepeat:
+ [| nSlots next newObj |
+ nSlots := (random next * 300) rounded. "Make sure we stray into overflow size field territory."
+ newObj := om allocateSlotsInOldSpace: nSlots format: om firstLongFormat classIndex: ClassBitmapCompactIndex.
+ (next := random next) > 0.95
+ ifTrue: "pinned"
+ [om
+ fillObj: newObj numSlots: nSlots with: pinFill + (pinCounter := pinCounter + 1);
+ setIsPinnedOf: newObj to: true]
+ ifFalse: "mobile"
+ [om
+ fillObj: newObj numSlots: nSlots with: liveFill + (liveCounter := liveCounter + 1)].
+ (next := random next) >= 0.333
+ ifTrue:
+ [om setIsMarkedOf: newObj to: true]
+ ifFalse: "dead or free"
+ [expectedFreeSpace := expectedFreeSpace + (om bytesInObject: newObj).
+ (om isPinned: newObj) "Must check /before/ setObjectFree: which clears all bits"
+ ifTrue: [pinCounter := pinCounter - 1]
+ ifFalse: [liveCounter := liveCounter - 1].
+ next >= 0.2
+ ifTrue: [om setIsMarkedOf: newObj to: false]
+ ifFalse: [om setObjectFree: newObj]]].
+ totalPinned := pinCounter.
+ totalLive := liveCounter.
+ self assert: totalPinned < (totalPinned + totalLive / 10). "should be about 5%"
+
+ "Check our checking code before the compaction, just in case..."
+ liveCounter := pinCounter := 0.
+ obj := lastObj.
+ 1 to: totalLive + totalPinned do:
+ [:n| | expectedFill actualFill |
+ [obj := om objectAfter: obj. (om isEnumerableObject: obj) and: [om isMarked: obj]] whileFalse.
+ expectedFill := (om isPinned: obj)
+ ifTrue: [pinFill + (pinCounter := pinCounter + 1)]
+ ifFalse: [liveFill + (liveCounter := liveCounter + 1)].
+ 1 to: (om numSlotsOf: obj) do:
+ [:i| self assert: expectedFill equals: (actualFill := om fetchPointer: i - 1 ofObject: obj)]].
+
+ "useful debugging:""om printOopsFrom: (om objectAfter: lastObj) to: om endOfMemory"
+ expectedFreeSpace := expectedFreeSpace + om bytesLeftInOldSpace.
+ om compactor compact.
+ self assert: expectedFreeSpace equals: om bytesLeftInOldSpace.
+ self assert: om allObjectsUnmarked.
+
+ liveCounter := pinCounter := 0.
+ obj := lastObj.
+ 1 to: totalLive + totalPinned do:
+ [:n| | expectedFill actualFill |
+ [obj := om objectAfter: obj. (om isEnumerableObject: obj) or: [obj >= om endOfMemory]] whileFalse.
+ expectedFill := (om isPinned: obj)
+ ifTrue: [pinFill + (pinCounter := pinCounter + 1)]
+ ifFalse: [liveFill + (liveCounter := liveCounter + 1)].
+ 1 to: (om numSlotsOf: obj) do:
+ [:i| self assert: expectedFill equals: (actualFill := om fetchPointer: i - 1 ofObject: obj)]].
+ "They should be the last objects..."
+ self assert: (om isFreeObject: (om objectAfter: obj)).
+ self assert: om endOfMemory equals: (om addressAfter: (om objectAfter: obj))!

Item was added:
+ ----- Method: SpurPlanningCompactorTests>>testRandomAssortments (in category 'tests') -----
+ testRandomAssortments
+ "Test that the compactor can handle some number of random assortments of live, pinned, dead, and free chunks."
+ | random |
+ random := Random new.
+ 10 timesRepeat: [self testRandomAssortment: (random next: 3000) readStream]!