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

commits at source.squeak.org commits at source.squeak.org
Mon Jan 9 17:40:58 UTC 2017


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

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

Name: VMMaker.oscog-eem.2078
Author: eem
Time: 9 January 2017, 9:40:09.059257 am
UUID: 2b2c29ff-6832-4346-b22a-9bc1adc3d9e7
Ancestors: VMMaker.oscog-rsf.2077

Slang:
Add support for constant reduction of const ifTrue: [bool] ifFalse: [statements] => bool to reduce isVanillaBlockClosure: to true when not using SistaV1BytecodeSet, and hence rescue C compilation of the non-Sista sources (ensureMethodIsCoggeds: needs this).

=============== Diff against VMMaker.oscog-rsf.2077 ===============

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 arms |
- 	| 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]]]].
+ 		"Look for Const ifTrue: [self foo] ifFalse: [false] => false"
+ 		 ((#(ifTrue:ifFalse: ifFalse:ifTrue:) includes: aNode selector)
+ 		  and: [(self isConstantNode: aNode receiver valueInto: [:v| val := v])
+ 		  and: [(#(true false) includes: val)
+ 		  and: [arms := aNode args collect:
+ 							[:altBlock| | bval |
+ 							 (altBlock statements size = 1
+ 							 and: [(self isConstantNode: altBlock statements last valueInto: [:v| bval := v])
+ 							 and: [#(true false) includes: bval]]) ifTrue:
+ 								[bval]].
+ 				arms asArray ~= #(nil nil)]]]) ifTrue:
+ 			[| arm |
+ 			 arm := aNode selector == #ifTrue:ifFalse: == val
+ 						ifTrue: [arms first]
+ 						ifFalse: [arms last].
+ 			 (#(true false) includes: arm) ifTrue:
+ 				[^arm]].
  		 ((#(= ~= < > <= >=) 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].
  		 "Inlining for e.g. CharacterTable ifNil: [...] ifNotNil: [...]], which compiles to CharacterTable == nil ifTrue: [...] ifFalse: [...]"
+ 		(aNode selector == #==
- 		( aNode selector == #==
  		 and: [aNode args first isVariable
  		 and: [aNode args first name = 'nil'
  		 and: [aNode receiver isConstant
  		 and: [aNode receiver value == nil]]]]) ifTrue:
  			[^true]].
  	^nil!



More information about the Vm-dev mailing list