Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.368.mcz ==================== Summary ==================== Name: Compiler-eem.368 Author: eem Time: 6 January 2018, 1:00:10.304648 pm UUID: 3055d203-f94c-47ba-8ea0-69c82d736955 Ancestors: Compiler-eem.367 Better separate SelectorNode and SpecialSelectorNode to avoid SopecialSelectorNode deferring to SelectorNode on super sends. Hence reduce use of the obsolete code variable, makimng SelectorNode>>reserve: more straight-forward and unused in SpecialSelectorNode. =============== Diff against Compiler-eem.367 =============== Item was changed: ----- Method: MessageNode>>sizeCodeForValue: (in category 'code generation') ----- sizeCodeForValue: encoder | total | + special > 0 ifTrue: + [encoder noteOptimizedSelector: originalSelector. + ^self perform: (MacroSizers at: special) with: encoder with: true]. + receiver == NodeSuper ifTrue: + [selector := selector forSuperSend "only necessary for special selectors"]. - special > 0 - ifTrue: - [encoder noteOptimizedSelector: originalSelector. - ^self perform: (MacroSizers at: special) with: encoder with: true]. - receiver == NodeSuper - ifTrue: [selector := selector copy "only necess for splOops"]. total := selector sizeCode: encoder args: arguments size super: receiver == NodeSuper. + receiver ifNotNil: + [total := total + (receiver sizeCodeForValue: encoder)]. - receiver == nil - ifFalse: [total := total + (receiver sizeCodeForValue: encoder)]. sizes := arguments collect: [:arg | | argSize | argSize := arg sizeCodeForValue: encoder. total := total + argSize. argSize]. ^total! Item was changed: ----- Method: SelectorNode>>emitCode:args:encoder:super: (in category 'code generation') ----- emitCode: stack args: nArgs encoder: encoder super: supered + code < Send ifTrue: + [self internalEncodingError]. stack pop: nArgs. + supered - ^supered ifTrue: [(encoder supportsFullBlocks and: [encoder generatingFullBlock]) ifTrue: [encoder genPushLiteral: (encoder sharableLitIndex: encoder classEncoding). encoder genSendDirectedSuper: index numArgs: nArgs] ifFalse: [encoder genSendSuper: index numArgs: nArgs]] ifFalse: + [encoder genSend: index numArgs: nArgs]! - [encoder - genSend: (code < Send ifTrue: [code negated] ifFalse: [index]) - numArgs: nArgs]! Item was added: + ----- Method: SelectorNode>>forSuperSend (in category 'code generation') ----- + forSuperSend + "Answer the receiver or a derivative, suitable for use in a super send. + This is overridden by SpecialSelectorNode to return a SelectorNode clone." + ^self! Item was added: + ----- Method: SelectorNode>>internalEncodingError (in category 'private') ----- + internalEncodingError + self error: 'with the split between SelectorNode and SpecialSelectorNode code should never be < Send for normal sends.'! Item was added: + ----- Method: SelectorNode>>key:code:index: (in category 'initialize-release') ----- + key: object code: byte index: idx + + key := object. + code := byte. + index := idx! Item was changed: ----- Method: SelectorNode>>reserve: (in category 'code generation') ----- reserve: encoder "If this is a yet unused literal of type -code, reserve it." + index ifNil: + [index := encoder sharableLitIndex: key. + code := Send]! - code < 0 ifTrue: [code := self code: (index := encoder sharableLitIndex: key) type: 0 - code]! Item was added: + ----- Method: SelectorNode>>resetForBlockGeneration (in category 'code generation') ----- + resetForBlockGeneration + "Recent the receiver to an unassigned state such that its index + in the encoder's literalStream is as yet to be determined." + index := nil! Item was changed: ----- Method: SelectorNode>>sizeCode:args:super: (in category 'code generation') ----- sizeCode: encoder args: nArgs super: supered self reserve: encoder. + code < Send ifTrue: + [self internalEncodingError]. + supered ifFalse: + [^encoder sizeSend: index numArgs: nArgs]. + (encoder supportsFullBlocks + and: [encoder generatingFullBlock]) ifTrue: + [^(encoder sizePushLiteral: (encoder sharableLitIndex: encoder classEncoding)) + + (encoder sizeSendDirectedSuper: index numArgs: nArgs)]. + ^encoder sizeSendSuper: index numArgs: nArgs! - ^supered - ifTrue: - [code < Send "i.e. its a special selector" ifTrue: - [code := self code: (index := encoder sharableLitIndex: key) type: 5]. - (encoder supportsFullBlocks - and: [encoder generatingFullBlock]) - ifTrue: [(encoder sizePushLiteral: (encoder sharableLitIndex: encoder classEncoding)) - + (encoder sizeSendDirectedSuper: index numArgs: nArgs)] - ifFalse: [encoder sizeSendSuper: index numArgs: nArgs]] - ifFalse: - [self flag: #yuck. "special selector sends cause this problem" - encoder - sizeSend: (code < Send ifTrue: [code negated] ifFalse: [index]) - numArgs: nArgs]! Item was changed: ----- Method: SpecialSelectorNode>>emitCode:args:encoder:super: (in category 'code generation') ----- emitCode: stack args: nArgs encoder: encoder super: supered "Generate a special selector send. + A super send of a special selector must be handled like a normal send. + This is handled in MessageNode>>sizeCodeForValue: by mapping any + SpecialSelectorNodes used in super sends into normal SelectorNodes." + supered ifTrue: [self invalidSuperSendError]. + stack pop: nArgs. + encoder genSendSpecial: code numArgs: nArgs! - A super send of a special selector must be handled like a normal send." - supered - ifTrue: - [super emitCode: stack args: nArgs encoder: encoder super: supered] - ifFalse: - [stack pop: nArgs. - encoder genSendSpecial: code numArgs: nArgs]! Item was added: + ----- Method: SpecialSelectorNode>>forSuperSend (in category 'code generation') ----- + forSuperSend + "Answer the receiver or a derivative, suitable for use in a super send." + + "Excuse the code negation nonsense. It is a vestige of a very concise but now + obsolete back-end bytecode encoding scheme. We're working on removing it." + ^SelectorNode new + key: key + code: SendType negated + index: index! Item was added: + ----- Method: SpecialSelectorNode>>invalidSuperSendError (in category 'private') ----- + invalidSuperSendError + self error: 'special selectors can only be used for ordinary sends'! Item was changed: ----- Method: SpecialSelectorNode>>sizeCode:args:super: (in category 'code generation') ----- sizeCode: encoder args: nArgs super: supered "Size a special selector send. + A super send of a special selector must be handled like a normal send. + This is handled in MessageNode>>sizeCodeForValue: by mapping any + SpecialSelectorNodes used in super sends into normal SelectorNodes." + supered ifTrue: [self invalidSuperSendError]. + ^encoder sizeSendSpecial: code numArgs: nArgs! - A super send of a special selector must be handled like a normal send." - ^supered - ifTrue: [super sizeCode: encoder args: nArgs super: supered] - ifFalse: [encoder sizeSendSpecial: code numArgs: nArgs]! |
Free forum by Nabble | Edit this page |