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

commits at source.squeak.org commits at source.squeak.org
Wed Oct 2 20:10:18 UTC 2013


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

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

Name: VMMaker.oscog-eem.425
Author: eem
Time: 2 October 2013, 1:07:23.528 pm
UUID: 0be2679f-a6b8-48d0-8ef2-27eb9b1f04fa
Ancestors: VMMaker.oscog-eem.424

Implement CogObjectRepresentationForSpur>>genInnerPrimitiveSize:.

Nuke a debugging halt.

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

Item was added:
+ ----- Method: CogObjectRepresentationFor32BitSpur>>genConvertIntegerToSmallIntegerInScratchReg: (in category 'compile abstract instructions') -----
+ genConvertIntegerToSmallIntegerInScratchReg: scratchReg
+ 	cogit LogicalShiftLeftCq: 1 R: scratchReg.
+ 	cogit AddCq: 1 R: scratchReg.
+ 	^0!

Item was added:
+ ----- Method: CogObjectRepresentationFor32BitSpur>>genConvertSmallIntegerToIntegerInScratchReg: (in category 'compile abstract instructions') -----
+ genConvertSmallIntegerToIntegerInScratchReg: scratchReg
+ 	cogit ArithmeticShiftRightCq: 1 R: scratchReg.
+ 	^0!

Item was added:
+ ----- Method: CogObjectRepresentationFor32BitSpur>>genGetSizeOf:into:formatReg:scratchReg:abortJumpsInto: (in category 'primitive generators') -----
+ genGetSizeOf: sourceReg into: destReg formatReg: formatReg scratchReg: scratchReg abortJumpsInto: aBinaryBlock
+ 	"Get the size of the non-immediate object in sourceReg into destReg using formatReg
+ 	 and scratchReg as temps.  None of these registers can overlap.  Supply the jumps
+ 	 taken if the object in sourceReg is not indexable, or if the object in sourceReg is a
+ 	 context.. Hack: If the object has a pointer format other than 2 leave the number of
+ 	 fixed fields in formatReg.  Used by primitiveSize, primitiveAt, and primitiveAtPut"
+ 	<returnTypeC: #'AbstractInstruction *'>
+ 	| jumpNotIndexable jumpSmallSize
+ 	  jumpBytesDone jumpShortsDone jumpArrayDone jump32BitLongsDone
+ 	  jumpIsBytes jumpHasFixedFields jumpIsShorts jumpIsContext  |
+ 	<inline: true>
+ 	"c.f. StackInterpreter>>stSizeOf: SpurMemoryManager>>lengthOf:format: fixedFieldsOf:format:length:"
+ 	<var: #jumpIsBytes type: #'AbstractInstruction *'>
+ 	<var: #jumpIsShorts type: #'AbstractInstruction *'>
+ 	<var: #jumpSmallSize type: #'AbstractInstruction *'>
+ 	<var: #jumpIsContext type: #'AbstractInstruction *'>
+ 	<var: #jumpArrayDone type: #'AbstractInstruction *'>
+ 	<var: #jumpNotIndexable type: #'AbstractInstruction *'>
+ 	<var: #jumpHasFixedFields type: #'AbstractInstruction *'>
+ 	<var: #jump32BitLongsDone type: #'AbstractInstruction *'>
+ 
+ 	cogit
+ 		MoveMw: 0 r: sourceReg R: formatReg;				"formatReg := least significant half of self baseHeader: receiver"
+ 		MoveR: formatReg R: scratchReg;
+ 		LogicalShiftRightCq: objectMemory formatShift R: formatReg;
+ 		AndCq: objectMemory formatMask R: formatReg.	"formatReg := self formatOfHeader: destReg"
+ 
+ 	"get numSlots into destReg."
+ 	cogit MoveMb: 7 r: sourceReg R: destReg. "MSB of header"
+ 	cogit CmpCq: objectMemory numSlotsMask R: destReg.
+ 	jumpSmallSize := cogit JumpLess: 0.
+ 	cogit MoveMw: -8 r: sourceReg R: destReg. "LSW of overflow size header"
+ 
+ 	"dispatch on format in a combination of highest dynamic frequency order first and convenience.
+ 		  0 = 0 sized objects (UndefinedObject True False et al)
+ 		  1 = non-indexable objects with inst vars (Point et al)
+ 		  2 = indexable objects with no inst vars (Array et al)
+ 		  3 = indexable objects with inst vars (MethodContext AdditionalMethodState et al)
+ 		  4 = weak indexable objects with inst vars (WeakArray et al)
+ 		  5 = weak non-indexable objects with inst vars (ephemerons) (Ephemeron)
+ 		  6 unused, reserved for exotic pointer objects?
+ 		  7 Forwarded Object, 1st field is pointer, rest of fields are ignored
+ 		  8 unused, reserved for exotic non-pointer objects?
+ 		  9 (?) 64-bit indexable
+ 		10 - 11 32-bit indexable
+ 		12 - 15 16-bit indexable
+ 		16 - 23 byte indexable
+ 		24 - 31 compiled method"
+ 	jumpSmallSize jmpTarget:
+ 					(cogit CmpCq: objectMemory firstByteFormat R: formatReg).
+ 	jumpIsBytes := cogit JumpGreaterOrEqual: 0.
+ 					cogit CmpCq: objectMemory arrayFormat R: formatReg.
+ 	jumpArrayDone := cogit JumpZero: 0.
+ 	jumpNotIndexable := cogit JumpLess: 0.
+ 					cogit CmpCq: objectMemory weakArrayFormat R: formatReg.
+ 	jumpHasFixedFields := cogit JumpLessOrEqual: 0.
+ 					cogit CmpCq: objectMemory firstShortFormat R: formatReg.
+ 	jumpIsShorts := cogit JumpGreaterOrEqual: 0.
+ 					cogit CmpCq: objectMemory firstLongFormat R: formatReg.
+ 	jump32BitLongsDone := cogit JumpGreaterOrEqual: 0.
+ 	"For now ignore 64-bit indexability."
+ 	jumpNotIndexable jmpTarget: cogit Label.
+ 	jumpNotIndexable := cogit Jump: 0.
+ 
+ 	jumpIsBytes jmpTarget:
+ 		(cogit LogicalShiftLeftCq: objectMemory shiftForWord R: destReg).
+ 		cogit AndCq: objectMemory wordSize - 1 R: formatReg.
+ 		cogit SubR: formatReg R: destReg.
+ 	jumpBytesDone := cogit Jump: 0.
+ 
+ 	jumpIsShorts jmpTarget:
+ 		(cogit LogicalShiftLeftCq: objectMemory shiftForWord - 1 R: destReg).
+ 		cogit AndCq: 1 R: formatReg.
+ 		cogit SubR: formatReg R: destReg.
+ 	jumpShortsDone := cogit Jump: 0.
+ 
+ 	jumpHasFixedFields jmpTarget:
+ 		(cogit AndCq: objectMemory classIndexMask R: scratchReg).
+ 	cogit CmpCq: ClassMethodContextCompactIndex R: scratchReg.
+ 	jumpIsContext := cogit JumpZero: 0.
+ 	scratchReg ~= TempReg ifTrue:
+ 		[cogit MoveR: scratchReg R: TempReg].
+ 	self flag: 'sometime soon we could inline the class fetch; it is only two indirections'.
+ 	cogit CallRT: ceClassAtIndexTrampoline.
+ 	scratchReg ~= TempReg ifTrue:
+ 		[cogit MoveR: TempReg R: scratchReg].
+ 	self genLoadSlot: InstanceSpecificationIndex sourceReg: scratchReg destReg: formatReg.
+ 	self genConvertSmallIntegerToIntegerInScratchReg: formatReg.
+ 	cogit
+ 		AndCq: objectMemory fixedFieldsOfClassFormatMask R: formatReg;
+ 		SubR: formatReg R: destReg.
+ 
+ 	jumpArrayDone jmpTarget:
+ 	(jump32BitLongsDone jmpTarget:
+ 	(jumpShortsDone jmpTarget:
+ 	(jumpBytesDone jmpTarget:
+ 		cogit Label))).
+ 	aBinaryBlock value: jumpNotIndexable value: jumpIsContext!

Item was changed:
  CogObjectRepresentation subclass: #CogObjectRepresentationForSpur
  	instanceVariableNames: 'ceClassAtIndexTrampoline'
  	classVariableNames: ''
+ 	poolDictionaries: 'VMSqueakClassIndices'
- 	poolDictionaries: ''
  	category: 'VMMaker-JIT'!

Item was added:
+ ----- Method: CogObjectRepresentationForSpur>>genInnerPrimitiveSize: (in category 'primitive generators') -----
+ genInnerPrimitiveSize: retNoffset
+ 	| jumpImm jumpNotIndexable jumpIsContext |
+ 	"c.f. StackInterpreter>>stSizeOf: lengthOf:baseHeader:format: fixedFieldsOf:format:length:"
+ 	<var: #jumpImm type: #'AbstractInstruction *'>
+ 	<var: #jumpNotIndexable type: #'AbstractInstruction *'>
+ 	<var: #jumpIsContext type: #'AbstractInstruction *'>
+ 	cogit MoveR: ReceiverResultReg R: TempReg.
+ 	jumpImm := self genJumpImmediateInScratchReg: TempReg.
+ 	self
+ 		genGetSizeOf: ReceiverResultReg
+ 		into: ClassReg
+ 		formatReg: SendNumArgsReg
+ 		scratchReg: TempReg
+ 		abortJumpsInto: [:jnx :jic| jumpNotIndexable := jnx. jumpIsContext := jic].
+ 	self genConvertIntegerToSmallIntegerInScratchReg: ClassReg.
+ 	cogit MoveR: ClassReg R: ReceiverResultReg.
+ 	self flag: 'currently caller pushes result'.
+ 	cogit RetN: retNoffset.
+ 	jumpImm jmpTarget: (jumpNotIndexable jmpTarget: (jumpIsContext jmpTarget: cogit Label)).
+ 	^0!

Item was added:
+ ----- Method: CogObjectRepresentationForSpur>>genJumpImmediateInScratchReg: (in category 'compile abstract instructions') -----
+ genJumpImmediateInScratchReg: aRegister
+ 	<returnTypeC: #'AbstractInstruction *'>
+ 	cogit AndCq: objectMemory tagMask R: aRegister.
+ 	^cogit JumpNonZero: 0!

Item was changed:
  ----- Method: CogObjectRepresentationForSqueakV3>>genGetSizeOf:into:formatReg:scratchReg:abortJumpsInto: (in category 'primitive generators') -----
  genGetSizeOf: sourceReg into: destReg formatReg: formatReg scratchReg: scratchReg abortJumpsInto: aBinaryBlock
  	"Get the size of the non-immediate object in sourceReg into destReg using formatReg
  	 and scratchReg as temps.  None of these registers can overlap.  Supply the jumps
  	 taken if the object in sourceReg is not indexable, or if the object in sourceReg is a
  	 context.. Hack: If the object has a pointer format other than 2 leave the number of
  	 fixed fields in formatReg.  Used by primitiveSize, primitiveAt, and primitiveAtPut"
  	<returnTypeC: #'AbstractInstruction *'>
  	| jumpNotIndexable jumpIsContext jumpShortHeader jumpSkip
+ 	  jumpFmtLeWeakArray jumpFmtIsArray jmpFmtGeFirstByte jumpGotByteSize jumpGotWordSize |
- 	  jumpFmtLe4 jumpFmtIs2 jmpFmtGe8 jumpGotByteSize jumpGotWordSize |
  	<inline: true>
  	"c.f. StackInterpreter>>stSizeOf: lengthOf:baseHeader:format: fixedFieldsOf:format:length:"
  	"and one wonders why Squeak V1 through V3 are slow..."
  	<var: #jumpNotIndexable type: #'AbstractInstruction *'>
  	<var: #jumpIsContext type: #'AbstractInstruction *'>
  	<var: #jumpShortHeader type: #'AbstractInstruction *'>
  	<var: #jumpSkip type: #'AbstractInstruction *'>
+ 	<var: #jumpFmtLeWeakArray type: #'AbstractInstruction *'>
+ 	<var: #jumpFmtIsArray type: #'AbstractInstruction *'>
+ 	<var: #jmpFmtGeFirstByte type: #'AbstractInstruction *'>
- 	<var: #jumpFmtLe4 type: #'AbstractInstruction *'>
- 	<var: #jumpFmtIs2 type: #'AbstractInstruction *'>
- 	<var: #jmpFmtGe8 type: #'AbstractInstruction *'>
  	<var: #jumpGotByteSize type: #'AbstractInstruction *'>
  	<var: #jumpGotWordSize type: #'AbstractInstruction *'>
  	cogit
  		MoveMw: 0 r: sourceReg R: formatReg;				"destReg := self baseHeader: receiver"
  		MoveR: formatReg R: destReg;
  		LogicalShiftRightCq: objectMemory instFormatFieldLSB R: formatReg;
  		AndCq: self instFormatFieldMask R: formatReg;		"formatReg := self formatOfHeader: destReg"
+ 		CmpCq: objectMemory arrayFormat R: formatReg.
- 		CmpCq: 2 R: formatReg.
  	jumpNotIndexable := cogit JumpLess: 0.
  	cogit
  		MoveR: destReg R: scratchReg;
  		LogicalShiftRightCq: objectMemory compactClassFieldLSB R: scratchReg;
  		AndCq: self compactClassFieldMask R: scratchReg;	"scratchReg := self compactClassIndexOfHeader: destReg"
  		CmpCq: ClassMethodContextCompactIndex R: scratchReg.
  	jumpIsContext := cogit JumpZero: 0.
  	cogit
  		MoveR: destReg R: scratchReg;
  		AndCq: TypeMask R: scratchReg;
  		CmpCq: HeaderTypeSizeAndClass R: scratchReg.	"(hdr bitAnd: TypeMask) = HeaderTypeSizeAndClass"
  	jumpShortHeader := cogit JumpNonZero: 0.
  	self assert: Size4Bit = 0.
  	cogit
  		MoveMw: 0 - (2 * BytesPerWord) r: sourceReg R: destReg; "(self sizeHeader: oop) bitAnd: LongSizeMask"
  		AndCq: LongSizeMask signedIntFromLong R: destReg.
  	jumpSkip :=  cogit Jump: 0.
  	jumpShortHeader jmpTarget: (cogit AndCq: SizeMask R: destReg).	"hdr bitAnd: SizeMask"
  	jumpSkip jmpTarget: (cogit SubCq: BaseHeaderSize R: destReg). "sz - BaseheaderSize for all three arms"
+ 	cogit CmpCq: objectMemory weakArrayFormat R: formatReg.	"fmt <= 4"
+ 	jumpFmtLeWeakArray := cogit JumpLessOrEqual: 0.
+ 	cogit CmpCq: objectMemory firstByteFormat R: formatReg.
+ 	jmpFmtGeFirstByte := cogit JumpLess: 0.
- 	cogit CmpCq: 4 R: formatReg.	"fmt <= 4"
- 	jumpFmtLe4 := cogit JumpLessOrEqual: 0.
- 	cogit CmpCq: 8 R: formatReg.
- 	jmpFmtGe8 := cogit JumpLess: 0.
  	cogit
  		AndCq: 3 R: formatReg;	"(sz - BaseHeaderSize) - (fmt bitAnd: 3) bytes"
  		SubR: formatReg R: destReg.
  	jumpGotByteSize := cogit Jump: 0.
+ 	jmpFmtGeFirstByte jmpTarget: (cogit LogicalShiftRightCq: 2 R: destReg). "(sz - BaseHeaderSize) >> 2 32-bit longs"
- 	jmpFmtGe8 jmpTarget: (cogit LogicalShiftRightCq: 2 R: destReg). "(sz - BaseHeaderSize) >> 2 32-bit longs"
  	jumpGotWordSize := cogit Jump: 0.
+ 	jumpFmtLeWeakArray jmpTarget: cogit Label.
- 	jumpFmtLe4 jmpTarget: cogit Label.
  	cogit
  		LogicalShiftRightCq: ShiftForWord R: destReg; "(sz - BaseHeaderSize) >> ShiftForWord words"
+ 		CmpCq: objectMemory arrayFormat R: formatReg.
+ 	jumpFmtIsArray := cogit JumpZero: 0.
- 		CmpCq: 2 R: formatReg.
- 	jumpFmtIs2 := cogit JumpZero: 0.
  	self genGetFixedFieldsOfPointerNonInt: sourceReg into: formatReg scratchReg: scratchReg.
  	cogit SubR: formatReg R: destReg.
+ 	jumpFmtIsArray jmpTarget:
- 	jumpFmtIs2 jmpTarget:
  	(jumpGotWordSize jmpTarget:
  	(jumpGotByteSize jmpTarget:
  		cogit Label)).
  	aBinaryBlock value: jumpNotIndexable value: jumpIsContext!

Item was changed:
  ----- Method: CogObjectRepresentationForSqueakV3>>genInnerPrimitiveSize: (in category 'primitive generators') -----
  genInnerPrimitiveSize: retNoffset
+ 	| jumpSI jumpNotIndexable jumpIsContext |
- 	| jumpNotSI jumpNotIndexable jumpIsContext |
  	"c.f. StackInterpreter>>stSizeOf: lengthOf:baseHeader:format: fixedFieldsOf:format:length:"
  	<var: #jumpNotSI type: #'AbstractInstruction *'>
  	<var: #jumpNotIndexable type: #'AbstractInstruction *'>
  	<var: #jumpIsContext type: #'AbstractInstruction *'>
  	cogit MoveR: ReceiverResultReg R: TempReg.
+ 	jumpSI := self genJumpSmallIntegerInScratchReg: TempReg.
- 	jumpNotSI := self genJumpSmallIntegerInScratchReg: TempReg.
  	self
  		genGetSizeOf: ReceiverResultReg
  		into: ClassReg
  		formatReg: SendNumArgsReg
  		scratchReg: TempReg
  		abortJumpsInto: [:jnx :jic| jumpNotIndexable := jnx. jumpIsContext := jic].
  	self genConvertIntegerToSmallIntegerInScratchReg: ClassReg.
  	cogit MoveR: ClassReg R: ReceiverResultReg.
  	self flag: 'currently caller pushes result'.
  	cogit RetN: retNoffset.
+ 	jumpSI jmpTarget: (jumpNotIndexable jmpTarget: (jumpIsContext jmpTarget: cogit Label)).
- 	jumpNotSI jmpTarget: (jumpNotIndexable jmpTarget: (jumpIsContext jmpTarget: cogit Label)).
  	^0!

Item was changed:
  ----- Method: Cogit>>cog:selector: (in category 'jit - api') -----
  cog: aMethodObj selector: aSelectorOop
  	"Attempt to produce a machine code method for the bytecode method
  	 object aMethodObj.  N.B. If there is no code memory available do *NOT*
  	 attempt to reclaim the method zone.  Certain clients (e.g. ceSICMiss:)
  	 depend on the zone remaining constant across method generation."
  	<api>
  	<returnTypeC: #'CogMethod *'>
  	| cogMethod |
  	<var: #cogMethod type: #'CogMethod *'>
  	self assert: ((coInterpreter methodHasCogMethod: aMethodObj) not
  				or: [(self noAssertMethodClassAssociationOf: aMethodObj) = objectMemory nilObject]).
- 	aSelectorOop = (coInterpreter specialSelector: 16) ifTrue: [self halt].
  	"coInterpreter stringOf: aSelectorOop"
  	coInterpreter
  		compilationBreak: aSelectorOop
  		point: (objectMemory lengthOf: aSelectorOop).
  	aMethodObj = breakMethod ifTrue: [self halt: 'Compilation of breakMethod'].
  	self cppIf: NewspeakVM
  		ifTrue: [cogMethod := methodZone findPreviouslyCompiledVersionOf: aMethodObj with: aSelectorOop.
  				cogMethod ifNotNil:
  					[(coInterpreter methodHasCogMethod: aMethodObj) not ifTrue:
  						[self assert: (coInterpreter rawHeaderOf: aMethodObj) = cogMethod methodHeader.
  						 cogMethod methodObject: aMethodObj.
  						 coInterpreter rawHeaderOf: aMethodObj put: cogMethod asInteger].
  					^cogMethod]].
  	"If the generators for the alternate bytecode set are missing then interpret."
  	(coInterpreter methodUsesAlternateBytecodeSet: aMethodObj)
  		ifTrue:
  			[(self numElementsIn: generatorTable) <= 256 ifTrue:
  				[^nil].
  			 bytecodeSetOffset := 256]
  		ifFalse:
  			[bytecodeSetOffset := 0].
  	extA := extB := 0.
  	methodObj := aMethodObj.
  	cogMethod := self compileCogMethod: aSelectorOop.
  	(cogMethod asInteger between: MaxNegativeErrorCode and: -1) ifTrue:
  		[cogMethod asInteger = InsufficientCodeSpace ifTrue:
  			[coInterpreter callForCogCompiledCodeCompaction].
  		"Right now no errors should be reported, so nothing more to do."
  		"self reportError: (self cCoerceSimple: cogMethod to: #sqInt)."
  		 ^nil].
  	"self cCode: ''
  		inSmalltalk:
  			[coInterpreter printCogMethod: cogMethod.
  			 ""coInterpreter symbolicMethod: aMethodObj.""
  			 self assertValidMethodMap: cogMethod."
  			 "self disassembleMethod: cogMethod."
  			 "printInstructions := clickConfirm := true""]."
  	^cogMethod!



More information about the Vm-dev mailing list