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

commits at source.squeak.org commits at source.squeak.org
Sat Jan 2 05:13:57 UTC 2021


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

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

Name: VMMaker.oscog-eem.2915
Author: eem
Time: 1 January 2021, 9:13:50.54602 pm
UUID: 58f28da2-d908-4533-971a-8d938c1bcc78
Ancestors: VMMaker.oscog-nice.2914

Spur Cogit:
Fix the broken value range checking code wot I wrote for signed bits array at:put:.

Simulation:
Fix mapping of break pcs on code compaction when break pc is an array of pcs.

=============== Diff against VMMaker.oscog-nice.2914 ===============

Item was changed:
  ----- Method: CogObjectRepresentationFor32BitSpur>>genPrimitiveAtPutSigned: (in category 'primitive generators') -----
  genPrimitiveAtPutSigned: signedVersion
  	"Generate the code for primitives 61 & 165, at:put:/basicAt:put: & integerAt:put:.  If signedVersion is true
  	 then generate signed accesses to the bits classes (a la 164 & 165).  If signedVersion is false,
  	 generate unsigned accesses (a la 60, 61, 63 & 64)."
  	| formatReg nSlotsOrBytesReg methodInBounds
  	  jumpImmediate jumpBadIndex jumpImmutable jumpNotIndexablePointers jumpNotIndexableBits
  	  jumpIsContext jumpIsCompiledMethod jumpIsBytes jumpIsShorts jumpHasFixedFields
  	  jumpArrayOutOfBounds jumpFixedFieldsOutOfBounds
  	  jumpWordsOutOfBounds jumpShortsOutOfBounds jumpBytesOutOfBounds
  	  jumpShortsOutOfRange jumpWordsOutOfRange jumpBytesOutOfRange
  	  jumpNonSmallIntegerValue jumpNotPointers
  	  |
+ 	self break.
  	"c.f. StackInterpreter>>stSizeOf: SpurMemoryManager>>lengthOf:format: fixedFieldsOf:format:length:"
  
  	nSlotsOrBytesReg := ClassReg.
  
  	cogit genLoadArgAtDepth: 1 into: Arg0Reg.
  	cogit genLoadArgAtDepth: 0 into: Arg1Reg.
  	jumpImmediate := self genJumpImmediate: ReceiverResultReg.
  	jumpBadIndex := self genJumpNotSmallInteger: Arg0Reg scratchReg: TempReg.
  	self genConvertSmallIntegerToIntegerInReg: Arg0Reg.
  	cogit SubCq: 1 R: Arg0Reg. "1-rel => 0-rel"
  
  	"formatReg := self formatOf: ReceiverResultReg"
  	self cppIf: IMMUTABILITY
  		ifTrue:
  		[ self genGetFormatOf: ReceiverResultReg
  			into: (formatReg := SendNumArgsReg)
  			leastSignificantHalfOfBaseHeaderIntoScratch: TempReg.
  		jumpImmutable := self genJumpBaseHeaderImmutable: TempReg ]
  		ifFalse: 
  		[ self genGetFormatOf: ReceiverResultReg
  			into: (formatReg := SendNumArgsReg)
  			leastSignificantHalfOfBaseHeaderIntoScratch: NoReg ].
  
  	self genGetNumSlotsOf: ReceiverResultReg into: nSlotsOrBytesReg.
  
  	"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"
  	cogit CmpCq: objectMemory weakArrayFormat R: formatReg.
  	jumpNotPointers := cogit JumpAbove: 0.
  	"optimistic store check; assume index in range (almost always is)."
  	self genStoreCheckReceiverReg: ReceiverResultReg
  		valueReg: Arg1Reg
  		scratchReg: TempReg
  		inFrame: false.
  
  	cogit CmpCq: objectMemory arrayFormat R: formatReg.
  	jumpNotIndexablePointers := cogit JumpBelow: 0.
  	jumpHasFixedFields := cogit JumpNonZero: 0.
  	cogit CmpR: Arg0Reg R: nSlotsOrBytesReg.
  	jumpArrayOutOfBounds := cogit JumpBelowOrEqual: 0.
  	cogit AddCq: objectMemory baseHeaderSize >> objectMemory shiftForWord R: Arg0Reg.
  	cogit MoveR: Arg1Reg Xwr: Arg0Reg R: ReceiverResultReg.
  	cogit MoveR: Arg1Reg R: ReceiverResultReg.
  	cogit genPrimReturn.
  
  	jumpHasFixedFields jmpTarget: cogit Label.
  	self genGetClassIndexOfNonImm: ReceiverResultReg into: formatReg.
  	cogit CmpCq: ClassMethodContextCompactIndex R: formatReg.
  	jumpIsContext := cogit JumpZero: 0.
  	"get # fixed fields in formatReg"
  	cogit PushR: nSlotsOrBytesReg.
  	self genGetClassObjectOfClassIndex: formatReg into: nSlotsOrBytesReg scratchReg: TempReg.
  	self genLoadSlot: InstanceSpecificationIndex sourceReg: nSlotsOrBytesReg destReg: formatReg.
  	cogit PopR: nSlotsOrBytesReg.
  	self genConvertSmallIntegerToIntegerInReg: formatReg.
  	cogit AndCq: objectMemory fixedFieldsOfClassFormatMask R: formatReg.
  	cogit SubR: formatReg R: nSlotsOrBytesReg.
  	cogit AddCq: objectMemory baseHeaderSize >> objectMemory shiftForWord R: formatReg.
  	cogit CmpR: Arg0Reg R: nSlotsOrBytesReg.
  	jumpFixedFieldsOutOfBounds := cogit JumpBelowOrEqual: 0.
  	cogit AddR: formatReg R: Arg0Reg.
  	cogit MoveR: Arg1Reg Xwr: Arg0Reg R: ReceiverResultReg.
  	cogit MoveR: Arg1Reg R: ReceiverResultReg.
  	cogit genPrimReturn.
  
  	jumpNotPointers jmpTarget: cogit Label.
  	jumpNonSmallIntegerValue := self genJumpNotSmallInteger: Arg1Reg scratchReg: TempReg.
  					cogit CmpCq: objectMemory firstByteFormat R: formatReg.
  	jumpIsBytes := cogit JumpAboveOrEqual: 0.
  					cogit CmpCq: objectMemory firstShortFormat R: formatReg.
  	jumpIsShorts := cogit JumpAboveOrEqual: 0.
  					cogit CmpCq: objectMemory firstLongFormat R: formatReg.
  	"For now ignore 64-bit indexability."
  	jumpNotIndexableBits := cogit JumpBelow: 0.
  
  	"fall through to words"
  	cogit CmpR: Arg0Reg R: nSlotsOrBytesReg.
  	jumpWordsOutOfBounds := cogit JumpBelowOrEqual: 0.
  	cogit MoveR: Arg1Reg R: TempReg.
  	self genConvertSmallIntegerToIntegerInReg: TempReg.
  	signedVersion ifFalse:
  		[(cogit lastOpcode setsConditionCodesFor: JumpLess) ifFalse:
  			[cogit CmpCq: 0 R: TempReg]. "N.B. FLAGS := TempReg - 0"
  		jumpWordsOutOfRange := cogit JumpLess: 0].
  	cogit AddCq: objectMemory baseHeaderSize >> objectMemory shiftForWord R: Arg0Reg.
  	cogit MoveR: TempReg Xwr: Arg0Reg R: ReceiverResultReg.
  	cogit MoveR: Arg1Reg R: ReceiverResultReg.
  	cogit genPrimReturn.
  
  	signedVersion
  		ifTrue:
  			[jumpIsBytes jmpTarget:
+ 			 (cogit ArithmeticShiftRightCq: 7 + objectMemory numSmallIntegerTagBits R: Arg1Reg R: TempReg). "Maps in range to -1,0".
- 			 (cogit MoveR: SendNumArgsReg R: TempReg).
- 			 cogit ArithmeticShiftRightCq: 7 R: TempReg. "Maps in range to -1,0".
  			 cogit AddCq: 1 R: TempReg. "Maps in range to 0,1"
  			 cogit CmpCq: 1 R: TempReg]
  		ifFalse:
  			[jumpIsBytes jmpTarget:
  			 (cogit CmpCq: (objectMemory integerObjectOf: 255) R: Arg1Reg)].
  	jumpBytesOutOfRange := cogit JumpAbove: 0.
  	cogit LogicalShiftLeftCq: objectMemory shiftForWord R: nSlotsOrBytesReg.
  	cogit AndCq: objectMemory wordSize - 1 R: formatReg R: TempReg.
  	cogit SubR: TempReg R: nSlotsOrBytesReg.
  	cogit CmpR: Arg0Reg R: nSlotsOrBytesReg.
  	jumpBytesOutOfBounds := cogit JumpBelowOrEqual: 0.
  	cogit CmpCq: objectMemory firstCompiledMethodFormat R: formatReg.
  	jumpIsCompiledMethod := cogit JumpAboveOrEqual: 0.
  	methodInBounds :=
  	cogit MoveR: Arg1Reg R: TempReg.
  	self genConvertSmallIntegerToIntegerInReg: TempReg.
  	cogit AddCq: objectMemory baseHeaderSize R: Arg0Reg.
  	cogit MoveR: TempReg Xbr: Arg0Reg R: ReceiverResultReg.
  	cogit MoveR: Arg1Reg R: ReceiverResultReg.
  	cogit genPrimReturn.
  
  	signedVersion
  		ifTrue:
  			[jumpIsShorts jmpTarget:
+ 			 (cogit ArithmeticShiftRightCq: 15 + objectMemory numSmallIntegerTagBits R: Arg1Reg R: TempReg). "Maps in range to -1,0".
- 			 (cogit MoveR: SendNumArgsReg R: TempReg).
- 			 cogit ArithmeticShiftRightCq: 15 R: TempReg. "Maps in range to -1,0".
  			 cogit AddCq: 1 R: TempReg. "Maps in range to 0,1"
  			 cogit CmpCq: 1 R: TempReg]
  		ifFalse:
  			[jumpIsShorts jmpTarget:
  			 (cogit CmpCq: (objectMemory integerObjectOf: 65535) R: Arg1Reg)].
  	jumpShortsOutOfRange := cogit JumpAbove: 0.
  	cogit LogicalShiftLeftCq: objectMemory shiftForWord - 1 R: nSlotsOrBytesReg.
  	cogit AndCq: objectMemory wordSize / 2 - 1 R: formatReg.
  	cogit SubR: formatReg R: nSlotsOrBytesReg.
  	cogit CmpR: Arg0Reg R: nSlotsOrBytesReg.
  	jumpShortsOutOfBounds := cogit JumpBelowOrEqual: 0.
  	cogit MoveR: Arg1Reg R: TempReg.
  	self genConvertSmallIntegerToIntegerInReg: TempReg.
  	cogit AddR: Arg0Reg R: ReceiverResultReg.
  	cogit AddR: Arg0Reg R: ReceiverResultReg.
  	cogit MoveR: TempReg M16: objectMemory baseHeaderSize r: ReceiverResultReg.
  	cogit MoveR: Arg1Reg R: ReceiverResultReg.
  	cogit genPrimReturn.
  
  	"Now check that the index is beyond the method's literals..."
  	jumpIsCompiledMethod jmpTarget: cogit Label.
  	self getLiteralCountOf: ReceiverResultReg plusOne: true inBytes: true into: nSlotsOrBytesReg scratch: TempReg.
  	cogit CmpR: Arg0Reg R: nSlotsOrBytesReg.
  	cogit JumpBelow: methodInBounds.
  
  	jumpIsContext jmpTarget: 
  	(jumpNotIndexableBits jmpTarget:
  	(jumpBytesOutOfRange jmpTarget:
  	(jumpShortsOutOfRange jmpTarget:
  	(jumpIsCompiledMethod jmpTarget:
  	(jumpArrayOutOfBounds jmpTarget:
  	(jumpBytesOutOfBounds jmpTarget:
  	(jumpShortsOutOfBounds jmpTarget:
  	(jumpWordsOutOfBounds jmpTarget:
  	(jumpNotIndexablePointers jmpTarget:
  	(jumpNonSmallIntegerValue jmpTarget:
  	(jumpFixedFieldsOutOfBounds jmpTarget: cogit Label))))))))))).
  	
  	signedVersion ifFalse:
  		[jumpWordsOutOfRange jmpTarget: jumpIsContext getJmpTarget].
  	self cppIf: IMMUTABILITY
  		ifTrue: [jumpImmutable jmpTarget: jumpIsContext getJmpTarget].
  
  	cogit AddCq: 1 R: Arg0Reg. "0-rel => 1-rel"
  	self genConvertIntegerToSmallIntegerInReg: Arg0Reg.
  
  	jumpBadIndex jmpTarget: (jumpImmediate jmpTarget: cogit Label).
  
  	^0 "Can't be complete because of contexts."!

Item was changed:
  ----- Method: CogObjectRepresentationFor64BitSpur>>genPrimitiveAtPutSigned: (in category 'primitive generators') -----
(excessive size, no diff calculated)

Item was changed:
  ----- Method: Cogit>>codeMemmove:_:_: (in category 'generate machine code - dual mapped zone support') -----
  codeMemmove: dest _: src _: bytes
  	"Move memory (copy allowing for overlap), applying the codeToDataDelta.
  	 This is used for code compaction and so works on readable addresses (delta is required)."
  	"production uses the macro..."
  	<cmacro: '(dest,src,bytes) memmove((char *)(dest)+codeToDataDelta,src,bytes)'>
  	self codeWriteBreakpoint: dest.
  	"simulation writes twice if simulating dual mapping..."
  	codeToDataDelta ~= 0 ifTrue:
  		[objectMemory memmove: dest asUnsignedInteger + codeToDataDelta _: src _: bytes].
  	objectMemory memmove: dest _: src _: bytes.
+ 	"and as a convenience, relocate the breakPC(s) if in this method..."
+ 	breakPC ifNotNil:
+ 		[breakPC isArray
+ 			ifTrue:
+ 				[breakPC withIndexDo:
+ 					[:pc :idx|
+ 					(pc between: src and: src + bytes - 1) ifTrue:
+ 						[breakPC at: idx put: pc - (src asInteger - dest asInteger)]]]
+ 			ifFalse:
+ 				[(breakPC between: src and: src + bytes - 1) ifTrue:
+ 					[breakPC := breakPC - (src asInteger - dest asInteger)]]]!
- 	"and as a convenience, relocate the breakPC if it is in this method"
- 	(breakPC notNil and: [breakPC between: src and: src + bytes - 1]) ifTrue:
- 		[breakPC := breakPC - (src - dest)]!



More information about the Vm-dev mailing list