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

commits at source.squeak.org commits at source.squeak.org
Wed Dec 16 05:19:17 UTC 2015


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

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

Name: VMMaker.oscog-eem.1598
Author: eem
Time: 15 December 2015, 9:17:32.657 pm
UUID: 247e48e6-ff12-40b9-b6f8-8f8e9b45c4a3
Ancestors: VMMaker.oscog-eem.1597

x64 Cogit:
Refactor compileOpenPIC:numArgs: to pull three probe generation sequences out into a single method.  Use a base register to point to the method cache if MoveMw:r:R: offsets aren't large enough to access the method cache (as may be the case on 64-bit systems).  Add CogAbstractInstruction>>isWithinMwOffsetRange: to answer if offsets are within the MoveMw:r:R: range.

Use the same base reg approach to dereference the class table in genGetClassObjectOfClassIndex:into:scratchReg:.

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

Item was added:
+ ----- Method: CogAbstractInstruction>>isWithinMwOffsetRange: (in category 'testing') -----
+ isWithinMwOffsetRange: address
+ 	"Answer if an address can be accessed using the offset in a MoveMw:r:R: or similar instruction.
+ 	 We assume this is true for 32-bit processors and expect 64-bit processors to answer false
+ 	 for values in the interpreter or the object memory."
+ 
+ 	^true!

Item was changed:
  ----- Method: CogObjectRepresentationForSpur>>genGetClassObjectOfClassIndex:into:scratchReg: (in category 'compile abstract instructions') -----
  genGetClassObjectOfClassIndex: instReg into: destReg scratchReg: scratchReg
  	"Fetch the class object whose index is in instReg into destReg.
  	 It is non-obvious, but the Cogit assumes loading a class does not involve
  	 a runtime call, so do not call classAtIndex:"
  	self assert: instReg ~= destReg.
  	self assert: instReg ~= scratchReg.
  	self assert: destReg ~= scratchReg.
  	cogit
  		MoveR: instReg R: scratchReg;
  		LogicalShiftRightCq: objectMemory classTableMajorIndexShift R: scratchReg;
  		LogicalShiftLeftCq: objectMemory shiftForWord R: scratchReg.
  	self assert: (self shouldAnnotateObjectReference: objectMemory classTableRootObj) not.
+ 	(cogit backEnd isWithinMwOffsetRange: objectMemory classTableRootObj + objectMemory baseHeaderSize)
+ 		ifTrue: [cogit MoveMw: objectMemory classTableRootObj + objectMemory baseHeaderSize r: scratchReg R: destReg]
+ 		ifFalse: [cogit
+ 					AddCq: objectMemory classTableRootObj R: scratchReg;
+ 					MoveMw: objectMemory baseHeaderSize r: scratchReg R: destReg].
  	cogit
- 		MoveMw: objectMemory classTableRootObj + objectMemory baseHeaderSize r: scratchReg R: destReg;
  		MoveR: instReg R: scratchReg;
  		AndCq: objectMemory classTableMinorIndexMask R: scratchReg;
  		AddCq: objectMemory baseHeaderSize >> objectMemory shiftForWord R: scratchReg;
  		MoveXwr: scratchReg R: destReg R: destReg.
  	^0!

Item was added:
+ ----- Method: CogX64Compiler>>isWithinMwOffsetRange: (in category 'testing') -----
+ isWithinMwOffsetRange: address
+ 	"Answer if an address can be accessed using the offset in a MoveMw:r:R: or similar instruction.
+ 	 We assume this is true for 32-bit processors and expect 64-bit processors to answer false
+ 	 for values in the interpreter or the object memory."
+ 
+ 	^address asUnsignedInteger < cogit methodZone zoneEnd!

Item was added:
+ ----- Method: CurrentImageCoInterpreterFacade>>unalignedLongAt: (in category 'accessing') -----
+ unalignedLongAt: anInteger
+ 	^objectMemory unalignedLongAt: anInteger!

Item was added:
+ ----- Method: CurrentImageCoInterpreterFacade>>unalignedLongAt:put: (in category 'accessing') -----
+ unalignedLongAt: anInteger put: value
+ 	^objectMemory unalignedLongAt: anInteger put: value!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>compileOpenPIC:numArgs: (in category 'in-line cacheing') -----
  compileOpenPIC: selector numArgs: numArgs
  	"Compile the code for an open PIC.  Perform a probe of the first-level method
  	 lookup cache followed by a call of ceSendFromInLineCacheMiss: if the probe fails."
+ 	| cacheBaseReg jumpSelectorMiss jumpClassMiss itsAHit jumpBCMethod |
- 	| jumpSelectorMiss jumpClassMiss itsAHit jumpBCMethod |
  	<var: #jumpSelectorMiss type: #'AbstractInstruction *'>
  	<var: #jumpClassMiss type: #'AbstractInstruction *'>
  	<var: #itsAHit type: #'AbstractInstruction *'>
  	<var: #jumpBCMethod type: #'AbstractInstruction *'>
  	self compilePICAbort: numArgs.
  	entry := objectRepresentation genGetClassTagOf: ReceiverResultReg into: ClassReg scratchReg: TempReg.
+ 	self MoveR: ClassReg R: SendNumArgsReg.
  
- 	"Do first of three probes.  See CoInterpreter>>lookupInMethodCacheSel:classTag:"
  	self flag: #lookupInMethodCacheSel:classTag:. "so this method shows up as a sender of lookupInMethodCacheSel:class:"
+ 
+ 	cacheBaseReg := NoReg.
+ 	(backEnd isWithinMwOffsetRange: coInterpreter methodCacheAddress) ifFalse:
+ 		[self MoveCq: coInterpreter methodCacheAddress R: (cacheBaseReg := Scratch0Reg)].
+ 
+ 	"Do first of three probes.  See CoInterpreter>>lookupInMethodCacheSel:classTag:"
+ 	jumpSelectorMiss := self compileOpenPICMethodCacheProbeFor: selector withShift: 0 baseRegOrNone: cacheBaseReg.
- 	self MoveR: ClassReg R: SendNumArgsReg.
- 	self annotate: (self XorCw: selector R: ClassReg) objRef: selector.
- 	self LogicalShiftLeftCq: objectMemory shiftForWord R: ClassReg.
- 	self AndCq: MethodCacheMask << objectMemory shiftForWord R: ClassReg.
- 	self MoveMw: coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheSelector << objectMemory shiftForWord)
- 		r: ClassReg
- 		R: TempReg.
- 	self annotate: (self CmpCw: selector R: TempReg) objRef: selector.
- 	jumpSelectorMiss := self JumpNonZero: 0.
- 	self MoveMw: coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheClass << objectMemory shiftForWord)
- 		r: ClassReg
- 		R: TempReg.
- 	self CmpR: SendNumArgsReg R: TempReg.
  	jumpClassMiss := self JumpNonZero: 0.
  
- 	itsAHit := self Label.
  	"Fetch the method.  The interpret trampoline requires the bytecoded method in SendNumArgsReg"
+ 	itsAHit := self MoveMw: (cacheBaseReg = NoReg
+ 								ifTrue: [coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheMethod << objectMemory shiftForWord)]
+ 								ifFalse: [MethodCacheMethod << objectMemory shiftForWord])
+ 					r: ClassReg
+ 					R: SendNumArgsReg.
+ 			.
- 	self MoveMw: coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheMethod << objectMemory shiftForWord)
- 		r: ClassReg
- 		R: SendNumArgsReg.
  	"If the method is compiled jump to its unchecked entry-point, otherwise interpret it."
  	objectRepresentation genLoadSlot: HeaderIndex sourceReg: SendNumArgsReg destReg: ClassReg.
  	jumpBCMethod := objectRepresentation genJumpImmediate: ClassReg.
  	jumpBCMethod jmpTarget: picInterpretAbort.
  	self AddCq: cmNoCheckEntryOffset R: ClassReg.
  	self JumpR: ClassReg.
  
  	"First probe missed.  Do second of three probes.  Shift hash right one and retry."
  	jumpSelectorMiss jmpTarget: (jumpClassMiss jmpTarget: self Label).
+ 	jumpSelectorMiss := self compileOpenPICMethodCacheProbeFor: selector withShift: 1 baseRegOrNone: cacheBaseReg.
- 	self MoveR: SendNumArgsReg R: ClassReg.
- 	self annotate: (self XorCw: selector R: ClassReg) objRef: selector.
- 	self LogicalShiftLeftCq: objectMemory shiftForWord - 1 R: ClassReg.
- 	self AndCq: MethodCacheMask << objectMemory shiftForWord R: ClassReg.
- 	self MoveMw: coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheSelector << objectMemory shiftForWord)
- 		r: ClassReg
- 		R: TempReg.
- 	self annotate: (self CmpCw: selector R: TempReg) objRef: selector.
- 	jumpSelectorMiss := self JumpNonZero: 0.
- 	self MoveMw: coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheClass << objectMemory shiftForWord)
- 		r: ClassReg
- 		R: TempReg.
- 	self CmpR: SendNumArgsReg R: TempReg.
  	self JumpZero: itsAHit.
  
  	"Second probe missed.  Do last probe.  Shift hash right two and retry."
  	jumpSelectorMiss jmpTarget: self Label.
+ 	jumpSelectorMiss := self compileOpenPICMethodCacheProbeFor: selector withShift: 2 baseRegOrNone: cacheBaseReg.
- 	self MoveR: SendNumArgsReg R: ClassReg.
- 	self annotate: (self XorCw: selector R: ClassReg) objRef: selector.
- 	objectMemory shiftForWord > 2 ifTrue:
- 		[self LogicalShiftLeftCq: objectMemory shiftForWord - 1 R: ClassReg].
- 	self AndCq: MethodCacheMask << objectMemory shiftForWord R: ClassReg.
- 	self MoveMw: coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheSelector << objectMemory shiftForWord)
- 		r: ClassReg
- 		R: TempReg.
- 	self annotate: (self CmpCw: selector R: TempReg) objRef: selector.
- 	jumpSelectorMiss := self JumpNonZero: 0.
- 	self MoveMw: coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheClass << objectMemory shiftForWord)
- 		r: ClassReg
- 		R: TempReg.
- 	self CmpR: SendNumArgsReg R: TempReg.
  	self JumpZero: itsAHit.
  
  	"Last probe missed.  Call ceSendFromInLineCacheMiss: to do the full lookup."
  	jumpSelectorMiss jmpTarget: self Label.
  	self numRegArgs > 0 ifTrue:
  		[backEnd genPushRegisterArgsForNumArgs: numArgs scratchReg: SendNumArgsReg].
  	self genSmalltalkToCStackSwitch: true.
  	methodLabel addDependent: (self annotateAbsolutePCRef: (self MoveCw: methodLabel asInteger R: SendNumArgsReg)).
  	self 
  		compileCallFor: #ceSendFromInLineCacheMiss:
  		numArgs: 1
  		arg: SendNumArgsReg
  		arg: nil
  		arg: nil
  		arg: nil
  		resultReg: NoReg
  		saveRegs: false
  	"Note that this call does not return."!

Item was added:
+ ----- Method: SimpleStackBasedCogit>>compileOpenPICMethodCacheProbeFor:withShift:baseRegOrNone: (in category 'in-line cacheing') -----
+ compileOpenPICMethodCacheProbeFor: selector withShift: shift baseRegOrNone: baseRegOrNone
+ 	"Compile one method cache probe in an OpenPIC's lookup of selector.  Answer the jump taken if the selector probe fails."
+ 	<returnTypeC: #'AbstractInstruction *'>
+ 	| jumpSelectorMiss |
+ 	<var: 'jumpSelectorMiss' type: #'AbstractInstruction *'>
+ 	self MoveR: SendNumArgsReg R: ClassReg.
+ 	self annotate: (self XorCw: selector R: ClassReg) objRef: selector.
+ 	objectMemory shiftForWord > shift ifTrue:
+ 		[self LogicalShiftLeftCq: objectMemory shiftForWord - shift R: ClassReg].
+ 	self AndCq: MethodCacheMask << objectMemory shiftForWord R: ClassReg.
+ 	baseRegOrNone = NoReg
+ 		ifTrue:
+ 			[self MoveMw: coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheSelector << objectMemory shiftForWord)
+ 				r: ClassReg
+ 				R: TempReg]
+ 		ifFalse:
+ 			[self AddR: baseRegOrNone R: ClassReg;
+ 				MoveMw: MethodCacheSelector << objectMemory shiftForWord r: ClassReg R: TempReg].
+ 	self annotate: (self CmpCw: selector R: TempReg) objRef: selector.
+ 	jumpSelectorMiss := self JumpNonZero: 0.
+ 	baseRegOrNone = NoReg
+ 		ifTrue:
+ 			[self MoveMw: coInterpreter methodCacheAddress asUnsignedInteger + (MethodCacheClass << objectMemory shiftForWord)
+ 				r: ClassReg
+ 				R: TempReg]
+ 		ifFalse:
+ 			[self MoveMw: MethodCacheClass << objectMemory shiftForWord r: ClassReg R: TempReg].
+ 	self CmpR: SendNumArgsReg R: TempReg.
+ 	^jumpSelectorMiss!



More information about the Vm-dev mailing list