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

commits at source.squeak.org commits at source.squeak.org
Sat Dec 9 00:04:16 UTC 2017

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

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

Name: VMMaker.oscog-eem.2293
Author: eem
Time: 8 December 2017, 4:03:39.353313 pm
UUID: 42fb0654-3c58-4388-b25e-dbad57cd0747
Ancestors: VMMaker.oscog-eem.2292

Fix vorgotten variables in the unused variable elimination scheme for inlined value:[value:*] and to:by:do:

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

Item was changed:
  ----- Method: CCodeGenerator>>generateToByDo:on:indent: (in category 'C translation') -----
  generateToByDo: msgNode on: aStream indent: level
  	"Generate the C code for this message onto the given stream."
  	"N.B. MessageNode>>asTranslatorNodeIn: adds the limit var as a hidden fourth argument."
  	| blockExpr iterationVar limitExpr mayHaveSideEffects limitVar step |
  	blockExpr := msgNode args third.
  	blockExpr args size = 1 ifFalse:
  		[self error: 'wrong number of block arguments'].
  	iterationVar := blockExpr args first.
  	limitExpr := msgNode args first.
  	aStream nextPutAll: 'for (', iterationVar, ' = '.
+ 	self noteUsedVariableName: iterationVar.
  	self emitCExpression: msgNode receiver on: aStream.
  	mayHaveSideEffects := msgNode args size = 4. "See TMethod>>prepareMethodIn:"
  	mayHaveSideEffects ifTrue:
  		[limitVar := msgNode args last.
  		 aStream nextPutAll: ', ', limitVar name, ' = '.
  		 self emitCExpression: limitExpr on: aStream.
  		 limitExpr := limitVar].
  	aStream nextPutAll: '; ', iterationVar.
  	step := msgNode args at: 2.
  	self generateToByDoLimitExpression: limitExpr
  		negative: (self stepExpressionIsNegative: step)
  		on: aStream.
  	aStream nextPutAll: '; ', iterationVar, ' += '.
  	self emitCExpression: step on: aStream.
  	aStream nextPutAll: ') {'; cr.
  	blockExpr emitCCodeOn: aStream level: level + 1 generator: self.
  	aStream tab: level.
  	aStream nextPut: $}!

Item was changed:
  ----- Method: CCodeGenerator>>generateValue:on:indent: (in category 'C translation') -----
  generateValue: aTSendNode on: aStream indent: level
  	"Reduce [:formal ... :formalN| body ] value: actual ... value: actualN
  	 to body with formals substituted for by actuals."
  	| substitution substitutionDict newLabels |
  	self assert: aTSendNode receiver isStmtList.
  	self assert: aTSendNode receiver args size = aTSendNode args size.
  	substitution := aTSendNode receiver copy.
  	substitution renameLabelsForInliningInto: currentMethod.
  	substitutionDict := Dictionary new: aTSendNode args size * 2.
  	aTSendNode receiver args with: aTSendNode args do:
  		[ :argName :exprNode |
  		exprNode isLeaf
  			ifTrue: [substitutionDict at: argName put: exprNode]
  				[aStream nextPutAll: argName; nextPutAll: ' = '.
+ 				 self noteUsedVariableName: argName.
  				 exprNode emitCCodeAsExpressionOn: aStream level: level generator: self.
  				 aStream nextPut: $; ; crtab: level]].
  		bindVariablesIn: substitutionDict;
  		emitCCodeOn: aStream level: level generator: self.
  	newLabels := Set withAll: currentMethod labels.
  	substitution nodesDo:
  		[:node| node isLabel ifTrue: [node label ifNotNil: [:label| newLabels add: label]]].
  	"now add the new labels so that a subsequent inline of
  	 the same block will be renamed with different labels."
  	currentMethod labels: newLabels!

Item was added:
+ ----- Method: CCodeGenerator>>noteUsedVariableName: (in category 'utilities') -----
+ noteUsedVariableName: variableName
+ 	currentMethod ifNotNil:
+ 		[:m| m noteUsedVariableName: variableName]!

More information about the Vm-dev mailing list