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

commits at source.squeak.org commits at source.squeak.org
Tue Oct 2 13:00:02 UTC 2018


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

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

Name: VMMaker.oscog-cb.2445
Author: cb
Time: 2 October 2018, 2:59:39.047824 pm
UUID: 8c661cb0-900c-4f0c-a9c0-219333c2e224
Ancestors: VMMaker.oscog-eem.2444

Change the objStack logic to mmap a new memory segment on overflow if not enough room on heap when allocating a new page.

Happened to me reliably on ~20Gb heap that the mark stack would overflow without enough space on heap during marking to allocate a new page. This code fixed the bug.

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

Item was changed:
  ----- Method: SpurMemoryManager>>ensureRoomOnObjStackAt: (in category 'obj stacks') -----
  ensureRoomOnObjStackAt: objStackRootIndex
  	"An obj stack is a stack of objects stored in a hidden root slot, such as
  	 the markStack or the ephemeronQueue.  It is a linked list of segments,
  	 with the hot end at the head of the list.  It is a word object.  The stack
  	 pointer is in ObjStackTopx and 0 means empty.  The list goes through
  	 ObjStackNextx. We don't want to shrink objStacks, since they're used
  	 in GC and its good to keep their memory around.  So unused pages
  	 created by popping emptying pages are kept on the ObjStackFreex list."
  	| stackOrNil freeOrNewPage |
  	stackOrNil := self fetchPointer: objStackRootIndex ofObject: hiddenRootsObj.
  	(stackOrNil = nilObj
  	 or: [(self fetchPointer: ObjStackTopx ofObject: stackOrNil) >= ObjStackLimit]) ifTrue:
  		[freeOrNewPage := stackOrNil = nilObj
  								ifTrue: [0]
  								ifFalse: [self fetchPointer: ObjStackFreex ofObject: stackOrNil].
  		 freeOrNewPage ~= 0
  			ifTrue: "the free page list is always on the new page."
  				[self storePointer: ObjStackFreex ofObjStack: stackOrNil withValue: 0.
  				 self assert: (marking not or: [self isMarked: freeOrNewPage])]
  			ifFalse:
  				[freeOrNewPage := self allocateSlotsInOldSpace: ObjStackPageSlots
  										format: self wordIndexableFormat
  										classIndex: self wordSizeClassIndexPun.
+ 				 freeOrNewPage ifNil: 
+ 					["Allocate a new segment an retry. This is very uncommon. But it happened to me (Clement)."
+ 					 self growOldSpaceByAtLeast: ObjStackPageSlots.
+ 					 freeOrNewPage := self allocateSlotsInOldSpace: ObjStackPageSlots
+ 										format: self wordIndexableFormat
+ 										classIndex: self wordSizeClassIndexPun.
+ 					freeOrNewPage ifNil: [self error: 'no memory to allocate or extend obj stack']].
- 				 freeOrNewPage ifNil: [self error: 'no memory to allocate or extend obj stack'].
  				 self storePointer: ObjStackFreex ofObjStack: freeOrNewPage withValue: 0.
  				 marking ifTrue: [self setIsMarkedOf: freeOrNewPage to: true]].
  		 self storePointer: ObjStackMyx ofObjStack: freeOrNewPage withValue: objStackRootIndex;
  			  storePointer: ObjStackNextx ofObjStack: freeOrNewPage withValue: (stackOrNil = nilObj ifTrue: [0] ifFalse: [stackOrNil]);
  			  storePointer: ObjStackTopx ofObjStack: freeOrNewPage withValue: 0;
  			  storePointer: objStackRootIndex ofObject: hiddenRootsObj withValue: freeOrNewPage.
  		 self assert: (self isValidObjStackAt: objStackRootIndex).
  		 "Added a new page; now update and answer the relevant cached first page."
  		 stackOrNil := self updateRootOfObjStackAt: objStackRootIndex with: freeOrNewPage].
  	self assert: (self isValidObjStackAt: objStackRootIndex).
  	^stackOrNil!



More information about the Vm-dev mailing list