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

commits at source.squeak.org commits at source.squeak.org
Sun Jan 10 18:49:14 UTC 2016

Eliot Miranda uploaded a new version of VMMaker to project VM Maker:

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

Name: VMMaker.oscog-eem.1627
Author: eem
Time: 10 January 2016, 10:47:33.98326 am
UUID: f97c427f-d97d-413b-9697-368e50fbf958
Ancestors: VMMaker.oscog-eem.1626

Slang: Avoid having to mark quick methiods as <inline: true> by providing #asSpecifiedOrQuick as an inlining policy.

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

Item was changed:
  ----- Method: CCodeGenerator>>collectInlineList: (in category 'inlining') -----
  collectInlineList: inlineFlagOrSymbol
  	"Make a list of methods that should be inlined.  If inlineFlagOrSymbol == #asSpecified
+ 	 only inline methods marked with <inline: true>.  If inlineFlagOrSymbol == #asSpecifiedOrQuick
+ 	 only inline methods marked with <inline: true> or methods that are quick (^constant, ^inst var)."
- 	 only inline methods marked with <inline: true>."
  	"Details: The method must not include any inline C, since the
  	 translator cannot currently map variable names in inlined C code.
  	 Methods to be inlined must be small or called from only one place."
  	| selectorsOfMethodsNotToInline callsOf |
+ 	self assert: (#(true false asSpecified asSpecifiedOrQuick) includes: inlineFlagOrSymbol).
- 	self assert: (#(true false asSpecified) includes: inlineFlagOrSymbol).
  	selectorsOfMethodsNotToInline := Set new: methods size.
  	selectorsOfMethodsNotToInline addAll: macros keys.
  	apiMethods ifNotNil:
  		[selectorsOfMethodsNotToInline addAll: apiMethods keys].
  	methods do:
  		m isStructAccessor ifTrue:
  			[selectorsOfMethodsNotToInline add: m selector]].
  	"build dictionary to record the number of calls to each method"
  	callsOf := Dictionary new: methods size * 2.
  	methods keysAndValuesDo:
  		[:s :m|
  		(m isRealMethod
  		 and: [self shouldGenerateMethod: m]) ifTrue:
  			[callsOf at: s put: 0]].
  	"For each method, scan its parse tree once or twice to:
  		1. determine if the method contains unrenamable C code or declarations or has a C builtin
  		2. determine how many nodes it has
  		3. increment the sender counts of the methods it calls"
  	inlineList := Set new: methods size * 2.
  	(methods reject: [:m| selectorsOfMethodsNotToInline includes: m selector]) do:
  		[:m| | inlineIt hasUnrenamableCCode nodeCount |
  		((breakSrcInlineSelectors includes: m selector)
  		 and: [breakOnInline isNil]) ifTrue:
  			[self halt].
  		inlineIt := #dontCare.
  		(translationDict includesKey: m selector)
  			ifTrue: [hasUnrenamableCCode := true]
  				[hasUnrenamableCCode := m hasUnrenamableCCode.
  				 nodeCount := 0.
  				 m parseTree nodesDo:
  					node isSend ifTrue:
  							at: node selector
  								[:senderCount| callsOf at: node selector put: senderCount + 1]].
  					 nodeCount := nodeCount + 1].
+ 				inlineIt := m extractInlineDirective].  "may be true, false, #always, #never or #dontCare"
- 				inlineIt := m extractInlineDirective].  "may be true, false, or #dontCare"
  		(hasUnrenamableCCode or: [inlineIt == false])
  			ifTrue: "don't inline if method has C code or contains negative inline directive"
  				[inlineIt == true ifTrue:
  						nextPutAll: 'failed to inline ';
  						nextPutAll: m selector;
  						nextPutAll: ' as it contains unrenamable C declarations or C code';
  						cr; flush].
  				selectorsOfMethodsNotToInline add: m selector]
+ 				[(inlineFlagOrSymbol caseOf: {
+ 						[#asSpecified]			-> [inlineIt == true].
+ 						[#asSpecifiedOrQuick]	-> [inlineIt == true or: [m compiledMethod isQuick]].
+ 						[true]					-> [nodeCount < 40 or: [inlineIt == true]].
+ 						[false]					-> [false]})
+ 					ifTrue: "inline if method has no C code and is either small or contains inline directive"
+ 						[inlineList add: m selector]
+ 					ifFalse:
+ 						[(#(asSpecified asSpecifiedOrQuick) includes: inlineFlagOrSymbol) ifTrue:
+ 							[selectorsOfMethodsNotToInline add: m selector]]]].
- 				[(inlineFlagOrSymbol == #asSpecified
- 					ifTrue: [inlineIt == true]
- 					ifFalse: [nodeCount < 40 or: [inlineIt == true]]) ifTrue:
- 				"inline if method has no C code and is either small or contains inline directive"
- 					[inlineList add: m selector]]].
+ 	(#(asSpecified asSpecifiedOrQuick) includes: inlineFlagOrSymbol) ifFalse:
- 	inlineFlagOrSymbol ~~ #asSpecified ifTrue:
  		[callsOf associationsDo:
  			(assoc value = 1
  			 and: [(selectorsOfMethodsNotToInline includes: assoc key) not]) ifTrue:
  				[inlineList add: assoc key]]]!

Item was changed:
  ----- Method: CogAbstractInstruction class>>requiredMethodNames: (in category 'translation') -----
  requiredMethodNames: options
  	^self selectors reject:
+ 		[:s| | m |
- 		[:s|
  		(self isAccessor: s)
+ 		or: [((m := self compiledMethodAt: s) isQuick and: [m pragmas isEmpty])
+ 		or: [(m pragmaAt: #doNotGenerate) notNil
+ 		or: [(m pragmaAt: #inline:) notNil and: [(m pragmaAt: #inline:) arguments first == true]]]]]!
- 		or: [((self compiledMethodAt: s) pragmaAt: #doNotGenerate) notNil
- 		or: [((self compiledMethodAt: s) pragmaAt: #inline:) notNil
- 			and: [((self compiledMethodAt: s) pragmaAt: #inline:) arguments first == true]]]]!

Item was changed:
  ----- Method: Cogit class>>doInlining (in category 'translation') -----
  	"inline only those methods that are marked with <inline: true>"
+ 	^#asSpecifiedOrQuick!
- 	^#asSpecified!

More information about the Vm-dev mailing list