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

commits at source.squeak.org commits at source.squeak.org
Sat Dec 5 23:08:32 UTC 2015


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

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

Name: VMMaker.oscog-eem.1555
Author: eem
Time: 5 December 2015, 3:06:42.81 pm
UUID: 0db98e05-01ec-4055-92eb-1ef1a08198ee
Ancestors: VMMaker.oscog-rmacnak.1554

Cogit:
Refactor the logic to handle UnimplementedPrimitive and UnfailingPrimitive in a common routine, passing the result of the primtiiev generator to #compileFallbackToInterpreterPrimitive:.  Add the notion of Completeprimitive for primitives that may fail, but handle all teh success cases, hence if a method including such a primitive doesn't use the error code teh Cogit doesn't have to compile the call to the interpreter primitive as a fallback.

Add genPrimitiveObjectAt to provide fast literal and header access on Spur.

Fix deep copying of the V3 simulator, restoring the ability to simulate v3.

Styreamline access to the tag patterns form the Cogit by using macros.

=============== Diff against VMMaker.oscog-rmacnak.1554 ===============

Item was changed:
  SharedPool subclass: #CogMethodConstants
  	instanceVariableNames: ''
+ 	classVariableNames: 'CMBlock CMClosedPIC CMFree CMMaxUsageCount CMMethod CMOpenPIC CheckAllocationFillerAfterPrimCall CompletePrimitive EncounteredUnknownBytecode InsufficientCodeSpace MaxLiteralCountForCompile MaxMethodSize MaxNegativeErrorCode MaxNumArgs MaxStackCheckOffset MethodTooBig NotFullyInitialized PrimCallCollectsProfileSamples PrimCallDoNotJIT PrimCallMayCallBack PrimCallNeedsNewMethod PrimCallNeedsPrimitiveFunction ShouldNotJIT UnfailingPrimitive UnimplementedPrimitive YoungSelectorInPIC'
- 	classVariableNames: 'CMBlock CMClosedPIC CMFree CMMaxUsageCount CMMethod CMOpenPIC CheckAllocationFillerAfterPrimCall EncounteredUnknownBytecode InsufficientCodeSpace MaxLiteralCountForCompile MaxMethodSize MaxNegativeErrorCode MaxNumArgs MaxStackCheckOffset MethodTooBig NotFullyInitialized PrimCallCollectsProfileSamples PrimCallDoNotJIT PrimCallMayCallBack PrimCallNeedsNewMethod PrimCallNeedsPrimitiveFunction ShouldNotJIT UnfailingPrimitive UnimplementedPrimitive YoungSelectorInPIC'
  	poolDictionaries: ''
  	category: 'VMMaker-JIT'!

Item was changed:
  ----- Method: CogMethodSurrogate32 class>>offsetOf: (in category 'accessing') -----
  offsetOf: aByteSymbol
  	"These should be generated!!!!"
  	| baseHeaderSize |
  	baseHeaderSize := self objectMemoryClass baseHeaderSize.
  	^aByteSymbol caseOf:
  		{	[#methodObject]		-> [8 + baseHeaderSize].
+ 			[#methodHeader]		-> [12 + baseHeaderSize].
  			[#selector]				-> [16 + baseHeaderSize].
  			[#blockEntryOffset]	-> [6 + baseHeaderSize].
  		}!

Item was changed:
  ----- Method: CogMethodSurrogate64 class>>offsetOf: (in category 'accessing') -----
  offsetOf: aByteSymbol
  	"These should be generated!!!!"
  	| baseHeaderSize |
  	baseHeaderSize := self objectMemoryClass baseHeaderSize.
  	^aByteSymbol caseOf:
  		{	[#methodObject]		-> [8 + baseHeaderSize].
+ 			[#methodHeader]		-> [16 + baseHeaderSize].
  			[#selector]				-> [24 + baseHeaderSize].
  			[#blockEntryOffset]	-> [6 + baseHeaderSize].
  		}!

Item was added:
+ ----- Method: CogObjectRepresentation>>genInnerPrimitiveObjectAt: (in category 'primitive generators') -----
+ genInnerPrimitiveObjectAt: retNOffset
+ 	"subclasses override if they can"
+ 	^cogit unimplementedPrimitive!

Item was added:
+ ----- Method: CogObjectRepresentationForSpur>>genInnerPrimitiveObjectAt: (in category 'primitive generators') -----
+ genInnerPrimitiveObjectAt: retNOffset
+ 	| headerReg
+ 	  jumpBadIndex jumpNotCogMethod jumpBounds jumpNotHeaderIndex |
+ 	<var: #jumpBounds type: #'AbstractInstruction *'>
+ 	<var: #jumpBadIndex type: #'AbstractInstruction *'>
+ 	<var: #jumpNotCogMethod type: #'AbstractInstruction *'>
+ 	<var: #jumpNotHeaderIndex type: #'AbstractInstruction *'>
+ 	jumpBadIndex := self genJumpNotSmallInteger: Arg0Reg.
+ 	"get header into Arg1Reg..."
+ 	cogit MoveMw: objectMemory baseHeaderSize r: ReceiverResultReg R: (headerReg := Arg1Reg).
+ 	jumpNotCogMethod := self genJumpSmallInteger: headerReg.
+ 	cogit MoveMw: (cogit offset: CogMethod of: #methodHeader) r: headerReg R: headerReg.
+ 	jumpNotCogMethod jmpTarget: (cogit
+ 		CmpCq: (objectMemory integerObjectOf: 1) R: Arg0Reg).
+ 	jumpNotHeaderIndex := cogit JumpNonZero: 0.
+ 	cogit
+ 		MoveR: headerReg R: ReceiverResultReg;
+ 		RetN: retNOffset.
+ 	jumpNotHeaderIndex jmpTarget: (cogit
+ 		AndCq: (objectMemory integerObjectOf: coInterpreter alternateHeaderNumLiteralsMask) R: headerReg).
+ 	cogit
+ 		SubCq: (objectMemory integerObjectOf: 1) - objectMemory smallIntegerTag R: Arg0Reg;
+ 		CmpR: headerReg R: Arg0Reg.
+ 	jumpBounds := cogit JumpAboveOrEqual: 0.
+ 
+ 	self genConvertSmallIntegerToIntegerInReg: Arg0Reg.
+ 	cogit
+ 		AddCq: objectMemory baseHeaderSize >> objectMemory shiftForWord R: Arg0Reg;
+ 		MoveXwr: Arg0Reg R: ReceiverResultReg R: ReceiverResultReg;
+ 		RetN: retNOffset.
+ 
+ 	jumpBounds jmpTarget: (cogit
+ 		AddCq: (objectMemory integerObjectOf: 1) - objectMemory smallIntegerTag R: Arg0Reg).
+ 	jumpBadIndex jmpTarget: cogit Label.
+ 	^CompletePrimitive!

Item was added:
+ ----- Method: CogVMSimulator>>primitiveObjectAt (in category 'object access primitives') -----
+ primitiveObjectAt
+ 	(self stackValue: 1) = 16r1148000 ifTrue: [self halt].
+ 	^super primitiveObjectAt!

Item was changed:
  ----- Method: CogVMSimulator>>veryDeepCopyWith: (in category 'debug support') -----
  veryDeepCopyWith: deepCopier
  	"Override to short-circuit the copying of any VMPluginCodeGenerators referenced from mappedPluginEntries and
  	 uniqueIndices. These can in turn hold onto Monticello state, resulting in a huge ammount of unnecessary copying."
  	deepCopier references
  		at: mappedPluginEntries ifAbsentPut: [mappedPluginEntries];
  		at: uniqueIndices ifAbsentPut: [uniqueIndices].
  	mappedPluginEntries do:
+ 		[:tuple| | block |
+ 		block := tuple third.
+ 		deepCopier references at: block ifAbsentPut: [block]].
- 		[:tuple|
- 		[:sim :sel :block :argCount|
- 		deepCopier references at: block ifAbsentPut: [block]] valueWithArguments: tuple].
  	uniqueIndices keysDo:
  		[:block|
  		deepCopier references at: block ifAbsentPut: [block]].
  	^super veryDeepCopyWith: deepCopier!

Item was changed:
  ----- Method: Cogit class>>initializeErrorCodes (in category 'class initialization') -----
  initializeErrorCodes
  	"External errors, returned to or from cog:selector:"
  	NotFullyInitialized := -1.
  	InsufficientCodeSpace := -2.
  	MethodTooBig := -4.
  	YoungSelectorInPIC := -5.
  	EncounteredUnknownBytecode := -6.
  	UnimplementedPrimitive := -7.
  	ShouldNotJIT := -8.
  	MaxNegativeErrorCode := ShouldNotJIT.
  	"Internal errors returned by generator routines to other generator routines"
  	BadRegisterSet := 1.
  	UnimplementedOperation := 2.
  	"Internal successes answered by CogObjectRepresentation to JIT, etc"
+ 	UnfailingPrimitive := 3. "Answered by a primitive generator for a primitive that will never fail"
+ 	CompletePrimitive := 4 "Answered by a primitive generator that does not bneed to fall back on the interpreter primitive except for an error code."!
- 	UnfailingPrimitive := 3!

Item was changed:
  ----- Method: Cogit>>checkValidObjectReferencesInClosedPIC: (in category 'garbage collection') -----
  checkValidObjectReferencesInClosedPIC: cPIC
  	<var: #cPIC type: #'CogMethod *'>
  	| ok pc |
  	ok := true.
  	pc := cPIC asInteger + firstCPICCaseOffset.
  	
  	"first we check the obj ref at the beginning of the CPIC"
  	(self checkMaybeObjRefInClosedPIC: (backEnd literalBeforeFollowingAddress: pc - backEnd jumpLongByteSize)) ifFalse:
  		[self print: 'object leak in CPIC '; printHex: cPIC asInteger;
  			print: ' @ '; printHex: pc - backEnd jumpLongByteSize; cr.
  		 ok := false].
  	
  	"Next we step over each case that is in use. We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter"
  	pc := self addressOfEndOfCase: cPIC cPICNumCases inCPIC: cPIC.
  	
  	"For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size"
  	2 to: cPIC cPICNumCases do:
  		[:i|
  		objectRepresentation inlineCacheTagsMayBeObjects ifTrue:
+ 			[(self checkMaybeObjRefInClosedPIC: (backEnd literal32BeforeFollowingAddress: pc - backEnd jumpLongConditionalByteSize)) ifFalse:
- 			[(self checkMaybeObjRefInClosedPIC: (literalsManager backEnd literal32BeforeFollowingAddress: pc - backEnd jumpLongConditionalByteSize)) ifFalse:
  				[self print: 'object leak in CPIC '; printHex: cPIC asInteger;
  					print: ' @ '; printHex: pc - backEnd jumpLongConditionalByteSize - backEnd loadLiteralByteSize; cr.
  				 ok := false]].
  		(self checkMaybeObjRefInClosedPIC: (backEnd literalBeforeFollowingAddress: pc - backEnd jumpLongConditionalByteSize - backEnd cmpC32RTempByteSize)) ifFalse:
  			[self print: 'object leak in CPIC '; printHex: cPIC asInteger;
  				print: ' @ '; printHex: pc - backEnd jumpLongConditionalByteSize; cr.
  			 ok := false].
  		pc := pc + cPICCaseSize].
  	^ok!

Item was added:
+ ----- Method: CurrentImageCoInterpreterFacade>>alternateHeaderNumLiteralsMask (in category 'accessing') -----
+ alternateHeaderNumLiteralsMask
+ 	^coInterpreter alternateHeaderNumLiteralsMask!

Item was changed:
  ----- Method: SimpleStackBasedCogit class>>initializePrimitiveTableForNewsqueak (in category 'class initialization') -----
  initializePrimitiveTableForNewsqueak
  	"Initialize the table of primitive generators.  This does not include normal primitives implemented in the coInterpreter.
  	 N.B. primitives that don't have an explicit arg count (the integer following the generator) may be variadic."
  	"SimpleStackBasedCogit initializePrimitiveTableForSqueakV3"
  	MaxCompiledPrimitiveIndex := 222.
  	primitiveTable := CArrayAccessor on: (Array new: MaxCompiledPrimitiveIndex + 1).
  	self table: primitiveTable from: 
  	#(	"Integer Primitives (0-19)"
  		(1 genPrimitiveAdd				1	mclassIsSmallInteger:)
  		(2 genPrimitiveSubtract			1	mclassIsSmallInteger:)
  		(3 genPrimitiveLessThan		1	mclassIsSmallInteger:)
  		(4 genPrimitiveGreaterThan		1	mclassIsSmallInteger:)
  		(5 genPrimitiveLessOrEqual		1	mclassIsSmallInteger:)
  		(6 genPrimitiveGreaterOrEqual	1	mclassIsSmallInteger:)
  		(7 genPrimitiveEqual			1	mclassIsSmallInteger:)
  		(8 genPrimitiveNotEqual		1	mclassIsSmallInteger:)
  		(9 genPrimitiveMultiply			1	processorHasMultiplyAndMClassIsSmallInteger:)
  		(10 genPrimitiveDivide			1	processorHasDivQuoRemAndMClassIsSmallInteger:)
  		(11 genPrimitiveMod			1	processorHasDivQuoRemAndMClassIsSmallInteger:)
  		(12 genPrimitiveDiv				1	processorHasDivQuoRemAndMClassIsSmallInteger:)
  		(13 genPrimitiveQuo			1	processorHasDivQuoRemAndMClassIsSmallInteger:)
  		(14 genPrimitiveBitAnd			1	mclassIsSmallInteger:)
  		(15 genPrimitiveBitOr			1	mclassIsSmallInteger:)
  		(16 genPrimitiveBitXor			1	mclassIsSmallInteger:)
  		(17 genPrimitiveBitShift			1	mclassIsSmallInteger:)
  		"(18 primitiveMakePoint)"
  		"(19 primitiveFail)"					"Guard primitive for simulation -- *must* fail"
  
  		"LargeInteger Primitives (20-39)"
  		"(20 primitiveFail)"
  		"(21 primitiveAddLargeIntegers)"
  		"(22 primitiveSubtractLargeIntegers)"
  		"(23 primitiveLessThanLargeIntegers)"
  		"(24 primitiveGreaterThanLargeIntegers)"
  		"(25 primitiveLessOrEqualLargeIntegers)"
  		"(26 primitiveGreaterOrEqualLargeIntegers)"
  		"(27 primitiveEqualLargeIntegers)"
  		"(28 primitiveNotEqualLargeIntegers)"
  		"(29 primitiveMultiplyLargeIntegers)"
  		"(30 primitiveDivideLargeIntegers)"
  		"(31 primitiveModLargeIntegers)"
  		"(32 primitiveDivLargeIntegers)"
  		"(33 primitiveQuoLargeIntegers)"
  		"(34 primitiveBitAndLargeIntegers)"
  		"(35 primitiveBitOrLargeIntegers)"
  		"(36 primitiveBitXorLargeIntegers)"
  		"(37 primitiveBitShiftLargeIntegers)"
  
  		"Float Primitives (38-59)"
  		"(38 primitiveFloatAt)"
  		"(39 primitiveFloatAtPut)"
  		(40 genPrimitiveAsFloat					0	processorHasDoublePrecisionFloatingPointSupport:)
  		(41 genPrimitiveFloatAdd				1	processorHasDoublePrecisionFloatingPointSupport:)
  		(42 genPrimitiveFloatSubtract			1	processorHasDoublePrecisionFloatingPointSupport:)
  		(43 genPrimitiveFloatLessThan			1	processorHasDoublePrecisionFloatingPointSupport:)
  		(44 genPrimitiveFloatGreaterThan		1	processorHasDoublePrecisionFloatingPointSupport:)
  		(45 genPrimitiveFloatLessOrEqual		1	processorHasDoublePrecisionFloatingPointSupport:)
  		(46 genPrimitiveFloatGreaterOrEqual	1	processorHasDoublePrecisionFloatingPointSupport:)
  		(47 genPrimitiveFloatEqual				1	processorHasDoublePrecisionFloatingPointSupport:)
  		(48 genPrimitiveFloatNotEqual			1	processorHasDoublePrecisionFloatingPointSupport:)
  		(49 genPrimitiveFloatMultiply			1	processorHasDoublePrecisionFloatingPointSupport:)
  		(50 genPrimitiveFloatDivide				1	processorHasDoublePrecisionFloatingPointSupport:)
  		"(51 primitiveTruncated)"
  		"(52 primitiveFractionalPart)"
  		"(53 primitiveExponent)"
  		"(54 primitiveTimesTwoPower)"
  		(55 genPrimitiveFloatSquareRoot		0	processorHasDoublePrecisionFloatingPointSupport:)
  		"(56 primitiveSine)"
  		"(57 primitiveArctan)"
  		"(58 primitiveLogN)"
  		"(59 primitiveExp)"
  
  		"Subscript and Stream Primitives (60-67)"
  		(60 genPrimitiveAt				1)
  		(61 genPrimitiveAtPut			2)
  		(62 genPrimitiveSize			0)
  		(63 genPrimitiveStringAt		1)
  		(64 genPrimitiveStringAtPut		2)
  		"The stream primitives no longer pay their way; normal Smalltalk code is faster."
  		(65 genFastPrimFail)"was primitiveNext"
  		(66 genFastPrimFail) "was primitiveNextPut"
  		(67 genFastPrimFail) "was primitiveAtEnd"
  
  		"StorageManagement Primitives (68-79)"
+ 		(68 genPrimitiveObjectAt			1)	"Good for debugger/InstructionStream performance"
- 		"(68 primitiveObjectAt)"
  		"(69 primitiveObjectAtPut)"
  		(70 genPrimitiveNew)				"For VMMirror support 1 argument instantiateFixedClass: as well as baiscNew"
  		(71 genPrimitiveNewWithArg)		"For VMMirror support 2 argument instantiateVariableClass:withSize: as well as baiscNew:"
  		"(72 primitiveArrayBecomeOneWay)"		"Blue Book: primitiveBecome"
  		"(73 primitiveInstVarAt)"
  		"(74 primitiveInstVarAtPut)"
  		(75 genPrimitiveIdentityHash	0)
  		"(76 primitiveStoreStackp)"					"Blue Book: primitiveAsObject"
  		"(77 primitiveSomeInstance)"
  		"(78 primitiveNextInstance)"
  		(79 genPrimitiveNewMethod	2)
  
  		"Control Primitives (80-89)"
  		"(80 primitiveFail)"							"Blue Book: primitiveBlockCopy"
  		"(81 primitiveFail)"							"Blue Book: primitiveValue"
  		"(82 primitiveFail)"							"Blue Book: primitiveValueWithArgs"
  		(83 genPrimitivePerform)
  		"(84 primitivePerformWithArgs)"
  		"(85 primitiveSignal)"
  		"(86 primitiveWait)"
  		"(87 primitiveResume)"
  		"(88 primitiveSuspend)"
  		"(89 primitiveFlushCache)"
  
  		"System Primitives (110-119)"
  		(110 genPrimitiveIdentical 1)
  		(111 genPrimitiveClass)			"For objectClass: and VMMirror support 1 argument classOf: as well as class"
  		"(112 primitiveBytesLeft)"
  		"(113 primitiveQuit)"
  		"(114 primitiveExitToDebugger)"
  		"(115 primitiveChangeClass)"					"Blue Book: primitiveOopsLeft"
  		"(116 primitiveFlushCacheByMethod)"
  		"(117 primitiveExternalCall)"
  		"(118 primitiveDoPrimitiveWithArgs)"
  		"(119 primitiveFlushCacheSelective)"
  
  		(169 genPrimitiveNotIdentical 1)
  
  		(170 genPrimitiveAsCharacter)			"SmallInteger>>asCharacter, Character class>>value:"
  		(171 genPrimitiveCharacterValue 0)	"Character>>value"
  			
  		"(173 primitiveSlotAt 1)"
  		"(174 primitiveSlotAtPut 2)"
  		(175 genPrimitiveIdentityHash	0)		"Behavior>>identityHash"
  
  		"Old closure primitives"
  		"(186 primitiveFail)" "was primitiveClosureValue"
  		"(187 primitiveFail)" "was primitiveClosureValueWithArgs"
  
  		"Perform method directly"
  		"(188 primitiveExecuteMethodArgsArray)"
  		"(189 primitiveExecuteMethod)"
  
  		"Unwind primitives"
  		"(195 primitiveFindNextUnwindContext)"
  		"(196 primitiveTerminateTo)"
  		"(197 primitiveFindHandlerContext)"
  		(198 genFastPrimFail "primitiveMarkUnwindMethod")
  		(199 genFastPrimFail "primitiveMarkHandlerMethod")
  
  		"new closure primitives"
  		"(200 primitiveClosureCopyWithCopiedValues)"
  		(201 genPrimitiveClosureValue	0) "value"
  		(202 genPrimitiveClosureValue	1) "value:"
  		(203 genPrimitiveClosureValue	2) "value:value:"
  		(204 genPrimitiveClosureValue	3) "value:value:value:"
  		(205 genPrimitiveClosureValue	4) "value:value:value:value:"
  		"(206 genPrimitiveClosureValueWithArgs)" "valueWithArguments:"
  
  		"(210 primitiveContextAt)"
  		"(211 primitiveContextAtPut)"
  		"(212 primitiveContextSize)"
  
  		"(218 primitiveDoNamedPrimitiveWithArgs)"
  		"(219 primitiveFail)"	"reserved for Cog primitives"
  
  		"(220 primitiveFail)"		"reserved for Cog primitives"
  
  		(221 genPrimitiveClosureValue	0) "valueNoContextSwitch"
  		(222 genPrimitiveClosureValue	1) "valueNoContextSwitch:"
  
  		"(541 primitiveSmallFloatAdd				1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(542 primitiveSmallFloatSubtract			1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(543 primitiveSmallFloatLessThan			1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(544 primitiveSmallFloatGreaterThan		1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(545 primitiveSmallFloatLessOrEqual		1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(546 primitiveSmallFloatGreaterOrEqual	1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(547 primitiveSmallFloatEqual				1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(548 primitiveSmallFloatNotEqual			1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(549 primitiveSmallFloatMultiply			1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(550 primitiveSmallFloatDivide				1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(551 primitiveSmallFloatTruncated			0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(552 primitiveSmallFloatFractionalPart		0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(553 primitiveSmallFloatExponent			0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(554 primitiveSmallFloatTimesTwoPower	1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(555 primitiveSmallFloatSquareRoot		0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(556 primitiveSmallFloatSine				0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(557 primitiveSmallFloatArctan				0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(558 primitiveSmallFloatLogN				0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(559 primitiveSmallFloatExp				0	processorHasDoublePrecisionFloatingPointSupport:)"
  	)!

Item was changed:
  ----- Method: SimpleStackBasedCogit class>>initializePrimitiveTableForSqueak (in category 'class initialization') -----
  initializePrimitiveTableForSqueak
  	"Initialize the table of primitive generators.  This does not include normal primitives implemented in the coInterpreter.
  	 N.B. primitives that don't have an explicit arg count (the integer following the generator) may be variadic."
  	"SimpleStackBasedCogit initializePrimitiveTableForSqueak"
  	MaxCompiledPrimitiveIndex := 222.
  	primitiveTable := CArrayAccessor on: (Array new: MaxCompiledPrimitiveIndex + 1).
  	self table: primitiveTable from: 
  	#(	"Integer Primitives (0-19)"
  		(1 genPrimitiveAdd				1	mclassIsSmallInteger:)
  		(2 genPrimitiveSubtract			1	mclassIsSmallInteger:)
  		(3 genPrimitiveLessThan		1	mclassIsSmallInteger:)
  		(4 genPrimitiveGreaterThan		1	mclassIsSmallInteger:)
  		(5 genPrimitiveLessOrEqual		1	mclassIsSmallInteger:)
  		(6 genPrimitiveGreaterOrEqual	1	mclassIsSmallInteger:)
  		(7 genPrimitiveEqual			1	mclassIsSmallInteger:)
  		(8 genPrimitiveNotEqual		1	mclassIsSmallInteger:)
  		(9 genPrimitiveMultiply			1	processorHasMultiplyAndMClassIsSmallInteger:)
  		(10 genPrimitiveDivide			1	processorHasDivQuoRemAndMClassIsSmallInteger:)
  		(11 genPrimitiveMod			1	processorHasDivQuoRemAndMClassIsSmallInteger:)
  		(12 genPrimitiveDiv				1	processorHasDivQuoRemAndMClassIsSmallInteger:)
  		(13 genPrimitiveQuo			1	processorHasDivQuoRemAndMClassIsSmallInteger:)
  		(14 genPrimitiveBitAnd			1	mclassIsSmallInteger:)
  		(15 genPrimitiveBitOr			1	mclassIsSmallInteger:)
  		(16 genPrimitiveBitXor			1	mclassIsSmallInteger:)
  		(17 genPrimitiveBitShift			1	mclassIsSmallInteger:)
  		"(18 primitiveMakePoint)"
  		"(19 primitiveFail)"					"Guard primitive for simulation -- *must* fail"
  
  		"LargeInteger Primitives (20-39)"
  		"(20 primitiveFail)"
  		"(21 primitiveAddLargeIntegers)"
  		"(22 primitiveSubtractLargeIntegers)"
  		"(23 primitiveLessThanLargeIntegers)"
  		"(24 primitiveGreaterThanLargeIntegers)"
  		"(25 primitiveLessOrEqualLargeIntegers)"
  		"(26 primitiveGreaterOrEqualLargeIntegers)"
  		"(27 primitiveEqualLargeIntegers)"
  		"(28 primitiveNotEqualLargeIntegers)"
  		"(29 primitiveMultiplyLargeIntegers)"
  		"(30 primitiveDivideLargeIntegers)"
  		"(31 primitiveModLargeIntegers)"
  		"(32 primitiveDivLargeIntegers)"
  		"(33 primitiveQuoLargeIntegers)"
  		"(34 primitiveBitAndLargeIntegers)"
  		"(35 primitiveBitOrLargeIntegers)"
  		"(36 primitiveBitXorLargeIntegers)"
  		"(37 primitiveBitShiftLargeIntegers)"
  
  		"Float Primitives (38-59)"
  		"(38 primitiveFloatAt)"
  		"(39 primitiveFloatAtPut)"
  		(40 genPrimitiveAsFloat					0	processorHasDoublePrecisionFloatingPointSupport:)
  		(41 genPrimitiveFloatAdd				1	processorHasDoublePrecisionFloatingPointSupport:)
  		(42 genPrimitiveFloatSubtract			1	processorHasDoublePrecisionFloatingPointSupport:)
  		(43 genPrimitiveFloatLessThan			1	processorHasDoublePrecisionFloatingPointSupport:)
  		(44 genPrimitiveFloatGreaterThan		1	processorHasDoublePrecisionFloatingPointSupport:)
  		(45 genPrimitiveFloatLessOrEqual		1	processorHasDoublePrecisionFloatingPointSupport:)
  		(46 genPrimitiveFloatGreaterOrEqual	1	processorHasDoublePrecisionFloatingPointSupport:)
  		(47 genPrimitiveFloatEqual				1	processorHasDoublePrecisionFloatingPointSupport:)
  		(48 genPrimitiveFloatNotEqual			1	processorHasDoublePrecisionFloatingPointSupport:)
  		(49 genPrimitiveFloatMultiply			1	processorHasDoublePrecisionFloatingPointSupport:)
  		(50 genPrimitiveFloatDivide				1	processorHasDoublePrecisionFloatingPointSupport:)
  		"(51 primitiveTruncated)"
  		"(52 primitiveFractionalPart)"
  		"(53 primitiveExponent)"
  		"(54 primitiveTimesTwoPower)"
  		(55 genPrimitiveFloatSquareRoot		0	processorHasDoublePrecisionFloatingPointSupport:)
  		"(56 primitiveSine)"
  		"(57 primitiveArctan)"
  		"(58 primitiveLogN)"
  		"(59 primitiveExp)"
  
  		"Subscript and Stream Primitives (60-67)"
  		(60 genPrimitiveAt				1)
  		(61 genPrimitiveAtPut			2)
  		(62 genPrimitiveSize			0)
  		(63 genPrimitiveStringAt		1)
  		(64 genPrimitiveStringAtPut		2)
  		"The stream primitives no longer pay their way; normal Smalltalk code is faster."
  		(65 genFastPrimFail)"was primitiveNext"
  		(66 genFastPrimFail) "was primitiveNextPut"
  		(67 genFastPrimFail) "was primitiveAtEnd"
  
  		"StorageManagement Primitives (68-79)"
+ 		(68 genPrimitiveObjectAt			1)	"Good for debugger/InstructionStream performance"
- 		"(68 primitiveObjectAt)"
  		"(69 primitiveObjectAtPut)"
  		(70 genPrimitiveNew			0)
  		(71 genPrimitiveNewWithArg	1)
  		"(72 primitiveArrayBecomeOneWay)"		"Blue Book: primitiveBecome"
  		"(73 primitiveInstVarAt)"
  		"(74 primitiveInstVarAtPut)"
  		(75 genPrimitiveIdentityHash	0)
  		"(76 primitiveStoreStackp)"					"Blue Book: primitiveAsObject"
  		"(77 primitiveSomeInstance)"
  		"(78 primitiveNextInstance)"
  		(79 genPrimitiveNewMethod	2)
  
  		"Control Primitives (80-89)"
  		"(80 primitiveFail)"							"Blue Book: primitiveBlockCopy"
  		"(81 primitiveFail)"							"Blue Book: primitiveValue"
  		"(82 primitiveFail)"							"Blue Book: primitiveValueWithArgs"
  		(83 genPrimitivePerform)
  		"(84 primitivePerformWithArgs)"
  		"(85 primitiveSignal)"
  		"(86 primitiveWait)"
  		"(87 primitiveResume)"
  		"(88 primitiveSuspend)"
  		"(89 primitiveFlushCache)"
  
  		"System Primitives (110-119)"
  		(110 genPrimitiveIdentical 1)
  		(111 genPrimitiveClass)				"Support both class and Context>>objectClass:"
  		"(112 primitiveBytesLeft)"
  		"(113 primitiveQuit)"
  		"(114 primitiveExitToDebugger)"
  		"(115 primitiveChangeClass)"					"Blue Book: primitiveOopsLeft"
  		"(116 primitiveFlushCacheByMethod)"
  		"(117 primitiveExternalCall)"
  		"(118 primitiveDoPrimitiveWithArgs)"
  		"(119 primitiveFlushCacheSelective)"
  
  		(169 genPrimitiveNotIdentical 1)
  
  		(170 genPrimitiveAsCharacter)			"SmallInteger>>asCharacter, Character class>>value:"
  		(171 genPrimitiveCharacterValue 0)	"Character>>value"
  			
  		"(173 primitiveSlotAt 1)"
  		"(174 primitiveSlotAtPut 2)"
  		(175 genPrimitiveIdentityHash	0)		"Behavior>>identityHash"
  
  		"Old closure primitives"
  		"(186 primitiveFail)" "was primitiveClosureValue"
  		"(187 primitiveFail)" "was primitiveClosureValueWithArgs"
  
  		"Perform method directly"
  		"(188 primitiveExecuteMethodArgsArray)"
  		"(189 primitiveExecuteMethod)"
  
  		"Unwind primitives"
  		"(195 primitiveFindNextUnwindContext)"
  		"(196 primitiveTerminateTo)"
  		"(197 primitiveFindHandlerContext)"
  		(198 genFastPrimFail "primitiveMarkUnwindMethod")
  		(199 genFastPrimFail "primitiveMarkHandlerMethod")
  
  		"new closure primitives"
  		"(200 primitiveClosureCopyWithCopiedValues)"
  		(201 genPrimitiveClosureValue	0) "value"
  		(202 genPrimitiveClosureValue	1) "value:"
  		(203 genPrimitiveClosureValue	2) "value:value:"
  		(204 genPrimitiveClosureValue	3) "value:value:value:"
  		(205 genPrimitiveClosureValue	4) "value:value:value:value:"
  		"(206 genPrimitiveClosureValueWithArgs)" "valueWithArguments:"
  
  		"(210 primitiveContextAt)"
  		"(211 primitiveContextAtPut)"
  		"(212 primitiveContextSize)"
  
  		"(218 primitiveDoNamedPrimitiveWithArgs)"
  		"(219 primitiveFail)"	"reserved for Cog primitives"
  
  		"(220 primitiveFail)"		"reserved for Cog primitives"
  
  		(221 genPrimitiveClosureValue	0) "valueNoContextSwitch"
  		(222 genPrimitiveClosureValue	1) "valueNoContextSwitch:"
  
  		"(541 primitiveSmallFloatAdd				1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(542 primitiveSmallFloatSubtract			1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(543 primitiveSmallFloatLessThan			1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(544 primitiveSmallFloatGreaterThan		1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(545 primitiveSmallFloatLessOrEqual		1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(546 primitiveSmallFloatGreaterOrEqual	1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(547 primitiveSmallFloatEqual				1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(548 primitiveSmallFloatNotEqual			1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(549 primitiveSmallFloatMultiply			1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(550 primitiveSmallFloatDivide				1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(551 primitiveSmallFloatTruncated			0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(552 primitiveSmallFloatFractionalPart		0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(553 primitiveSmallFloatExponent			0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(554 primitiveSmallFloatTimesTwoPower	1	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(555 primitiveSmallFloatSquareRoot		0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(556 primitiveSmallFloatSine				0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(557 primitiveSmallFloatArctan				0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(558 primitiveSmallFloatLogN				0	processorHasDoublePrecisionFloatingPointSupport:)"
  		"(559 primitiveSmallFloatExp				0	processorHasDoublePrecisionFloatingPointSupport:)"
  	)!

Item was added:
+ ----- Method: SimpleStackBasedCogit>>compileFallbackToInterpreterPrimitive: (in category 'primitive generators') -----
+ compileFallbackToInterpreterPrimitive: code
+ 	<inline: false>
+ 	(code < 0 and: [code ~= UnimplementedPrimitive]) ifTrue: "Generator failed, so no point continuing..."
+ 		[^code].
+ 	code = UnfailingPrimitive ifTrue:
+ 		[^0].
+ 	(code = CompletePrimitive
+ 	 and: [(self methodUsesPrimitiveErrorCode) not]) ifTrue:
+ 		[^0].
+ 	^self compileInterpreterPrimitive: (coInterpreter
+ 											functionPointerForCompiledMethod: methodObj
+ 											primitiveIndex: primitiveIndex)!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genDoubleArithmetic:preOpCheck: (in category 'primitive generators') -----
  genDoubleArithmetic: arithmeticOperator preOpCheck: preOpCheckOrNil
  	"Stack looks like
  		receiver (also in ResultReceiverReg)
  		arg
  		return address"
  	<var: #preOpCheckOrNil declareC: 'AbstractInstruction *(*preOpCheckOrNil)(int rcvrReg, int argReg)'>
  	| jumpFailClass jumpFailAlloc jumpFailCheck jumpImmediate jumpNonInt doOp fail |
  	<var: #jumpFailClass type: #'AbstractInstruction *'>
  	<var: #jumpFailAlloc type: #'AbstractInstruction *'>
  	<var: #jumpNonInt type: #'AbstractInstruction *'>
  	<var: #jumpImmediate type: #'AbstractInstruction *'>
  	<var: #jumpFailCheck type: #'AbstractInstruction *'>
  	<var: #doOp type: #'AbstractInstruction *'>
  	<var: #fail type: #'AbstractInstruction *'>
  	self genLoadArgAtDepth: 0 into: ClassReg.
  	objectRepresentation genGetDoubleValueOf: ReceiverResultReg into: DPFPReg0.
  	jumpImmediate := objectRepresentation genJumpImmediate: ClassReg.
  	objectRepresentation genGetCompactClassIndexNonImmOf: ClassReg into: SendNumArgsReg.
  	objectRepresentation genCmpClassFloatCompactIndexR: SendNumArgsReg.
  	jumpFailClass := self JumpNonZero: 0.
  	objectRepresentation genGetDoubleValueOf: ClassReg into: DPFPReg1.
  	doOp := self Label.
  	preOpCheckOrNil ifNotNil:
  		[jumpFailCheck := self perform: preOpCheckOrNil with: DPFPReg0 with: DPFPReg1].
  	self gen: arithmeticOperator operand: DPFPReg1 operand: DPFPReg0.
  	jumpFailAlloc := objectRepresentation
  					genAllocFloatValue: DPFPReg0
  					into: SendNumArgsReg
  					scratchReg: ClassReg
  					scratchReg: TempReg.
  	self MoveR: SendNumArgsReg R: ReceiverResultReg.
  	self RetN: (self primRetNOffsetFor: 1).
  	jumpImmediate jmpTarget: self Label.
  	objectRepresentation smallIntegerIsOnlyImmediateType ifFalse:
  		[jumpNonInt := objectRepresentation genJumpNotSmallInteger: ClassReg scratchReg: TempReg].
  	objectRepresentation genConvertSmallIntegerToIntegerInReg: ClassReg.
  	self ConvertR: ClassReg Rd: DPFPReg1.
  	self Jump: doOp.
  	jumpFailAlloc jmpTarget: self Label.
+ 	self compileFallbackToInterpreterPrimitive: 0.
- 	self compileFallbackToInterpreterPrimitive.
  	fail := self Label.
  	jumpFailClass jmpTarget: fail.
  	preOpCheckOrNil ifNotNil:
  		[jumpFailCheck jmpTarget: fail].
  	objectRepresentation smallIntegerIsOnlyImmediateType ifFalse:
  		[jumpNonInt jmpTarget: fail].
  	^0!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveAsCharacter (in category 'primitive generators') -----
  genPrimitiveAsCharacter
  	| na r |
  	na := coInterpreter argumentCountOf: methodObj.
+ 	na <= 1
+ 		ifTrue:
+ 			[na = 1 ifTrue:
+ 				[self genLoadArgAtDepth: 0 into: Arg0Reg].
+ 			 r := objectRepresentation
+ 					genInnerPrimitiveAsCharacter: (self primRetNOffsetFor: na)
+ 					inReg: (na = 0 ifTrue: [ReceiverResultReg] ifFalse: [Arg0Reg])]
+ 		ifFalse: [r := 0].
+ 	^self compileFallbackToInterpreterPrimitive: r!
- 	na <= 1 ifTrue:
- 		[na = 1 ifTrue:
- 			[self genLoadArgAtDepth: 0 into: Arg0Reg].
- 		 (r := objectRepresentation
- 				genInnerPrimitiveAsCharacter: (self primRetNOffsetFor: na)
- 				inReg: (na = 0 ifTrue: [ReceiverResultReg] ifFalse: [Arg0Reg])) < 0 ifTrue:
- 			[^r]].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveAsFloat (in category 'primitive generators') -----
  genPrimitiveAsFloat
  	"Stack looks like
  		receiver (also in ResultReceiverReg)
  		return address"
  	| jumpFailAlloc |
  	<var: #jumpFailAlloc type: #'AbstractInstruction *'>
  	self MoveR: ReceiverResultReg R: ClassReg.
  	objectRepresentation genConvertSmallIntegerToIntegerInReg: ClassReg.
  	self ConvertR: ClassReg Rd: DPFPReg0.
  	jumpFailAlloc := objectRepresentation
  					genAllocFloatValue: DPFPReg0
  					into: SendNumArgsReg
  					scratchReg: ClassReg
  					scratchReg: TempReg.
  	self MoveR: SendNumArgsReg R: ReceiverResultReg.
  	self RetN: (self primRetNOffsetFor: 0).
  	jumpFailAlloc jmpTarget: self Label.
+ 	^self compileFallbackToInterpreterPrimitive: 0!
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveAt (in category 'primitive generators') -----
  genPrimitiveAt
- 	| r |
  	self genLoadArgAtDepth: 0 into: Arg0Reg.
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveAt: (self primRetNOffsetFor: 1))!
- 	(r := objectRepresentation genInnerPrimitiveAt: (self primRetNOffsetFor: 1)) < 0 ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveAtPut (in category 'primitive generators') -----
  genPrimitiveAtPut
  	| savedIndex r |
  	savedIndex := opcodeIndex.
  	self genLoadArgAtDepth: 1 into: Arg0Reg.
  	self genLoadArgAtDepth: 0 into: Arg1Reg.
+ 	r := objectRepresentation genInnerPrimitiveAtPut: (self primRetNOffsetFor: 2).
- 	((r := objectRepresentation genInnerPrimitiveAtPut: (self primRetNOffsetFor: 2)) < 0
- 	 and: [r ~= UnimplementedPrimitive]) ifTrue:
- 		[^r].
  	"If primitive is unimplemented, discard arg load."
  	r = UnimplementedPrimitive ifTrue:
  		[opcodeIndex := savedIndex].
+ 	^self compileFallbackToInterpreterPrimitive: r!
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveCharacterValue (in category 'primitive generators') -----
  genPrimitiveCharacterValue
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveCharacterValue: (self primRetNOffsetFor: 0))!
- 	| r |
- 	(r := objectRepresentation genInnerPrimitiveCharacterValue: (self primRetNOffsetFor: 0)) < 0 ifTrue:
- 		[^r].
- 	^r = UnfailingPrimitive
- 		ifTrue: [0]
- 		ifFalse: [self compileFallbackToInterpreterPrimitive]!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveClass (in category 'primitive generators') -----
  genPrimitiveClass
+ 	methodOrBlockNumArgs > 0 ifTrue:
+ 		[methodOrBlockNumArgs > 1 ifTrue:
+ 			[^self compileFallbackToInterpreterPrimitive: 0].
+ 		 self genLoadArgAtDepth: 0 into: ReceiverResultReg].
- 	NewspeakVM
- 		ifTrue:
- 			[methodOrBlockNumArgs > 0 ifTrue:
- 				[methodOrBlockNumArgs > 1 ifTrue:
- 					[^self compileFallbackToInterpreterPrimitive].
- 			 self genLoadArgAtDepth: 0 into: ReceiverResultReg]]
- 		ifFalse:
- 			[self assert: methodOrBlockNumArgs = 0].
  	(objectRepresentation
  			genGetClassObjectOf: ReceiverResultReg
  			into: ReceiverResultReg
  			scratchReg: TempReg
  			instRegIsReceiver: (NewspeakVM ifTrue: [methodOrBlockNumArgs = 0] ifFalse: [true])) = BadRegisterSet ifTrue:
  		[objectRepresentation
  			genGetClassObjectOf: ReceiverResultReg
  			into: ClassReg
  			scratchReg: TempReg
  			instRegIsReceiver: (NewspeakVM ifTrue: [methodOrBlockNumArgs = 0] ifFalse: [true]).
  		 self MoveR: ClassReg R: ReceiverResultReg].
  	self RetN: (self primRetNOffsetFor: methodOrBlockNumArgs).
  	^0!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveFloatSquareRoot (in category 'primitive generators') -----
  genPrimitiveFloatSquareRoot
  	"Stack looks like
  		receiver (also in ResultReceiverReg)
  		return address"
  	| jumpFailAlloc |
  	<var: #jumpFailAlloc type: #'AbstractInstruction *'>
  	objectRepresentation genGetDoubleValueOf: ReceiverResultReg into: DPFPReg0.
  	self SqrtRd: DPFPReg0.
  	jumpFailAlloc := objectRepresentation
  					genAllocFloatValue: DPFPReg0
  					into: SendNumArgsReg
  					scratchReg: ClassReg
  					scratchReg: TempReg.
  	self MoveR: SendNumArgsReg R: ReceiverResultReg.
  	self RetN: (self primRetNOffsetFor: 0).
  	jumpFailAlloc jmpTarget: self Label.
+ 	^self compileFallbackToInterpreterPrimitive: 0!
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveIdentityHash (in category 'primitive generators') -----
  genPrimitiveIdentityHash
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveIdentityHash: (self primRetNOffsetFor: 0))!
- 	| r |
- 	(r := objectRepresentation genInnerPrimitiveIdentityHash: (self primRetNOffsetFor: 0)) < 0 ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveNew (in category 'primitive generators') -----
  genPrimitiveNew
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveNew: (self primRetNOffsetFor: 0))!
- 	| r |
- 	((r := objectRepresentation genInnerPrimitiveNew: (self primRetNOffsetFor: 0)) < 0
- 	 and: [r ~= UnimplementedPrimitive]) ifTrue:
- 		[^r].
- 	"Call the interpreter primitive either when the machine-code primitive
- 	 fails, or if the machine-code primitive is unimplemented."
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveNewMethod (in category 'primitive generators') -----
  genPrimitiveNewMethod
+ 	| r savedIndex |
- 	| savedIndex r |
  	savedIndex := opcodeIndex.
  	self genLoadArgAtDepth: 0 into: Arg0Reg.
+ 	r := objectRepresentation genInnerPrimitiveNewMethod: (self primRetNOffsetFor: 2).
- 	((r := objectRepresentation genInnerPrimitiveNewMethod: (self primRetNOffsetFor: 2)) < 0
- 	 and: [r ~= UnimplementedPrimitive]) ifTrue:
- 		[^r].
  	"If primitive is unimplemented, discard arg load."
  	r = UnimplementedPrimitive ifTrue:
  		[opcodeIndex := savedIndex].
+ 	^self compileFallbackToInterpreterPrimitive: r!
- 	"Call the interpreter primitive either when the machine-code primitive
- 	 fails, or if the machine-code primitive is unimplemented."
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveNewWithArg (in category 'primitive generators') -----
  genPrimitiveNewWithArg
  	| savedIndex r |
  	savedIndex := opcodeIndex.
  	self genLoadArgAtDepth: 0 into: Arg0Reg.
+ 	r := objectRepresentation genInnerPrimitiveNewWithArg: (self primRetNOffsetFor: 1).
- 	((r := objectRepresentation genInnerPrimitiveNewWithArg: (self primRetNOffsetFor: 1)) < 0
- 	 and: [r ~= UnimplementedPrimitive]) ifTrue:
- 		[^r].
  	"If primitive is unimplemented, discard arg load."
  	r = UnimplementedPrimitive ifTrue:
  		[opcodeIndex := savedIndex].
  	"Call the interpreter primitive either when the machine-code primitive
  	 fails, or if the machine-code primitive is unimplemented."
+ 	^self compileFallbackToInterpreterPrimitive: r!
- 	^self compileFallbackToInterpreterPrimitive!

Item was added:
+ ----- Method: SimpleStackBasedCogit>>genPrimitiveObjectAt (in category 'primitive generators') -----
+ genPrimitiveObjectAt
+ 	| savedIndex r |
+ 	savedIndex := opcodeIndex.
+ 	self genLoadArgAtDepth: 0 into: Arg0Reg.
+ 	r := objectRepresentation genInnerPrimitiveObjectAt: (self primRetNOffsetFor: 1).
+ 	"If primitive is unimplemented, discard arg load."
+ 	r = UnimplementedPrimitive ifTrue:
+ 		[opcodeIndex := savedIndex].
+ 	^self compileFallbackToInterpreterPrimitive: r!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveSize (in category 'primitive generators') -----
  genPrimitiveSize
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveSize: (self primRetNOffsetFor: 0))!
- 	| r |
- 	(r := objectRepresentation genInnerPrimitiveSize: (self primRetNOffsetFor: 0)) < 0 ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveStringAt (in category 'primitive generators') -----
  genPrimitiveStringAt
- 	| r |
  	self genLoadArgAtDepth: 0 into: Arg0Reg.
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveStringAt: (self primRetNOffsetFor: 1))!
- 	(r := objectRepresentation genInnerPrimitiveStringAt: (self primRetNOffsetFor: 1)) < 0 ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimitiveStringAtPut (in category 'primitive generators') -----
  genPrimitiveStringAtPut
  	| savedIndex r |
  	savedIndex := opcodeIndex.
  	self genLoadArgAtDepth: 1 into: Arg0Reg.
  	self genLoadArgAtDepth: 0 into: Arg1Reg.
+ 	r := objectRepresentation genInnerPrimitiveStringAtPut: (self primRetNOffsetFor: 2).
- 	((r := objectRepresentation genInnerPrimitiveStringAtPut: (self primRetNOffsetFor: 2)) < 0
- 	 and: [r ~= UnimplementedPrimitive]) ifTrue:
- 		[^r].
  	"If primitive is unimplemented, discard arg load."
  	r = UnimplementedPrimitive ifTrue:
  		[opcodeIndex := savedIndex].
+ 	^self compileFallbackToInterpreterPrimitive: r!
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: Spur32BitCoMemoryManager>>smallIntegerTag (in category 'cog jit support') -----
  smallIntegerTag
  	"Beware, SmallInteger tags are 1 or 3.  But SmallInteger's identityHash is 1."
  	<api>
+ 	<cmacro: '() 1'>
  	^1!

Item was changed:
  ----- Method: Spur64BitCoMemoryManager>>smallIntegerTag (in category 'cog jit support') -----
  smallIntegerTag
  	<api>
+ 	<cmacro: '() 1'>
  	^1!

Item was changed:
  ----- Method: Spur64BitMemoryManager>>smallFloatTag (in category 'cog jit support') -----
  smallFloatTag
+ 	<api>
+ 	<cmacro: '() 3'>
  	^3!

Item was changed:
  ----- Method: SpurMemoryManager>>characterTag (in category 'object access') -----
  characterTag
  	<api>
+ 	<cmacro: '() 2'>
  	^2!

Item was added:
+ ----- Method: StackInterpreter>>alternateHeaderNumLiteralsMask (in category 'compiled methods') -----
+ alternateHeaderNumLiteralsMask
+ 	<api>
+ 	<cmacro: '() AlternateHeaderNumLiteralsMask'>
+ 	^AlternateHeaderNumLiteralsMask!

Item was changed:
  ----- Method: StackInterpreterSimulator>>veryDeepCopyWith: (in category 'debug support') -----
  veryDeepCopyWith: deepCopier
  	"Override to short-circuit the copying of any VMPluginCodeGenerators referenced from mappedPluginEntries.
  	 These can in turn hold onto Monticello state, resulting in a huge ammount of unnecessary copying."
+ 	deepCopier references
+ 		at: mappedPluginEntries ifAbsentPut: [mappedPluginEntries].
+ 	mappedPluginEntries do:
+ 		[:tuple| | block |
+ 		block := tuple third.
+ 		deepCopier references at: block ifAbsentPut: [block]].
- 	self objectMemory hasSpurMemoryManagerAPI ifTrue: 
- 		[deepCopier references
- 			at: mappedPluginEntries ifAbsentPut: [mappedPluginEntries].
- 		mappedPluginEntries do:
- 			[:tuple|
- 			[:sim :sel :block :argCount|
- 			deepCopier references at: block ifAbsentPut: [block]] valueWithArguments: tuple]].
  	^super veryDeepCopyWith: deepCopier!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genDoubleArithmetic:preOpCheck: (in category 'primitive generators') -----
  genDoubleArithmetic: arithmeticOperator preOpCheck: preOpCheckOrNil
  	"Receiver and arg in registers.
  	 Stack looks like
  		return address"
  	<var: #preOpCheckOrNil declareC: 'AbstractInstruction *(*preOpCheckOrNil)(int rcvrReg, int argReg)'>
  	| jumpFailClass jumpFailAlloc jumpFailCheck jumpImmediate jumpNonInt doOp |
  	<var: #jumpFailClass type: #'AbstractInstruction *'>
  	<var: #jumpFailAlloc type: #'AbstractInstruction *'>
  	<var: #jumpImmediate type: #'AbstractInstruction *'>
  	<var: #jumpNonInt type: #'AbstractInstruction *'>
  	<var: #jumpFailCheck type: #'AbstractInstruction *'>
  	<var: #doOp type: #'AbstractInstruction *'>
  	objectRepresentation genGetDoubleValueOf: ReceiverResultReg into: DPFPReg0.
  	self MoveR: Arg0Reg R: ClassReg.
  	jumpImmediate := objectRepresentation genJumpImmediate: Arg0Reg.
  	objectRepresentation genGetCompactClassIndexNonImmOf: Arg0Reg into: SendNumArgsReg.
  	objectRepresentation genCmpClassFloatCompactIndexR: SendNumArgsReg.
  	jumpFailClass := self JumpNonZero: 0.
  	objectRepresentation genGetDoubleValueOf: Arg0Reg into: DPFPReg1.
  	doOp := self Label.
  	preOpCheckOrNil ifNotNil:
  		[jumpFailCheck := self perform: preOpCheckOrNil with: DPFPReg0 with: DPFPReg1].
  	self gen: arithmeticOperator operand: DPFPReg1 operand: DPFPReg0.
  	jumpFailAlloc := objectRepresentation
  						genAllocFloatValue: DPFPReg0
  						into: SendNumArgsReg
  						scratchReg: ClassReg
  						scratchReg: TempReg.
  	self MoveR: SendNumArgsReg R: ReceiverResultReg.
  	self RetN: 0.
  	"We need to push the register args on two paths; this one and the interpreter primitive path.
  	But the interpreter primitive path won't unless regArgsHaveBeenPushed is false."
  	self assert: methodOrBlockNumArgs <= self numRegArgs.
  	jumpFailClass jmpTarget: self Label.
  	preOpCheckOrNil ifNotNil:
  		[jumpFailCheck jmpTarget: jumpFailClass getJmpTarget].
  	backEnd genPushRegisterArgsForNumArgs: methodOrBlockNumArgs scratchReg: SendNumArgsReg.
  	jumpFailClass := self Jump: 0.
  	jumpImmediate jmpTarget: self Label.
  	objectRepresentation smallIntegerIsOnlyImmediateType ifFalse:
  		[jumpNonInt := objectRepresentation genJumpNotSmallInteger: Arg0Reg].
  	objectRepresentation genConvertSmallIntegerToIntegerInReg: ClassReg.
  	self ConvertR: ClassReg Rd: DPFPReg1.
  	self Jump: doOp.
  	jumpFailAlloc jmpTarget: self Label.
+ 	self compileFallbackToInterpreterPrimitive: 0.
- 	self compileFallbackToInterpreterPrimitive.
  	jumpFailClass jmpTarget: self Label.
  	objectRepresentation smallIntegerIsOnlyImmediateType ifFalse:
  		[jumpNonInt jmpTarget: jumpFailClass getJmpTarget].
  	^0!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveAsCharacter (in category 'primitive generators') -----
  genPrimitiveAsCharacter
  	| na r |
  	na := coInterpreter argumentCountOf: methodObj.
+ 	r := na <= 1
+ 			ifTrue:
+ 				[objectRepresentation
+ 						genInnerPrimitiveAsCharacter: 0
+ 						inReg: (na = 0 ifTrue: [ReceiverResultReg] ifFalse: [Arg0Reg])]
+ 			ifFalse: [0].
+ 	^self compileFallbackToInterpreterPrimitive: r!
- 	na <= 1 ifTrue:
- 		[(r := objectRepresentation
- 				genInnerPrimitiveAsCharacter: 0
- 				inReg: (na = 0 ifTrue: [ReceiverResultReg] ifFalse: [Arg0Reg])) < 0 ifTrue:
- 			[^r]].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveAsFloat (in category 'primitive generators') -----
  genPrimitiveAsFloat
  	| jumpFailAlloc |
  	<var: #jumpFailAlloc type: #'AbstractInstruction *'>
  	self MoveR: ReceiverResultReg R: TempReg.
  	objectRepresentation genConvertSmallIntegerToIntegerInReg: TempReg.
  	self ConvertR: TempReg Rd: DPFPReg0.
  	jumpFailAlloc := objectRepresentation
  						genAllocFloatValue: DPFPReg0
  						into: SendNumArgsReg
  						scratchReg: ClassReg
  						scratchReg: TempReg.
  	self MoveR: SendNumArgsReg R: ReceiverResultReg.
  	self RetN: 0.
  	jumpFailAlloc jmpTarget: self Label.
+ 	^self compileFallbackToInterpreterPrimitive: 0!
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveAt (in category 'primitive generators') -----
  genPrimitiveAt
- 	| r |
  	self assert: self numRegArgs >= 1.
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveAt: 0)!
- 	(r := objectRepresentation genInnerPrimitiveAt: 0) < 0 ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveAtPut (in category 'primitive generators') -----
  genPrimitiveAtPut
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveAtPut: 0)!
- 	| r |
- 	((r := objectRepresentation genInnerPrimitiveAtPut: 0) < 0
- 	 and: [r ~= UnimplementedPrimitive]) ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveCharacterValue (in category 'primitive generators') -----
  genPrimitiveCharacterValue
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveCharacterValue: 0)!
- 	| r |
- 	(r := objectRepresentation genInnerPrimitiveCharacterValue: 0) < 0 ifTrue:
- 		[^r].
- 	^r = UnfailingPrimitive
- 		ifTrue: [0]
- 		ifFalse: [self compileFallbackToInterpreterPrimitive]!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveClass (in category 'primitive generators') -----
  genPrimitiveClass
  	"Primitive class must be variadic for objectClass:"
  	| reg |
  	methodOrBlockNumArgs > 0
  		ifTrue:
  			[methodOrBlockNumArgs > 1 ifTrue:
+ 				[^self compileFallbackToInterpreterPrimitive: 0].
- 				[^self compileFallbackToInterpreterPrimitive].
  			 reg := Arg0Reg]
  		ifFalse:
  			[reg := ReceiverResultReg].
  	(objectRepresentation
  			genGetClassObjectOf: reg
  			into: ReceiverResultReg
  			scratchReg: TempReg
  			instRegIsReceiver: methodOrBlockNumArgs = 0) = BadRegisterSet ifTrue:
  		[objectRepresentation
  			genGetClassObjectOf: reg
  			into: ClassReg
  			scratchReg: TempReg
  			instRegIsReceiver: methodOrBlockNumArgs = 0.
  		 self MoveR: ClassReg R: ReceiverResultReg].
  	self RetN: 0.
  	^0!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveFloatSquareRoot (in category 'primitive generators') -----
  genPrimitiveFloatSquareRoot
  	| jumpFailAlloc |
  	<var: #jumpFailAlloc type: #'AbstractInstruction *'>
  	objectRepresentation genGetDoubleValueOf: ReceiverResultReg into: DPFPReg0.
  	self SqrtRd: DPFPReg0.
  	jumpFailAlloc := objectRepresentation
  						genAllocFloatValue: DPFPReg0
  						into: SendNumArgsReg
  						scratchReg: ClassReg
  						scratchReg: TempReg.
  	self MoveR: SendNumArgsReg R: ReceiverResultReg.
  	self RetN: 0.
  	jumpFailAlloc jmpTarget: self Label.
+ 	^self compileFallbackToInterpreterPrimitive: 0!
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveIdentityHash (in category 'primitive generators') -----
  genPrimitiveIdentityHash
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveIdentityHash: 0)!
- 	| r |
- 	(r := objectRepresentation genInnerPrimitiveIdentityHash: 0) < 0 ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveNew (in category 'primitive generators') -----
  genPrimitiveNew
  	| r numArgs |
  	NewspeakVM
  		ifTrue:
+ 			[r := 0.
+ 			 numArgs := coInterpreter argumentCountOf: methodObj.
- 			[numArgs := coInterpreter argumentCountOf: methodObj.
  			 numArgs = 1 ifTrue:
+ 				[r := objectRepresentation genInnerPrimitiveMirrorNew: 0].
- 				[((r := objectRepresentation genInnerPrimitiveMirrorNew: 0) < 0
- 				  and: [r ~= UnimplementedPrimitive]) ifTrue:
- 					[^r]].
  			 numArgs = 0 ifTrue:
+ 				[r := objectRepresentation genInnerPrimitiveNew: 0]]
- 				[((r := objectRepresentation genInnerPrimitiveNew: 0) < 0
- 				  and: [r ~= UnimplementedPrimitive]) ifTrue:
- 					[^r]]]
  		ifFalse:
+ 			[r := objectRepresentation genInnerPrimitiveNew: 0].
- 			[((r := objectRepresentation genInnerPrimitiveNew: 0) < 0
- 			  and: [r ~= UnimplementedPrimitive]) ifTrue:
- 				[^r]].
  	"Call the interpreter primitive either when the machine-code primitive
  	 fails, or if the machine-code primitive is unimplemented."
+ 	^self compileFallbackToInterpreterPrimitive: r!
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveNewMethod (in category 'primitive generators') -----
  genPrimitiveNewMethod
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveNewMethod: 0)!
- 	| r |
- 	((r := objectRepresentation genInnerPrimitiveNewMethod: 0) < 0
- 	 and: [r ~= UnimplementedPrimitive]) ifTrue:
- 		[^r].
- 	"Call the interpreter primitive either when the machine-code primitive
- 	 fails, or if the machine-code primitive is unimplemented."
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveNewWithArg (in category 'primitive generators') -----
  genPrimitiveNewWithArg
  	| r numArgs |
  	NewspeakVM
  		ifTrue:
+ 			[r := 0.
+ 			 numArgs := coInterpreter argumentCountOf: methodObj.
- 			[numArgs := coInterpreter argumentCountOf: methodObj.
  			 numArgs = 2 ifTrue:
+ 				[r := objectRepresentation genInnerPrimitiveMirrorNewWithArg: 0].
- 				[((r := objectRepresentation genInnerPrimitiveMirrorNewWithArg: 0) < 0
- 				  and: [r ~= UnimplementedPrimitive]) ifTrue:
- 					[^r]].
  			 numArgs = 1 ifTrue:
+ 				[r := objectRepresentation genInnerPrimitiveNewWithArg: 0]]
- 				[((r := objectRepresentation genInnerPrimitiveNewWithArg: 0) < 0
- 				  and: [r ~= UnimplementedPrimitive]) ifTrue:
- 					[^r]]]
  		ifFalse:
+ 			[r := objectRepresentation genInnerPrimitiveNewWithArg: 0].
- 			[((r := objectRepresentation genInnerPrimitiveNewWithArg: 0) < 0
- 			  and: [r ~= UnimplementedPrimitive]) ifTrue:
- 				[^r]].
  	"Call the interpreter primitive either when the machine-code primitive
  	 fails, or if the machine-code primitive is unimplemented."
+ 	^self compileFallbackToInterpreterPrimitive: r!
- 	^self compileFallbackToInterpreterPrimitive!

Item was added:
+ ----- Method: StackToRegisterMappingCogit>>genPrimitiveObjectAt (in category 'primitive generators') -----
+ genPrimitiveObjectAt
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveObjectAt: 0)!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveSize (in category 'primitive generators') -----
  genPrimitiveSize
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveSize: 0)!
- 	| r |
- 	(r := objectRepresentation genInnerPrimitiveSize: 0) < 0 ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveStringAt (in category 'primitive generators') -----
  genPrimitiveStringAt
- 	| r |
  	self assert: self numRegArgs >= 1.
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveStringAt: 0)!
- 	(r := objectRepresentation genInnerPrimitiveStringAt: 0) < 0 ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genPrimitiveStringAtPut (in category 'primitive generators') -----
  genPrimitiveStringAtPut
+ 	^self compileFallbackToInterpreterPrimitive:
+ 		(objectRepresentation genInnerPrimitiveStringAtPut: 0)!
- 	| r |
- 	((r := objectRepresentation genInnerPrimitiveStringAtPut: 0) < 0
- 	 and: [r ~= UnimplementedPrimitive]) ifTrue:
- 		[^r].
- 	^self compileFallbackToInterpreterPrimitive!



More information about the Vm-dev mailing list