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

commits at source.squeak.org commits at source.squeak.org
Sun Mar 22 23:07:41 UTC 2015


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

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

Name: VMMaker.oscog-eem.1110
Author: eem
Time: 22 March 2015, 4:05:48.065 pm
UUID: 4950d2be-40ff-4b33-b2ff-ab97229ff92d
Ancestors: VMMaker.oscog-eem.1109

Do dead-code elimination on (expr and: [false]) ifTrue:
and hence fix a few exprs in primitiveVMMarameter

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

Item was changed:
  ----- Method: CCodeGenerator>>nilOrBooleanConstantReceiverOf: (in category 'utilities') -----
  nilOrBooleanConstantReceiverOf: aNode
  	"Answer nil or the boolean constant that is the receiver of the given message send.
  	 Used to suppress conditional code when the condition is a translation-time constant."
  
  	| val receiver argument |
  	generateDeadCode ifTrue:[^nil].
  	((self isConstantNode: aNode valueInto: [:v| val := v])
  	 and: [#(true false) includes: val]) ifTrue:
  		[^val].
  	aNode isSend ifTrue:
  		[aNode selector == #not ifTrue:
  			[(self nilOrBooleanConstantReceiverOf: aNode receiver) ifNotNil:
  				[:bool| ^bool not]].
  		 ((#(isNil notNil) includes: aNode selector)
  		  and: [self isNilConstantReceiverOf: aNode]) ifTrue:
  			[^aNode selector == #isNil].
  		 ((#(or: and:) includes: aNode selector)
  		 and: [aNode args last isStmtList
  		 and: [aNode args last statements size = 1]]) ifTrue:
  			[(self nilOrBooleanConstantReceiverOf: aNode receiver) ifNotNil:
  				[:rcvr|
  				((rcvr == false and: [aNode selector == #and:])
  				 or: [rcvr == true and: [aNode selector == #or:]]) ifTrue:
  					[^rcvr].
  				(self nilOrBooleanConstantReceiverOf: aNode args last statements first) ifNotNil:
  					[:arg|
+ 					^rcvr perform: aNode selector with: [arg]]].
+ 			 "We can also eliminate expr and: [false], but only if expr is side-effect free.
+ 			  This is a weak test; we don't traverse calls.  Caveat emptor!!"
+ 			 (aNode selector == #and:
+ 			  and: [(aNode receiver noneSatisfy: [:node| node isAssignment]) "No side-effects in the elided expression"
+ 			  and: [aNode args last statements size = 1]]) ifTrue:
+ 				[(self nilOrBooleanConstantReceiverOf: aNode args last statements first) ifNotNil:
+ 					[:arg|
+ 					arg ifFalse:
+ 						[^arg]]]].
- 					^rcvr perform: aNode selector with: [arg]]]].
  		 ((#(= ~= < > <= >=) includes: aNode selector)
  		  and: [(self isConstantNode: aNode receiver valueInto: [:v| receiver := v])
  		  and: [receiver isInteger
  		  and: [(self isConstantNode: aNode args first valueInto: [:v| argument := v])
  		  and: [argument isInteger]]]]) ifTrue:
  			[^receiver perform: aNode selector with: argument]].
  	^nil!



More information about the Vm-dev mailing list