Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.959.mcz
==================== Summary ====================
Name: Collections-ul.959
Author: ul
Time: 13 September 2021, 8:09:57.683039 pm
UUID: 38711725-42d6-45cb-8915-e517d1fc8fd8
Ancestors: Collections-eem.958
- WeakIdentityDictionary and WeakKeyDictionary must implement #at:ifPresent:
- WeakKeyDictionary must also override #at:ifPresent:ifAbsent:
- implement KeyedSet >> #at:ifPresent:ifAbsent: while at these methods
- CharacterSet class >> #cleanUp: was missing two cached instances: Ascii and NonAscii
=============== Diff against Collections-eem.958 ===============
Item was changed:
----- Method: CharacterSet class>>cleanUp: (in category 'initialize-release') -----
cleanUp: aggressive
+ CrLf := NonSeparators := Separators := Ascii := NonAscii := nil!
- CrLf := NonSeparators := Separators := nil!
Item was added:
+ ----- Method: KeyedSet>>at:ifPresent:ifAbsent: (in category 'accessing') -----
+ at: key ifPresent: oneArgBlock ifAbsent: absentBlock
+ "Lookup the given key in the receiver. If it is present, answer the
+ value of evaluating the oneArgBlock with the value associated
+ with the key, otherwise answer the value of absentBlock."
+
+ ^(array at: (self scanFor: key))
+ ifNil: [ absentBlock value ]
+ ifNotNil: [ :value | oneArgBlock value: value enclosedSetElement ]!
Item was added:
+ ----- Method: WeakIdentityDictionary>>at:ifPresent: (in category 'accessing') -----
+ at: key ifPresent: aBlock
+ "Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil."
+
+ ^(array at: (self scanFor: key)) ifNotNil: [ :association |
+ association == vacuum ifFalse: [
+ aBlock value: association value ] ]!
Item was added:
+ ----- Method: WeakKeyDictionary>>at:ifPresent: (in category 'accessing') -----
+ at: key ifPresent: aBlock
+ "Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil.
+ While no nil key can be added, keys become nil when they are garbage collected.
+ This must not let nil accidentally 'inherit' the value of such a stale association."
+
+ ^key ifNotNil: [ super at: key ifPresent: aBlock ]!
Item was added:
+ ----- Method: WeakKeyDictionary>>at:ifPresent:ifAbsent: (in category 'accessing') -----
+ at: key ifPresent: oneArgBlock ifAbsent: absentBlock
+ "Lookup the given key in the receiver. If it is present, answer the
+ value of evaluating the oneArgBlock with the value associated
+ with the key, otherwise answer the value of absentBlock."
+
+ ^key ifNotNil: [ super at: key ifPresent: oneArgBlock ifAbsent: absentBlock ]!
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.1413.mcz
==================== Summary ====================
Name: Kernel-ul.1413
Author: ul
Time: 13 September 2021, 8:06:11.922907 pm
UUID: 2751b4f0-b45d-4578-b539-a3ccfd56d4ee
Ancestors: Kernel-ul.1412
- MethodDictionary must override #at:ifPresent:
- remove accidentally commited junk #isPowerOfTwo2 and #isPowerOfTwo3
=============== Diff against Kernel-ul.1412 ===============
Item was added:
+ ----- Method: MethodDictionary>>at:ifPresent: (in category 'accessing') -----
+ at: key ifPresent: aBlock
+ "Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil."
+
+ ^(array at: (self scanFor: key)) ifNotNil: [ :value | aBlock value: value ]!
Item was removed:
- ----- Method: SmallInteger>>isPowerOfTwo2 (in category 'testing') -----
- isPowerOfTwo2
- "Return true if the receiver is an integral power of two. Optimized version."
-
- ^self strictlyPositive and: [ (self bitAnd: self - 1) = 0 ]!
Item was removed:
- ----- Method: SmallInteger>>isPowerOfTwo3 (in category 'testing') -----
- isPowerOfTwo3
- "Return true if the receiver is an integral power of two. Optimized version."
-
- self > 0 ifFalse: [ ^false ].
- (self bitAnd: self - 1) = 0 ifFalse: [ ^false ].
- ^true!
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.1412.mcz
==================== Summary ====================
Name: Kernel-ul.1412
Author: ul
Time: 13 September 2021, 7:42:57.781301 pm
UUID: 99321567-2351-48d2-9568-eb9d99079021
Ancestors: Kernel-eem.1410, Kernel-ul.1411
CompiledCode >> #hash :
- remove #species from the hash calculation because #= doesn't compare that either
- use #hashMultiply to mix in values with fewer collisions (increases the number of different hash values by about 1.5x in the image)
- actualized comments
- reset DebuggerMethodMap's MapCache, so that all collections relying on CompiledCode's #hash in a Trunk image are absent
- finally, rehash all hashed collections just to be sure no collections are left in an invalid state
Also merge with Kernel-ul.1411.
=============== Diff against Kernel-eem.1410 ===============
Item was changed:
----- Method: CompiledCode>>hash (in category 'comparing') -----
hash
+ "CompiledCode>>#= compares code, i.e. same literals and same bytecode.
+ So we look at the size, the header and some bytes between initialPC and endPC,
+ but neither selector nor methodClass because the #= does not either..
+ Note that we must override ByteArray>>#hash which looks at all bytes of the receiver.
+ Using bytes from the pointer part of a CompiledCode can lead to a variable hash
- "CompiledMethod>>#= compares code, i.e. same literals and same bytecode.
- So we look at the header, methodClass and some bytes between initialPC and endPC,
- but /not/ the selector because the equal method does not compare selectors.
- Note that we must override ByteArray>hash which looks at all bytes of the receiver.
- Using bytes from the pointer part of a CompiledMethod can lead to a variable hash
if and when when the GC moves literals in the receiver."
+
| initialPC endPC hash |
initialPC := self initialPC.
endPC := self endPC.
+ hash := (((self size hashMultiply + self header) hashMultiply + initialPC) hashMultiply + endPC) hashMultiply.
- hash := self species hash + self header + initialPC + endPC bitAnd: 16rFFFFFFF.
"sample approximately 20 bytes"
initialPC to: endPC by: (endPC - initialPC // 20 max: 1) do:
+ [:i| hash := (hash + (self at: i)) hashMultiply].
- [:i| hash := hash + (self at: i)].
^hash
+ "(CompiledCode>>#hash) hash"!
- "(CompiledMethod>>#hash) hash"!
Item was added:
+ ----- Method: Fraction>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ "Return true if the receiver is an integral power of two."
+
+ ^numerator = 1 and: [ denominator isPowerOfTwo ]!
Item was removed:
- ----- Method: Integer>>isPowerOfTwo (in category 'testing') -----
- isPowerOfTwo
- "Return true if the receiver is an integral power of two."
-
- ^self strictlyPositive and: [ (self bitAnd: self - 1) = 0 ]!
Item was added:
+ ----- Method: Number>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ "Return true if the receiver is an integral power of two."
+
+ self subclassResponsibility!
Item was added:
+ ----- Method: ScaledDecimal>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ "Return true if the receiver is an integral power of two."
+
+ ^fraction isPowerOfTwo!
Item was added:
+ ----- Method: SmallInteger>>isPowerOfTwo2 (in category 'testing') -----
+ isPowerOfTwo2
+ "Return true if the receiver is an integral power of two. Optimized version."
+
+ ^self strictlyPositive and: [ (self bitAnd: self - 1) = 0 ]!
Item was added:
+ ----- Method: SmallInteger>>isPowerOfTwo3 (in category 'testing') -----
+ isPowerOfTwo3
+ "Return true if the receiver is an integral power of two. Optimized version."
+
+ self > 0 ifFalse: [ ^false ].
+ (self bitAnd: self - 1) = 0 ifFalse: [ ^false ].
+ ^true!
Item was changed:
+ (PackageInfo named: 'Kernel') postscript: 'DebuggerMethodMap voidMapCache.
+ Smalltalk garbageCollect.
+ HashedCollection rehashAll'!
- (PackageInfo named: 'Kernel') postscript: 'EventSensor initialize..
- EventSensor startUp..'!
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.1411.mcz
==================== Summary ====================
Name: Kernel-ul.1411
Author: ul
Time: 10 September 2021, 3:16:23.23175 pm
UUID: 9d7f74f9-52b9-4a1c-babf-60de439244bb
Ancestors: Kernel-ul.1409
- let all Numbers respond to #isPowerOfTwo.
- removed Integer >> #isPowerOfTwo because it was not used: all subclasses implement that method
=============== Diff against Kernel-ul.1409 ===============
Item was added:
+ ----- Method: Fraction>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ "Return true if the receiver is an integral power of two."
+
+ ^numerator = 1 and: [ denominator isPowerOfTwo ]!
Item was removed:
- ----- Method: Integer>>isPowerOfTwo (in category 'testing') -----
- isPowerOfTwo
- "Return true if the receiver is an integral power of two."
-
- ^self strictlyPositive and: [ (self bitAnd: self - 1) = 0 ]!
Item was added:
+ ----- Method: Number>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ "Return true if the receiver is an integral power of two."
+
+ self subclassResponsibility!
Item was added:
+ ----- Method: ScaledDecimal>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ "Return true if the receiver is an integral power of two."
+
+ ^fraction isPowerOfTwo!
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1410.mcz
==================== Summary ====================
Name: Kernel-eem.1410
Author: eem
Time: 12 September 2021, 10:24:18.099359 pm
UUID: 80f1546b-b2a1-4ffb-a174-d21d2eb2eb67
Ancestors: Kernel-ul.1409
Since Compiledmethod>>= is true if method classes differ, a COmpiledMethod's hash must not tae methodClass into account.
=============== Diff against Kernel-ul.1409 ===============
Item was changed:
----- Method: CompiledCode>>hash (in category 'comparing') -----
hash
"CompiledMethod>>#= compares code, i.e. same literals and same bytecode.
So we look at the header, methodClass and some bytes between initialPC and endPC,
but /not/ the selector because the equal method does not compare selectors.
Note that we must override ByteArray>hash which looks at all bytes of the receiver.
+ Using bytes from the pointer part of a CompiledMethod can lead to a variable hash
- Using bytes from the pointer part of a COmpiledmethod can lead to a variable hash
if and when when the GC moves literals in the receiver."
| initialPC endPC hash |
initialPC := self initialPC.
endPC := self endPC.
+ hash := self species hash + self header + initialPC + endPC bitAnd: 16rFFFFFFF.
- hash := self species hash + self header + initialPC + endPC + self methodClass hash bitAnd: 16rFFFFFFF.
"sample approximately 20 bytes"
initialPC to: endPC by: (endPC - initialPC // 20 max: 1) do:
[:i| hash := hash + (self at: i)].
^hash
"(CompiledMethod>>#hash) hash"!
Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.958.mcz
==================== Summary ====================
Name: Collections-eem.958
Author: eem
Time: 12 September 2021, 10:21:36.638507 pm
UUID: b2a7ddb8-1520-483b-96b1-1bf44bf6ec20
Ancestors: Collections-dtl.957
Faster at:ifPresent:
=============== Diff against Collections-dtl.957 ===============
Item was changed:
----- Method: Dictionary>>at:ifPresent: (in category 'accessing') -----
at: key ifPresent: aBlock
"Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil."
+ ^(array at: (self scanFor: key)) ifNotNil: [:assoc| aBlock value: assoc value]!
- | v |
- v := self at: key ifAbsent: [^ nil].
- ^ aBlock value: v
- !
Item was changed:
----- Method: KeyedSet>>at:ifPresent: (in category 'accessing') -----
at: key ifPresent: aBlock
"Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil."
+ ^(array at: (self scanFor: key)) ifNotNil: [:obj| aBlock value: obj enclosedSetElement]!
- | v |
- v := self at: key ifAbsent: [^ nil].
- ^ aBlock value: v
- !
David T. Lewis uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-dtl.957.mcz
==================== Summary ====================
Name: Collections-dtl.957
Author: dtl
Time: 8 September 2021, 5:57:05.466076 pm
UUID: c8292c9b-808c-42b3-931b-84065ca758af
Ancestors: Collections-ct.956
LazyCharacterSet>>printOn: should not raise an error, otherwise things get confusing in the debugger.
(LazyCharacterSet including: [:e | e asciiValue < 256 ]) printString
=============== Diff against Collections-ct.956 ===============
Item was added:
+ ----- Method: LazyCharacterSet>>printElementsOn: (in category 'printing') -----
+ printElementsOn: aString
+ "Do nothing,elements cannot be directly enumerated"!