Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1161.mcz ==================== Summary ==================== Name: Kernel-eem.1161 Author: eem Time: 14 March 2018, 7:16:26.289237 pm UUID: 53deb012-ffaa-41f5-a0d0-7e8ddfb4bbb1 Ancestors: Kernel-eem.1160 Reimplement CompiledMethod>>messages[Do:] so that they function in the full blocks regime (i.e. they include messages in block methods). =============== Diff against Kernel-eem.1160 =============== Item was added: + ----- Method: CompiledCode>>messages (in category 'scanning') ----- + messages + "Answer a Set of all the message selectors sent by this method." + + | encoderClass scanner aSet | + encoderClass := self encoderClass. + aSet := Set new. + scanner := InstructionStream on: self. + scanner scanFor: [ :x | + | selector | + (selector := encoderClass selectorToSendOrItselfFor: scanner in: self at: scanner pc) == scanner + ifFalse: + [aSet add: selector] + ifTrue: + [(encoderClass blockMethodOrNilFor: scanner in: self at: scanner pc) ifNotNil: + [:blockMethod| aSet addAll: blockMethod messages]]. + false "keep scanning" ]. + ^aSet! Item was added: + ----- Method: CompiledCode>>messagesDo:encoderClass:visitedSet: (in category 'private') ----- + messagesDo: aBlock encoderClass: encoderClass visitedSet: visitedSet + "The inner engine for messagesDo:" + + | scanner | + scanner := InstructionStream on: self. + scanner scanFor: [ :x | + | selector | + (selector := encoderClass selectorToSendOrItselfFor: scanner in: self at: scanner pc) == scanner + ifFalse: + [(visitedSet ifAbsentAdd: selector) ifTrue: + [aBlock value: selector]] + ifTrue: + [(encoderClass blockMethodOrNilFor: scanner in: self at: scanner pc) ifNotNil: + [:blockMethod| + blockMethod messagesDo: aBlock encoderClass: encoderClass visitedSet: visitedSet]]. + false "keep scanning" ]! Item was changed: ----- Method: CompiledCode>>refersTo:bytecodeScanner:thorough: (in category 'literals') ----- refersTo: literal bytecodeScanner: scanBlockOrNil thorough: thorough "Answer if the receiver refers to the literal. If the scan block is non-nil, then use it to find the literal in bytecode. If thorough is true, dive down into literal arrays and method properties to locate references to the literal there-in." 2 to: ((self isCompiledBlock or: [thorough]) + ifTrue: [self numLiterals] "exclude outerCode or methodClass" + ifFalse: [self numLiterals - 1]) "exclude selector/properties and methodClass" - ifTrue: [self numLiterals ] "exclude outerCode or methodClass" - ifFalse: [self numLiterals - 1]) "exclude selector/properties and methodClass" do: [:i| | lit | lit := self objectAt: i. (literal == lit or: [literal literalEqual: lit]) ifTrue: [^true]. "== for Float bindingOf: #NaN since NaN ~= NaN" lit isCompiledCode ifTrue: [(lit refersTo: literal bytecodeScanner: scanBlockOrNil thorough: thorough) ifTrue: [^true]] ifFalse: [thorough ifTrue: [lit isVariableBinding ifTrue: [literal == lit key ifTrue: [^true]] ifFalse: [(lit isArray and: [(lit hasLiteral: literal) or: [literal isVariableBinding and: [literal key isSymbol and: [lit hasLiteral: literal key]]]]) ifTrue: [^true]]]]]. scanBlockOrNil ifNotNil: [(self scanFor: scanBlockOrNil) ifTrue: [^true]]. ^false! Item was changed: ----- Method: CompiledMethod>>messagesDo: (in category 'scanning') ----- messagesDo: aBlock "Evaluate aBlock exactly once with all the message selectors sent by me." + self isQuick ifFalse: + [self messagesDo: aBlock + encoderClass: self encoderClass + visitedSet: IdentitySet new]! - | scanner aSet | - self isQuick ifTrue: [ ^self ]. - scanner := InstructionStream on: self. - scanner scanFor: [ :x | - | selector | - (selector := scanner selectorToSendOrSelf) == scanner ifFalse: [ - ((aSet ifNil: [ aSet := IdentitySet new ]) ifAbsentAdd: selector) ifTrue: [ - aBlock value: selector ] ]. - false "keep scanning" ]! Item was added: + ----- Method: InstructionStream>>blockMethodOrNil (in category 'scanning') ----- + blockMethodOrNil + "If this instruction is a full block creation, answer the block's method, otherwise nil." + + | method | + method := self method. + ^method encoderClass blockMethodOrNilFor: self in: method at: pc! |
Free forum by Nabble | Edit this page |