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

commits at source.squeak.org commits at source.squeak.org
Wed Nov 15 22:27:05 UTC 2017


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

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

Name: VMMaker.oscog-eem.2279
Author: eem
Time: 15 November 2017, 2:26:14.871383 pm
UUID: ec78abc1-3128-47b0-bff8-25bab14bae2d
Ancestors: VMMaker.oscog-eem.2278

VMMaker: Fix bad misinitialization bug where options from a previous translation were not clearedf out.  This caused the recent misgeneration of src/vm/cogit.c

Slang: Back out of the inlining optimization used in the logging methods that are now unused.  Better format a method.

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

Item was changed:
  ----- Method: BraceNode>>asTranslatorNodeIn: (in category '*VMMaker-C translation') -----
  asTranslatorNodeIn: aTMethod
  	"make a CCodeGenerator equivalent of me."
  
  	"This is for case statements"
+ 	(elements allSatisfy: [:elem| elem isMessageNode and: [elem selector key = #->]]) ifTrue:
- 	(elements allSatisfy:
- 		[:elem|
- 		elem isMessageNode
- 		and: [elem selector key = #->]]) ifTrue:
  		[self assert: (elements allSatisfy:
  			[:elem|
  			elem receiver isBlockNode
  			and: [elem arguments first isBlockNode
  			and: [elem receiver isPotentialCCaseLabelIn: aTMethod]]]).
  		^TBraceCaseNode new
  			caseLabels: (elements collect: [:elem| elem receiver asTranslatorNodeIn: aTMethod]);
  			cases: (elements collect: [:elem| elem arguments first asTranslatorNodeIn: aTMethod]);
  			comment: comment].
  
  	"This is for varargs selectors (variants of printf:)"
  	^elements collect: [:elem| elem asTranslatorNodeIn: aTMethod]!

Item was changed:
  ----- Method: TMethod>>inlineSend:directReturn:exitVar:in: (in category 'inlining') -----
  inlineSend: aSendNode directReturn: directReturn exitVar: exitVar in: aCodeGen
  	"Answer a collection of statements to replace the given send.  directReturn indicates
  	 that the send is the expression in a return statement, so returns can be left in the
  	 body of the inlined method. If exitVar is nil, the value returned by the send is not
  	 used; thus, returns need not assign to the output variable.
  
  	 Types are propagated to as-yet-untyped variables when inlining a send that is assigned,
  	 otherwise the assignee variable type must match the return type of the inlinee.  Return
  	 types are not propagated."
  
+ 	| sel meth methArgs exitLabel inlineStmts label exitType elidedArgs |
- 	| sel meth methArgs exitLabel inlineStmts exitType elidedArgs argAssignments conditional |
  	sel := aSendNode selector.
  	meth := aCodeGen methodNamed: sel.
  	methArgs := meth args.
  	"convenient for debugging..."
  	aCodeGen maybeBreakForInlineOf: aSendNode in: self.
  	elidedArgs := #().
  	(methArgs notEmpty and: [methArgs first beginsWith: 'self_in_'])
  		ifTrue: "If the first arg is not used we can and should elide it."
  			[| varNode |
  			 varNode := TVariableNode new setName: methArgs first.
  			 (meth parseTree noneSatisfy: [:node| varNode isSameAs: node]) ifTrue:
  				[elidedArgs := {methArgs first}].
  			 methArgs := methArgs allButFirst].
  	methArgs size = aSendNode args size ifFalse:
  		[^nil].
  	meth := meth copy.
  
  	(meth statements size > 1
  	 and: [meth statements first isSend
  	 and: [meth statements first selector == #flag:]]) ifTrue:
  		[meth statements removeFirst].
  
  	"Propagate the return type of an inlined method"
  	(directReturn or: [exitVar notNil]) ifTrue:
  		[exitType := directReturn 
  						ifTrue: [returnType] 
  						ifFalse: [(self typeFor: exitVar in: aCodeGen) ifNil: [#sqInt]].
  		(exitType = #void or: [exitType = meth returnType]) ifFalse:
  			[meth propagateReturnIn: aCodeGen]].
  
  	"Propagate any unusual argument types to untyped argument variables"
  	methArgs
  		with: aSendNode args
  		do: [:formal :actual|
  			(meth declarationAt: formal ifAbsent: nil) ifNil:
  				[(self typeFor: actual in: aCodeGen) ifNotNil:
  					[:type|
  					type ~= #sqInt ifTrue:
  						[meth declarationAt: formal put: (type last = $* ifTrue: [type, formal] ifFalse: [type, ' ', formal])]]]].
  
  	meth renameVarsForInliningInto: self except: elidedArgs in: aCodeGen.
  	meth renameLabelsForInliningInto: self.
  	self addVarsDeclarationsAndLabelsOf: meth except: elidedArgs.
  	meth hasReturn ifTrue:
  		[directReturn ifFalse:
  			[exitLabel := self unusedLabelForInliningInto: self.
  			 (meth exitVar: exitVar label: exitLabel) "is label used?"
  				ifTrue: [ labels add: exitLabel ]
  				ifFalse: [ exitLabel := nil ]]].
  	(inlineStmts := OrderedCollection new: meth statements size + meth args size + 2)
+ 		add: (label := TLabeledCommentNode new setComment: 'begin ', sel);
+ 		addAll: (self argAssignmentsFor: meth send: aSendNode except: elidedArgs in: aCodeGen);
+ 		addAll: meth statements.  "method body"
- 		add: (TLabeledCommentNode new setComment: 'begin ', sel).
- 	argAssignments := self argAssignmentsFor: meth send: aSendNode except: elidedArgs in: aCodeGen.
- 	"If the method being inlined is of the form
- 		guard ifTrue: [...]
- 	 and the argument assignments have no side effects,
- 	 and guard does not refer to the arguments,
- 	 push the argument assignments past the guard into the block so that they too are guarded."
- 	(meth statements size = 1
- 	 and: [(conditional := meth statements first) isConditionalSend
- 	 and: [conditional numArgs = 1
- 	 and: [(argAssignments noneSatisfy: [:assign| assign expression hasSideEffect])
- 	 and: [conditional receiver noneSatisfy: [:node| node isVariable and: [methArgs includes: node name]]]]]])
- 		ifTrue: [conditional args first statements addAllFirst: argAssignments]
- 		ifFalse: [inlineStmts addAll: argAssignments].
- 	inlineStmts addAll: meth statements.  "method body"
  	directReturn ifTrue:
  		[meth endsWithReturn
  			ifTrue:
  				[exitVar ifNotNil: "don't remove the returns if being invoked in the context of a return"
  					[inlineStmts at: inlineStmts size put: inlineStmts last copyWithoutReturn]]
  			ifFalse:
  				[inlineStmts add:
  					(TReturnNode new setExpression: (TVariableNode new setName: 'nil'))]].
  	exitLabel ifNotNil:
  		[inlineStmts add:
  			(TLabeledCommentNode new setLabel:
  				exitLabel comment: 'end ', meth selector)].
  	inlineStmts size = 1 ifTrue: "Nuke empty methods; e.g. override of flushAtCache"
  		[self assert: inlineStmts first isComment.
  		 inlineStmts removeFirst].
  	^inlineStmts!

Item was changed:
  ----- Method: VMMaker>>options: (in category 'initialize') -----
  options: anArrayOfPairs
+ 	optionsDictionary removeAll.
  	self assert: anArrayOfPairs size even.
  	1 to: anArrayOfPairs size by: 2 do:
  		[:i| | key |
  		key := anArrayOfPairs at: i.
  		self assert: key isSymbol.
  		optionsDictionary at: key put: (anArrayOfPairs at: i + 1)]!



More information about the Vm-dev mailing list