Eliot Miranda uploaded a new version of Cog to project VM Maker: http://source.squeak.org/VMMaker/Cog-eem.128.mcz
==================== Summary ====================
Name: Cog-eem.128 Author: eem Time: 13 January 2014, 1:10:54.717 pm UUID: c941142d-2ead-413e-b128-c9c5a2777b4a Ancestors: Cog-eem.127
Spur bootstrap: Rescue the launchSaved short-cut by hacking newSpace initialization.
Add report of average object size to the image bootstrap code.
Provide a bigger eden so that the launchSaved route can accomodate the interpreter reserve.
=============== Diff against Cog-eem.127 ===============
Item was changed: Object subclass: #SpurBootstrap + instanceVariableNames: 'oldHeap newHeap oldHeapSize newHeapSize oldHeapNumObjs newHeapNumObjs map reverseMap classToIndex oldInterpreter lastClassTablePage literalMap methodClasses installedPrototypes sizeSym rehashSym classMetaclass' - instanceVariableNames: 'oldHeap newHeap oldHeapSize newHeapSize map reverseMap classToIndex oldInterpreter lastClassTablePage literalMap methodClasses installedPrototypes sizeSym rehashSym classMetaclass' classVariableNames: 'ImageHeaderFlags ImageName ImageScreenSize TransformedImage' poolDictionaries: 'VMObjectIndices' category: 'Cog-Bootstrapping'!
!SpurBootstrap commentStamp: 'eem 9/11/2013 05:45' prior: 0! SpurBootstrap bootstraps an image in SpurMemoryManager format from a Squeak V3 + closures format.
e.g. (SpurBootstrap32 new on: '/Users/eliot/Cog/startreader.image') transform; launch
Bootstrap issues: - should it implement a deterministic Symbol identityHash? This means set a Symbol's identityHash at instance creation time based on its string hash so that e.g. MethodDIctionary instances have a deterministic order and don't need to be rehashed on load. - should it collapse ContextPart and MethodContext down onto Context (and perhaps eliminate BlockContext)?
Instance Variables classToIndex: <Dictionary> lastClassTablePage: <Integer> map: <Dictionary> methodClasses: <Set> newHeap: <SpurMemoryManager> oldHeap: <NewObjectMemory> oldInterpreter: <StackInterpreterSimulator> reverseMap: <Dictionary> symbolMap: <Dictionary>
classToIndex - oldClass to new classIndex map
lastClassTablePage - oop in newHeap of last classTable page. U<sed in validation to filter-out class table.
methodClasses - cache of methodClassAssociations for classes in which modified methods are installed
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
reverseMap - newObject to oldObject map
symbolMap - symbol toi symbol oop in oldHeap, used to map prototype methdos to methods in oldHeap!
Item was changed: ----- Method: SpurBootstrap>>bootstrapImage (in category 'bootstrap image') ----- bootstrapImage oldHeap fullGC. + self measureOldHeapPostGC. - oldHeapSize := oldHeap freeStart. self initMaps. self findRequiredGlobals. Transcript cr; nextPutAll: 'transforming image...'; flush. self cloneNilTrueAndFalse. self allocateFreeLists. self buildClassMap. self allocateClassTable. self cloneObjects. self fillInObjects. self fillInClassTable. newHeapSize := newHeap freeStart. + newHeap initializePostBootstrap. + self measureNewHeapPostInitPostBootstrap! - newHeap initializePostBootstrap!
Item was changed: ----- Method: SpurBootstrap>>launch:simulatorClass:headerFlags: (in category 'testing') ----- launch: heap simulatorClass: simulatorClass headerFlags: headerFlags | sim methodCacheSize | sim := simulatorClass onObjectMemory: heap. heap coInterpreter: sim. (sim class allInstVarNames includes: 'cogCodeSize') ifTrue: [sim initializeInterpreter: 0. methodCacheSize := sim methodCache size * heap wordSize. sim instVarNamed: 'heapBase' put: heap startOfMemory; instVarNamed: 'numStackPages' put: 8; instVarNamed: 'cogCodeSize' put: 1024*1024; moveMethodCacheToMemoryAt: sim cogCodeSize + sim computeStackZoneSize; movePrimTraceLogToMemoryAt: sim cogCodeSize + sim computeStackZoneSize + methodCacheSize; "sendTrace: 1+ 2 + 8 + 16;" initializeCodeGenerator] ifFalse: [sim initializeInterpreter: 0]. + heap + initializeNewSpaceVariables; + bootstrapping: false; + assimilateNewSegment: (heap segmentManager segments at: 0). sim setImageHeaderFlagsFrom: headerFlags; imageName: ImageName; flushExternalPrimitives; openAsMorph; transcript: Transcript. "deep copy copies this" "sim instVarNamed: 'printSends' put: true; instVarNamed: 'printReturns' put: true; instVarNamed: 'methodDictLinearSearchLimit' put: SmallInteger maxVal." "for now" heap setCheckForLeaks: 0; runLeakCheckerForFullGC: true.
sim halt; run!
Item was added: + ----- Method: SpurBootstrap>>measureNewHeapPostInitPostBootstrap (in category 'stats') ----- + measureNewHeapPostInitPostBootstrap + | savedEndOfMemory | + "need to hack around the fact that newHeap isn't all there yet. + In particular, it has no freeList so can't free space from + freeOldSpaceStart to endOfMemory to make oldSpace enumerable." + newHeapNumObjs := 0. + savedEndOfMemory := newHeap endOfMemory. + newHeap setEndOfMemory: newHeap freeOldSpaceStart. + newHeap allObjectsDo: [:o| newHeapNumObjs := newHeapNumObjs + 1]. + newHeap setEndOfMemory: savedEndOfMemory!
Item was added: + ----- Method: SpurBootstrap>>measureOldHeapPostGC (in category 'stats') ----- + measureOldHeapPostGC + oldHeapSize := oldHeap freeStart. + oldHeapNumObjs := 0. + oldHeap allObjectsDo: [:o| oldHeapNumObjs := oldHeapNumObjs + 1]!
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 := Spur32BitMMLESimulator new. newHeap allocateMemoryOfSize: (oldHeap youngStart * 3 / 2 roundUpTo: 1024 * 1024) + newSpaceSize: 2 * 1024 * 1024 - newSpaceSize: 1024 * 1024 stackSize: 1024 * 1024 codeSize: 0. newHeap setCheckForLeaks: 15 - 6. "don't check become; or newSpace; soooo many rehashes in bootstrap" newHeap bootstrapping: true. self initMaps!
Item was added: + ----- Method: SpurBootstrap>>reportSizes (in category 'bootstrap image') ----- + reportSizes + | change oldAvgBytes newAvgBytes | + change := newHeapSize - oldHeapSize / oldHeapSize. + oldAvgBytes := oldHeapSize asFloat / oldHeapNumObjs. + Transcript + nextPutAll: 'done.'; cr; + nextPutAll: 'old heap size: '; print: oldHeapSize; tab; + nextPutAll: ' (avg obj bytes '; print: (oldAvgBytes roundTo: 0.01); nextPutAll: ' words '; print: (oldAvgBytes / self wordSize roundTo: 0.01); nextPut: $); cr; + nextPutAll: 'initial new heap size: '; print: newHeapSize; cr; + nextPutAll: 'change: '; print: (change * 100.0 roundTo: 0.01); nextPut: $%; cr; + flush. + newHeapSize := newHeap endOfMemory + - newHeap scavenger eden limit + - newHeap totalFreeListBytes. + change := newHeapSize - oldHeapSize / oldHeapSize. + newAvgBytes := newHeapSize asFloat / newHeapNumObjs. + Transcript + nextPutAll: 'final new heap size: '; print: newHeapSize; tab; + nextPutAll: ' (avg obj bytes '; print: (newAvgBytes roundTo: 0.01); nextPutAll: ' words '; print: (newAvgBytes / self wordSize roundTo: 0.01); nextPut: $); cr; + nextPutAll: 'change: '; print: (change * 100.0 roundTo: 0.01); nextPut: $%; cr; + flush!
Item was changed: ----- Method: SpurBootstrap>>transform (in category 'bootstrap image') ----- transform - | change | self rememberRehashSymbol. self findRequiredGlobals. self installModifiedMethods. self bootstrapImage. self validate. self rememberRehashSymbol. self rehashImage. self followForwardingPointers. self scavengeImage. self freeForwarders. self compactImage. + self reportSizes! - change := newHeapSize - oldHeapSize / oldHeapSize. - Transcript - nextPutAll: 'done.'; cr; - nextPutAll: 'old heap size: '; print: oldHeapSize; cr; - nextPutAll: 'initial new heap size: '; print: newHeapSize; cr; - nextPutAll: 'change: '; print: (change * 100.0 roundTo: 0.01); nextPut: $%; cr; - flush. - newHeapSize := newHeap endOfMemory - - newHeap scavenger eden limit - - newHeap totalFreeListBytes. - change := newHeapSize - oldHeapSize / oldHeapSize. - Transcript - nextPutAll: 'final new heap size: '; print: newHeapSize; cr; - nextPutAll: 'change: '; print: (change * 100.0 roundTo: 0.01); nextPut: $%; cr; - flush.!
vm-dev@lists.squeakfoundation.org