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

commits at source.squeak.org commits at source.squeak.org
Thu Nov 19 22:32:52 UTC 2020


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

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

Name: VMMaker.oscog-eem.2889
Author: eem
Time: 19 November 2020, 2:32:43.668199 pm
UUID: 01cc1b20-736a-4b9d-9631-743896b4dc66
Ancestors: VMMaker.oscog-eem.2888

But we can do a little better than VMMaker.oscog-eem.2888.  Better comment argAssignmentsFor:send:except:in: and make sure that side-effect-less longAt: is recognised as such, hcen inlining of SpurMemoryManager>>#isClassOfNonImm:equalTo:compactClassIndex: is much improved (less noise).

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

Item was changed:
  ----- Method: TMethod>>argAssignmentsFor:send:except:in: (in category 'inlining') -----
  argAssignmentsFor: meth send: aSendNode except: elidedArgs in: aCodeGen
+ 	"Answer a collection of assignment nodes that assign the given argument expressions
+ 	 to the formal parameter variables of the given method.
- 	"Answer a collection of assignment nodes that assign the given argument expressions to the formal parameter variables of the given method."
- 	"Optimization: If the actual parameters are either constants or local variables in the target method (the receiver), substitute them directly into the body of meth. Note that global variables cannot be substituted because the inlined method might depend on the exact ordering of side effects to the globals.
- 	 Optimization: Don't answer statements for formal parameters which are unused in the method body."
  
+ 	 Optimization: If the actual parameters are either constants or local variables in the target
+ 	 method (the receiver), substitute them directly into the body of meth. Note that global
+ 	 variables cannot be substituted because the inlined method might depend on the exact
+ 	 ordering of side effects to the globals.
+ 
+ 	 Optimization: Don't generate assignment statements for formal parameters which are unused in
+ 	 the method body, retaining statements for unused parameter expressions that have side-effects."
+ 
  	| stmtList substitutionDict argList referencedArguments |
  	meth args size > (argList := aSendNode args) size ifTrue:
  		[self assert: (meth args first beginsWith: 'self_in_').
  		 argList := {aSendNode receiver}, aSendNode args].
  	stmtList := OrderedCollection new: argList size.
  	substitutionDict := Dictionary new: argList size.
  	meth args with: argList do:
  		[:argName :exprNode |
  		(self isNode: exprNode substitutableFor: argName inMethod: meth in: aCodeGen)
  			ifTrue:
  				[substitutionDict
  					at: argName
  					put: (aCodeGen
  							node: exprNode
  							typeCompatibleWith: argName
  							inliningInto: meth
  							in: self).
  				 locals remove: argName ifAbsent: [self assert: (argName beginsWith: 'self_in_')].
  				 declarations removeKey: argName ifAbsent: nil]
  			ifFalse: "Add an assignment for anything except an unused self_in_foo argument"
  				[(elidedArgs includes: argName) ifFalse:
  					[self deny: exprNode isLiteralBlock.
  					 stmtList addLast:
  						(TAssignmentNode new
  							setVariable: (TVariableNode new setName: argName)
  							expression: (aCodeGen
  											node: exprNode copy
  											typeCompatibleWith: argName
  											inliningInto: meth
  											in: self))]]].
  	meth parseTree: (meth parseTree bindVariablesIn: substitutionDict).
  	referencedArguments := meth allReferencedArgumentsUsing: aCodeGen.
+ 	"Now filter-out assignments for unused formal parameters, while
+ 	 retaining any actual parameter expressions that have side-effects."
  	^(stmtList
  		collect:
  			[:assignment|
  			(referencedArguments includes: assignment variable name)
  				ifTrue: [assignment]
  				ifFalse:
  					[assignment expression hasSideEffect ifTrue:
  						[assignment expression]]])
  		select: [:node| node notNil]!

Item was changed:
  ----- Method: TSendNode>>hasSideEffect (in category 'testing') -----
  hasSideEffect
  	"Answer if the parse tree rooted at this node has a side-effect or not."
+ 	selector == #longAt: ifTrue: "Important for inlining Spur's isClassOfNonImm:equalTo:compactClassIndex:"
+ 		[^arguments first hasSideEffect "a.k.a. arguments anySatisfy: [:node| node hasSideEffect]"].
+ 	^(#(#+ #- #* #/ #// #\\ #= #== #~= #~~ << >>) includes: selector) not!
- 	^(#(#+ #- #* #/ #// #\\ #= #== #~= #~~) includes: selector) not!



More information about the Vm-dev mailing list