Eliot Miranda uploaded a new version of Cog to project VM Maker: http://source.squeak.org/VMMaker/Cog-eem.115.mcz
==================== Summary ====================
Name: Cog-eem.115 Author: eem Time: 16 October 2013, 2:00:16.525 pm UUID: dca22737-f388-4220-8acf-a37421113258 Ancestors: Cog-eem.114
Fix the handleFailingBasicNew[:] prototypes (they were calling failingFailingBasicNew[:], not handleFailingFailingBasicNew[:]. Make them call an explicit grow primitive after GC if free space is insufficient for the allocation request. Still need to add a fudge factor for object header size, but where, in the image or in the VM?
Fix the rehashMap size.
=============== Diff against Cog-eem.114 ===============
Item was changed: ----- Method: SpurBootstrap class>>BehaviorPROTOTYPEhandleFailingBasicNew (in category 'method prototypes') ----- BehaviorPROTOTYPEhandleFailingBasicNew "This basicNew gets sent after basicNew has failed and allowed a scavenging garbage collection to occur. The scavenging collection will have happened as the VM is activating the (failing) basicNew. If failingBasicNew fails then the scavenge failed to reclaim sufficient space and a global garbage collection is required.
Primitive. Answer an instance of this class with the number of indexable variables specified by the argument, sizeRequested. Fail if this class is not indexable or if the argument is not a positive Integer, or if there is not enough memory available. Essential. See Object documentation whatIsAPrimitive."
<primitive: 70> self isVariable ifTrue: [^self basicNew: 0]. + Smalltalk garbageCollect < 1048576 ifTrue: + [Smalltalk growMemoryByAtLeast: 1048576]. + ^self handleFailingFailingBasicNew "retry after global garbage collect"! - Smalltalk garbageCollect. - ^self failingFailingBasicNew "retry after global garbage collect"!
Item was changed: ----- Method: SpurBootstrap class>>BehaviorPROTOTYPEhandleFailingBasicNew: (in category 'method prototypes') ----- BehaviorPROTOTYPEhandleFailingBasicNew: sizeRequested "This basicNew: gets sent after basicNew: has failed and allowed a scavenging garbage collection to occur. The scavenging collection will have happened as the VM is activating the (failing) basicNew:. + If handleFailingBasicNew: fails then the scavenge failed to reclaim + sufficient space and a global garbage collection is required. - If failingBasicNew: fails then the scavenge failed to reclaim sufficient - space and a global garbage collection is required.
Primitive. Answer an instance of this class with the number of indexable variables specified by the argument, sizeRequested. Fail if this class is not indexable or if the argument is not a positive Integer, or if there is not enough memory available. Essential. See Object documentation whatIsAPrimitive."
<primitive: 71> self isVariable ifFalse: [self error: self printString, ' cannot have variable sized instances']. (sizeRequested isInteger and: [sizeRequested >= 0]) ifTrue: + [Smalltalk garbageCollect < sizeRequested ifTrue: + [Smalltalk growMemoryByAtLeast: sizeRequested]. + ^self handleFailingFailingBasicNew: sizeRequested "retry after global garbage collect and possible grow"]. - [Smalltalk garbageCollect. - ^self failingFailingBasicNew: sizeRequested "retry after global garbage collect"]. self primitiveFailed!
Item was added: + ----- Method: SpurBootstrap class>>SmalltalkImagePROTOTYPEgrowMemoryByAtLeast: (in category 'method prototypes') ----- + SmalltalkImagePROTOTYPEgrowMemoryByAtLeast: numBytes + "Grow memory by at least the requested number of bytes. + Fail if no memory is available." + <primitive: 180> + ^self primitiveFailed!
Item was added: + ----- Method: SpurBootstrap class>>SystemDictionaryPROTOTYPEgrowMemoryByAtLeast: (in category 'method prototypes') ----- + SystemDictionaryPROTOTYPEgrowMemoryByAtLeast: numBytes + "Grow memory by at least the requested number of bytes. + Fail if no memory is available." + <primitive: 180> + ^self primitiveFailed!
Item was changed: ----- Method: SpurBootstrap>>rehashImage (in category 'bootstrap image') ----- rehashImage "Rehash all collections in newHeap. Find out which classes implement rehash, entering a 1 against their classIndex in rehashFlags. Enumerate all objects, rehashing those whose class has a bit set in rehashFlags." | n sim rehashFlags | sim := StackInterpreterSimulator onObjectMemory: newHeap. newHeap coInterpreter: sim. sim initializeInterpreter: 0. sim instVarNamed: 'methodDictLinearSearchLimit' put: SmallInteger maxVal.
newHeap setHashBitsOf: newHeap nilObject to: 1; setHashBitsOf: newHeap falseObject to: 2; setHashBitsOf: newHeap trueObject to: 3.
+ rehashFlags := ByteArray new: newHeap numClassTablePages * newHeap classTablePageSize. - rehashFlags := ByteArray new: newHeap classTableIndex + 7 // 8. n := 0. newHeap classTableObjectsDo: [:class| | classIndex | sim messageSelector: (map at: rehashSym). "Lookup rehash but don't be fooled by ProtoObject>>rehash, which is just ^self." ((sim lookupMethodNoMNUEtcInClass: class) = 0 and: [(sim isQuickPrimitiveIndex: (sim primitiveIndexOf: (sim instVarNamed: 'newMethod'))) not]) ifTrue: [n := n + 1. classIndex := newHeap rawHashBitsOf: class. rehashFlags at: classIndex >> 3 + 1 put: ((rehashFlags at: classIndex >> 3 + 1) bitOr: (1 << (classIndex bitAnd: 7)))]]. Transcript cr; print: n; nextPutAll: ' classes understand rehash. rehashing instances...'; flush. n := 0. self withExecutableInterpreter: sim do: [sim setBreakSelector: 'error:'. "don't rehash twice (actually without limit), so don't rehash any new objects created." newHeap allExistingOldSpaceObjectsDo: [:o| | classIndex | classIndex := newHeap classIndexOf: o. ((rehashFlags at: classIndex >> 3 + 1) anyMask: 1 << (classIndex bitAnd: 7)) ifTrue: [(n := n + 1) \ 8 = 0 ifTrue: [Transcript nextPut: $.; flush]. "2845 = n ifTrue: [self halt]." "Rehash an object if its size is > 0. Symbol implements rehash, but let's not waste time rehashing it; in Squeak up to 2013 symbols are kept in a set which will get reashed anyway.. Don't rehash empty collections; they may be large for a reason and rehashing will shrink them." ((sim addressCouldBeClassObj: o) or: [(self interpreter: sim object: o perform: (map at: sizeSym) withArguments: #()) = (newHeap integerObjectOf: 0)]) ifFalse: [self interpreter: sim object: o perform: (map at: rehashSym) withArguments: #()]]]]!
vm-dev@lists.squeakfoundation.org