[Vm-dev] VM Maker: Cog-eem.63.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Sep 2 03:47:01 UTC 2013


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

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

Name: Cog-eem.63
Author: eem
Time: 1 September 2013, 8:46:37.722 pm
UUID: 3bfeebef-ce05-4800-9514-708d11b3078f
Ancestors: Cog-eem.62

Check that all objects can be enumerated after the bootstrap.
Check that the right number of objects are created.
Lots of asserts added to allocateClassTable to check header access
and objectAfter:.  Needs VMMaker.oscog-eem.340.

=============== Diff against Cog-eem.62 ===============

Item was changed:
  Object subclass: #SpurBootstrap
+ 	instanceVariableNames: 'oldHeap newHeap map reverseMap classToIndex oldInterpreter pastClassTable'
- 	instanceVariableNames: 'oldHeap newHeap map classToIndex oldInterpreter'
  	classVariableNames: ''
  	poolDictionaries: 'VMObjectIndices'
  	category: 'Cog-Bootstrapping'!
  
  !SpurBootstrap commentStamp: 'eem 8/31/2013 12:20' prior: 0!
  SpurBootstrap bootstraps an image in CogMemoryManager format from a Squeak V3 + closures format.
  
  e.g.
  	(SpurBootstrap32 new on: '/Users/eliot/Cog/startreader.image') transform
  Instance Variables
  	classToIndex:		<Dictionary>
  	map:		<Dictionary>
  	newHeap:		<CogMemoryManager>
  	oldHeap:		<NewObjectMemory>
  	oldInterpreter:		<StackInterpreterSimulator>
  
  classToIndex
  	- oldClass to new classIndex map
  
  map
  	- oldObject to newObject map
  
  newHeap
  	- the output, bootstrapped image
  
  oldHeap
  	- the input, image
  
  oldInterpreter
  	- the interpreter associated with oldHeap, needed for a hack to grab WeakArray
  !

Item was changed:
  ----- Method: SpurBootstrap>>allocateClassTable (in category 'bootstrap') -----
  allocateClassTable
  	"Allocate the root of the classTable plus enough pages to accomodate all classes in
  	 the classToIndex map.  Don;t fill in the entries yet; the classes have yet to be cloned."
  	| tableRootSize tableRoot page maxSize numPages |
  	tableRootSize := self classTableSize / newHeap classTablePageSize.
  	tableRoot := newHeap
  					allocateSlots: tableRootSize
  					format: newHeap arrayFormat
  					classIndex: newHeap arrayClassIndexPun.
+ 	self assert: (newHeap rawSlotSizeOf: tableRoot) = tableRootSize.
+ 	self assert: (newHeap formatOf: tableRoot) = newHeap arrayFormat.
+ 	self assert: (newHeap classIndexOf: tableRoot) = newHeap arrayClassIndexPun.
  	newHeap classTableRootObj: tableRoot.
  	newHeap nilFieldsOf: tableRoot.
  	"first page is strong"
  	page := newHeap
+ 					allocateSlots: newHeap classTablePageSize
- 					allocateSlots: tableRootSize
  					format: newHeap arrayFormat
  					classIndex: newHeap arrayClassIndexPun.
+ 	self assert: (newHeap rawSlotSizeOf: page) = newHeap classTablePageSize.
+ 	self assert: (newHeap formatOf: tableRoot) = newHeap arrayFormat.
+ 	self assert: (newHeap classIndexOf: tableRoot) = newHeap arrayClassIndexPun.
+ 	self assert: (newHeap objectAfter: tableRoot) = page.
  	newHeap nilFieldsOf: page.
  	newHeap storePointer: 0 ofObject: tableRoot withValue: page.
  	maxSize := classToIndex inject: 0 into: [:a :b| a max: b].
  	numPages := (maxSize + newHeap classTableMinorIndexMask / newHeap classTablePageSize) truncated.
  	2 to: numPages do:
  		[:i|
  		page := newHeap
+ 					allocateSlots: newHeap classTablePageSize
- 					allocateSlots: tableRootSize
  					format: newHeap weakArrayFormat
  					classIndex: newHeap weakArrayClassIndexPun.
+ 		self assert: (newHeap rawSlotSizeOf: page) = newHeap classTablePageSize.
+ 		self assert: (newHeap formatOf: page) = newHeap weakArrayFormat.
+ 		self assert: (newHeap classIndexOf: page) = newHeap weakArrayClassIndexPun.
  		newHeap nilFieldsOf: page.
+ 		newHeap storePointer: i - 1 ofObject: tableRoot withValue: page.
+ 		self assert: (newHeap objectAfter: (newHeap fetchPointer: i - 2 ofObject: tableRoot)) = page].
+ 	pastClassTable := newHeap freeStart.!
- 		newHeap storePointer: i - 1 ofObject: tableRoot withValue: page]!

Item was changed:
  ----- Method: SpurBootstrap>>clone:classIndex: (in category 'bootstrap') -----
+ clone: oldObj classIndex: classIndex
+ 	| newObj |
+ 	newObj := newHeap
- clone: oldObj classIndex: classIndex 
- 	map
- 		at: oldObj
- 		put: (newHeap
  				allocateSlots: (oldHeap fetchWordLengthOf: oldObj)
  				format: (self newFormatFor: oldObj)
+ 				classIndex: classIndex.
+ 	reverseMap at: newObj put: oldObj.
+ 	^map at: oldObj put: newObj!
- 				classIndex: classIndex)!

Item was changed:
  ----- Method: SpurBootstrap>>cloneNilTrueAndFalse (in category 'bootstrap') -----
  cloneNilTrueAndFalse
  	{	oldHeap nilObject.
  		oldHeap falseObject.
  		oldHeap trueObject. }
  		with: (self firstOrdinaryClassIndex to: self firstOrdinaryClassIndex + 2)
  		do: [:obj :classIndex|
  			classToIndex at: (oldHeap fetchClassOfNonInt: obj) put: classIndex.
  			self clone: obj classIndex: classIndex].
+ 	newHeap
+ 		nilObject: (map at: oldHeap nilObject); "needed for nilling objects etc"
+ 		falseObject: (map at: oldHeap falseObject);
+ 		trueObject: (map at: oldHeap trueObject)!
- 	newHeap nilObject: (map at: oldHeap nilObject). "needed for nilling objects etc"!

Item was changed:
  ----- Method: SpurBootstrap>>cloneObjects (in category 'bootstrap') -----
  cloneObjects
  	| characterClass characterTable oldObj oldClass |
  	characterClass := oldHeap classCharacter.
  	characterTable := oldHeap characterTable.
  	oldObj := oldHeap objectAfter: oldHeap trueObject.
  	[oldObj < oldHeap freeStart] whileTrue:
  		[oldClass := oldHeap fetchClassOfNonInt: oldObj.
  		 (oldObj ~= characterTable
  		 and: [oldClass ~= characterClass]) ifTrue:
  			[self clone: oldObj classIndex: (classToIndex at: oldClass)].
+ 		 oldObj := oldHeap objectAfter: oldObj].
+ 	newHeap specialObjectsOop: (map at: oldHeap specialObjectsOop)!
- 		 oldObj := oldHeap objectAfter: oldObj]!

Item was changed:
  ----- Method: SpurBootstrap>>on: (in category 'initialize-release') -----
  on: imageName
  	StackInterpreter initializeWithOptions: Dictionary new.
  	oldInterpreter := StackInterpreterSimulator new.
  	oldInterpreter openOn: imageName extraMemory: 0.
  	oldHeap := oldInterpreter objectMemory.
  	newHeap := CMM32LSBSimulator new.
+ 	newHeap
+ 		allocateMemoryOfSize: (oldHeap youngStart * 5 / 4 roundUpTo: 8)
+ 		newSpaceSize: 1024 * 1024
+ 		codeSize: 1024 * 1024.
+ 	map := Dictionary new: oldHeap memory size // 4.
+ 	reverseMap := Dictionary new: oldHeap memory size // 4.
+ 	classToIndex := Dictionary new: 1024!
- 	newHeap allocateMemoryOfSize: oldHeap memory size * 5 / 4.
- 	map := IdentityDictionary new: oldHeap memory size.
- 	classToIndex := IdentityDictionary new: 1024!

Item was changed:
  ----- Method: SpurBootstrap>>transform (in category 'bootstrap') -----
  transform
  	self cloneNilTrueAndFalse.
  	self buildClassMap.
  	self allocateClassTable.
  	self cloneObjects.
  	self fillInObjects.
+ 	self fillInClassTable.
+ 	self validate!
- 	self fillInClassTable!

Item was added:
+ ----- Method: SpurBootstrap>>validate (in category 'bootstrap') -----
+ validate
+ 	| p i |
+ 	i := 0.
+ 	newHeap allObjectsDo:
+ 		[:o|
+ 		o >= pastClassTable ifTrue:
+ 			[self assert: (reverseMap includesKey: o)].
+ 		i := i + 1. p := o].
+ 	p class.
+ 	self assert: (i between: map size and: map size + 5) "+ 5 is room for classTable"!



More information about the Vm-dev mailing list