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

commits at source.squeak.org commits at source.squeak.org
Thu Sep 19 01:21:51 UTC 2013

Eliot Miranda uploaded a new version of Cog to project VM Maker:

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

Name: Cog-eem.91
Author: eem
Time: 18 September 2013, 6:21:37.61 pm
UUID: b0e94ed6-219d-4e9a-8e04-ab08c6805eeb
Ancestors: Cog-eem.90

Add a prototype for Character>>hash.  Add checks for other
quick methods.

Get scavengeImage to completely flush newSpace at the end of the
bootstrap.  Follow forwarders before flushing new space.

Bootstrasp now completes.

=============== Diff against Cog-eem.90 ===============

Item was added:
+ ----- Method: SpurBootstrap class>>CharacterPROTOTYPEhash (in category 'method prototypes') -----
+ CharacterPROTOTYPEhash
+ 	<primitive: 171>
+ 	^self primitiveFailed!

Item was added:
+ ----- Method: SpurBootstrap>>followForwardingPointers (in category 'bootstrap image') -----
+ followForwardingPointers
+ 	newHeap allObjectsDo:
+ 		[:o|
+ 		(newHeap isForwarded: o) ifFalse:
+ 			[0 to: (newHeap numPointerSlotsOf: o) - 1 do:
+ 				[:i| | field |
+ 				field := newHeap fetchPointer: i ofObject: o.
+ 				(newHeap isOopForwarded: field) ifTrue:
+ 					[newHeap
+ 						storePointer: i
+ 						ofObject: o
+ 						withValue: (newHeap followForwarded: field)]]]]!

Item was changed:
  ----- Method: SpurBootstrap>>rehashImage (in category 'bootstrap image') -----
  	"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.
  		setHashBitsOf: newHeap nilObject to: 1;
  		setHashBitsOf: newHeap falseObject to: 2;
  		setHashBitsOf: newHeap trueObject to: 3.
  	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.
  				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..
- 					  Symbol implements rehash, but doesn't understand size, so don't send size to classes.
  					  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:
- 							withArguments: #()) ~= (newHeap integerObjectOf: 0)]) ifTrue:
  						[self interpreter: sim
  							object: o
  							perform: (map at: rehashSym)
  							withArguments: #()]]]]!

Item was changed:
  ----- Method: SpurBootstrap>>replacementForCharacterMethod: (in category 'bootstrap methods') -----
  replacementForCharacterMethod: characterMethodOop
  	"Answer a replacement method for the argument if it refers
  	 to Character's old inst var value.  Otherwise answer nil."
  	| proxy asIntegerProxy clone assembly newInsts newMethod |
  	"(oldHeap stringOf: (oldHeap longAt: characterMethodOop + (oldHeap lastPointerOf: characterMethodOop) - 4)) = 'isOctetCharacter' ifTrue:
  		[self halt]."
  	proxy := VMCompiledMethodProxy new
  				for: characterMethodOop
  				coInterpreter: oldInterpreter
  				objectMemory: oldHeap.
  	clone := self cloneMethodProxy: proxy.
+ 	"Quick methods accessing value should have been replaced."
+ 	clone isReturnField ifTrue: [self halt].
  	clone hasInstVarRef ifFalse:
  	clone setSourcePointer: 0.
  	asIntegerProxy := VMObjectProxy new
  							for: (symbolMap at: #asInteger)
  							coInterpreter: oldInterpreter
  							objectMemory: oldHeap.
  	assembly := BytecodeDisassembler new disassemble: clone.
  	assembly literals: (assembly literals allButLast: 2), {asIntegerProxy}, (assembly literals last: 2).
  		"Do this by looking for index of pushReceiverVariable: and replacing it by pushSelf, send asInteger"
  	newInsts := (assembly instructions piecesCutWhere:
  					[:msgOrLabelAssoc :nextInst|
  					 msgOrLabelAssoc isVariableBinding not
  					 and: [msgOrLabelAssoc selector == #pushReceiverVariable:]]) fold:
  				[:a :b|
  				 a allButLast,
  				 {	Message selector: #pushReceiver.
  						selector: #send:super:numArgs:
  						arguments: {asIntegerProxy. false. 0}},
  	assembly instructions: newInsts.
  	newMethod := assembly assemble.
  		installableMethodFor: newMethod
  		selector: clone selector
  		className: #Character
  		isMeta: false!

Item was changed:
  ----- Method: SpurBootstrap>>scavengeImage (in category 'bootstrap image') -----
  	"Scavenge the image to get it into a simpler state."
  	newHeap coInterpreter voidVMStateForSnapshot.
+ 	newHeap flushNewSpace!
- 	newHeap sufficientSpaceAfterGC: 0!

Item was changed:
  ----- Method: SpurBootstrap>>transform (in category 'bootstrap image') -----
  	self rememberRehashSymbol.
  	self installModifiedMethods.
  	self bootstrapImage.
  	self validate.
  	self rehashImage.
- 	self scavengeImage.
  	self followForwardingPointers.
+ 	self scavengeImage.
  	Transcript nextPutAll: 'done.'; flush.!

More information about the Vm-dev mailing list