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

commits at source.squeak.org commits at source.squeak.org
Sat Feb 14 01:38:35 UTC 2015

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

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

Name: VMMaker.oscog-eem.1063
Author: eem
Time: 13 February 2015, 5:37:10.894 pm
UUID: c4480dac-ed58-41cc-a585-b6b4a89c72c8
Ancestors: VMMaker.oscog-eem.1062

Rescue translation of the non-64-bit Spur VMs by
a) doing a better job of suoper expansions, handling expansions
	that are returning ifs as well as just returns correctly.
b) transforming variable := expr ifTrue: [s1] ifFalse: [s2] into
    expr ifTrue: [variable := s1] ifFalse: [variable := s2]
to allow inlining of s1 & s2.

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

Item was changed:
  ----- Method: ReturnNode>>asTranslatorNodeIn: (in category '*VMMaker-C translation') -----
  asTranslatorNodeIn: aTMethod
  	"Make a CCodeGenerator equivalent of a return."
  	| exprTranslation lastExpr |
  	exprTranslation := expr asTranslatorNodeIn: aTMethod.
  	(expr isMessage
  	 and: [expr receiver isVariableNode
  	 and: [expr receiver key = 'super'
  	 and: [exprTranslation isStmtList]]]) ifTrue:
  		["super expansions containing returns are fine, and (as of 6/25/2012 19:27) the last
  		  return is elided from the expansion by TMethod>>superExpansionNodeFor:args:. 
  		  So we need to ensure the last expression is a return and simply reuse any other
  		  returns in the expansion."
+ 		lastExpr := exprTranslation statements last.
+ 		(lastExpr isReturn
+ 		 or: [lastExpr isReturningIf]) ifFalse:
+ 			[exprTranslation statements
+ 				at: exprTranslation statements size
+ 				put:
+ 					(TReturnNode new 
+ 						setExpression: lastExpr;
+ 						comment: comment;
+ 						yourself)].
- 		exprTranslation statements last isReturn ifFalse:
- 			[lastExpr := exprTranslation statements removeLast.
- 			 exprTranslation statements addLast:
- 				(TReturnNode new 
- 					setExpression: lastExpr;
- 					comment: comment;
- 					yourself)].
  	^TReturnNode new 
  		setExpression: exprTranslation;
  		comment: comment;

Item was changed:
  ----- Method: TAssignmentNode>>emitStatementListExpansion:on:level:generator: (in category 'C code generation') -----
  emitStatementListExpansion: stmtList on: aStream level: level generator: aCodeGen
+ 	stmtList statements last = variable ifTrue:
- 	| lastStmt copy |
- 	lastStmt := stmtList statements last.
- 	lastStmt = variable ifTrue:
  		[^expression emitCCodeOn: aStream level: level generator: aCodeGen].
+ 	stmtList copy
+ 		assignLastExpressionTo: variable;
+ 		emitCCodeOn: aStream level: level generator: aCodeGen!
- 	copy := stmtList copy.
- 	copy statements
- 		at: stmtList statements size
- 		put: (TAssignmentNode new
- 				setVariable: variable
- 				expression: lastStmt).
- 	copy emitCCodeOn: aStream level: level generator: aCodeGen!

Item was changed:
  ----- Method: TAssignmentNode>>setVariable:expression: (in category 'accessing') -----
  setVariable: varNode expression: expressionNode
+ 	self assert: (expressionNode isGoTo or: [expressionNode isLabel]) not.
  	variable := varNode.
  	expression := expressionNode.!

Item was added:
+ ----- Method: TMethod>>transformConditionalAssignment:in: (in category 'inlining') -----
+ transformConditionalAssignment: node in: aCodeGen
+ 	"If possible asnwer the transformation of code of the form
+ 		var := e1
+ 				ifTrue: [e2 ifTrue: [v1] ifFalse: [v2]]
+ 				ifFalse: [v3]
+ 	 into
+ 		e1
+ 			ifTrue: [e2 ifTrue: [var := v1] ifFalse: [var := v2]]
+ 			ifFalse: [var := v3]
+ 	 to allow inlining of v1, v2, et al.  Otherwise answer nil."
+ 	| expr |
+ 	^(node isAssignment
+ 	   and: [(expr := node expression) isSend
+ 	   and: [#(ifTrue:ifFalse: ifFalse:ifTrue:) includes: expr selector]]) ifTrue:
+ 		[expr copy
+ 			arguments:
+ 				(expr args collect:
+ 					[:stmtList| stmtList copy assignLastExpressionTo: node variable]);
+ 			yourself]!

Item was changed:
  ----- Method: TMethod>>tryToInlineMethodsIn: (in category 'inlining') -----
  tryToInlineMethodsIn: aCodeGen
  	"Expand any (complete) inline methods called by this method. Set the complete bit when all inlining has been done. Return true if something was inlined."
  	| stmtLists didSomething newStatements sendsToInline |
  	self definedAsMacro ifTrue:
  		[complete := true.
  	didSomething := false.
  	sendsToInline := Dictionary new: 100.
+ 			(self transformConditionalAssignment: node in: aCodeGen) ifNotNil:
+ 				[:replacement|
+ 				 sendsToInline at: node put: replacement].
  			(self inlineableFunctionCall: node in: aCodeGen) ifTrue:
  				[(self inlineFunctionCall: node in: aCodeGen) ifNotNil:
  					 sendsToInline at: node put: replacement]]]
  		unless: "Don't inline the arguments to asserts to keep the asserts readable"
  			node isSend
  			and: [node selector == #cCode:inSmalltalk:
  				or: [aCodeGen isAssertSelector: node selector]]].
  	sendsToInline isEmpty ifFalse:
  		[didSomething := true.
  		parseTree := parseTree replaceNodesIn: sendsToInline].
  	didSomething ifTrue:
  		[writtenToGlobalVarsCache := nil.
  	stmtLists := self statementsListsForInliningIn: aCodeGen.
  	stmtLists do:
  		newStatements := OrderedCollection new: 100.
  		stmtList statements do:
  			(self inlineCodeOrNilForStatement: stmt in: aCodeGen)
  				ifNil: [newStatements addLast: stmt]
  				ifNotNil: [:inlinedStmts|
  					didSomething := true.
  					newStatements addAllLast: inlinedStmts]].
  		stmtList setStatements: newStatements asArray].
  	didSomething ifTrue:
  		[writtenToGlobalVarsCache := nil.
  	complete ifFalse:
  		[self checkForCompleteness: stmtLists in: aCodeGen.
  		 complete ifTrue: [ didSomething := true ]].  "marking a method complete is progress"

Item was added:
+ ----- Method: TStmtListNode>>assignLastExpressionTo: (in category 'transformations') -----
+ assignLastExpressionTo: variableNode
+ 	"Destructively transform the receiver so that its last expression is assigned to the argument."
+ 	| index |
+ 	index := statements findLast: [:expr| (expr isGoTo or: [expr isLabel]) not].
+ 	statements
+ 		at: index
+ 		put: (TAssignmentNode new
+ 				setVariable: variableNode
+ 				expression: (statements at: index))!

More information about the Vm-dev mailing list