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

commits at source.squeak.org commits at source.squeak.org
Mon Feb 11 21:36:51 UTC 2013


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

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

Name: Compiler-eem.252
Author: eem
Time: 11 February 2013, 1:35:53.482 pm
UUID: eb0dde9d-1648-4b12-88ca-44c46fda0e9e
Ancestors: Compiler-eem.251

Yet another fix for decompilation of to:do: loops compiled
with Compiler-nice.224 or later.  If the stack is non-empty
when convertDoDoLoop is invoked, the stack must be left
non-empty.  This really does fix decompilation of e.g.
	^nil to: 3 do: [:i| i class]
and not just
	true ifTrue: [^thisContext method decompile].
	^nil to: 3 do: [:i| i class]

=============== Diff against Compiler-eem.251 ===============

Item was changed:
  ----- Method: Decompiler>>convertToDoLoop (in category 'private') -----
  convertToDoLoop
  	"If statements contains the pattern
  		var := startExpr.
  		[var <= limit] whileTrue: [...statements... var := var + incConst]
  	then replace this by
  		startExpr to: limit by: incConst do: [:var | ...statements...]"
  	| leaveOnStack initStmt toDoStmt limitStmt |
  	leaveOnStack := false.
  	(stack notEmpty
  	 and: [stack last isAssignmentNode])
  		ifTrue:
  			[initStmt := stack last.
  			 (toDoStmt := statements last toDoFromWhileWithInit: initStmt) ifNil:
  				[^self].
  			 stack removeLast.
  			 statements removeLast; addLast: toDoStmt.
  			 leaveOnStack := true]
  		ifFalse:
  			[statements size < 2 ifTrue:
  				[^self].
  			initStmt := statements at: statements size-1.
  			(toDoStmt := statements last toDoFromWhileWithInit: initStmt) ifNil:
  				[^self].
  			statements removeLast; removeLast; addLast: toDoStmt].
  	initStmt variable scope: -1.  "Flag arg as block temp"
  
  	"Attempt further conversion of the pattern
  		limitVar := limitExpr.
  		startExpr to: limitVar by: incConst do: [:var | ...statements...]
  	to
  		startExpr to: limitExpr by: incConst do: [:var | ...statements...].
  	The complication here is that limitVar := limitExpr's value may be used, in which case it'll
  	be statements last, or may not be used, in which case it'll be statements nextToLast."
  	statements size < 2 ifTrue:
+ 		[leaveOnStack ifTrue:
+ 			[stack addLast: statements removeLast].
+ 			 ^self].
- 		[^self].
  	limitStmt := statements last.
  	((limitStmt isMemberOf: AssignmentNode)
  		and: [limitStmt variable isTemp
  		and: [limitStmt variable == toDoStmt arguments first]]) ifFalse:
  			[limitStmt := statements at: statements size-1.
  			((limitStmt isMemberOf: AssignmentNode)
  				and: [limitStmt variable isTemp
  				and: [limitStmt variable == toDoStmt arguments first]]) ifFalse:
  					[leaveOnStack ifTrue:
  						[stack addLast: statements removeLast].
  					^self]].
  
  	(self blockScopeRefersOnlyOnceToTemp: limitStmt variable fieldOffset) ifFalse:
  		[^self].
  	toDoStmt arguments at: 1 put: limitStmt value.
  	limitStmt variable scope: -2.  "Flag limit var so it won't print"
  	statements last == limitStmt
  		ifTrue: [statements removeLast]
  		ifFalse: [statements removeLast; removeLast; addLast: toDoStmt]!



More information about the Squeak-dev mailing list