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

commits at source.squeak.org commits at source.squeak.org
Fri May 9 18:23:10 UTC 2014

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

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

Name: VMMaker.oscog-eem.709
Author: eem
Time: 9 May 2014, 11:19:07.459 am
UUID: c02c4c66-6d97-4c82-8c28-12766fc8b13d
Ancestors: VMMaker.oscog-eem.708

Fix (i.e. prevent) inlining of api methods in the Cogit used in
the CoInterpreter and vice verce.

When "adding" a method marked <doNotImplement> make
sure that any inherited version of the method is removed.

Remove an obsolete def of CoInterpreter>>freeStart.

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

Item was changed:
  ----- Method: CCodeGenerator>>addMethodFor:selector: (in category 'utilities') -----
  addMethodFor: aClass selector: selector
  	"Add the given method to the code base and answer its translation
  	 or nil if it shouldn't be translated."
  	| method tmethod |
  	selector == #initialize ifTrue:
  	method := aClass compiledMethodAt: selector.
  	(method pragmaAt: #doNotGenerate) ifNotNil:
+ 		[methods removeKey: selector ifAbsent: [].
+ 		 ^nil].
- 		[^nil].
  	method isSubclassResponsibility ifTrue:
+ 		[methods removeKey: selector ifAbsent: [].
+ 		 ^nil].
- 		[^nil].
  	(self shouldIncludeMethodFor: aClass selector: selector) ifFalse:
+ 		[methods removeKey: selector ifAbsent: [].
+ 		 ^nil].
- 		[^nil].
  	tmethod := self addMethod: (self compileToTMethodSelector: selector in: aClass).
  	"If the method has a macro then add the macro.  But keep the method
  	 for analysis purposes (e.g. its variable accesses)."
  	(method pragmaAt: #cmacro:) ifNotNil:
  		self addMacro: (pragma argumentAt: 1) for: selector.
  		(inlineList includes: selector) ifTrue:
  			[inlineList := inlineList copyWithout: selector]].
  	(method propertyValueAt: #cmacro:) ifNotNil:
  		self addMacro: macro for: selector.
  		(inlineList includes: selector) ifTrue:
  			[inlineList := inlineList copyWithout: selector]].

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>."
  	"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) 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 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 |
  		breakSrcInlineSelector = m selector 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, 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 == #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]]].
  	inlineFlagOrSymbol ~~ #asSpecified ifTrue:
  		[callsOf associationsDo:
  			(assoc value = 1
  			 and: [(selectorsOfMethodsNotToInline includes: assoc key) not]) ifTrue:
  				[inlineList add: assoc key]]]!

Item was removed:
- ----- Method: CoInterpreter>>freeStart (in category 'cog jit support') -----
- freeStart
- 	<doNotGenerate>
- 	^objectMemory freeStart!

More information about the Vm-dev mailing list