The Trunk: 60Deprecated-mt.39.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: 60Deprecated-mt.39.mcz

commits-2
Marcel Taeumel uploaded a new version of 60Deprecated to project The Trunk:
http://source.squeak.org/trunk/60Deprecated-mt.39.mcz

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

Name: 60Deprecated-mt.39
Author: mt
Time: 12 July 2019, 10:00:59.145568 am
UUID: c876b270-643e-414c-853b-9ec38a9b2fb3
Ancestors: 60Deprecated-mt.38

Refactoring of #literalsDo: - Step 2 of 3.

For more information, see http://forum.world.st/Please-Review-Refactoring-for-literalsDo-etc-tp5099756p5100896.html.

=============== Diff against 60Deprecated-mt.38 ===============

Item was added:
+ ----- Method: CompiledBlock>>allSubLiterals (in category '*60Deprecated-literals') -----
+ allSubLiterals
+ | literalsExceptOuter unfoldedSubLiterals |
+ literalsExceptOuter := self literals allButLast.
+ unfoldedSubLiterals := literalsExceptOuter
+ select: [:lit| lit isCompiledCode]
+ thenCollect: [:blockMethod| blockMethod allSubLiterals].
+ unfoldedSubLiterals ifEmpty:
+ [^literalsExceptOuter].
+ ^literalsExceptOuter, (unfoldedSubLiterals fold: [:a :b| a, b])!

Item was added:
+ ----- Method: CompiledCode>>messagesDo:encoderClass:visitedSet: (in category '*60Deprecated-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 added:
+ ----- Method: CompiledCode>>refersTo:bytecodeScanner:thorough: (in category '*60Deprecated-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
+ 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 added:
+ ----- Method: CompiledCode>>refersTo:primaryBytecodeScanner:secondaryBytecodeScanner:thorough: (in category '*60Deprecated-literals') -----
+ refersTo: literal primaryBytecodeScanner: primaryScanBlockOrNil secondaryBytecodeScanner: secondaryScanBlockOrNil thorough: thorough
+ "Answer if the receiver refers to the literal.  If the scan blocks are non-nil, then
+ use them 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."
+ ^self
+ refersTo: literal
+ bytecodeScanner: (self signFlag
+ ifTrue: [secondaryScanBlockOrNil]
+ ifFalse: [primaryScanBlockOrNil])
+ thorough: thorough!

Item was added:
+ ----- Method: CompiledMethod>>hasLiteralThorough: (in category '*60Deprecated-literals') -----
+ hasLiteralThorough: literal
+ "Answer true if any literal in this method is literal,
+ even if embedded in array structure."
+
+ (self penultimateLiteral isMethodProperties
+ and: [self penultimateLiteral hasLiteralThorough: literal]) ifTrue:[^true].
+ 2 to: self numLiterals - 1 "exclude superclass + selector/properties"
+   do:[:index | | lit |
+ (((lit := self objectAt: index) literalEqual: literal)
+ or: [(lit isVariableBinding and: [lit key == literal])
+ or: [lit isArray and: [lit hasLiteral: literal]]]) ifTrue:
+ [^ true]].
+ ^ false !

Item was added:
+ ----- Method: CompiledMethod>>refersToLiteral: (in category '*60Deprecated-literals') -----
+ refersToLiteral:aLiteral
+
+ ^self hasLiteral: aLiteral.!