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

commits at source.squeak.org commits at source.squeak.org
Sat Jan 21 01:54:36 UTC 2017


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

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

Name: VMMaker.oscog-eem.2106
Author: eem
Time: 20 January 2017, 5:53:50.348341 pm
UUID: a8025b13-c9b8-4ab6-9874-42a8f78daac1
Ancestors: VMMaker.oscog-cb.2105

SistaCogit:
Fix coging optimized methods with lots of literals.

Decode a method header when doing longPrintOop:.

Fix the ssFlushTo: call in genExtJumpIfNotInstanceOfBehaviorsBytecode

Use Spur's single-bit tests for immediates in the CogObjectRepresetationFor??BitSpur's branchIf:has[Not]ImmediateTag:target:

Remember to preserve BytecodeSetHasExtensions when constructing the Cogit hybrid bytecode tables (otherwise initExts dies in the Simulator, but not in C cuz nil = 0).

Hack around Pharo's String class>>findSubstringViaPrimitive:in:startingAt:matchTable: in the simulator.

=============== Diff against VMMaker.oscog-cb.2105 ===============

Item was changed:
  ----- Method: CCodeGenerator>>compileToTMethodSelector:in: (in category 'utilities') -----
  compileToTMethodSelector: selector in: aClass
  	"Compile a method to a TMethod"
+ 	| implementingClass |
+ 	implementingClass := aClass.
- 
  	^(Compiler new
+ 		parse: ([aClass sourceCodeAt: selector]
+ 					on: KeyNotFound
+ 					do: [:ex| "Quick hack for simulating Pharo images..."
+ 						(PharoVM and: [aClass == String class and: [selector == #findSubstringViaPrimitive:in:startingAt:matchTable:]]) ifFalse:
+ 							[ex pass].
+ 						(implementingClass :=  ByteString) sourceCodeAt: #findSubstring:in:startingAt:matchTable:])
+ 		in: implementingClass
- 		parse: (aClass sourceCodeAt: selector)
- 		in: aClass
  		notifying: nil)
  			asTranslationMethodOfClass: self translationMethodClass!

Item was changed:
  ----- Method: CoInterpreter>>methodWithHeaderShouldBeCogged: (in category 'compiled methods') -----
  methodWithHeaderShouldBeCogged: methodHeader
  	"At the moment jit any method with less than N literals, where N defaults to 60.
  	 See e.g. SimpleStackBasedCogit class>>initialize.
  	 In my dev image eem 2/22/2009 13:39
  		(30 to: 100 by: 5) collect:
  			[:n| n -> (SystemNavigation default allSelect: [:m| m numLiterals > n]) size]
  		#(30->1681 35->1150 40->765 45->523 50->389 55->289 60->206
  		    65->151 70->124 75->99 80->73 85->63 90->54 95->42 100->38).
  	 And running the CogVMSimulator with flagging of interpreted methods turned on reveals
  	 the following sizes of interpreted methods.
  		| sizes |
  		sizes := Bag new.
  		SystemNavigation default allSelect: [:m| m flag ifTrue: [sizes add: m numLiterals]. false].
  		sizes sortedElements asArray
  			#(	40->4 41->1 42->2 44->1 45->3 46->1 47->2 48->1
  				50->2 51->1 53->1 55->1 56->1
  				87->1 108->1 171->1)
  	 literalCountOfHeader: does not include the header word."
+ 	^SistaVM
+ 		ifTrue: [(self isOptimizedMethodHeader: methodHeader)
+ 				or: [(objectMemory literalCountOfMethodHeader: methodHeader) <= maxLiteralCountForCompile]]
+ 		ifFalse: [(objectMemory literalCountOfMethodHeader: methodHeader) <= maxLiteralCountForCompile]!
- 	^(objectMemory literalCountOfMethodHeader: methodHeader) <= maxLiteralCountForCompile!

Item was changed:
  ----- Method: CoInterpreter>>printMethodHeaderOop: (in category 'debug printing') -----
  printMethodHeaderOop: anOop
  	"Print the CogMethod and its header if this is a CogMethod reference."
  	| cogMethod |
  	<var: #cogMethod type: #'CogMethod *'>
  	(self isCogMethodReference: anOop) ifTrue:
  		[cogMethod := cogMethodZone methodFor: (self pointerForOop: anOop).
  		 cogMethod ~= 0 ifTrue:
+ 			[^self printHex: anOop; space; printDecodeMethodHeaderOop: cogMethod methodHeader]].
+ 	^self printDecodeMethodHeaderOop: anOop!
- 			[^self printHex: anOop; space; printOopShort: cogMethod methodHeader]].
- 	^self printOopShort: anOop!

Item was changed:
  ----- Method: CogObjectRepresentationFor32BitSpur>>branchIf:hasImmediateTag:target: (in category 'sista support') -----
  branchIf: reg hasImmediateTag: classIndex target: targetFixUp
  	<var: #targetFixUp type: #'AbstractInstruction *'>
  	| jmpImmediate|
  	<inline: true>
- 	cogit MoveR: reg R: TempReg.
  	classIndex = objectMemory smallIntegerTag ifTrue:
+ 		[jmpImmediate := self genJumpSmallInteger: reg].
- 		[jmpImmediate := self genJumpSmallIntegerInScratchReg: TempReg].
  	classIndex = objectMemory characterTag ifTrue:
+ 		[jmpImmediate := self genJumpCharacter: reg].
- 		[jmpImmediate := self genJumpCharacterInScratchReg: TempReg].
  	jmpImmediate jmpTarget: targetFixUp!

Item was changed:
  ----- Method: CogObjectRepresentationFor32BitSpur>>branchIf:hasNotImmediateTag:target: (in category 'sista support') -----
  branchIf: reg hasNotImmediateTag: classIndex target: targetFixUp
  	<var: #targetFixUp type: #'AbstractInstruction *'>
+ 	| jmpImmediate |
- 	| jmpImmediate|
  	<inline: true>
- 	cogit MoveR: reg R: TempReg.
  	classIndex = objectMemory smallIntegerTag ifTrue:
+ 		[jmpImmediate := self genJumpNotSmallInteger: reg].
- 		[jmpImmediate := self genJumpNotSmallIntegerInScratchReg: TempReg].
  	classIndex = objectMemory characterTag ifTrue:
+ 		[jmpImmediate := self genJumpNotCharacter: reg].
- 		[jmpImmediate := self genJumpNotCharacterInScratchReg: TempReg].
  	jmpImmediate jmpTarget: targetFixUp!

Item was changed:
  ----- Method: CogObjectRepresentationFor64BitSpur>>branchIf:hasImmediateTag:target: (in category 'sista support') -----
  branchIf: reg hasImmediateTag: classIndex target: targetFixUp
  	<var: #targetFixUp type: #'AbstractInstruction *'>
+ 	| jmpImmediate |
- 	| jmpImmediate|
  	<inline: true>
- 	cogit MoveR: reg R: TempReg.
  	classIndex = objectMemory smallIntegerTag ifTrue:
+ 		[jmpImmediate := self genJumpSmallInteger: reg].
- 		[jmpImmediate := self genJumpSmallIntegerInScratchReg: TempReg].
  	classIndex = objectMemory characterTag ifTrue:
+ 		[jmpImmediate := self genJumpCharacter: reg].
- 		[jmpImmediate := self genJumpCharacterInScratchReg: TempReg].
  	classIndex = objectMemory smallFloatTag ifTrue:
+ 		[jmpImmediate := self genJumpSmallFloat: reg].
- 		[jmpImmediate := self genJumpSmallFloatInScratchReg: TempReg].
  	jmpImmediate jmpTarget: targetFixUp!

Item was changed:
  ----- Method: CogObjectRepresentationFor64BitSpur>>branchIf:hasNotImmediateTag:target: (in category 'sista support') -----
  branchIf: reg hasNotImmediateTag: classIndex target: targetFixUp
  	<var: #targetFixUp type: #'AbstractInstruction *'>
+ 	| jmpImmediate |
- 	| jmpImmediate|
  	<inline: true>
- 	cogit MoveR: reg R: TempReg.
  	classIndex = objectMemory smallIntegerTag ifTrue:
+ 		[jmpImmediate := self genJumpNotSmallInteger: reg].
- 		[jmpImmediate := self genJumpNotSmallIntegerInScratchReg: TempReg].
  	classIndex = objectMemory characterTag ifTrue:
+ 		[jmpImmediate := self genJumpNotCharacter: reg].
- 		[jmpImmediate := self genJumpNotCharacterInScratchReg: TempReg].
  	classIndex = objectMemory smallFloatTag ifTrue:
+ 		[jmpImmediate := self genJumpNotSmallFloat: reg].
- 		[jmpImmediate := self genJumpNotSmallFloatInScratchReg: TempReg].
  	jmpImmediate jmpTarget: targetFixUp!

Item was changed:
  ----- Method: Cogit class>>initializeBytecodeTableForSqueakV3PlusClosuresNewspeakV4Hybrid (in category 'class initialization') -----
  initializeBytecodeTableForSqueakV3PlusClosuresNewspeakV4Hybrid
  	"SimpleStackBasedCogit initializeBytecodeTableForSqueakV3PlusClosuresNewspeakV4Hybrid"
  	"StackToRegisterMappingCogit initializeBytecodeTableForSqueakV3PlusClosuresNewspeakV4Hybrid"
  
  	| v3Table v4Table |
  	"N.B. Must do it backwards to evaluate AltBlockCreationBytecodeSize & BlockCreationBytecodeSize et al correctly."
  	self initializeBytecodeTableForNewspeakV4.
  	v4Table := generatorTable.
  	AltBlockCreationBytecodeSize := BlockCreationBytecodeSize.
  	AltNSSendIsPCAnnotated := NSSendIsPCAnnotated.
  	AltFirstSpecialSelector := FirstSpecialSelector.
  	AltNumSpecialSelectors := NumSpecialSelectors.
  	self initializeBytecodeTableForSqueakV3PlusClosures.
+ 	BytecodeSetHasExtensions := true.
  	v3Table := generatorTable.
  	generatorTable := CArrayAccessor on: v3Table object, v4Table object!

Item was changed:
  ----- Method: Cogit class>>initializeBytecodeTableForSqueakV3PlusClosuresSistaV1Hybrid (in category 'class initialization') -----
  initializeBytecodeTableForSqueakV3PlusClosuresSistaV1Hybrid
  	"SimpleStackBasedCogit initializeBytecodeTableForSqueakV3PlusClosuresSistaV1Hybrid"
  	"StackToRegisterMappingCogit initializeBytecodeTableForSqueakV3PlusClosuresSistaV1Hybrid"
  
  	| v3Table v1Table |
  	"N.B. Must do it backwards to evaluate AltBlockCreationBytecodeSize & BlockCreationBytecodeSize et al correctly."
  	self initializeBytecodeTableForSistaV1.
  	v1Table := generatorTable.
  	AltBlockCreationBytecodeSize := BlockCreationBytecodeSize.
  	AltFirstSpecialSelector := FirstSpecialSelector.
  	AltNumSpecialSelectors := NumSpecialSelectors.
  	self initializeBytecodeTableForSqueakV3PlusClosures.
+ 	BytecodeSetHasExtensions := true.
  	v3Table := generatorTable.
  	generatorTable := CArrayAccessor on: v3Table object, v1Table object!

Item was changed:
  ----- Method: InterpreterPlugin class>>methodForTranslatedPrimitiveTuple: (in category 'translated primitives') -----
  methodForTranslatedPrimitiveTuple: tuple
  	| class |
  	class := Smalltalk classNamed: tuple first.
  	^class
  		compiledMethodAt: tuple last
+ 		ifAbsent:
+ 			[class class
+ 				compiledMethodAt: tuple last
+ 				ifAbsent: [tuple = #(String findSubstringViaPrimitive:in:startingAt:matchTable:) ifTrue:
+ 							[ByteString compiledMethodAt: #findSubstring:in:startingAt:matchTable:]]]!
- 		ifAbsent: [class class compiledMethodAt: tuple last]!

Item was changed:
  ----- Method: SistaCogit>>genExtJumpIfNotInstanceOfBehaviorsBytecode (in category 'bytecode generators') -----
  genExtJumpIfNotInstanceOfBehaviorsBytecode
  	"SistaV1: *	254		11111110	kkkkkkkk	jjjjjjjj		branch If Not Instance Of Behavior/Array Of Behavior kkkkkkkk (+ Extend A * 256, where Extend A >= 0) distance jjjjjjjj (+ Extend B * 256, where Extend B >= 0)"
  	| reg literal distance targetFixUp inverse |
  
  	"We lose the information of in which register is stack top 
  	 when jitting the branch target so we need to flush everything. 
  	 We could use a fixed register here...."
  	reg := self allocateRegForStackEntryAt: 0.
  	self ssTop popToReg: reg.
- 	self ssFlushTo: simStackPtr. "flushed but the value is still in reg"
  	self ssPop: 1.
+ 	self ssFlushTo: simStackPtr. "flushed but the value is still in reg"
  
  	literal := self getLiteral: (extA * 256 + byte1).
  	(inverse := extB < 0) ifTrue:
  		[extB := extB + 128].
  	distance := extB * 256 + byte2.
  	extA := extB := numExtB := 0.
  
  	targetFixUp := self cCoerceSimple: (self ensureFixupAt: bytecodePC + 3 + distance - initialPC) to: #'AbstractInstruction *'.
  	inverse
  		ifFalse: 
  			[(objectMemory isArrayNonImm: literal)
  				ifTrue: [objectRepresentation branchIf: reg notInstanceOfBehaviors: literal target: targetFixUp]
  				ifFalse: [objectRepresentation branchIf: reg notInstanceOfBehavior: literal target: targetFixUp] ]
  		ifTrue:
  			[(objectMemory isArrayNonImm: literal)
  				ifTrue: [objectRepresentation branchIf: reg instanceOfBehaviors: literal target: targetFixUp]
  				ifFalse: [objectRepresentation branchIf: reg instanceOfBehavior: literal target: targetFixUp]].
  
  	^0!

Item was added:
+ ----- Method: StackDepthFinder>>branchIfInstanceOf:distance: (in category 'instruction decoding') -----
+ branchIfInstanceOf: behaviorOrArrayOfBehavior distance: delta
+ 	self drop.
+ 	self doJump: delta!

Item was changed:
  ----- Method: StackInterpreter class>>initializeBytecodeTableForSqueakV3PlusClosuresNewspeakV4Hybrid (in category 'initialization') -----
  initializeBytecodeTableForSqueakV3PlusClosuresNewspeakV4Hybrid
  	"StackInterpreter initializeBytecodeTableForSqueakV3PlusClosuresNewspeakV4Hybrid"
  
  	| v3Table v4Table |
  	self initializeBytecodeTableForNewspeakV4.
  	v4Table := BytecodeTable.
  	AltBytecodeEncoderClassName := BytecodeEncoderClassName.
  	AltLongStoreBytecode := LongStoreBytecode.
  	self initializeBytecodeTableForSqueakV3PlusClosures.
+ 	BytecodeSetHasExtensions := true.
  	v3Table := BytecodeTable.
  	BytecodeTable := v3Table, v4Table!

Item was changed:
  ----- Method: StackInterpreter class>>initializeBytecodeTableForSqueakV3PlusClosuresSistaV1Hybrid (in category 'initialization') -----
  initializeBytecodeTableForSqueakV3PlusClosuresSistaV1Hybrid
  	"StackInterpreter initializeBytecodeTableForSqueakV3PlusClosuresSistaV1Hybrid"
  
  	| v3Table v1Table |
  	self initializeBytecodeTableForSistaV1.
  	v1Table := BytecodeTable.
  	AltBytecodeEncoderClassName := BytecodeEncoderClassName.
  	AltLongStoreBytecode := LongStoreBytecode.
  	self initializeBytecodeTableForSqueakV3PlusClosures.
+ 	BytecodeSetHasExtensions := true.
  	v3Table := BytecodeTable.
  	BytecodeTable := v3Table, v1Table!

Item was added:
+ ----- Method: StackInterpreter>>printDecodeMethodHeaderOop: (in category 'printing') -----
+ printDecodeMethodHeaderOop: methodHeaderOop
+ 	self printOopShort: methodHeaderOop.
+ 	(self methodHeaderHasPrimitive: methodHeaderOop) ifTrue:
+ 		[self print: ' hasPrim'].
+ 	(self methodHeaderIndicatesLargeFrame: methodHeaderOop) ifTrue:
+ 		[self print: ' largeFrame'].
+ 	(SistaVM and: [self isOptimizedMethodHeader: methodHeaderOop]) ifTrue:
+ 		[self print: ' optimized'].
+ 	(MULTIPLEBYTECODESETS and: [self integerValueOf: methodHeaderOop]) < 0 ifTrue:
+ 		[self print: ' altSet'].
+ 	NewspeakVM ifTrue:
+ 		[self print: ((self accessModifierOfMethodHeader: methodHeaderOop) caseOf: {
+ 						[0] -> [' public'].
+ 						[1] -> [' private'].
+ 						[2] -> [' protected'].
+ 						[3] -> [' access undefined'] })].
+ 	self print: ' nLits '; printNum: (objectMemory literalCountOfMethodHeader: methodHeaderOop);
+ 		print: ' nArgs '; printNum: (self argumentCountOfMethodHeader: methodHeaderOop);
+ 		print: ' nTemps '; printNum: (self temporaryCountOfMethodHeader: methodHeaderOop)!

Item was changed:
  ----- Method: StackInterpreter>>printMethodHeaderOop: (in category 'debug printing') -----
  printMethodHeaderOop: anOop
  	"Override hook for CoInterpreter"
  	<inline: true>
+ 	^self printDecodeMethodHeaderOop: anOop!
- 	^self printOopShort: anOop!



More information about the Vm-dev mailing list