[Vm-dev] VM Maker: VMMaker.oscog-eem.2006.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Nov 26 03:19:59 UTC 2016

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

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

Name: VMMaker.oscog-eem.2006
Author: eem
Time: 25 November 2016, 7:19:10.023637 pm
UUID: cad39d34-1c14-416f-aeae-5b9fc776a3fc
Ancestors: VMMaker.oscog-eem.2005

methodOrBlockNumTemps must not be reset to the actual value ignoring the initial pushNils.  Doing so wrecks spilling.

scanMethod must add an extra fixup for conditional branches since, if preceded by a special selector send, there may be two fixups created, one for each target, the target of the jump and the fall-through after the non-inlined send (see e.g. the two ensureFixupAt: sends in genBinaryInlineComparison:opFalse:destReg:).

This gets execution as far as the send of #<= in the loop in Interval>>#collect: which ends up passing nil as the second argument.  It maybe time to tackle inlining of special selector comparisons.

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

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>compileBlockFrameBuild: (in category 'compile abstract instructions') -----
  compileBlockFrameBuild: blockStart
  	"Build a frame for a block activation.  See CoInterpreter class>>initializeFrameIndices.
  	 Override to push the register receiver and register arguments, if any, and to correctly
  	 initialize the explicitly nilled/pushed temp entries (they are /not/ of type constant nil)."
  	super compileBlockFrameBuild: blockStart.
  	methodOrBlockNumTemps := blockStart numArgs + blockStart numCopied + blockStart numInitialNils.
  	self initSimStackForFramefulMethod: blockStart startpc.
  	blockStart numInitialNils > 0 ifTrue:
  		[blockStart numInitialNils > 1
  				[self genMoveNilR: TempReg.
  				 1 to: blockStart numInitialNils do:
  					[:ign| self PushR: TempReg]]
+ 				[self genPushConstant: objectMemory nilObject]]!
- 				[self genPushConstant: objectMemory nilObject].
- 		 methodOrBlockNumTemps := blockStart numArgs + blockStart numCopied]!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>scanMethod (in category 'compile abstract instructions') -----
  	"Scan the method (and all embedded blocks) to determine
  		- what the last bytecode is; extra bytes at the end of a method are used to encode things like source pointers or temp names
  		- if the method needs a frame or not
  		- what are the targets of any backward branches.
  		- how many blocks it creates
  	 Answer the block count or on error a negative error code"
  	| latestContinuation nExts descriptor pc numBlocks distance targetPC framelessStackDelta seenInstVarStore |
  	<var: #descriptor type: #'BytecodeDescriptor *'>
  	needsFrame := useTwoPaths := seenInstVarStore := false.
  	LowcodeVM ifTrue: [ hasNativeFrame := false ].
  	self maybeInitNumFixups.
  	self maybeInitNumCounters.
  	prevBCDescriptor := nil.
  	NewspeakVM ifTrue:
  		[numIRCs := 0].
  	(primitiveIndex > 0
  	 and: [coInterpreter isQuickPrimitiveIndex: primitiveIndex]) ifTrue:
  	pc := latestContinuation := initialPC.
  	numBlocks := framelessStackDelta := nExts := extA := extB := 0.
  	[pc <= endPC] whileTrue:
  		[byte0 := (objectMemory fetchByte: pc ofObject: methodObj) + bytecodeSetOffset.
  		 descriptor := self generatorAt: byte0.
  		 descriptor isExtension ifTrue:
  			[descriptor opcode = Nop ifTrue: "unknown bytecode tag; see Cogit class>>#generatorTableFrom:"
  			 self loadSubsequentBytesForDescriptor: descriptor at: pc.
  			 self perform: descriptor generator].
  		 (descriptor isReturn
  		  and: [pc >= latestContinuation]) ifTrue:
  			[endPC := pc].
  		  needsFrame ifFalse:
  			[(descriptor needsFrameFunction isNil
  			  or: [self perform: descriptor needsFrameFunction with: framelessStackDelta])
  						["With immutability we win simply by avoiding a frame build if the receiver is young and not immutable."
  						 self cppIf: IMMUTABILITY
  							ifTrue: [descriptor is1ByteInstVarStore
  									ifTrue: [useTwoPaths := true]
  									ifFalse: [needsFrame := true. useTwoPaths := false]]
  							ifFalse: [needsFrame := true. useTwoPaths := false]]
  						[framelessStackDelta := framelessStackDelta + descriptor stackDelta.
  						 "Without immutability we win if there are two or more stores and the receiver is new."
  						 self cppIf: IMMUTABILITY
  							ifTrue: []
  								[descriptor is1ByteInstVarStore ifTrue:
  										ifTrue: [useTwoPaths := true]
  										ifFalse: [seenInstVarStore := true]]]]].
  		 descriptor isBranch ifTrue:
  			[distance := self spanFor: descriptor at: pc exts: nExts in: methodObj.
  			 targetPC := pc + descriptor numBytes + distance.
  			 (self isBackwardBranch: descriptor at: pc exts: nExts in: methodObj)
  				ifTrue: [self initializeFixupAt: targetPC - initialPC]
  					[latestContinuation := latestContinuation max: targetPC.
+ 					 (descriptor isBranchTrue or: [descriptor isBranchFalse]) ifTrue:
+ 						[self maybeCountFixup].
  					 self maybeCountFixup.
  					 self maybeCountCounter]].
  		 descriptor isBlockCreation ifTrue:
  			[numBlocks := numBlocks + 1.
  			 distance := self spanFor: descriptor at: pc exts: nExts in: methodObj.
  			 targetPC := pc + descriptor numBytes + distance.
  			 latestContinuation := latestContinuation max: targetPC.
  			 self maybeCountFixup].
  		 NewspeakVM ifTrue:
+ 			[descriptor hasIRC ifTrue: [numIRCs := numIRCs + 1]].
- 			[descriptor hasIRC ifTrue:
- 				[numIRCs := numIRCs + 1]].
  		 pc := pc + descriptor numBytes.
+ 		 nExts := descriptor isExtension ifTrue: [nExts + 1] ifFalse: [extA := extB := 0].
- 		 descriptor isExtension
- 			ifTrue: [nExts := nExts + 1]
- 			ifFalse: [nExts := extA := extB := 0].
  		 prevBCDescriptor := descriptor].

More information about the Vm-dev mailing list