[squeak-dev] The Trunk: Compiler-eem.317.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Nov 21 23:20:39 UTC 2015


Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.317.mcz

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

Name: Compiler-eem.317
Author: eem
Time: 21 November 2015, 3:20:26.817 pm
UUID: 956bcba6-bf0a-463c-aaef-90903732fb85
Ancestors: Compiler-nice.316

Small improvement to compiler performance.  There is no need to scan for an assignment to the limit in a to:[by:]do: when the to: argument is known to be an argument, because arguments are not written to.

=============== Diff against Compiler-nice.316 ===============

Item was changed:
  ----- Method: MessageNode>>transformToDo: (in category 'macro transformations') -----
  transformToDo: encoder
  	" var := rcvr. L1: [var <= arg1] Bfp(L2) [block body. var := var + inc] Jmp(L1) L2: "
+ 	| limit increment block initStmt test incStmt limitInit blockVar myRange blockRange |
- 	| limit increment block initStmt test incStmt limitInit blockVar myRange blockRange limitIsAssignedTo |
  	block := arguments last.
  	"First check for valid arguments"
  	(block notNil
  	 and: [block isBlockNode
  	 and: [block numberOfArguments = 1
  	 and: [block firstArgument isVariableReference "As with debugger remote vars"]]]) ifFalse:
  		[^false].
  	arguments size = 3
  		ifTrue: [increment := arguments at: 2.
  				(increment isConstantNumber
  				 and: [increment literalValue ~= 0]) ifFalse: [^false]]
  		ifFalse: [increment := encoder encodeLiteral: 1].
  	(limit := arguments at: 1) isVariableReference ifTrue:
+ 		[| shouldScanForAssignment |
+ 		 shouldScanForAssignment := limit isArg not
+ 										or: [limit isBlockArg and: [Scanner allowBlockArgumentAssignment]].
+ 		 shouldScanForAssignment ifTrue:
+ 			 [block nodesDo:
+ 				[:node|
+ 				(node isAssignmentNode and: [node variable = limit]) ifTrue:
+ 					[^false]]]].
- 		[limitIsAssignedTo := false.
- 		 block nodesDo:
- 			[:node|
- 			(node isAssignmentNode and: [node variable = limit]) ifTrue:
- 				[limitIsAssignedTo := true]].
- 		 limitIsAssignedTo ifTrue:
- 			[^false]].
  	arguments size < 3 ifTrue:   "transform to full form"
  		[selector := SelectorNode new key: #to:by:do: code: #macro].
  
  	"Now generate auxiliary structures"
  	myRange := encoder rawSourceRanges at: self ifAbsent: [1 to: 0].
  	blockRange := encoder rawSourceRanges at: block ifAbsent: [1 to: 0].
  	blockVar := block firstArgument.
  	initStmt := AssignmentNode new variable: blockVar value: receiver.
+ 	(limit isVariableReference or: [limit isConstantNumber])
- 	limit isVariableReference | limit isConstantNumber
  		ifTrue: [limitInit := nil]
  		ifFalse:  "Need to store limit in a var"
  			[limit := encoder bindBlockArg: blockVar key, 'LimiT' within: block.
  			 limit scope: -2.  "Already done parsing block; flag so it won't print"
  			 block addArgument: limit.
  			 limitInit := AssignmentNode new
  							variable: limit
  							value: arguments first].
  	test := MessageNode new
  				receiver: blockVar
  				selector: (increment key > 0 ifTrue: [#<=] ifFalse: [#>=])
  				arguments: {limit}
  				precedence: precedence
  				from: encoder
  				sourceRange: (myRange first to: blockRange first).
  	incStmt := AssignmentNode new
  				variable: blockVar
  				value: (MessageNode new
  							receiver: blockVar selector: #+
  							arguments: {increment}
  							precedence: precedence
  							from: encoder
  							sourceRange: (myRange last to: (myRange last max: blockRange last)))
  				from: encoder
  				sourceRange: (myRange last to: (myRange last max: blockRange last)).
  	arguments := {limit. increment. block. initStmt. test. incStmt. limitInit}.
  	block noteOptimizedIn: self.
  	^true!



More information about the Squeak-dev mailing list