[Vm-dev] VM Maker: VMMaker.oscog-cb.2270.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Oct 3 09:57:08 UTC 2017


ClementBera uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-cb.2270.mcz

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

Name: VMMaker.oscog-cb.2270
Author: cb
Time: 3 October 2017, 11:56:48.524436 am
UUID: 9894330d-79a5-4d1c-bdcd-f205dfd8bf32
Ancestors: VMMaker.oscog-cb.2269

SpurSweeper is working in the simulator, effectively changing Spur's fullGC to a mark-sweep algorithm when enabled.
Still need to check:
- SpurSweeper for snapshot
- Compilation to C (where I may need help since spurSweeper needs to call another comapctor for snapshots)

=============== Diff against VMMaker.oscog-cb.2269 ===============

Item was changed:
  CogClass subclass: #SpurCompactor
  	instanceVariableNames: 'manager scavenger coInterpreter'
  	classVariableNames: ''
  	poolDictionaries: 'SpurMemoryManagementConstants VMBasicConstants VMSpurObjectRepresentationConstants'
  	category: 'VMMaker-SpurMemoryManager'!
  
+ !SpurCompactor commentStamp: 'cb 10/3/2017 10:49' prior: 0!
+ Common superclass of all compactors to define apis and simulation variables.
- !SpurCompactor commentStamp: 'cb 9/29/2017 16:38' prior: 0!
- Common superclass of all compactors to define apis and common behaviors.
  
+ The full GC in Spur is split in two, the marking phase and the compactor phase. The subclasses of SpurCompactor are implementations of the second phase, so they are called once the marking phase is finished. SpurCompactor is reponsible for:
+ - freeing unmarked objects
+ - compacting the live old space objects (though each subclass define what it does, some spurCompactor may not compact)
+ - unmarking all objects remaining live
+ - updating oops directly referred by the VM when they are moved (remapObj:/shouldRemapObj: thingy)
+ 
+ The main apis are the following:
+ - biasForGC/biasForSnapshot: tells the compactor if the GC is performed for snapshots or not, in general we want to compact more aggressively for snapshots to avoid saving large files with many unused space.
+ - compact: main API, should free the unmarked object, unmark the objects remaining live and potentially compact the heap
+ - remapObj:/shouldRemapObj: => Not really sure what this does, it seems it has to do with updating oops directly referred by the VM when they are moved. 
+ 
+ 
  Instance Variables
  	coInterpreter:				<StackInterpreter>
  	compactedCopySpace:		<SpurNewSpaceSpace>
  	manager:					<SpurMemoryManager>!

Item was changed:
  ----- Method: SpurCompactor>>biasForGC (in category 'api') -----
+ biasForGC
+ 	self subclassResponsibility!
- biasForGC!

Item was changed:
  ----- Method: SpurCompactor>>biasForSnapshot (in category 'api') -----
+ biasForSnapshot
+ 	self subclassResponsibility!
- biasForSnapshot!

Item was changed:
  ----- Method: SpurCompactor>>compact (in category 'api') -----
+ compact
+ 	self subclassResponsibility!
- compact!

Item was changed:
  ----- Method: SpurCompactor>>printTheBogons: (in category 'debugging') -----
+ printTheBogons: aBogon
+ 	<inline: true>
+ 	coInterpreter
+ 		print: 'bogon '; printHexnp: aBogon; cr!
- printTheBogons: bogon!

Item was changed:
+ ----- Method: SpurCompactor>>remapObj: (in category 'api') -----
+ remapObj: objOop
+ 	self subclassResponsibility!
- ----- Method: SpurCompactor>>remapObj: (in category 'debugging') -----
- remapObj: objOop!

Item was changed:
+ ----- Method: SpurCompactor>>shouldRemapObj: (in category 'api') -----
+ shouldRemapObj: objOop
+ 	self subclassResponsibility!
- ----- Method: SpurCompactor>>shouldRemapObj: (in category 'debugging') -----
- shouldRemapObj: objOop!

Item was removed:
- ----- Method: SpurMemoryManager>>totalFreeOldSpace (in category 'accessing') -----
- totalFreeOldSpace
- 	<cmacro: '() GIV(totalFreeOldSpace)'>
- 	^totalFreeOldSpace!

Item was removed:
- ----- Method: SpurPigCompactor>>printTheBogons: (in category 'debug support') -----
- printTheBogons: aBogon
- 	<inline: true>
- 	coInterpreter
- 		print: 'bogon '; printHexnp: aBogon; cr!

Item was changed:
  ----- Method: SpurSweeper>>bulkFreeChunkFrom: (in category 'sweep phase') -----
  bulkFreeChunkFrom: objOop
  	"ObjOop is either a freeChunk or an object to free, always in old space. The old space entity before objOop is necessarily a marked object.
  	 Attempts to free as many byte from objOop, looking ahead for multiple freechunks / objects to free in a row"
  	| bytes start next currentObj |
  	
  	"Avoids pathological case, not point in dealing with non-mergeable free chunks, we would remove them and re-add them to the free list."
  	(self isSingleFreeObject: objOop) ifTrue: [^0].
  	
  	"We free unmarked objects and freechunks next to each others and merge them at the same time"
  	start := manager startOfObject: objOop.
  	currentObj := objOop.
  	bytes := 0.
+ 	[bytes := bytes + (manager bytesInObject: currentObj).
- 	[bytes := bytes + self bytesInObject: currentObj.
  	self freeEntity: currentObj.
  	next := manager objectStartingAt: start + bytes.
  	self canUseNextEntityAsFreeSpace: next] 
  		whileTrue: [currentObj := next].
  	
+ 	manager addFreeChunkWithBytes: bytes at: start.
+ 	
+ 	^ next!
- 	manager totalFreeOldSpace: manager totalFreeOldSpace + bytes.
- 	^manager freeChunkWithBytes: bytes at: start!

Item was changed:
  ----- Method: SpurSweeper>>compact (in category 'api') -----
  compact
  	"Unless we're snapshotting, use a non-compacting sweep algorithm"
  	<inline: #never> "for profiling"
  	biasForGC
  		ifTrue: [self globalSweep]
  		ifFalse: [aggressiveCompactor compact]!

Item was changed:
  ----- Method: SpurSweeper>>globalSweep (in category 'sweep phase') -----
  globalSweep
+ 	"Iterate over all entities, in order, if the entity is a free chunk or unmarked object, 
+ 	 make a new big piece of free chunk, else unmark the object which stay live."
+ 
+ 	| currentEntity start |
+ 	currentEntity := manager firstObject.
+ 	[self oop: currentEntity isLessThan: manager endOfMemory] whileTrue:
+ 		[(self canUseAsFreeSpace: currentEntity) 
+ 			ifTrue: ["bulkFreeChunkFrom: may change a 1 word header
+ 					object to a double word header object"
+ 					start := manager startOfObject: currentEntity.
+ 					self bulkFreeChunkFrom: currentEntity.
+ 					currentEntity := manager objectStartingAt: start]
+ 			ifFalse: [self unmark: currentEntity].
+ 		 currentEntity := manager objectAfter: currentEntity limit: manager endOfMemory].
+ 			
+ 	manager checkFreeSpace: GCModeFull.
+ 		
+ 	manager unmarkSurvivingObjectsForCompact.
- 	"allOldSpaceEntitiesDo: computes the address of the next object only once the block has been evaluated,
- 	 hence when we rewrite object iterated over as a larger free chunk, the next object is the object after the chunk"
- 	self allOldSpaceEntitiesDo: 
- 		[:objOop | (self canUseAsFreeSpace: objOop) ifTrue: [self bulkFreeChunkFrom: objOop]].
  	!

Item was added:
+ ----- Method: SpurSweeper>>remapObj: (in category 'api') -----
+ remapObj: objOop
+ 	<api>
+ 	<inline: false>
+ 	^manager vanillaRemapObj: objOop!

Item was added:
+ ----- Method: SpurSweeper>>shouldRemapObj: (in category 'api') -----
+ shouldRemapObj: objOop
+ 	<api>
+ 	^manager vanillaShouldRemapObj: objOop!

Item was added:
+ ----- Method: SpurSweeper>>unmark: (in category 'sweep phase') -----
+ unmark: objOop
+ 	self assert: ((manager isMarked: objOop) and: [(manager isFreeObject: objOop) not]).
+ 	(manager isSegmentBridge: objOop) ifFalse: [manager setIsMarkedOf: objOop to: false].
+ 	(manager isPinned: objOop) ifTrue: [manager segmentManager notePinned: objOop]!



More information about the Vm-dev mailing list