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

commits at source.squeak.org commits at source.squeak.org
Wed Nov 30 19:36:58 UTC 2016

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

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

Name: VMMaker.oscog-eem.2013
Author: eem
Time: 30 November 2016, 11:36:10.308574 am
UUID: 03cb6548-31c9-4a99-9fc6-38fc19a63a24
Ancestors: VMMaker.oscog-eem.2012

Fix slips in allocateRegForStackEntryAt:notConflictingWith: and CogRegisterAllocatingSimStackEntry>>registerMaskOrNone.

Improve Spur genGetClassObjectOf:into:scratchReg:instRegIsReceiver: to avoid reg-reg copies.

Fix reconcileRegisterStateForJoinAfterSpecialSelectorSendwhich must traverse entire stack.  Hence extend reconcilePoppingWith: to deal with spilled target entries.

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

Item was changed:
  ----- Method: CogObjectRepresentationForSpur>>genGetClassObjectOf:into:scratchReg:instRegIsReceiver: (in category 'compile abstract instructions') -----
  genGetClassObjectOf: instReg into: destReg scratchReg: scratchReg instRegIsReceiver: instRegIsReceiver
  	"Fetch the instance's class into destReg.  If the instance is not the receiver and is forwarded, follow forwarding."
  	| jumpIsImm jumpNotForwarded loop |
  	<var: #jumpIsImm type: #'AbstractInstruction *'>
  	<var: #jumpNotForwarded type: #'AbstractInstruction *'>
  	<var: #loop type: #'AbstractInstruction *'>
  	(instReg = destReg or: [instReg = scratchReg or: [destReg = scratchReg]]) ifTrue:
  	loop := cogit MoveR: instReg R: scratchReg.
  	cogit AndCq: objectMemory tagMask R: scratchReg.
  	jumpIsImm := cogit JumpNonZero: 0.
  	self flag: #endianness.
  	"Get least significant half of header word in destReg"
  	cogit MoveMw: 0 r: instReg R: scratchReg.
  	"mask off class index"
  	cogit AndCq: objectMemory classIndexMask R: scratchReg.
  	instRegIsReceiver ifFalse:
  		["if it is forwarded..."
  		cogit CmpCq: objectMemory isForwardedObjectClassIndexPun R: scratchReg.
  		jumpNotForwarded := cogit JumpNonZero: 0.
  		"...follow the forwarding pointer and loop to fetch its classIndex"
  		cogit MoveMw: objectMemory baseHeaderSize r: instReg R: instReg.
  		cogit Jump: loop.
  		jumpNotForwarded jmpTarget: cogit Label].
  	jumpIsImm jmpTarget:
  	(cogit MoveR: scratchReg R: destReg).
  	scratchReg = TempReg
+ 		ifTrue:
+ 			[cogit PushR: instReg.
+ 			 self genGetClassObjectOfClassIndex: destReg into: instReg scratchReg: TempReg.
+ 			 cogit MoveR: instReg R: destReg.
+ 			 cogit PopR: instReg]
+ 		ifFalse:
+ 			[self genGetClassObjectOfClassIndex: destReg into: scratchReg scratchReg: TempReg.
+ 			 cogit MoveR: scratchReg R: destReg].
- 		ifTrue: [cogit PushR: instReg]
- 		ifFalse: [cogit MoveR: instReg R: scratchReg].
- 	self genGetClassObjectOfClassIndex: destReg into: instReg scratchReg: TempReg.
- 	cogit MoveR: instReg R: destReg.
- 	scratchReg = TempReg
- 		ifTrue: [cogit PopR: instReg]
- 		ifFalse: [cogit MoveR: scratchReg R: instReg].

Item was changed:
  ----- Method: CogRegisterAllocatingSimStackEntry>>reconcilePoppingWith: (in category 'compile abstract instructions') -----
+ reconcilePoppingWith: targetEntry
+ 	"Make the state of a targetEntry, a stack entry following a non-inlined special selector
+ 	 send, the same as the corresponding entry (the receiver) along the inlined path."
+ 	<var: #targetEntry type: #'targetEntry *'>
+ 	targetEntry spilled ifTrue:
+ 		[self assert: (self isSameEntryAs: targetEntry).
+ 		 targetEntry liveRegister = NoReg ifTrue:
+ 			[^self].
+ 		 type caseOf: {
+ 				[SSBaseOffset]	-> [cogit MoveMw: offset r: register R: targetEntry liveRegister].
+ 				[SSSpill]		-> [cogit MoveMw: offset r: register R: targetEntry liveRegister].
+ 				[SSConstant]	-> [cogit genMoveConstant: constant R: targetEntry liveRegister].
+ 				[SSRegister]	-> [targetEntry liveRegister ~= register ifTrue:
+ 										[cogit MoveR: register R: targetEntry liveRegister]] }.
+ 		 ^self].
+ 	targetEntry type = SSConstant ifTrue:
- reconcilePoppingWith: simStackEntry
- 	"Make the state of a simStackEntry, a stack entry along the inlined special selector path,
- 	 the same as the corresponding simStackEntry along the non-inlined path (the receiver)."
- 	<var: #simStackEntry type: #'SimStackEntry *'>
- 	simStackEntry type = SSConstant ifTrue:
  		[cogit AddCw: BytesPerWord R: SPReg.
+ 	targetEntry registerOrNone ~= NoReg ifTrue:
+ 		[cogit PopR: targetEntry registerOrNone.
- 	simStackEntry registerOrNone ~= NoReg ifTrue:
- 		[cogit PopR: simStackEntry registerOrNone.
  	self halt!

Item was changed:
  ----- Method: CogRegisterAllocatingSimStackEntry>>registerMaskOrNone (in category 'accessing') -----
  	liveRegister ~= NoReg ifTrue:
+ 		[^cogit registerMaskFor: liveRegister].
- 		[^cogit registerMaskFor: register].
  	^super registerMaskOrNone!

Item was changed:
  ----- Method: RegisterAllocatingCogit>>reconcileRegisterStateForJoinAfterSpecialSelectorSend (in category 'bytecode generator support') -----
  	"When the control flow from the inlined special selector code (e.g. add or comparison)
  	 joins the control flow from the send, taken when the inlined code fails, we should decide
  	 whether to reload any registers known to contain useful values or mark them as dead."
  	"If ReceiverResultReg is live along the inlined path, and is used before the next full send,
  	 reload it on the uncommon path."
  	scratchOptStatus isReceiverResultRegLive ifTrue:
  		[(self existsInstVarRefBeforeSendOrReturn
  		  or: [self receiverRefOnScratchSimStack])
  				[optStatus isReceiverResultRegLive: true.
  				 optStatus ssEntry storeToReg: ReceiverResultReg]
  			ifFalse: [optStatus isReceiverResultRegLive: false]].
  	"Restore the simStack to that in scratchSimStack,
  	 popping any spilled state back into allocated registers."
  	simSpillBase := scratchSpillBase.
  	simStackPtr to: 0 by: -1 do:
  		 self assert: (i = simStackPtr
  						ifTrue: [(self simStackAt: i) type = SSRegister]
  						ifFalse: [(self simStackAt: i) spilled]).
- 		 (self simStack: scratchSimStack at: i) spilled ifTrue:
- 			[self assert: ((self simStack: scratchSimStack at: i) isSameEntryAs: (self simStackAt: i)).
- 			 ^self].
  		 (self simStackAt: i) reconcilePoppingWith: (self simStack: scratchSimStack at: i).
  			at: i
  			put: (self
  					cCode: [scratchSimStack at: i]
  					inSmalltalk: [(scratchSimStack at: i) copy])]!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>allocateRegForStackEntryAt:notConflictingWith: (in category 'simulation stack') -----
  allocateRegForStackEntryAt: index notConflictingWith: regMask
  	"If the stack entry is already in a register not conflicting with regMask, answers it,
  	else allocate a new register not conflicting with reg mask"
  	<var: #stackEntry type: #'CogSimStackEntry *'>
  	| stackEntry mask |
  	stackEntry := self ssValue: index.
  	mask := stackEntry registerMaskOrNone.
  	(mask ~= 0 and: [mask noMask: regMask]) ifTrue: 
+ 		[^stackEntry registerOrNone].
- 		[^stackEntry register].
  	^self allocateRegNotConflictingWith: regMask!

More information about the Vm-dev mailing list