[squeak-dev] The Trunk: Compiler-nice.194.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Mar 4 03:52:55 UTC 2011

Nicolas Cellier uploaded a new version of Compiler to project The Trunk:

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

Name: Compiler-nice.194
Author: nice
Time: 4 March 2011, 4:51:51.372 am
UUID: de6fad00-fa6c-4622-9c03-046113d7e4fe
Ancestors: Compiler-ul.193

Fix cascading of special messages.

During inlining of some special messages, the MessageNode selector and/or arguments might be destructively replaced.
(for example #ifFalseifTrue: ifNil:ifNotNil: etc...)

If we later decide to un-optimize, it is necessary to restore the originalSelector and originalArguments.
(for example when these messages are cascaded)

Also fix a bug occuring when decompiling these cascaded specials.

Thanks to Juan for testing/enhancing this useless but beautiful stuff.

TODO: automate some tests.

=============== Diff against Compiler-ul.193 ===============

Item was changed:
  ----- Method: DecompilerConstructor>>decodeIfNilWithReceiver:selector:arguments: (in category 'constructor') -----
  decodeIfNilWithReceiver: receiver selector: selector arguments: arguments
+ 	receiver ifNil: [ ^nil ].		"For instance, when cascading"
  	selector == #ifTrue:ifFalse:
  		ifFalse: [^ nil].
  	(receiver isMessage: #==
  				receiver: nil
  				arguments: [:argNode | argNode == NodeNil])
  		ifFalse: [^ nil].
  	^ (MessageNode new
  			receiver: receiver
  			selector: (SelectorNode new key: #ifTrue:ifFalse: code: #macro)
  			arguments: arguments
  			precedence: 3)
  		noteSpecialSelector: #ifNil:ifNotNil:!

Item was changed:
  ParseNode subclass: #MessageNode
+ 	instanceVariableNames: 'receiver selector precedence special arguments sizes equalNode caseErrorNode originalSelector originalArguments'
- 	instanceVariableNames: 'receiver selector precedence special arguments sizes equalNode caseErrorNode'
  	classVariableNames: 'MacroEmitters MacroPrinters MacroSelectors MacroSizers MacroTransformers StdTypers ThenFlag'
  	poolDictionaries: ''
  	category: 'Compiler-ParseNodes'!
  !MessageNode commentStamp: '<historical>' prior: 0!
  I represent a receiver and its message.
  Precedence codes:
  	1 unary
  	2 binary
  	3 keyword
  	4 other
  If special>0, I compile special code in-line instead of sending messages with literal methods as remotely copied contexts.!

Item was changed:
  ----- Method: MessageNode>>ensureCanCascade: (in category 'testing') -----
  ensureCanCascade: encoder
  	special > 0 ifTrue:
  		[special := 0.
+ 		selector := encoder encodeSelector: originalSelector.
+ 		arguments := originalArguments.
+ 		arguments do:
- 		 selector := encoder encodeSelector: selector key.
- 		 arguments do:
  			each isBlockNode ifTrue:
  				[each deoptimize]]]!

Item was changed:
  ----- Method: MessageNode>>receiver:arguments:precedence: (in category 'private') -----
  receiver: rcvr arguments: args precedence: p
  	receiver := rcvr.
  	arguments := args.
+ 	originalArguments := arguments copy.
  	sizes := Array new: arguments size.
  	precedence := p!

Item was changed:
  ----- Method: MessageNode>>receiver:selector:arguments:precedence: (in category 'initialize-release') -----
  receiver: rcvr selector: selNode arguments: args precedence: p 
  	self receiver: rcvr
  		arguments: args
  		precedence: p.
+ 	originalSelector := selNode key.
  	selNode code == #macro
  		ifTrue: [self noteSpecialSelector: selNode key]
  		ifFalse: [special := 0].
  	selector := selNode.
  	"self pvtCheckForPvtSelector: encoder"
  	"We could test code being decompiled, but the compiler should've checked already. And where to send the complaint?"!

Item was changed:
  ----- Method: MessageNode>>receiver:selector:arguments:precedence:from: (in category 'initialize-release') -----
  receiver: rcvr selector: aSelector arguments: args precedence: p from: encoder 
  	self receiver: rcvr
  		arguments: args
  		precedence: p.
+ 	originalSelector := aSelector.
  	self noteSpecialSelector: aSelector.
  	(self transform: encoder)
  			[selector isNil ifTrue:
  				[selector := SelectorNode new 
  								key: (MacroSelectors at: special)
  								code: #macro]]
  			[selector := encoder encodeSelector: aSelector.
  			rcvr == NodeSuper ifTrue: [encoder noteSuper]].
  	self pvtCheckForPvtSelector: encoder!

More information about the Squeak-dev mailing list