Marcel Taeumel uploaded a new version of Kernel to project The Trunk: http://source.squeak.org/trunk/Kernel-mt.1542.mcz
==================== Summary ====================
Name: Kernel-mt.1542 Author: mt Time: 15 December 2023, 3:31:10.454782 pm UUID: 796c80fe-bf50-614e-920a-09a0162f1edd Ancestors: Kernel-mt.1541
Fixes #literalsDo: performance (2 of 2).
=============== Diff against Kernel-mt.1541 ===============
Item was changed: ----- Method: CompiledCode>>allLiteralsDo: (in category 'literals') ----- allLiteralsDo: aBlock + "Overwritten to really enumerate all literals. Also the implicit ones." - "Enumerate all literals thoroughly. Follow nested instances of CompiledCode. Do not treat compiled code as literals here." + self + allLiteralsDo: aBlock + scanForSpecial: true.! - self codeLiteralsDo: - [:compiledCode | - compiledCode literalsDo: - [:literal | - literal isCompiledCode ifFalse: - [literal allLiteralsDo: aBlock]]. - compiledCode implicitLiteralsDo: aBlock]!
Item was removed: - ----- Method: CompiledCode>>hasLiteral:scanForSpecial: (in category 'literals') ----- - hasLiteral: aLiteral scanForSpecial: aBoolean - "Like #hasLiteral: but can scan for encoder-specific special literals. Not that scanning has a noticeable performance impact." - - | scanBlock | - (super hasLiteral: aLiteral) ifTrue: [^ true]. - - aBoolean ifFalse: [^ false]. - - scanBlock := self class - scanBlocksForLiteral: aLiteral - do: [:primaryScanner :secondaryScanner | - "E.g., scanner for SistaV1 or scanner for V3PlusClosures" - self signFlag ifTrue: [secondaryScanner] ifFalse: [primaryScanner]]. - - self codeLiteralsDo: [:compiledCode | - (compiledCode scanFor: scanBlock) ifTrue: [^ true]]. - - ^ false!
Item was removed: - ----- Method: CompiledMethod>>allLiteralsDo: (in category 'literals') ----- - allLiteralsDo: aBlock - "Overwritten to skip certain (raw) literals." - - " Exclude method selector (or properties) and the method's class." - 1 to: self numLiterals - 2 do: [:index | - (self literalAt: index) allLiteralsDo: aBlock]. - - "Enumerate the implicit literals in bytecodes of the receiver." - self implicitLiteralsDo: aBlock. - - "Enumerate method selector only through additional method state." - self penultimateLiteral isMethodProperties - ifTrue: [self penultimateLiteral allLiteralsDo: aBlock]!
Item was added: + ----- Method: CompiledMethod>>allLiteralsDo:scanForSpecial: (in category 'literals') ----- + allLiteralsDo: aBlock scanForSpecial: aBoolean + "Overwritten to skip certain (raw) literals." + + "Exclude method selector (or properties) and the method's class. Include code literals." + 1 to: self numLiterals - 2 do: [:index | + (self literalAt: index) allLiteralsDo: aBlock scanForSpecial: aBoolean]. + + "Enumerate the implicit literals in bytecodes of the receiver." + aBoolean ifTrue: [self implicitLiteralsDo: aBlock]. + + "Enumerate method selector only through additional method state." + self penultimateLiteral isMethodProperties + ifTrue: [self penultimateLiteral allLiteralsDo: aBlock scanForSpecial: aBoolean]!
Item was changed: ----- Method: Object>>allLiteralsDo: (in category 'literals') ----- allLiteralsDo: aBlock + "Enumerate all literals in the receiver. Note that subclasses may override this to expose the literals they hold such as Array or Pragma. Also note that CompiledCode, being the typical entry point for such an operation, will rather call #allLiteralsDo:#scanForSpecial: on all code literals (and regular literals) to avoid expensive byte-code scanning if possible."
self flag: #discuss. "mt: Better implement this only on Symbol, Array, Number, Binding, etc. instead of Object?" aBlock value: self.!
Item was changed: ----- Method: Object>>hasLiteral: (in category 'literals') ----- hasLiteral: literal
+ ^ self + hasLiteralSuchThat: [:lit | lit literalEqual: literal] + scanForSpecial: (BytecodeEncoder canBeSpecialLiteral: literal)! - ^ self hasLiteralSuchThat: [:lit | lit literalEqual: literal]!
Item was changed: ----- Method: Object>>hasLiteralSuchThat: (in category 'literals') ----- hasLiteralSuchThat: testBlock + "Also see #hasLiteral:. Do not scan for implicit (i.e. special) literals by default to get a faster response."
+ ^ self hasLiteralSuchThat: testBlock scanForSpecial: false! - self allLiteralsDo: [:literal | - (testBlock value: literal) ifTrue: [^ true]]. - - ^ false!
packages@lists.squeakfoundation.org