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

commits at source.squeak.org commits at source.squeak.org
Wed Aug 14 00:51:30 UTC 2013


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

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

Name: VMMaker.oscog-eem.318
Author: eem
Time: 13 August 2013, 5:48:34.574 pm
UUID: 8925d5a6-c7d2-41a7-b776-b1d53ec31cfc
Ancestors: VMMaker.oscog-eem.317

Make primitiveObjectAtPut fail if changing the header word and the
new header has a different literal count.  Avoids crashing the VM
when inadvertently changing the header, as a Newspeak bootstrap
did recently.

Implement frameless inst var store from arguments, so e.g.
Point>>setX:Y: is frameless.  Needs heavy testing so not yet
the default.

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

Item was changed:
  ----- Method: CoInterpreterPrimitives>>primitiveObjectAtPut (in category 'object access primitives') -----
  primitiveObjectAtPut
  	"Store a literal into a CompiledMethod at the given index. Defined for CompiledMethods only."
  	| thisReceiver rawHeader realHeader index newValue |
  	newValue := self stackValue: 0.
  	index := self stackValue: 1.
+ 	(objectMemory isNonIntegerObject: index) ifTrue:
- 	((objectMemory isNonIntegerObject: index)
- 	 or: [index = ConstOne and: [(objectMemory isNonIntegerObject: newValue)]]) ifTrue:
  		[^self primitiveFailFor: PrimErrBadArgument].
  	index := objectMemory integerValueOf: index.
  	thisReceiver := self stackValue: 2.
  	rawHeader := self rawHeaderOf: thisReceiver.
  	realHeader := (self isCogMethodReference: rawHeader)
  					ifTrue: [(self cCoerceSimple: rawHeader to: #'CogMethod *') methodHeader]
  					ifFalse: [rawHeader].
  	(index > 0
  	 and: [index <= ((self literalCountOfHeader: realHeader) + LiteralStart)]) ifFalse:
  		[^self primitiveFailFor: PrimErrBadIndex].
+ 	index = 1
+ 		ifTrue:
+ 			[((objectMemory isNonIntegerObject: newValue)
+ 			 or: [(self literalCountOfHeader: newValue) ~= (self literalCountOfHeader: realHeader)]) ifTrue:
+ 				[^self primitiveFailFor: PrimErrBadArgument].
+ 			 (self isCogMethodReference: rawHeader)
+ 				ifTrue: [(self cCoerceSimple: rawHeader to: #'CogMethod *') methodHeader: newValue]
+ 				ifFalse: [objectMemory storePointerUnchecked: 0 ofObject: thisReceiver withValue: newValue]]
+ 		ifFalse:
+ 			[objectMemory storePointer: index - 1 ofObject: thisReceiver withValue: newValue].
- 	(index = 1
- 	 and: [self isCogMethodReference: rawHeader])
- 		ifTrue: [(self cCoerceSimple: rawHeader to: #'CogMethod *') methodHeader: newValue]
- 		ifFalse: [objectMemory storePointer: index - 1 ofObject: thisReceiver withValue: newValue].
  	self pop: 3 thenPush: newValue!

Item was removed:
- ----- Method: Cogit class>>initializeBytecodeTable (in category 'class initialization') -----
- initializeBytecodeTable
- 	"SimpleStackBasedCogit initializeBytecodeTable"
- 	"StackToRegisterMappingCogit initializeBytecodeTable"
- 
- 	NewspeakVM ifTrue:
- 		[^MULTIPLEBYTECODESETS
- 			ifTrue: [self initializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid]
- 			ifFalse: [self initializeBytecodeTableForNewspeakV3PlusClosures]].
- 
- 	^self initializeBytecodeTableForSqueakV3PlusClosures!

Item was added:
+ ----- Method: Cogit class>>initializeBytecodeTableWith: (in category 'class initialization') -----
+ initializeBytecodeTableWith: optionsDictionary
+ 	"SimpleStackBasedCogit initializeBytecodeTableWith: Dictionary new"
+ 	"StackToRegisterMappingCogit initializeBytecodeTableWith: Dictionary new"
+ 
+ 	(optionsDictionary at: #bytecodeTableInitializer ifAbsent: nil) ifNotNil:
+ 		[:initalizer| ^self perform: initalizer].
+ 
+ 	NewspeakVM ifTrue:
+ 		[^MULTIPLEBYTECODESETS
+ 			ifTrue: [self initializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid]
+ 			ifFalse: [self initializeBytecodeTableForNewspeakV3PlusClosures]].
+ 	^self initializeBytecodeTableForSqueakV3PlusClosures!

Item was changed:
  ----- Method: Cogit class>>initializeWithOptions: (in category 'class initialization') -----
  initializeWithOptions: optionsDictionary
  
  	self initializeMiscConstantsWith: optionsDictionary. "must preceed other initialization."
  	self initializeErrorCodes.
  	self initializeCogMethodConstants.
  	self initializeAnnotationConstants.
+ 	self initializeBytecodeTableWith: optionsDictionary.
- 	self initializeBytecodeTable.
  	self initializePrimitiveTable!

Item was added:
+ ----- Method: Cogit class>>newInitializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid (in category 'class initialization') -----
+ newInitializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid
+ 	"SimpleStackBasedCogit newInitializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid"
+ 	"StackToRegisterMappingCogit newInitializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid"
+ 
+ 	| v3Table v4Table |
+ 	"N.B. Must do it backwards to evaluate AltBlockCreationBytecodeSize & BlockCreationBytecodeSize correctly."
+ 	self newInitializeBytecodeTableForNewspeakV4.
+ 	v4Table := generatorTable.
+ 	AltBlockCreationBytecodeSize := BlockCreationBytecodeSize.
+ 	AltNSSendIsPCAnnotated := NSSendIsPCAnnotated.
+ 	self newInitializeBytecodeTableForNewspeakV3PlusClosures.
+ 	v3Table := generatorTable.
+ 	generatorTable := CArrayAccessor on: v3Table object, v4Table object!

Item was changed:
  ----- Method: SimpleStackBasedCogit class>>initializePrimitiveTableForSqueakV3 (in category 'class initialization') -----
  initializePrimitiveTableForSqueakV3
  	"Initialize the table of primitive generators.  This does not include normal primitives implemened in the coInterpreter."
  	"SimpleStackBasedCogit initializePrimitiveTableForSqueakV3"
  	MaxCompiledPrimitiveIndex := 222.
  	primitiveTable := CArrayAccessor on: (Array new: MaxCompiledPrimitiveIndex + 1).
  	self table: primitiveTable from: 
  	#(	"Integer Primitives (0-19)"
  		(1 genPrimitiveAdd				1)
  		(2 genPrimitiveSubtract			1)
  		(3 genPrimitiveLessThan			1)
  		(4 genPrimitiveGreaterThan		1)
  		(5 genPrimitiveLessOrEqual		1)
  		(6 genPrimitiveGreaterOrEqual	1)
  		(7 genPrimitiveEqual				1)
  		(8 genPrimitiveNotEqual			1)
  		(9 genPrimitiveMultiply			1	processorHasMultiply:)
  		(10 genPrimitiveDivide			1	processorHasDivQuoRem:)
  		(11 genPrimitiveMod				1	processorHasDivQuoRem:)
  		(12 genPrimitiveDiv				1	processorHasDivQuoRem:)
  		(13 genPrimitiveQuo				1	processorHasDivQuoRem:)
  		(14 genPrimitiveBitAnd			1)
  		(15 genPrimitiveBitOr			1)
  		(16 genPrimitiveBitXor			1)
  		(17 genPrimitiveBitShift			1)
  		"(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 primitiveAtPut)"
  		(62 genPrimitiveSize		0)
  		(63 genPrimitiveStringAt	1)
  		"(64 primitiveStringAtPut)"
  		"The stream primitives no longer pay their way; normal Smalltalk code is faster."
  		"(65 primitiveFail)""was primitiveNext"
  		"(66 primitiveFail)" "was primitiveNextPut"
  		"(67 primitiveFail)" "was primitiveAtEnd"
  
  		"StorageManagement Primitives (68-79)"
  		"(68 primitiveObjectAt)"
  		"(69 primitiveObjectAtPut)"
  		"(70 primitiveNew)"
  		"(71 primitiveNewWithArg)"
  		"(72 primitiveArrayBecomeOneWay)"	"Blue Book: primitiveBecome"
  		"(73 primitiveInstVarAt)"
  		"(74 primitiveInstVarAtPut)"
  		(75 genPrimitiveIdentityHash	0)
  		"(76 primitiveStoreStackp)"					"Blue Book: primitiveAsObject"
  		"(77 primitiveSomeInstance)"
  		"(78 primitiveNextInstance)"
  		"(79 primitiveNewMethod)"
  
  		"Control Primitives (80-89)"
  		"(80 primitiveFail)"					"Blue Book: primitiveBlockCopy"
  		"(81 primitiveFail)"					"Blue Book: primitiveValue"
  		"(82 primitiveFail)"					"Blue Book: primitiveValueWithArgs"
  		"(83 primitivePerform)"
  		"(84 primitivePerformWithArgs)"
  		"(85 primitiveSignal)"
  		"(86 primitiveWait)"
  		"(87 primitiveResume)"
  		"(88 primitiveSuspend)"
  		"(89 primitiveFlushCache)"
  
  		"Input/Output Primitives (90-109); We won't compile any of these"
  
  		"System Primitives (110-119)"
  		(110 genPrimitiveEquivalent 1)
+ 		(111 genPrimitiveClass)
- 		"(111 genPrimitiveClass)"
  		"(112 primitiveBytesLeft)"
  		"(113 primitiveQuit)"
  		"(114 primitiveExitToDebugger)"
  		"(115 primitiveChangeClass)"					"Blue Book: primitiveOopsLeft"
  		"(116 primitiveFlushCacheByMethod)"
  		"(117 primitiveExternalCall)"
  		"(118 primitiveDoPrimitiveWithArgs)"
  		"(119 primitiveFlushCacheSelective)"
  			"Squeak 2.2 and earlier use 119.  Squeak 2.3 and later use 116.
  			Both are supported for backward compatibility."
  
  		"Miscellaneous Primitives (120-127); We won't compile any of these"
  
  		"Squeak Primitives Start Here"
  
  		"Squeak Miscellaneous Primitives (128-149); We won't compile any of these"
  
  		"File Primitives (150-169) - NO LONGER INDEXED; We won't compile any of these"
  		(169 genPrimitiveNotEquivalent 1)
  
  		"Sound Primitives (170-199) - NO LONGER INDEXED; We won't compile any of these"
  
  		"Old closure primitives"
  		"(186 primitiveFail)" "was primitiveClosureValue"
  		"(187 primitiveFail)" "was primitiveClosureValueWithArgs"
  
  		"Perform method directly"
  		"(188 primitiveExecuteMethodArgsArray)"
  		"(189 primitiveExecuteMethod)"
  
  		"Sound Primitives (continued) - NO LONGER INDEXED; We won't compile any of these"
  		"(190 194 primitiveFail)"
  
  		"Unwind primitives"
  		"(195 primitiveFindNextUnwindContext)"
  		"(196 primitiveTerminateTo)"
  		"(197 primitiveFindHandlerContext)"
  		(198 genFastPrimFail "primitiveMarkUnwindMethod")
  		(199 genFastPrimFail "primitiveMarkHandlerMethod")
  
  		"new closure primitives (were Networking primitives)"
  		"(200 primitiveClosureCopyWithCopiedValues)"
  		(201 genPrimitiveClosureValue) "value"
  		(202 genPrimitiveClosureValue) "value:"
  		(203 genPrimitiveClosureValue) "value:value:"
  		(204 genPrimitiveClosureValue) "value:value:value:"
  		(205 genPrimitiveClosureValue) "value:value:value:value:"
  		"(206 genPrimitiveClosureValueWithArgs)" "valueWithArguments:"
  
  		"(207 209 primitiveFail)"	"reserved for Cog primitives"
  
  		"(210 primitiveContextAt)"
  		"(211 primitiveContextAtPut)"
  		"(212 primitiveContextSize)"
  		"(213 217 primitiveFail)"	"reserved for Cog primitives"
  		"(218 primitiveDoNamedPrimitiveWithArgs)"
  		"(219 primitiveFail)"	"reserved for Cog primitives"
  
  		"(220 primitiveFail)"		"reserved for Cog primitives"
  
  		(221 genPrimitiveClosureValue) "valueNoContextSwitch"
  		(222 genPrimitiveClosureValue) "valueNoContextSwitch:"
  
  		"(223 229 primitiveFail)"	"reserved for Cog primitives"
  	)!

Item was added:
+ ----- Method: SimpleStackBasedCogit>>genPrimitiveClass (in category 'primitive generators') -----
+ genPrimitiveClass
+ 	"Stack looks like
+ 		receiver (also in ReceiverResultReg)
+ 		return address"
+ 	objectRepresentation genGetClassObjectOf: ReceiverResultReg into: ReceiverResultReg scratchReg: TempReg.
+ 	self flag: 'currently caller pushes result'.
+ 	self RetN: BytesPerWord.
+ 	^0!

Item was added:
+ ----- Method: StackToRegisterMappingCogit class>>newInitializeBytecodeTableForNewspeakV3PlusClosures (in category 'class initialization') -----
+ newInitializeBytecodeTableForNewspeakV3PlusClosures
+ 	"StackToRegisterMappingCogit newInitializeBytecodeTableForNewspeakV3PlusClosures"
+ 
+ 	isPushNilFunction := #v3:Is:Push:Nil:.
+ 	pushNilSizeFunction := #v3PushNilSize:.
+ 	NSSendIsPCAnnotated := true. "IsNSSendCall used by PushImplicitReceiver"
+ 	self flag:
+ 'Special selector send class must be inlined to agree with the interpreter, which
+  inlines class.  If class is sent to e.g. a general instance of ProtoObject then unless
+  class is inlined there will be an MNU.  It must be that the Cointerpreter and Cogit
+  have identical semantics.  We get away with not hardwiring the other special
+  selectors either because in the Cointerpreter they are not inlined or because they
+  are inlined only to instances of classes for which there will always be a method.'.
+ 	self generatorTableFrom: #(
+ 		(1    0   15 genPushReceiverVariableBytecode needsFrameNever: 1)
+ 		(1  16   31 genPushTemporaryVariableBytecode needsFrameIfMod16GENumArgs: 1)
+ 		(1  32   63 genPushLiteralConstantBytecode needsFrameNever: 1)
+ 		(1  64   95 genPushLiteralVariableBytecode needsFrameNever: 1)
+ 		(1  96 103 genStoreAndPopReceiverVariableBytecode needsFrameNever: -1) "N.B. not frameless if immutability"
+ 		(1 104 111 genStoreAndPopTemporaryVariableBytecode)
+ 		(1 112 112 genPushReceiverBytecode needsFrameNever: 1)
+ 		(1 113 113 genPushConstantTrueBytecode needsFrameNever: 1)
+ 		(1 114 114 genPushConstantFalseBytecode needsFrameNever: 1)
+ 		(1 115 115 genPushConstantNilBytecode needsFrameNever: 1)
+ 		(1 116 119 genPushQuickIntegerConstantBytecode needsFrameNever: 1)
+ 		"method returns in blocks need a frame because of nonlocalReturn:through:"
+ 		(1 120 120 genReturnReceiver				return needsFrameIfInBlock: isMappedInBlock 0)
+ 		(1 121 121 genReturnTrue					return needsFrameIfInBlock: isMappedInBlock 0)
+ 		(1 122 122 genReturnFalse					return needsFrameIfInBlock: isMappedInBlock 0)
+ 		(1 123 123 genReturnNil					return needsFrameIfInBlock: isMappedInBlock 0)
+ 		(1 124 124 genReturnTopFromMethod		return needsFrameIfInBlock: isMappedInBlock -1)
+ 		(1 125 125 genReturnTopFromBlock		return needsFrameNever: -1)
+ 
+ 		(3 126 126 genDynamicSuperSendBytecode isMapped)		"Newspeak"
+ 		(2 127 127 genPushImplicitReceiverBytecode isMapped)	"Newspeak"
+ 
+ 		(2 128 128 extendedPushBytecode needsFrameNever: 1)
+ 		(2 129 129 extendedStoreBytecode)
+ 		(2 130 130 extendedStoreAndPopBytecode)
+ 		(2 131 131 genExtendedSendBytecode isMapped)
+ 		(3 132 132 doubleExtendedDoAnythingBytecode isMapped)
+ 		(2 133 133 genExtendedSuperBytecode isMapped)
+ 		(2 134 134 genSecondExtendedSendBytecode isMapped)
+ 		(1 135 135 genPopStackBytecode needsFrameNever: -1)
+ 		(1 136 136 duplicateTopBytecode needsFrameNever: 1)
+ 
+ 		(1 137 137 genPushActiveContextBytecode)
+ 		(2 138 138 genPushNewArrayBytecode)
+ 
+ 		(2 139 139 genPushExplicitOuterSendReceiverBytecode isMapped)	"Newspeak"
+ 
+ 		(3 140 140 genPushRemoteTempLongBytecode)
+ 		(3 141 141 genStoreRemoteTempLongBytecode)
+ 		(3 142 142 genStoreAndPopRemoteTempLongBytecode)
+ 		(4 143 143 genPushClosureCopyCopiedValuesBytecode block v3:Block:Code:Size:)
+ 
+ 		(1 144 151 genShortUnconditionalJump			branch v3:ShortForward:Branch:Distance:)
+ 		(1 152 159 genShortJumpIfFalse					branch isBranchFalse isMapped "because of mustBeBoolean"
+ 															v3:ShortForward:Branch:Distance:)
+ 		(2 160 163 genLongUnconditionalBackwardJump	branch isMapped "because of interrupt check"
+ 															v3:Long:Branch:Distance:)
+ 		(2 164 167 genLongUnconditionalForwardJump		branch v3:Long:Branch:Distance:)
+ 		(2 168 171 genLongJumpIfTrue					branch isBranchTrue isMapped "because of mustBeBoolean"
+ 															v3:LongForward:Branch:Distance:)
+ 		(2 172 175 genLongJumpIfFalse					branch isBranchFalse isMapped "because of mustBeBoolean"
+ 															v3:LongForward:Branch:Distance:)
+ 
+ 		(1 176 176 genSpecialSelectorArithmetic isMapped AddRR)
+ 		(1 177 177 genSpecialSelectorArithmetic isMapped SubRR)
+ 		(1 178 178 genSpecialSelectorComparison isMapped JumpLess)
+ 		(1 179 179 genSpecialSelectorComparison isMapped JumpGreater)
+ 		(1 180 180 genSpecialSelectorComparison isMapped JumpLessOrEqual)
+ 		(1 181 181 genSpecialSelectorComparison isMapped JumpGreaterOrEqual)
+ 		(1 182 182 genSpecialSelectorComparison isMapped JumpZero)
+ 		(1 183 183 genSpecialSelectorComparison isMapped JumpNonZero)
+ 		(1 184 189 genSpecialSelectorSend isMapped)	 " #* #/ #\\ #@ #bitShift: //"
+ 		(1 190 190 genSpecialSelectorArithmetic isMapped AndRR)
+ 		(1 191 191 genSpecialSelectorArithmetic isMapped OrRR)
+ 		(1 192 197 genSpecialSelectorSend isMapped) "#at: #at:put: #size #next #nextPut: #atEnd"
+ 		(1 198 198 genSpecialSelectorEqualsEquals needsFrameNever: notMapped -1) "not mapped because it is directly inlined (for now)"
+ 		(1 199 199 genSpecialSelectorClass needsFrameNever: notMapped 0) "not mapped because it is directly inlined (for now)"
+ 		(1 200 207 genSpecialSelectorSend isMapped) "#blockCopy: #value #value: #do: #new #new: #x #y"
+ 		(1 208 223 genSendLiteralSelector0ArgsBytecode isMapped)
+ 		(1 224 239 genSendLiteralSelector1ArgBytecode isMapped)
+ 		(1 240 255 genSendLiteralSelector2ArgsBytecode isMapped))!

Item was added:
+ ----- Method: StackToRegisterMappingCogit class>>newInitializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid (in category 'class initialization') -----
+ newInitializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid
+ 	"StackToRegisterMappingCogit newInitializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid"
+ 
+ 	super newInitializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid.
+ 	isPushNilFunction := #v3or4:Is:Push:Nil:.
+ 	pushNilSizeFunction := #v3or4PushNilSize:!

Item was added:
+ ----- Method: StackToRegisterMappingCogit class>>newInitializeBytecodeTableForNewspeakV4 (in category 'class initialization') -----
+ newInitializeBytecodeTableForNewspeakV4
+ 	"StackToRegisterMappingCogit newInitializeBytecodeTableForNewspeakV4"
+ 
+ 	isPushNilFunction := #v4:Is:Push:Nil:.
+ 	pushNilSizeFunction := #v4PushNilSize:.
+ 	NSSendIsPCAnnotated := false. "IsNSSendCall used by SendAbsentImplicit"
+ 	self flag:
+ 'Special selector send class must be inlined to agree with the interpreter, which
+  inlines class.  If class is sent to e.g. a general instance of ProtoObject then unless
+  class is inlined there will be an MNU.  It must be that the Cointerpreter and Cogit
+  have identical semantics.  We get away with not hardwiring the other special
+  selectors either because in the Cointerpreter they are not inlined or because they
+  are inlined only to instances of classes for which there will always be a method.'.
+ 	self generatorTableFrom: #(
+ 		"1 byte bytecodes"
+ 		(1    0   15 genPushReceiverVariableBytecode needsFrameNever: 1)
+ 		(1  16   31 genPushLiteralVariable16CasesBytecode needsFrameNever: 1)
+ 		(1  32   63 genPushLiteralConstantBytecode needsFrameNever: 1)
+ 		(1  64   75 genPushTemporaryVariableBytecode needsFrameIfMod16GENumArgs: 1)
+ 		(1  76   76 genPushReceiverBytecode needsFrameNever: 1)
+ 		(1  77   77 genExtPushPseudoVariableOrOuterBytecode)
+ 		(1  78   78 genPushConstantZeroBytecode needsFrameNever: 1)
+ 		(1  79   79 genPushConstantOneBytecode needsFrameNever: 1)
+ 
+ 		(1   80   80 genSpecialSelectorArithmetic isMapped AddRR)
+ 		(1   81   81 genSpecialSelectorArithmetic isMapped SubRR)
+ 		(1   82   82 genSpecialSelectorComparison isMapped JumpLess)
+ 		(1   83   83 genSpecialSelectorComparison isMapped JumpGreater)
+ 		(1   84   84 genSpecialSelectorComparison isMapped JumpLessOrEqual)
+ 		(1   85   85 genSpecialSelectorComparison isMapped JumpGreaterOrEqual)
+ 		(1   86   86 genSpecialSelectorComparison isMapped JumpZero)
+ 		(1   87   87 genSpecialSelectorComparison isMapped JumpNonZero)
+ 		(1   88   93 genSpecialSelectorSend isMapped)	 " #* #/ #\\ #@ #bitShift: //"
+ 		(1   94   94 genSpecialSelectorArithmetic isMapped AndRR)
+ 		(1   95   95 genSpecialSelectorArithmetic isMapped OrRR)
+ 		(1   96 101 genSpecialSelectorSend isMapped) "#at: #at:put: #size #next #nextPut: #atEnd"
+ 		(1 102 102 genSpecialSelectorEqualsEquals needsFrameNever: notMapped -1) "not mapped because it is directly inlined (for now)"
+ 		(1 103 103 genSpecialSelectorClass needsFrameNever: notMapped 0) "not mapped because it is directly inlined (for now)"
+ 		(1 104 111 genSpecialSelectorSend isMapped) "#blockCopy: #value #value: #do: #new #new: #x #y"
+ 
+ 		(1 112 127 genSendLiteralSelector0ArgsBytecode isMapped)
+ 		(1 128 143 genSendLiteralSelector1ArgBytecode isMapped)
+ 		(1 144 159 genSendLiteralSelector2ArgsBytecode isMapped)
+ 		(1 160 175	genSendAbsentImplicit0ArgsBytecode isMapped)
+ 
+ 		(1 176 183 genStoreAndPopReceiverVariableBytecode needsFrameNever: -1) "N.B. not frameless if immutability"
+ 		(1 184 191 genStoreAndPopTemporaryVariableBytecode)
+ 
+ 		(1 192 199 genShortUnconditionalJump	branch v3:ShortForward:Branch:Distance:)
+ 		(1 200 207 genShortJumpIfTrue			branch isBranchTrue isMapped "because of mustBeBoolean"
+ 													v3:ShortForward:Branch:Distance:)
+ 		(1 208 215 genShortJumpIfFalse			branch isBranchFalse isMapped "because of mustBeBoolean"
+ 													v3:ShortForward:Branch:Distance:)
+ 
+ 		(1 216 216 genReturnReceiver				return needsFrameIfInBlock: isMappedInBlock 0)
+ 		(1 217 217 genReturnTopFromMethod		return needsFrameIfInBlock: isMappedInBlock -1)
+ 		(1 218 218 genExtReturnTopFromBlock	return needsFrameNever: -1)
+ 
+ 		(1 219 219 duplicateTopBytecode			needsFrameNever: 1)
+ 		(1 220 220 genPopStackBytecode			needsFrameNever: -1)
+ 		(1 221 221 genExtNopBytecode			needsFrameNever: 0)
+ 		(1 222 223	unknownBytecode)
+ 
+ 		"2 byte bytecodes"
+ 		(2 224 224 extABytecode extension					needsFrameNever: 0)
+ 		(2 225 225 extBBytecode extension					needsFrameNever: 0)
+ 		(2 226 226 genExtPushReceiverVariableBytecode)
+ 		(2 227 227 genExtPushLiteralVariableBytecode		needsFrameNever: 1)
+ 		(2 228 228 genExtPushLiteralBytecode					needsFrameNever: 1)
+ 		(2 229 229 genExtPushIntegerBytecode				needsFrameNever: 1)
+ 		(2 230 230 genLongPushTemporaryVariableBytecode)
+ 		(2 231 231 genPushNewArrayBytecode)
+ 		(2 232 232 genExtStoreReceiverVariableBytecode)
+ 		(2 233 233 genExtStoreLiteralVariableBytecode)
+ 		(2 234 234 genLongStoreTemporaryVariableBytecode)
+ 		(2 235 235 genExtStoreAndPopReceiverVariableBytecode)
+ 		(2 236 236 genExtStoreAndPopLiteralVariableBytecode)
+ 		(2 237 237 genLongStoreAndPopTemporaryVariableBytecode)
+ 
+ 		(2 238 238 genExtSendBytecode isMapped)
+ 		(2 239 239 genExtSendSuperBytecode isMapped)
+ 		(2 240 240 genExtSendAbsentImplicitBytecode isMapped)
+ 		(2 241 241 genExtSendAbsentDynamicSuperBytecode isMapped)
+ 
+ 		(2 242 242 genExtUnconditionalJump	branch isMapped "because of interrupt check" v4:Long:Branch:Distance:)
+ 		(2 243 243 genExtJumpIfTrue			branch isBranchTrue isMapped "because of mustBeBoolean" v4:Long:Branch:Distance:)
+ 		(2 244 244 genExtJumpIfFalse			branch isBranchFalse isMapped "because of mustBeBoolean" v4:Long:Branch:Distance:)
+ 
+ 		(2 245 248	unknownBytecode)
+ 
+ 		"3 byte bytecodes"
+ 		(3 249 249 callPrimitiveBytecode)
+ 		(3 250 250 genPushRemoteTempLongBytecode)
+ 		(3 251 251 genStoreRemoteTempLongBytecode)
+ 		(3 252 252 genStoreAndPopRemoteTempLongBytecode)
+ 		(3 253 253 genExtPushClosureBytecode block v4:Block:Code:Size:)
+ 
+ 		(3 254 255	unknownBytecode))!

Item was added:
+ ----- Method: StackToRegisterMappingCogit class>>newInitializeBytecodeTableForSqueakV3PlusClosures (in category 'class initialization') -----
+ newInitializeBytecodeTableForSqueakV3PlusClosures
+ 	"StackToRegisterMappingCogit newInitializeBytecodeTableForSqueakV3PlusClosures"
+ 
+ 	isPushNilFunction := #v3:Is:Push:Nil:.
+ 	pushNilSizeFunction := #v3PushNilSize:.
+ 	self flag:
+ 'Special selector send class must be inlined to agree with the interpreter, which
+  inlines class.  If class is sent to e.g. a general instance of ProtoObject then unless
+  class is inlined there will be an MNU.  It must be that the Cointerpreter and Cogit
+  have identical semantics.  We get away with not hardwiring the other special
+  selectors either because in the Cointerpreter they are not inlined or because they
+  are inlined only to instances of classes for which there will always be a method.'.
+ 	self generatorTableFrom: #(
+ 		(1    0   15 genPushReceiverVariableBytecode needsFrameNever: 1)
+ 		(1  16   31 genPushTemporaryVariableBytecode needsFrameIfMod16GENumArgs: 1)
+ 		(1  32   63 genPushLiteralConstantBytecode needsFrameNever: 1)
+ 		(1  64   95 genPushLiteralVariableBytecode needsFrameNever: 1)
+ 		(1  96 103 genStoreAndPopReceiverVariableBytecode needsFrameNever: -1) "N.B. not frameless if immutability"
+ 		(1 104 111 genStoreAndPopTemporaryVariableBytecode)
+ 		(1 112 112 genPushReceiverBytecode needsFrameNever: 1)
+ 		(1 113 113 genPushConstantTrueBytecode needsFrameNever: 1)
+ 		(1 114 114 genPushConstantFalseBytecode needsFrameNever: 1)
+ 		(1 115 115 genPushConstantNilBytecode needsFrameNever: 1)
+ 		(1 116 119 genPushQuickIntegerConstantBytecode needsFrameNever: 1)
+ 		"method returns in blocks need a frame because of nonlocalReturn:through:"
+ 		(1 120 120 genReturnReceiver				return needsFrameIfInBlock: isMappedInBlock 0)
+ 		(1 121 121 genReturnTrue					return needsFrameIfInBlock: isMappedInBlock 0)
+ 		(1 122 122 genReturnFalse					return needsFrameIfInBlock: isMappedInBlock 0)
+ 		(1 123 123 genReturnNil					return needsFrameIfInBlock: isMappedInBlock 0)
+ 		(1 124 124 genReturnTopFromMethod		return needsFrameIfInBlock: isMappedInBlock -1)
+ 		(1 125 125 genReturnTopFromBlock		return needsFrameNever: -1)
+ 
+ 		(1 126 127 unknownBytecode)
+ 
+ 		(2 128 128 extendedPushBytecode needsFrameNever: 1)
+ 		(2 129 129 extendedStoreBytecode)
+ 		(2 130 130 extendedStoreAndPopBytecode)
+ 		(2 131 131 genExtendedSendBytecode isMapped)
+ 		(3 132 132 doubleExtendedDoAnythingBytecode isMapped)
+ 		(2 133 133 genExtendedSuperBytecode isMapped)
+ 		(2 134 134 genSecondExtendedSendBytecode isMapped)
+ 		(1 135 135 genPopStackBytecode needsFrameNever: -1)
+ 		(1 136 136 duplicateTopBytecode needsFrameNever: 1)
+ 
+ 		(1 137 137 genPushActiveContextBytecode)
+ 		(2 138 138 genPushNewArrayBytecode)
+ 
+ 		(1 139 139 unknownBytecode)
+ 
+ 		(3 140 140 genPushRemoteTempLongBytecode)
+ 		(3 141 141 genStoreRemoteTempLongBytecode)
+ 		(3 142 142 genStoreAndPopRemoteTempLongBytecode)
+ 		(4 143 143 genPushClosureCopyCopiedValuesBytecode block v3:Block:Code:Size:)
+ 
+ 		(1 144 151 genShortUnconditionalJump			branch v3:ShortForward:Branch:Distance:)
+ 		(1 152 159 genShortJumpIfFalse					branch isBranchFalse isMapped "because of mustBeBoolean"
+ 															v3:ShortForward:Branch:Distance:)
+ 		(2 160 163 genLongUnconditionalBackwardJump	branch isMapped "because of interrupt check"
+ 															v3:Long:Branch:Distance:)
+ 		(2 164 167 genLongUnconditionalForwardJump		branch v3:Long:Branch:Distance:)
+ 		(2 168 171 genLongJumpIfTrue					branch isBranchTrue isMapped "because of mustBeBoolean"
+ 															v3:LongForward:Branch:Distance:)
+ 		(2 172 175 genLongJumpIfFalse					branch isBranchFalse isMapped "because of mustBeBoolean"
+ 															v3:LongForward:Branch:Distance:)
+ 
+ 		(1 176 176 genSpecialSelectorArithmetic isMapped AddRR)
+ 		(1 177 177 genSpecialSelectorArithmetic isMapped SubRR)
+ 		(1 178 178 genSpecialSelectorComparison isMapped JumpLess)
+ 		(1 179 179 genSpecialSelectorComparison isMapped JumpGreater)
+ 		(1 180 180 genSpecialSelectorComparison isMapped JumpLessOrEqual)
+ 		(1 181 181 genSpecialSelectorComparison isMapped JumpGreaterOrEqual)
+ 		(1 182 182 genSpecialSelectorComparison isMapped JumpZero)
+ 		(1 183 183 genSpecialSelectorComparison isMapped JumpNonZero)
+ 		(1 184 189 genSpecialSelectorSend isMapped)	 " #* #/ #\\ #@ #bitShift: //"
+ 		(1 190 190 genSpecialSelectorArithmetic isMapped AndRR)
+ 		(1 191 191 genSpecialSelectorArithmetic isMapped OrRR)
+ 		(1 192 197 genSpecialSelectorSend isMapped) "#at: #at:put: #size #next #nextPut: #atEnd"
+ 		(1 198 198 genSpecialSelectorEqualsEquals needsFrameNever: notMapped -1) "not mapped because it is directly inlined (for now)"
+ 		(1 199 199 genSpecialSelectorClass needsFrameNever: notMapped 0) "not mapped because it is directly inlined (for now)"
+ 		(1 200 207 genSpecialSelectorSend isMapped) "#blockCopy: #value #value: #do: #new #new: #x #y"
+ 		(1 208 223 genSendLiteralSelector0ArgsBytecode isMapped)
+ 		(1 224 239 genSendLiteralSelector1ArgBytecode isMapped)
+ 		(1 240 255 genSendLiteralSelector2ArgsBytecode isMapped))!

Item was added:
+ ----- Method: StackToRegisterMappingCogit>>genFramelessStorePop:ReceiverVariable: (in category 'bytecode generators') -----
+ genFramelessStorePop: popBoolean ReceiverVariable: slotIndex
+ 	<inline: false>
+ 	| topReg valueReg constVal |
+ 	self assert: needsFrame not.
+ 	self ssFlushUpThroughReceiverVariable: slotIndex.
+ 	"Avoid store check for immediate values"
+ 	constVal := self ssTop maybeConstant.
+ 	(self ssTop type = SSConstant
+ 	 and: [(objectRepresentation shouldAnnotateObjectReference: constVal) not]) ifTrue:
+ 		[self ensureReceiverResultRegContainsSelf.
+ 		 self ssStorePop: popBoolean toPreferredReg: TempReg.
+ 		 traceStores > 0 ifTrue:
+ 			[self CallRT: ceTraceStoreTrampoline].
+ 		 ^objectRepresentation
+ 			genStoreImmediateInSourceReg: TempReg
+ 			slotIndex: slotIndex
+ 			destReg: ReceiverResultReg].
+ 	topReg := ClassReg.
+ 	self ssPop: 1.
+ 	self ssAllocateCallReg: topReg. "for the ceStoreCheck call in genStoreSourceReg:... below"
+ 	self ssPush: 1.
+ 	valueReg := self ssStorePop: popBoolean toPreferredReg: topReg.
+ 	valueReg ~= topReg ifTrue:
+ 		[self MoveR: valueReg R: topReg].
+ 	"Note that ReceiverResultReg remains live after ceStoreCheckTrampoline."
+ 	self ensureReceiverResultRegContainsSelf.
+ 	 traceStores > 0 ifTrue:
+ 		[self MoveR: topReg R: TempReg.
+ 		 self CallRT: ceTraceStoreTrampoline].
+ 	^objectRepresentation
+ 		genStoreSourceReg: topReg
+ 		slotIndex: slotIndex
+ 		destReg: ReceiverResultReg
+ 		scratchReg: TempReg!

Item was added:
+ ----- Method: StackToRegisterMappingCogit>>genPrimitiveClass (in category 'primitive generators') -----
+ genPrimitiveClass
+ 	objectRepresentation
+ 		genGetClassObjectOf: ReceiverResultReg
+ 		into: ReceiverResultReg
+ 		scratchReg: TempReg.
+ 	self RetN: 0.
+ 	^0!

Item was changed:
  ----- Method: StackToRegisterMappingCogit>>genStorePop:ReceiverVariable: (in category 'bytecode generators') -----
  genStorePop: popBoolean ReceiverVariable: slotIndex
  	<inline: false>
  	| topReg valueReg constVal |
+ 	needsFrame ifFalse:
+ 		[^self genFramelessStorePop: popBoolean ReceiverVariable: slotIndex].
  	self ssFlushUpThroughReceiverVariable: slotIndex.
  	"Avoid store check for immediate values"
  	constVal := self ssTop maybeConstant.
  	(self ssTop type = SSConstant
  	 and: [(objectRepresentation shouldAnnotateObjectReference: constVal) not]) ifTrue:
  		[self ensureReceiverResultRegContainsSelf.
  		 self ssStorePop: popBoolean toPreferredReg: TempReg.
  		 traceStores > 0 ifTrue:
  			[self CallRT: ceTraceStoreTrampoline].
  		 ^objectRepresentation
  			genStoreImmediateInSourceReg: TempReg
  			slotIndex: slotIndex
  			destReg: ReceiverResultReg].
  	((topReg := self ssTop registerOrNil) isNil
  	 or: [topReg = ReceiverResultReg]) ifTrue:
  		[topReg := ClassReg].
  	self ssPop: 1.
  	self ssAllocateCallReg: topReg. "for the ceStoreCheck call in genStoreSourceReg:... below"
  	self ssPush: 1.
  	valueReg := self ssStorePop: popBoolean toPreferredReg: topReg.
  	valueReg = ReceiverResultReg ifTrue:
  		[self MoveR: valueReg R: topReg].
  	"Note that ReceiverResultReg remains live after ceStoreCheckTrampoline."
  	self ensureReceiverResultRegContainsSelf.
  	 traceStores > 0 ifTrue:
  		[self MoveR: topReg R: TempReg.
  		 self CallRT: ceTraceStoreTrampoline].
  	^objectRepresentation
  		genStoreSourceReg: topReg
  		slotIndex: slotIndex
  		destReg: ReceiverResultReg
  		scratchReg: TempReg!

Item was added:
+ ----- Method: VMMaker class>>generateNewNewspeakCogVM (in category 'configurations') -----
+ generateNewNewspeakCogVM
+ 	"VMMaker generateNewNewspeakCogVM"
+ 	^VMMaker
+ 		generate: CoInterpreter
+ 		and: StackToRegisterMappingCogit"Cogit chooseCogitClass"
+ 		with: #(	NewspeakVM true
+ 				MULTIPLEBYTECODESETS true
+ 				bytecodeTableInitializer newInitializeBytecodeTableForNewspeakV3PlusClosuresNewspeakV4Hybrid)
+ 		to: (FileDirectory default pathFromURI: 'oscogvm/nscogsrc')
+ 		platformDir: (FileDirectory default pathFromURI: 'oscogvm/platforms')
+ 		including:#(	AsynchFilePlugin BMPReadWriterPlugin BalloonEnginePlugin BitBltSimulation DSAPlugin DropPlugin
+ 					FileCopyPlugin FilePlugin FloatArrayPlugin FloatMathPlugin InflatePlugin JPEGReadWriter2Plugin
+ 					JPEGReaderPlugin LargeIntegersPlugin Matrix2x3Plugin MiscPrimitivePlugin NewsqueakIA32ABIPlugin
+ 					RePlugin SecurityPlugin SocketPlugin SoundPlugin SqueakSSLPlugin SurfacePlugin ThreadedIA32FFIPlugin
+ 					UUIDPlugin UnixOSProcessPlugin VMProfileLinuxSupportPlugin VMProfileMacSupportPlugin Win32OSProcessPlugin)!



More information about the Vm-dev mailing list