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

commits at source.squeak.org commits at source.squeak.org
Wed Dec 7 04:53:00 UTC 2022


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

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

Name: VMMaker.oscog-eem.3280
Author: eem
Time: 6 December 2022, 8:52:36.917493 pm
UUID: d6a800e7-dd9a-44d1-8421-b9a7e664d3bc
Ancestors: VMMaker.oscog-eem.3279

Add a primitive that computes the transitive closure of objects accessible from an array of roots.  This is the collection half of the storeImageSegment primtiive.  This can be used either to debug failures in the storeImageSegment primitive, and may eventually be used to implement it in a more general way.

Thanks to Igor Stasenko for suggesting this decomposition a few years ago.

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

Item was added:
+ ----- Method: InterpreterPrimitives>>primitiveObjectsAccessibleFromRoots (in category 'image segment in/out') -----
+ primitiveObjectsAccessibleFromRoots
+ 	"This primitive is called from Squeak as...
+ 		arrayOfRoots uniquelyAccessibleObjects"
+ 
+ 	"This primitive answers an array of the receiver and every object in its proper tree of subParts (ie, that is not refered to from anywhere else outside the tree)."
+ 	"This primitive could be used to implement the primitiveStoreImageSegment segment, thanks to a suggestion from Igor Stassenko. Currently it is
+ 	 used only to debug that primitive."
+ 
+ 	| arrayOfRoots result |
+ 	arrayOfRoots := self stackTop.
+ 
+ 	"Essential type checks"
+ 	(objectMemory isArray: arrayOfRoots)				"Must be indexable pointers"
+ 		ifFalse: [^self primitiveFail].
+ 
+ 	result := objectMemory objectsAccessibleFromRoots: arrayOfRoots.
+ 	(objectMemory hasSpurMemoryManagerAPI
+ 	 and: [(objectMemory isIntegerObject: result)
+ 	 and: [(objectMemory integerValueOf: result) = PrimErrNoMemory]]) ifTrue:
+ 		[objectMemory fullGC.
+ 		 arrayOfRoots := self stackTop.
+ 		 result := objectMemory objectsAccessibleFromRoots: arrayOfRoots].
+ 	(objectMemory isIntegerObject: result)
+ 		ifTrue: [self primitiveFailFor: (objectMemory integerValueOf: result)]
+ 		ifFalse: [self methodReturnValue: result]!

Item was added:
+ ----- Method: ObjectMemory>>objectsAccessibleFromRoots: (in category 'image segment in/out') -----
+ objectsAccessibleFromRoots: arrayOfRoots
+ 	^self integerObjectOf: PrimErrUnsupported!

Item was added:
+ ----- Method: SpurMemoryManager>>objectsAccessibleFromRoots: (in category 'image segment in/out') -----
+ objectsAccessibleFromRoots: arrayOfRootsArg
+ 	"This primitive is called from Squeak as...
+ 		arrayOfRoots uniquelyAccessibleObjects
+ 
+ 	This primitive answers an array of the receiver and every object in its proper tree of subParts (ie, that is not refered to from anywhere else outside the tree).
+ 
+ 	 The primitive can fail for the following reasons with the specified failure codes:
+ 		PrimErrNoMemory:			additional allocations failed"
+ 
+ 	<inline: false>
+ 	| arrayOfRoots arrayOfObjects |
+ 	<var: 'segAddr' type: #usqInt>
+ 
+ 	self runLeakCheckerFor: GCCheckImageSegment.
+ 
+ 	"First scavenge to collect any new space garbage that refers to the graph."
+ 	self scavengingGC.
+ 	arrayOfRoots := self updatePostScavenge: arrayOfRootsArg.
+ 	
+ 	"Now compute the transitive closure, collecting the sequence of objects to be stored in the arrayOfObjects array.
+ 	 Included in arrayOfObjects are the arrayOfRoots and all its contents.  All objects have been unmarked."
+ 	arrayOfObjects := self objectsReachableFromRoots: arrayOfRoots.
+ 	arrayOfObjects ifNil:
+ 		[^self integerObjectOf: PrimErrNoMemory].
+ 	"If objectsReachableFromRoots: answers an integer there is not enough continuous free space in which to allocate the
+ 	 reachable objects.  If there is sufficient free space then answer an error code to prompt a compacting GC and a retry."
+ 	(self isIntegerObject: arrayOfObjects) ifTrue:
+ 		[totalFreeOldSpace - self allocationUnit >= (self integerValueOf: arrayOfObjects) ifTrue:
+ 			[^self integerObjectOf: PrimErrNeedCompaction].
+ 		 ^self integerObjectOf: PrimErrNoMemory].
+ 
+ 	self assert: self allObjectsUnmarked. "work to be done when the incremental GC is written"
+ 	self deny: (self forwardersIn: arrayOfObjects).
+ 
+ 	^arrayOfObjects!

Item was changed:
  ----- Method: StackInterpreter class>>initializePrimitiveTable (in category 'initialization') -----
(excessive size, no diff calculated)



More information about the Vm-dev mailing list