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

commits at source.squeak.org commits at source.squeak.org
Sun Jun 1 18:30:11 UTC 2014


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.744.mcz

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

Name: VMMaker.oscog-eem.744
Author: eem
Time: 1 June 2014, 11:27:29.023 am
UUID: 22b7a9e4-4046-41fd-a835-969d865245e0
Ancestors: VMMaker.oscog-eem.743

In Spur refactor closure creeation in the Cogit to not flush
copied values to the stack, assigning them direct to the
closure.  Generates much more compact code.

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

Item was added:
+ ----- Method: CogObjectRepresentation>>createsClosuresInline (in category 'bytecode generator support') -----
+ createsClosuresInline
+ 	"Answer if the object representation allocates closures inline.  By
+ 	 default answer false. Better code can be generated when creating
+ 	 closures inline if copied values are /not/ flushed to the stack."
+ 	^false!

Item was added:
+ ----- Method: CogObjectRepresentationFor32BitSpur>>createsClosuresInline (in category 'bytecode generator support') -----
+ createsClosuresInline
+ 	"Answer if the object representation allocates closures inline.  By
+ 	 default answer false. Better code can be generated when creating
+ 	 closures inline if copied values are /not/ flushed to the stack."
+ 	^true!

Item was changed:
  ----- Method: CogObjectRepresentationFor32BitSpur>>genCreateClosureAt:numArgs:numCopied:contextNumArgs:large:inBlock: (in category 'bytecode generator support') -----
  genCreateClosureAt: bcpc numArgs: numArgs numCopied: numCopied contextNumArgs: ctxtNumArgs large: isLargeCtxt inBlock: isInBlock
  	"Create a closure with the given startpc, numArgs and numCopied
  	 within a context with ctxtNumArgs, large if isLargeCtxt that is in a
  	 block if isInBlock.  If numCopied > 0 pop those values off the stack."
+ 	self genNoPopCreateClosureAt: bcpc
+ 		numArgs: numArgs
+ 		numCopied: numCopied
+ 		contextNumArgs: ctxtNumArgs
+ 		large: isLargeCtxt
+ 		inBlock: isInBlock.
- 	| slotSize header skip |
- 	<var: #skip type: #'AbstractInstruction *'>
- 
- 	"First get thisContext into ReceiverResultRega and thence in ClassReg."
- 	self genGetActiveContextNumArgs: ctxtNumArgs large: isLargeCtxt inBlock: isInBlock.
- 	cogit MoveR: ReceiverResultReg R: ClassReg.
- 
- 	slotSize := ClosureFirstCopiedValueIndex + numCopied.
- 	header := objectMemory
- 					headerForSlots: slotSize
- 					format: objectMemory indexablePointersFormat
- 					classIndex: ClassBlockClosureCompactIndex.
- 	cogit
- 		MoveAw: objectMemory freeStartAddress R: ReceiverResultReg;
- 		MoveCq: (self cCoerceSimple: header to: #usqInt) R: TempReg;
- 		MoveR: TempReg Mw: 0 r: ReceiverResultReg;
- 		MoveCq: header >> 32 R: TempReg;
- 		MoveR: TempReg Mw: 4 r: ReceiverResultReg;
- 		MoveR: ReceiverResultReg R: TempReg;
- 		AddCq: (objectMemory smallObjectBytesForSlots: slotSize) R: TempReg;
- 		MoveR: TempReg Aw: objectMemory freeStartAddress;
- 		CmpCq: objectMemory getScavengeThreshold R: TempReg.
- 	skip := cogit JumpBelow: 0.
- 	cogit CallRT: ceSheduleScavengeTrampoline.
- 	skip jmpTarget: cogit Label.
- 
- 	cogit
- 		MoveR: ClassReg Mw: ClosureOuterContextIndex * BytesPerOop + BaseHeaderSize r: ReceiverResultReg;
- 		MoveCq: (objectMemory integerObjectOf: bcpc) R: TempReg;
- 		MoveR: TempReg Mw: ClosureStartPCIndex * BytesPerOop + BaseHeaderSize r: ReceiverResultReg;
- 		MoveCq: (objectMemory integerObjectOf: numArgs) R: TempReg;
- 		MoveR: TempReg Mw: ClosureNumArgsIndex * BytesPerOop + BaseHeaderSize r: ReceiverResultReg.
  	1 to: numCopied do:
  		[:i|
  		cogit
  			PopR: TempReg;
  			MoveR: TempReg
  				Mw: numCopied - i + ClosureFirstCopiedValueIndex * BytesPerOop + BaseHeaderSize
  					r: ReceiverResultReg].
  	^0!

Item was added:
+ ----- Method: CogObjectRepresentationFor32BitSpur>>genNoPopCreateClosureAt:numArgs:numCopied:contextNumArgs:large:inBlock: (in category 'bytecode generator support') -----
+ genNoPopCreateClosureAt: bcpc numArgs: numArgs numCopied: numCopied contextNumArgs: ctxtNumArgs large: isLargeCtxt inBlock: isInBlock
+ 	"Create a closure with the given startpc, numArgs and numCopied
+ 	 within a context with ctxtNumArgs, large if isLargeCtxt that is in a
+ 	 block if isInBlock.  Do /not/ initialize the copied values."
+ 	| slotSize header skip |
+ 	<var: #skip type: #'AbstractInstruction *'>
+ 
+ 	"First get thisContext into ReceiverResultRega and thence in ClassReg."
+ 	self genGetActiveContextNumArgs: ctxtNumArgs large: isLargeCtxt inBlock: isInBlock.
+ 	cogit MoveR: ReceiverResultReg R: ClassReg.
+ 
+ 	slotSize := ClosureFirstCopiedValueIndex + numCopied.
+ 	header := objectMemory
+ 					headerForSlots: slotSize
+ 					format: objectMemory indexablePointersFormat
+ 					classIndex: ClassBlockClosureCompactIndex.
+ 	cogit
+ 		MoveAw: objectMemory freeStartAddress R: ReceiverResultReg;
+ 		MoveCq: (self cCoerceSimple: header to: #usqInt) R: TempReg;
+ 		MoveR: TempReg Mw: 0 r: ReceiverResultReg;
+ 		MoveCq: header >> 32 R: TempReg;
+ 		MoveR: TempReg Mw: 4 r: ReceiverResultReg;
+ 		MoveR: ReceiverResultReg R: TempReg;
+ 		AddCq: (objectMemory smallObjectBytesForSlots: slotSize) R: TempReg;
+ 		MoveR: TempReg Aw: objectMemory freeStartAddress;
+ 		CmpCq: objectMemory getScavengeThreshold R: TempReg.
+ 	skip := cogit JumpBelow: 0.
+ 	cogit CallRT: ceSheduleScavengeTrampoline.
+ 	skip jmpTarget: cogit Label.
+ 
+ 	cogit
+ 		MoveR: ClassReg Mw: ClosureOuterContextIndex * BytesPerOop + BaseHeaderSize r: ReceiverResultReg;
+ 		MoveCq: (objectMemory integerObjectOf: bcpc) R: TempReg;
+ 		MoveR: TempReg Mw: ClosureStartPCIndex * BytesPerOop + BaseHeaderSize r: ReceiverResultReg;
+ 		MoveCq: (objectMemory integerObjectOf: numArgs) R: TempReg;
+ 		MoveR: TempReg Mw: ClosureNumArgsIndex * BytesPerOop + BaseHeaderSize r: ReceiverResultReg.
+ 	^0!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPushClosureCopyCopiedValuesBytecode (in category 'bytecode generators') -----
  genPushClosureCopyCopiedValuesBytecode
  	"Block compilation.  At this point in the method create the block.  Note its start
  	 and defer generating code for it until after the method and any other preceeding
  	 blocks.  The block's actual code will be compiled later."
  	"143   10001111 llllkkkk jjjjjjjj iiiiiiii	Push Closure Num Copied llll Num Args kkkk BlockSize jjjjjjjjiiiiiiii"
  	| numArgs numCopied |
  	self assert: needsFrame.
  	self addBlockStartAt: bytecodePC + 4 "0 relative"
  		numArgs: (numArgs := byte1 bitAnd: 16rF)
  		numCopied: (numCopied := byte1 >> 4)
  		span: (byte2 << 8) + byte3.
+ 
+ 	objectRepresentation createsClosuresInline ifTrue:
+ 		[self assert: objectRepresentation getActiveContextAllocatesInMachineCode.
+ 		 optStatus isReceiverResultRegLive: false.
+ 		 self ssAllocateCallReg: ReceiverResultReg
+ 			and: SendNumArgsReg
+ 			and: ClassReg.
+ 		 objectRepresentation
+ 			genNoPopCreateClosureAt: bytecodePC + 5 "1 relative"
+ 			numArgs: numArgs
+ 			numCopied: numCopied
+ 			contextNumArgs: methodOrBlockNumArgs
+ 			large: (coInterpreter methodNeedsLargeContext: methodObj)
+ 			inBlock: inBlock.
+ 		 1 to: numCopied do:
+ 			[:i| | reg |
+ 			 reg := self ssStorePop: true toPreferredReg: TempReg.
+ 			 objectRepresentation
+ 				genStoreSourceReg: reg
+ 				slotIndex: ClosureFirstCopiedValueIndex + numCopied - i
+ 				intoNewObjectInDestReg: ReceiverResultReg].
+ 		 ^self ssPushRegister: ReceiverResultReg].
+ 
  	numCopied > 0 ifTrue:
  		[self ssFlushTo: simStackPtr].
  	optStatus isReceiverResultRegLive: false.
  	objectRepresentation getActiveContextAllocatesInMachineCode
  		ifTrue: [self ssAllocateCallReg: ReceiverResultReg
  					and: SendNumArgsReg
  					and: ClassReg]
  		ifFalse: [self ssAllocateCallReg: SendNumArgsReg
  					and: ReceiverResultReg].
  	objectRepresentation
  		genCreateClosureAt: bytecodePC + 5 "1 relative"
  		numArgs: numArgs
  		numCopied: numCopied
  		contextNumArgs: methodOrBlockNumArgs
  		large: (coInterpreter methodNeedsLargeContext: methodObj)
  		inBlock: inBlock.
  	numCopied > 0 ifTrue:
  		[self ssPop: numCopied].
  	^self ssPushRegister: ReceiverResultReg!



More information about the Vm-dev mailing list