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

commits at source.squeak.org commits at source.squeak.org
Thu Sep 5 21:35:20 UTC 2019


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

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

Name: VMMaker.oscog-eem.2550
Author: eem
Time: 5 September 2019, 2:35:03.722412 pm
UUID: ee7482ae-8091-4a50-8a5a-316fac3479b1
Ancestors: VMMaker.oscog-nice.2549

Simplify the recenty changed Interpreter{rimitives (small)float primitives to avoid using cppIf:; since the distinction between 32-bit and 64-bit VM versions is handled at generation time different VM sources are generated for each and hence cppIf: is neither needed nor appropriate.

Set hasYoungReferrer via an accessor; this in anticipation of adding a cmHasLiteral bit that will be used in Spur to optimize post-become adding of methods to the YoungReferrer list and of literal variable access.  Refactor method zone printing to provide summaries of the number of methods, and the number of methods on the young referrer and open pic lists.

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

Item was changed:
  ----- Method: CogIA32Compiler>>generateCheckFeatures (in category 'feature detection') -----
  generateCheckFeatures
+ 	<inline: true>
  	cogit
  		PushR: EDX;
  		PushR: ECX;
  		PushR: EBX;
  		MoveCq: 1 R: EAX;
  		gen: CPUID;
  		MoveR: EDX R: EAX;
  		PopR: EBX;
  		PopR: ECX;
  		PopR: EDX;
  		RetN: 0!

Item was changed:
  ----- Method: CogIA32Compiler>>generateCheckLZCNT (in category 'feature detection') -----
  generateCheckLZCNT
  	"to check is Leading Zero Count operation is present
  	cf. MSVC builtin __lzcnt documentation
  	The result will be in bit 5 of return value (in EAX)"
+ 	<inline: true>
  	cogit
  		PushR: EDX;
  		PushR: ECX;
  		PushR: EBX;
  		MoveCq: 16r80000001 R: EAX;
  		gen: CPUID;
  		MoveR: ECX R: EAX;
  		PopR: EBX;
  		PopR: ECX;
  		PopR: EDX;
  		RetN: 0!

Item was changed:
  ----- Method: CogIA32Compiler>>generateLowLevelTryLock: (in category 'multi-threading') -----
  generateLowLevelTryLock: vmOwnerLockAddress
  	"Generate a function that attempts to lock the vmOwnerLock and answers
  	 true if it succeeded."
+ 	<inline: true>
  	vmOwnerLockAddress = 0 ifTrue:
  		[cogit
  			MoveCq: 1 R: EAX;
  			RetN: 0.
  		 ^self].
  	cogit
  		MoveCq: 1 R: EAX;
  		gen: MFENCE; "make the XCHG globally consistent"
  		gen: XCHGAwR operand: vmOwnerLockAddress operand: EAX;
  		gen: SFENCE; "make the store globally visible"
  		SubCq: 1 R: EAX; "Since we only ever set the lock to 1 or 0, subtracting 1 sets
  						   EAX to 0 if the lock was already locked and non-zero if it wasn't."
  		RetN: 0!

Item was changed:
  ----- Method: CogMethodZone>>printCogMethods (in category 'printing') -----
  printCogMethods
  	<api>
  	<returnTypeC: #void>
+ 	self printCogMethodsSummarizing: false!
- 	| cogMethod nm nc no nf nu |
- 	<var: #cogMethod type: #'CogMethod *'>
- 	nm := nc := no := nf := nu := 0.
- 	cogMethod := coInterpreter cCoerceSimple: baseAddress to: #'CogMethod *'.
- 	[cogMethod < self limitZony] whileTrue:
- 		[coInterpreter printCogMethod: cogMethod.
- 		 cogMethod cmType
- 			caseOf: {
- 			[CMFree]		->	[nf := nf + 1].
- 			[CMMethod]	->	[nm := nm + 1].
- 			[CMClosedPIC]	->	[nc := nc + 1].
- 			[CMOpenPIC]	->	[no:= no+ 1] }
- 			otherwise: [nu := nu + 1].
- 		 cogMethod := self methodAfter: cogMethod].
- 	coInterpreter print: 'CMMethod '; printNum: nm;  print: ' CMClosedPIC '; printNum: nc;  print: ' CMOpenPIC '; printNum: no;  print: ' CMFree '; printNum: nf.
- 	nu > 0 ifTrue:
- 		[coInterpreter print: ' UNKNOWN '; printNum: nu].
- 	coInterpreter print: ' total '; printNum: nm+nc+no+nf+nu; cr!

Item was added:
+ ----- Method: CogMethodZone>>printCogMethodsSummarizing: (in category 'printing') -----
+ printCogMethodsSummarizing: summarize
+ 	<inline: true>
+ 	| cogMethod nm nc no nf nu |
+ 	<var: #cogMethod type: #'CogMethod *'>
+ 	nm := nc := no := nf := nu := 0.
+ 	cogMethod := coInterpreter cCoerceSimple: baseAddress to: #'CogMethod *'.
+ 	[cogMethod < self limitZony] whileTrue:
+ 		[summarize ifFalse:
+ 			[coInterpreter printCogMethod: cogMethod].
+ 		 cogMethod cmType
+ 			caseOf: {
+ 			[CMFree]		->	[nf := nf + 1].
+ 			[CMMethod]	->	[nm := nm + 1].
+ 			[CMClosedPIC]	->	[nc := nc + 1].
+ 			[CMOpenPIC]	->	[no:= no+ 1] }
+ 			otherwise: [nu := nu + 1].
+ 		 cogMethod := self methodAfter: cogMethod].
+ 	coInterpreter print: 'CMMethod '; printNum: nm;  print: ' CMClosedPIC '; printNum: nc;  print: ' CMOpenPIC '; printNum: no;  print: ' CMFree '; printNum: nf.
+ 	nu > 0 ifTrue:
+ 		[coInterpreter print: ' UNKNOWN '; printNum: nu].
+ 	coInterpreter print: ' total '; printNum: nm+nc+no+nf+nu; cr!

Item was changed:
  ----- Method: CogMethodZone>>printOpenPICList (in category 'accessing') -----
  printOpenPICList
  	<api>
+ 	^self printOpenPICListSummarizing: false!
- 	| n openPIC |
- 	<var: #openPIC type: #'CogMethod *'>
- 	n := 0.
- 	openPIC := openPICList.
- 	[openPIC == nil] whileFalse:
- 		[n := n + 1.
- 		 coInterpreter printCogMethod: openPIC.
- 		 openPIC := self cCoerceSimple: openPIC nextOpenPIC to: #'CogMethod *'].
- 	^n!

Item was added:
+ ----- Method: CogMethodZone>>printOpenPICListSummarizing: (in category 'accessing') -----
+ printOpenPICListSummarizing: summarize
+ 	<inline: true>
+ 	| n openPIC |
+ 	<var: #openPIC type: #'CogMethod *'>
+ 	n := 0.
+ 	openPIC := openPICList.
+ 	[openPIC == nil] whileFalse:
+ 		[n := n + 1.
+ 		 summarize ifFalse:
+ 			[coInterpreter printCogMethod: openPIC].
+ 		 openPIC := self cCoerceSimple: openPIC nextOpenPIC to: #'CogMethod *'].
+ 	summarize ifTrue:
+ 		[coInterpreter print: 'num open PICs '; printNum: n; cr].
+ 	^n!

Item was added:
+ ----- Method: CogMethodZone>>summarizeZone (in category 'printing') -----
+ summarizeZone
+ 	<doNotGenerate>
+ 	| pointer cogMethod ny nf nn |
+ 	<var: #cogMethod type: #'CogMethod *'>
+ 	self printCogMethodsSummarizing: true.
+ 	self printOpenPICListSummarizing: true.
+ 	ny := nf := nn := 0.
+ 	pointer := youngReferrers.
+ 	[pointer < limitAddress] whileTrue:
+ 		[cogMethod := coInterpreter cCoerceSimple: (objectMemory longAt: pointer) to: #'CogMethod *'.
+ 		 cogMethod cmRefersToYoung ifTrue:
+ 			[ny := ny + 1].
+ 		 cogMethod cmType = CMFree ifTrue:
+ 			[nf := nf + 1].
+ 		 (cogMethod cmRefersToYoung or: [cogMethod cmType = CMFree]) ifFalse:
+ 			[nn := nn + 1].
+ 		 pointer := pointer + objectMemory wordSize].
+ 	coInterpreter print: 'num free '; printNum: nf; print: ' num young '; printNum: ny; print: ' num neither '; printNum: nn; cr!

Item was changed:
  ----- Method: CogX64Compiler>>generateCheckLZCNT (in category 'feature detection') -----
  generateCheckLZCNT
  	"to check is Leading Zero Count operation is present
  	cf. MSVC builtin __lzcnt documentation
  	The result will be in bit 5 of return value (in RAX)"
+ 	<inline: true>
  	cogit
  		PushR: RDX;
  		PushR: RCX;
  		PushR: RBX;
  		MoveCq: 16r80000001 R: RAX;
  		gen: CPUID;
  		MoveR: RCX R: RAX;
  		PopR: RBX;
  		PopR: RCX;
  		PopR: RDX;
  		RetN: 0!

Item was changed:
  ----- Method: Cogit>>annotate:objRef: (in category 'method map') -----
  annotate: abstractInstruction objRef: anOop
  	<var: #abstractInstruction type: #'AbstractInstruction *'>
  	<returnTypeC: #'AbstractInstruction *'>
  	(objectRepresentation shouldAnnotateObjectReference: anOop) ifTrue:
  		[(objectMemory isYoungObject: anOop) ifTrue:
+ 			[self setHasYoungReferent: true].
- 			[hasYoungReferent := true].
  		 abstractInstruction annotation: IsObjectReference].
  	^abstractInstruction!

Item was changed:
  ----- Method: Cogit>>compileCogFullBlockMethod: (in category 'compile abstract instructions') -----
  compileCogFullBlockMethod: numCopied
  	<returnTypeC: #'CogMethod *'>
  	<option: #SistaV1BytecodeSet>
  	| numBytecodes numBlocks numCleanBlocks result |
+ 	self setHasYoungReferent: (objectMemory isYoungObject: methodObj).
- 	hasYoungReferent := (objectMemory isYoungObject: methodObj).
  	methodOrBlockNumArgs := coInterpreter argumentCountOf: methodObj.
  	inBlock := InFullBlock.
  	postCompileHook := nil.
  	maxLitIndex := -1.
  	self assert: (coInterpreter primitiveIndexOf: methodObj) = 0.
  	initialPC := coInterpreter startPCOfMethod: methodObj.
  	"initial estimate.  Actual endPC is determined in scanMethod."
  	endPC := objectMemory numBytesOf: methodObj.
  	numBytecodes := endPC - initialPC + 1.
  	primitiveIndex := 0.
  	self allocateOpcodes: (numBytecodes + 10) * self estimateOfAbstractOpcodesPerBytecodes
  		bytecodes: numBytecodes
  		ifFail: [^coInterpreter cCoerceSimple: MethodTooBig to: #'CogMethod *'].
  	self flag: #TODO. "currently copiedValue access implies frameful method, this is suboptimal"
  	(numBlocks := self scanMethod) < 0 ifTrue:
  		[^coInterpreter cCoerceSimple: numBlocks to: #'CogMethod *'].
  	self assert: numBlocks = 0. "blocks in full blocks are full blocks, they are not inlined."
  	numCleanBlocks := self scanForCleanBlocks.
  	self assert: numCleanBlocks = 0. "blocks in full blocks are full blocks, they are not inlined."
  	self allocateBlockStarts: numBlocks + numCleanBlocks.
  	blockCount := 0.
  	numCleanBlocks > 0 ifTrue:
  		[self addCleanBlockStarts].
  	(self maybeAllocAndInitCounters
  	 and: [self maybeAllocAndInitIRCs]) ifFalse: "Inaccurate error code, but it'll do.  This will likely never fail."
  		[^coInterpreter cCoerceSimple: InsufficientCodeSpace to: #'CogMethod *'].
  
  	blockEntryLabel := nil.
  	methodLabel dependent: nil.
  	(result := self compileEntireFullBlockMethod: numCopied) < 0 ifTrue:
  		[^coInterpreter cCoerceSimple: result to: #'CogMethod *'].
  	^self generateCogFullBlock!

Item was changed:
  ----- Method: Cogit>>compileCogMethod: (in category 'compile abstract instructions') -----
  compileCogMethod: selector
  	<returnTypeC: #'CogMethod *'>
  	| numBytecodes numBlocks numCleanBlocks result extra |
+ 	self setHasYoungReferent: ((objectMemory isYoungObject: methodObj)
+ 								  or: [objectMemory isYoung: selector]).
- 	hasYoungReferent := (objectMemory isYoungObject: methodObj)
- 						  or: [objectMemory isYoung: selector].
  	methodOrBlockNumArgs := coInterpreter argumentCountOf: methodObj.
  	inBlock := 0.
  	postCompileHook := nil.
  	maxLitIndex := -1.
  	extra := ((primitiveIndex := coInterpreter primitiveIndexOf: methodObj) > 0
  			and: [(coInterpreter isQuickPrimitiveIndex: primitiveIndex) not])
  				ifTrue: [30]
  				ifFalse: [10].
  	initialPC := coInterpreter startPCOfMethod: methodObj.
  	"initial estimate.  Actual endPC is determined in scanMethod."
  	endPC := (coInterpreter isQuickPrimitiveIndex: primitiveIndex)
  					ifTrue: [initialPC - 1]
  					ifFalse: [objectMemory numBytesOf: methodObj].
  	numBytecodes := endPC - initialPC + 1.
  	self allocateOpcodes: (numBytecodes + extra) * self estimateOfAbstractOpcodesPerBytecodes
  		bytecodes: numBytecodes
  		ifFail: [^coInterpreter cCoerceSimple: MethodTooBig to: #'CogMethod *'].
  	(numBlocks := self scanMethod) < 0 ifTrue:
  		[^coInterpreter cCoerceSimple: numBlocks to: #'CogMethod *'].
  	numCleanBlocks := self scanForCleanBlocks.
  	self methodFoundInvalidPostScan ifTrue:
  		[^coInterpreter cCoerceSimple: ShouldNotJIT to: #'CogMethod *'].
  	self allocateBlockStarts: numBlocks + numCleanBlocks.
  	blockCount := 0.
  	numCleanBlocks > 0 ifTrue:
  		[self addCleanBlockStarts].
  	(self maybeAllocAndInitCounters
  	 and: [self maybeAllocAndInitIRCs]) ifFalse: "Inaccurate error code, but it'll do.  This will likely never fail."
  		[^coInterpreter cCoerceSimple: InsufficientCodeSpace to: #'CogMethod *'].
  	
  	blockEntryLabel := nil.
  	methodLabel dependent: nil.
  	(result := self compileEntireMethod) < 0 ifTrue:
  		[^coInterpreter cCoerceSimple: result to: #'CogMethod *'].
  	^self generateCogMethod: selector!

Item was changed:
  ----- Method: Cogit>>genLoadInlineCacheWithSelector: (in category 'in-line cacheing') -----
  genLoadInlineCacheWithSelector: selectorIndex
  	"The in-line cache for a send is implemented as a constant load into ClassReg.
  	 We always use a 32-bit load, even in 64-bits.
  
  	 In the initial (unlinked) state the in-line cache is notionally loaded with the selector.
  	 But since in 64-bits an arbitrary selector oop won't fit in a 32-bit constant load, we
  	 instead load the cache with the selector's index, either into the literal frame of the
  	 current method, or into the special selector array.  Negative values are 1-relative
  	 indices into the special selector array.
  
  	 When a send is linked, the load of the selector, or selector index, is overwritten with a
  	 load of the receiver's class, or class tag.  Hence, the 64-bit VM is currently constrained
  	 to use class indices as cache tags.  If out-of-line literals are used, distinct caches /must
  	 not/ share acche locations, for if they do, send cacheing will be confused by the sharing.
  	 Hence we use the MoveUniqueC32:R: instruction that will not share literal locations."
  
  	| cacheValue |
  	self assert: (selectorIndex < 0
  					ifTrue: [selectorIndex negated between: 1 and: self numSpecialSelectors]
  					ifFalse: [selectorIndex between: 0 and: (objectMemory literalCountOf: methodObj) - 1]).
  
  	self inlineCacheTagsAreIndexes
  		ifTrue:
  			[cacheValue := selectorIndex]
  		ifFalse:
  			[| selector |
  			 selector := selectorIndex < 0
  							ifTrue: [(coInterpreter specialSelector: -1 - selectorIndex)]
  							ifFalse: [self getLiteral: selectorIndex].
  			 self assert: (objectMemory addressCouldBeOop: selector).
  			 (objectMemory isYoung: selector) ifTrue:
+ 				[self setHasYoungReferent: true].
- 				[hasYoungReferent := true].
  			 cacheValue := selector].
  
  	self MoveUniqueC32: cacheValue R: ClassReg!

Item was changed:
  ----- Method: Cogit>>generateTrampolines (in category 'initialization') -----
  generateTrampolines
  	"Generate the run-time entries and exits at the base of the native code zone and update the base.
  	 Read the class-side method trampolines for documentation on the various trampolines"
  	| methodZoneStart |
  	methodZoneStart := methodZoneBase.
  	methodLabel address: methodZoneStart.
  	self allocateOpcodes: 80 bytecodes: 0.
+ 	self setHasYoungReferent: false.
- 	hasYoungReferent := false.
  	objectRepresentation maybeGenerateSelectorIndexDereferenceRoutine.
  	self generateSendTrampolines.
  	self generateMissAbortTrampolines.
  	objectRepresentation generateObjectRepresentationTrampolines.
  	self generateRunTimeTrampolines.
  	NewspeakVM ifTrue: [self generateNewspeakRuntime].
  	SistaVM ifTrue: [self generateSistaRuntime].
  	self generateEnilopmarts.
  	self generateTracingTrampolines.
  
  	"finish up"
  	self recordGeneratedRunTime: 'methodZoneBase' address: methodZoneBase.
  	processor flushICacheFrom: methodZoneStart asUnsignedInteger to: methodZoneBase asUnsignedInteger!

Item was changed:
  ----- Method: Cogit>>maybeGenerateCheckLZCNT (in category 'initialization') -----
  maybeGenerateCheckLZCNT
  	| startAddress |
  	<inline: true>
  	backEnd numCheckLZCNTOpcodes > 0 ifTrue:
  		[self allocateOpcodes: backEnd numCheckLZCNTOpcodes bytecodes: 0.
  		 startAddress := methodZoneBase.
+ 		 methodLabel address: startAddress. "for pc-relative MoveCq: 16r80000001 R: RAX;"
  		 backEnd generateCheckLZCNT.
  		 self outputInstructionsForGeneratedRuntimeAt: startAddress.
  		 self recordGeneratedRunTime: 'ceCheckLZCNTFunction' address: startAddress.
  		 ceCheckLZCNTFunction := self cCoerceSimple: startAddress to: #'usqIntptr_t (*)(void)']!

Item was added:
+ ----- Method: Cogit>>setHasYoungReferent: (in category 'accessing') -----
+ setHasYoungReferent: boolean
+ 	"Written this way to allow reak-pointing in the simulator."
+ 	<cmacro: '(b) (hasYoungReferent = (b))'>
+ 	boolean ifTrue:
+ 		[self halt].
+ 	"(hasYoungReferent == false and: [boolean == true]) ifTrue:
+ 		[self halt]."
+ 	hasYoungReferent := boolean!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveHighBit (in category 'arithmetic integer primitives') -----
  primitiveHighBit
  	| integerReceiverOop leadingZeroCount highestBitZeroBased |
  	integerReceiverOop := self stackTop.
  	"Convert the receiver Oop to use a single tag bit"
  	self numSmallIntegerTagBits > 1
  		ifTrue: [integerReceiverOop := (integerReceiverOop >>> (self numSmallIntegerTagBits-1) bitOr: 1)].
  	self cppIf: #'__GNUC__' defined
  		ifTrue:
  			["Note: in gcc, result is undefined if input is zero (for compatibility with BSR fallback when no CLZ instruction available).
  			but input is never zero because we pass the oop with tag bits set, so we are safe"
  			objectMemory wordSize = 4
  				ifTrue: [leadingZeroCount := self __builtin_clz: integerReceiverOop]
  				ifFalse: [leadingZeroCount := self __builtin_clzll: integerReceiverOop].
  			leadingZeroCount = 0
  				ifTrue:
  					["highBit is not defined for negative Integer"
  					self primitiveFail]
  				ifFalse:
  					["Nice bit trick: 1-based high-bit is (32 - clz) - 1 to account for tag bit.
  					This is like two-complement - clz - 1 on 5 bits, or in other words a bit-invert operation clz ^16r1F"
  					self pop: 1 thenPushInteger: (leadingZeroCount bitXor: (BytesPerWord * 8 - 1))].
  			^self].
  	self cppIf: #'__GNUC__' defined not & (#'_MSC_VER' defined | #'__ICC' defined)
  		ifTrue:
  			["In MSVC, _lzcnt and _lzcnt64 builtins do not fallback to BSR when not supported by CPU
  			Instead of messing with __cpuid() we always use the BSR intrinsic"
  			
  			"Trick: we test the oop sign rather than the integerValue. Assume oop are signed (so far, they are, sqInt are signed)"
  			integerReceiverOop < 0 ifTrue: [self primitiveFail] ifFalse: [		
  			"Setting this variable is useless, but VMMaker will generate it at a worse place"
  			highestBitZeroBased := 0.
  			"We do not even test the return value, because integerReceiverOop is never zero"
  			self cCode: [objectMemory wordSize = 4
  					ifTrue: [self _BitScanReverse: highestBitZeroBased address _: integerReceiverOop]
  					ifFalse: [self _BitScanReverse64: highestBitZeroBased address _: integerReceiverOop]]
  				inSmalltalk: [highestBitZeroBased := integerReceiverOop highBit - 1].
  			"thanks to the tag bit, the +1 operation for getting 1-based rank is not necessary"
  			self pop: 1 thenPushInteger: highestBitZeroBased].
  			^self].
  	self cppIf:  #'__GNUC__' defined not & #'_MSC_VER' defined not & #'__ICC' defined not
  		ifTrue:
  			["not gcc/clang, nor MSVC/ICC, you have to implement if your compiler provide useful builtins"
+ 			self cCode:
+ 					[self primitiveFail]
+ 				inSmalltalk: "Simulate so that the simulatror is closer to the actual VM"
+ 					[integerReceiverOop < 0
+ 						ifTrue: [self primitiveFail]
+ 						ifFalse: [self pop: 1 thenPushInteger: integerReceiverOop highBit - 1]]]!
- 			self primitiveFail].!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveSmallFloatEqual (in category 'arithmetic float primitives') -----
  primitiveSmallFloatEqual
  	<option: #Spur64BitMemoryManager>
+ 	| rcvr arg |
- 	| rcvr arg intArg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory smallFloatValueOf: (self stackValue: 1).
  	arg := objectMemory loadFloatOrIntFrom: self stackTop.
  	self successful ifTrue:
+ 		[(rcvr = arg
+ 		  and: [objectMemory isIntegerObject: self stackTop])
+ 			ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 				[| intArg |
+ 				intArg := objectMemory integerValueOf: self stackTop.
+ 				self pop: 2 thenPushBool: rcvr asInteger = intArg]
- 		[self cppIf: objectMemory wordSize > 4
- 			ifTrue: [((objectMemory isIntegerObject: self stackTop) and: [rcvr = arg])
- 				ifTrue:
- 					["Resolve case of ambiguity so as to have comparison of exact values"
- 					intArg := objectMemory integerValueOf: self stackTop.
- 					self pop: 2 thenPushBool: rcvr asInteger = intArg]
- 				ifFalse: [self pop: 2 thenPushBool: rcvr = arg]]
  			ifFalse: [self pop: 2 thenPushBool: rcvr = arg]]!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveSmallFloatGreaterOrEqual (in category 'arithmetic float primitives') -----
  primitiveSmallFloatGreaterOrEqual
  	<option: #Spur64BitMemoryManager>
+ 	| rcvr arg |
- 	| rcvr arg intArg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory smallFloatValueOf: (self stackValue: 1).
  	arg := objectMemory loadFloatOrIntFrom: self stackTop.
  	self successful ifTrue:
+ 		[(rcvr = arg
+ 		  and: [objectMemory isIntegerObject: self stackTop])
+ 			ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 				[| intArg |
+ 				intArg := objectMemory integerValueOf: self stackTop.
+ 				self pop: 2 thenPushBool: rcvr asInteger >= intArg]
- 		[self cppIf: objectMemory wordSize > 4
- 			ifTrue: [((objectMemory isIntegerObject: self stackTop) and: [rcvr = arg])
- 				ifTrue:
- 					["Resolve case of ambiguity so as to have comparison of exact values"
- 					intArg := objectMemory integerValueOf: self stackTop.
- 					self pop: 2 thenPushBool: rcvr asInteger >= intArg]
- 				ifFalse: [self pop: 2 thenPushBool: rcvr >= arg]]
  			ifFalse: [self pop: 2 thenPushBool: rcvr >= arg]]!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveSmallFloatGreaterThan (in category 'arithmetic float primitives') -----
  primitiveSmallFloatGreaterThan
  	<option: #Spur64BitMemoryManager>
+ 	| rcvr arg |
- 	| rcvr arg intArg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory smallFloatValueOf: (self stackValue: 1).
  	arg := objectMemory loadFloatOrIntFrom: self stackTop.
  	self successful ifTrue:
+ 		[(rcvr = arg
+ 		  and: [objectMemory isIntegerObject: self stackTop])
+ 			ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 				[| intArg |
+ 				intArg := objectMemory integerValueOf: self stackTop.
+ 				self pop: 2 thenPushBool: rcvr asInteger > intArg]
- 		[self cppIf: objectMemory wordSize > 4
- 			ifTrue: [((objectMemory isIntegerObject: self stackTop) and: [rcvr = arg])
- 				ifTrue:
- 					["Resolve case of ambiguity so as to have comparison of exact values"
- 					intArg := objectMemory integerValueOf: self stackTop.
- 					self pop: 2 thenPushBool: rcvr asInteger > intArg]
- 				ifFalse: [self pop: 2 thenPushBool: rcvr > arg]]
  			ifFalse: [self pop: 2 thenPushBool: rcvr > arg]]!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveSmallFloatLessOrEqual (in category 'arithmetic float primitives') -----
  primitiveSmallFloatLessOrEqual
  	<option: #Spur64BitMemoryManager>
+ 	| rcvr arg |
- 	| rcvr arg intArg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory smallFloatValueOf: (self stackValue: 1).
  	arg := objectMemory loadFloatOrIntFrom: self stackTop.
  	self successful ifTrue:
+ 		[(rcvr = arg
+ 		  and: [objectMemory isIntegerObject: self stackTop])
+ 			ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 				[| intArg |
+ 				intArg := objectMemory integerValueOf: self stackTop.
+ 				self pop: 2 thenPushBool: rcvr asInteger <= intArg]
- 		[self cppIf: objectMemory wordSize > 4
- 			ifTrue: [((objectMemory isIntegerObject: self stackTop) and: [rcvr = arg])
- 				ifTrue:
- 					["Resolve case of ambiguity so as to have comparison of exact values"
- 					intArg := objectMemory integerValueOf: self stackTop.
- 					self pop: 2 thenPushBool: rcvr asInteger <= intArg]
- 				ifFalse: [self pop: 2 thenPushBool: rcvr <= arg]]
  			ifFalse: [self pop: 2 thenPushBool: rcvr <= arg]]!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveSmallFloatLessThan (in category 'arithmetic float primitives') -----
  primitiveSmallFloatLessThan
  	<option: #Spur64BitMemoryManager>
+ 	| rcvr arg |
- 	| rcvr arg intArg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory smallFloatValueOf: (self stackValue: 1).
  	arg := objectMemory loadFloatOrIntFrom: self stackTop.
  	self successful ifTrue:
+ 		[(rcvr = arg
+ 		  and: [objectMemory isIntegerObject: self stackTop])
+ 			ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 				[| intArg |
+ 				intArg := objectMemory integerValueOf: self stackTop.
+ 				self pop: 2 thenPushBool: rcvr asInteger < intArg]
- 		[self cppIf: objectMemory wordSize > 4
- 			ifTrue: [((objectMemory isIntegerObject: self stackTop) and: [rcvr = arg])
- 				ifTrue:
- 					["Resolve case of ambiguity so as to have comparison of exact values"
- 					intArg := objectMemory integerValueOf: self stackTop.
- 					self pop: 2 thenPushBool: rcvr asInteger < intArg]
- 				ifFalse: [self pop: 2 thenPushBool: rcvr < arg]]
  			ifFalse: [self pop: 2 thenPushBool: rcvr < arg]]!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveSmallFloatNotEqual (in category 'arithmetic float primitives') -----
  primitiveSmallFloatNotEqual
  	<option: #Spur64BitMemoryManager>
+ 	| rcvr arg |
- 	| rcvr arg intArg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory smallFloatValueOf: (self stackValue: 1).
  	arg := objectMemory loadFloatOrIntFrom: self stackTop.
  	self successful ifTrue:
+ 		[(rcvr = arg
+ 		  and: [objectMemory isIntegerObject: self stackTop])
+ 			ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 				[| intArg |
+ 				intArg := objectMemory integerValueOf: self stackTop.
+ 				self pop: 2 thenPushBool: (rcvr asInteger = intArg) not]
- 		[self cppIf: objectMemory wordSize > 4
- 			ifTrue: [((objectMemory isIntegerObject: self stackTop) and: [rcvr = arg])
- 				ifTrue: ["Resolve case of ambiguity so as to have comparison of exact values"
- 					intArg := objectMemory integerValueOf: self stackTop.
- 					self pop: 2 thenPushBool: (rcvr asInteger = intArg) not]
- 				ifFalse: [self pop: 2 thenPushBool: (rcvr = arg) not]]
  			ifFalse: [self pop: 2 thenPushBool: (rcvr = arg) not]]!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genNSSend:numArgs:depth:sendTable: (in category 'bytecode generators') -----
  genNSSend: selectorIndex numArgs: numArgs depth: depth sendTable: sendTable
  	<var: #sendTable type: #'sqInt *'>
  	| selector nsSendCache |
  	self assert: (selectorIndex between: 0 and: (objectMemory literalCountOf: methodObj) - 1).
  	selector := self getLiteral: selectorIndex.
  	self assert: (objectMemory addressCouldBeOop: selector).	
  	(objectMemory isYoung: selector) ifTrue:
+ 		[self setHasYoungReferent: true].
- 		[hasYoungReferent := true].
  
  	nsSendCache := theIRCs + (NumOopsPerNSC * objectMemory bytesPerOop * indexOfIRC).
  	indexOfIRC := indexOfIRC + 1.
  	self assert: (objectMemory isInOldSpace: nsSendCache).
  	self initializeNSSendCache: nsSendCache selector: selector numArgs: numArgs depth: depth.
  
  	"This leaves the method receiver on the stack, which might not be the implicit receiver.
  	 But the lookup trampoline will establish the on-stack receiver once it locates it."
  	self marshallAbsentReceiverSendArguments: numArgs.
  
  	"Load the cache last so it is a fixed distance from the call."
  	self MoveUniqueCw: nsSendCache R: SendNumArgsReg.
  	self CallNewspeakSend: (sendTable at: (numArgs min: NumSendTrampolines - 1)).
  
  	self PushR: ReceiverResultReg.
  	^0!

Item was changed:
  ----- Method: Spur32BitMemoryManager>>loadFloatOrIntFrom: (in category 'interpreter access') -----
  loadFloatOrIntFrom: floatOrInt
  	"If floatOrInt is an integer and we enable mixed arithmetic in primitives, then convert it to a C double float and return it.
  	 If it is a Float, then load its value and return it.
  	 Otherwise fail -- ie return with primErrorCode non-zero."
  
  	<inline: true>
  	<returnTypeC: #double>
  
+ 	(coInterpreter primitiveDoMixedArithmetic and: [self isIntegerObject: floatOrInt]) ifTrue:
- 	(self primitiveDoMixedArithmetic and: [self isIntegerObject: floatOrInt]) ifTrue:
  		[^(self integerValueOf: floatOrInt) asFloat].
  	^self floatValueOf: floatOrInt!

Item was changed:
  ----- Method: StackInterpreter>>primitiveFloatEqual:toArg: (in category 'comparison float primitives') -----
  primitiveFloatEqual: rcvrOop toArg: argOop
  	| rcvr arg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory loadFloatOrIntFrom: rcvrOop.
  	arg := objectMemory loadFloatOrIntFrom: argOop.
+ 	(objectMemory wordSize > 4
+ 	 and: [rcvr = arg]) ifTrue:
+ 		[(objectMemory isIntegerObject: argOop) ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 			[^rcvr asInteger = (objectMemory integerValueOf: argOop)].
+ 		 (objectMemory isIntegerObject: rcvrOop) ifTrue:
+ 			["Same when used from bytecodePrim...
+ 			  note that rcvr and arg cannot be both integer (case is already handled)"
+ 			^(objectMemory integerValueOf: rcvrOop) = arg asInteger]].
- 	self cppIf: objectMemory wordSize > 4
- 		ifTrue: [rcvr = arg
- 			ifTrue:
- 				[(objectMemory isIntegerObject: argOop)
- 					ifTrue:
- 						["Resolve case of ambiguity so as to have comparison of exact values"
- 						^ rcvr asInteger = (objectMemory integerValueOf: argOop)]
- 					ifFalse: [(objectMemory isIntegerObject: rcvrOop)
- 						ifTrue:
- 							["Same when used from bytecodePrim...
- 							note that rcvr and arg cannot be both integer (case is already handled)"
- 							^ (objectMemory integerValueOf: rcvrOop) = arg asInteger]]]].
  	^rcvr = arg!

Item was changed:
  ----- Method: StackInterpreter>>primitiveFloatGreater:thanArg: (in category 'comparison float primitives') -----
  primitiveFloatGreater: rcvrOop thanArg: argOop
  	| rcvr arg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory loadFloatOrIntFrom: rcvrOop.
  	arg := objectMemory loadFloatOrIntFrom: argOop.
+ 	(objectMemory wordSize > 4
+ 	 and: [rcvr = arg]) ifTrue:
+ 		[(objectMemory isIntegerObject: argOop) ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 			[^rcvr asInteger > (objectMemory integerValueOf: argOop)].
+ 		 (objectMemory isIntegerObject: rcvrOop) ifTrue:
+ 			["Same when used from bytecodePrim...
+ 			  note that rcvr and arg cannot be both integer (case is already handled)"
+ 			^(objectMemory integerValueOf: rcvrOop) > arg asInteger]].
- 	self cppIf: objectMemory wordSize > 4
- 		ifTrue: [rcvr = arg
- 			ifTrue:
- 				[(objectMemory isIntegerObject: argOop)
- 					ifTrue:
- 						["Resolve case of ambiguity so as to have comparison of exact values"
- 						^ rcvr asInteger > (objectMemory integerValueOf: argOop)]
- 					ifFalse: [(objectMemory isIntegerObject: rcvrOop)
- 						ifTrue:
- 							["Same when used from bytecodePrim...
- 							note that rcvr and arg cannot be both integer (case is already handled)"
- 							^ (objectMemory integerValueOf: rcvrOop) > arg asInteger]]]].
  	^rcvr > arg!

Item was changed:
  ----- Method: StackInterpreter>>primitiveFloatGreaterOrEqual:toArg: (in category 'comparison float primitives') -----
  primitiveFloatGreaterOrEqual: rcvrOop toArg: argOop
  	| rcvr arg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory loadFloatOrIntFrom: rcvrOop.
  	arg := objectMemory loadFloatOrIntFrom: argOop.
+ 	(objectMemory wordSize > 4
+ 	 and: [rcvr = arg]) ifTrue:
+ 		[(objectMemory isIntegerObject: argOop) ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 			[^rcvr asInteger >= (objectMemory integerValueOf: argOop)].
+ 		 (objectMemory isIntegerObject: rcvrOop) ifTrue:
+ 			["Same when used from bytecodePrim...
+ 			  note that rcvr and arg cannot be both integer (case is already handled)"
+ 			^(objectMemory integerValueOf: rcvrOop) >= arg asInteger]].
- 	self cppIf: objectMemory wordSize > 4
- 		ifTrue: [rcvr = arg
- 			ifTrue:
- 				[(objectMemory isIntegerObject: argOop)
- 					ifTrue:
- 						["Resolve case of ambiguity so as to have comparison of exact values"
- 						^ rcvr asInteger >= (objectMemory integerValueOf: argOop)]
- 					ifFalse: [(objectMemory isIntegerObject: rcvrOop)
- 						ifTrue:
- 							["Same when used from bytecodePrim...
- 							note that rcvr and arg cannot be both integer (case is already handled)"
- 							^ (objectMemory integerValueOf: rcvrOop) >= arg asInteger]]]].
  	^rcvr >= arg!

Item was changed:
  ----- Method: StackInterpreter>>primitiveFloatLess:thanArg: (in category 'comparison float primitives') -----
  primitiveFloatLess: rcvrOop thanArg: argOop
  	| rcvr arg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory loadFloatOrIntFrom: rcvrOop.
  	arg := objectMemory loadFloatOrIntFrom: argOop.
+ 	(objectMemory wordSize > 4
+ 	 and: [rcvr = arg]) ifTrue:
+ 		[(objectMemory isIntegerObject: argOop) ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 			[^rcvr asInteger < (objectMemory integerValueOf: argOop)].
+ 		 (objectMemory isIntegerObject: rcvrOop) ifTrue:
+ 			["Same when used from bytecodePrim...
+ 			  note that rcvr and arg cannot be both integer (case is already handled)"
+ 			^(objectMemory integerValueOf: rcvrOop) < arg asInteger]].
- 	self cppIf: objectMemory wordSize > 4
- 		ifTrue: [rcvr = arg
- 			ifTrue:
- 				[(objectMemory isIntegerObject: argOop)
- 					ifTrue:
- 						["Resolve case of ambiguity so as to have comparison of exact values"
- 						^ rcvr asInteger < (objectMemory integerValueOf: argOop)]
- 					ifFalse: [(objectMemory isIntegerObject: rcvrOop)
- 						ifTrue:
- 							["Same when used from bytecodePrim...
- 							note that rcvr and arg cannot be both integer (case is already handled)"
- 							^ (objectMemory integerValueOf: rcvrOop) < arg asInteger]]]].
  	^rcvr < arg!

Item was changed:
  ----- Method: StackInterpreter>>primitiveFloatLessOrEqual:toArg: (in category 'comparison float primitives') -----
  primitiveFloatLessOrEqual: rcvrOop toArg: argOop
  	| rcvr arg |
  	<var: #rcvr type: #double>
  	<var: #arg type: #double>
  
  	rcvr := objectMemory loadFloatOrIntFrom: rcvrOop.
  	arg := objectMemory loadFloatOrIntFrom: argOop.
+ 	(objectMemory wordSize > 4
+ 	 and: [rcvr = arg]) ifTrue:
+ 		[(objectMemory isIntegerObject: argOop) ifTrue: "Resolve case of ambiguity so as to have comparison of exact values"
+ 			[^rcvr asInteger <= (objectMemory integerValueOf: argOop)].
+ 		 (objectMemory isIntegerObject: rcvrOop) ifTrue:
+ 			["Same when used from bytecodePrim...
+ 			  note that rcvr and arg cannot be both integer (case is already handled)"
+ 			^(objectMemory integerValueOf: rcvrOop) <= arg asInteger]].
- 	self cppIf: objectMemory wordSize > 4
- 		ifTrue: [rcvr = arg
- 			ifTrue:
- 				[(objectMemory isIntegerObject: argOop)
- 					ifTrue:
- 						["Resolve case of ambiguity so as to have comparison of exact values"
- 						^ rcvr asInteger <= (objectMemory integerValueOf: argOop)]
- 					ifFalse: [(objectMemory isIntegerObject: rcvrOop)
- 						ifTrue:
- 							["Same when used from bytecodePrim...
- 							note that rcvr and arg cannot be both integer (case is already handled)"
- 							^ (objectMemory integerValueOf: rcvrOop) <= arg asInteger]]]].
  	^rcvr <= arg!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genNSSend:numArgs:depth:sendTable: (in category 'bytecode generators') -----
  genNSSend: selectorIndex numArgs: numArgs depth: depth sendTable: sendTable
  	<var: #sendTable type: #'sqInt *'>
  	| selector nsSendCache |
  	self assert: (selectorIndex between: 0 and: (objectMemory literalCountOf: methodObj) - 1).
  	selector := self getLiteral: selectorIndex.
  	self assert: (objectMemory addressCouldBeOop: selector).	
  	(objectMemory isYoung: selector) ifTrue:
+ 		[self setHasYoungReferent: true].
- 		[hasYoungReferent := true].
  
  	nsSendCache := theIRCs + (NumOopsPerNSC * objectMemory bytesPerOop * indexOfIRC).
  	indexOfIRC := indexOfIRC + 1.
  	self assert: (objectMemory isInOldSpace: nsSendCache).
  	self initializeNSSendCache: nsSendCache selector: selector numArgs: numArgs depth: depth.
  
  	self ssAllocateCallReg: SendNumArgsReg.
  
  	"This may leave the method receiver on the stack, which might not be the implicit receiver.
  	 But the lookup trampoline will establish an on-stack receiver once it locates it."
  	self marshallAbsentReceiverSendArguments: numArgs.
  
  	"Load the cache last so it is a fixed distance from the call."
  	self MoveUniqueCw: nsSendCache R: SendNumArgsReg.
  	self CallNewspeakSend: (sendTable at: (numArgs min: NumSendTrampolines - 1)).
  
  	self voidReceiverOptStatus.
  	self ssPushRegister: ReceiverResultReg.
  	^0!



More information about the Vm-dev mailing list