Discussion:
[squeak-dev] The Trunk: Kernel-eem.1198.mcz
c***@source.squeak.org
0000-11-26 03:36:00 UTC
Permalink
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1198.mcz

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

Name: Kernel-eem.1198
Author: eem
Time: 24 November 2018, 1:44:47.526422 pm
UUID: 100137c4-2514-4b7f-9064-3dcdfe7d8cc9
Ancestors: Kernel-eem.1197

Redefine LargePositiveInteger hash for compatibility between 32-bit and 64-bit systems.

=============== Diff against Kernel-eem.1197 ===============

Item was changed:
----- Method: LargePositiveInteger>>hash (in category 'comparing') -----
hash
+ "Answer an integer value that is related to the value of the receiver.
+ Take care that the hash value is the same in both 32-bit and 64-bit versions.
+ Since the integers are by definition perfectly distributed a SmallInteger's hash is itself
+ (it is impossible to derive a hash function that is better distributed than the SmallIntegers
+ themselves). Therefore, for integers that could possibly fit in the SmallInteger range, answer
+ self. For values well outside of the SmallInteger range on 64-bits answer a hash that avoids
+ large integer arithmetic."
+ ^self digitLength <= 8
+ ifTrue: [self]
+ ifFalse:
+ [ByteArray
+ hashBytes: self
+ startingWith: self species hash]!
-
- ^ByteArray
- hashBytes: self
- startingWith: self species hash!

Item was changed:
----- Method: SmallInteger>>hash (in category 'comparing') -----
hash
+ "Answer an integer value that is related to the value of the receiver.
+ Since the integers are by definition perfectly distributed answer self
+ (it is impossible to derive a hash function that is better distributed
+ than the SmallIntegers themselves). c.f. LargePositiveInteger hash."

^self!

Item was changed:
(PackageInfo named: 'Kernel') postscript: '"below, add code to be run after the loading of this package"
+ "Since Kernel-eem.1198 redefines LargePositiveInteger hash,
+ rehash all hashed collections that contain hashed large integers."
+ HashedCollection allSubclassesDo:
+ [:c| | f |
+ f := (c includesBehavior: Set)
+ ifTrue: [[:i| i]]
+ ifFalse: [[:i| i keys]].
+ c allInstancesDo:
+ [:h|
+ ((f value: h) detect: [:e| e isInteger and: [e class ~~ SmallInteger]] ifNone: nil) ifNotNil:
+ [h halt rehash]]]'!
- ((ByteArray subclasses includes: CompiledMethod)
- and: [CompiledMethod superclass ~= ByteArray]) ifTrue:
- [ByteArray removeSubclass: CompiledMethod].
- (Smalltalk classNamed: #FullBlockClosure) ifNotNil:
- [:fbc|
- (fbc identityHash ~= 38) ifTrue:
Levente Uzonyi
2018-11-24 23:14:13 UTC
Permalink
Post by c***@source.squeak.org
http://source.squeak.org/trunk/Kernel-eem.1198.mcz
==================== Summary ====================
Name: Kernel-eem.1198
Author: eem
Time: 24 November 2018, 1:44:47.526422 pm
UUID: 100137c4-2514-4b7f-9064-3dcdfe7d8cc9
Ancestors: Kernel-eem.1197
Redefine LargePositiveInteger hash for compatibility between 32-bit and 64-bit systems.
=============== Diff against Kernel-eem.1197 ===============
----- Method: LargePositiveInteger>>hash (in category 'comparing') -----
hash
+ "Answer an integer value that is related to the value of the receiver.
+ Take care that the hash value is the same in both 32-bit and 64-bit versions.
+ Since the integers are by definition perfectly distributed a SmallInteger's hash is itself
+ (it is impossible to derive a hash function that is better distributed than the SmallIntegers
+ themselves). Therefore, for integers that could possibly fit in the SmallInteger range, answer
+ self. For values well outside of the SmallInteger range on 64-bits answer a hash that avoids
+ large integer arithmetic."
+ ^self digitLength <= 8
+ ifTrue: [self]
+ [ByteArray
+ hashBytes: self
+ startingWith: self species hash]!
-
- ^ByteArray
- hashBytes: self
- startingWith: self species hash!
----- Method: SmallInteger>>hash (in category 'comparing') -----
hash
+ "Answer an integer value that is related to the value of the receiver.
+ Since the integers are by definition perfectly distributed answer self
+ (it is impossible to derive a hash function that is better distributed
+ than the SmallIntegers themselves). c.f. LargePositiveInteger hash."
^self!
(PackageInfo named: 'Kernel') postscript: '"below, add code to be run after the loading of this package"
+ "Since Kernel-eem.1198 redefines LargePositiveInteger hash,
+ rehash all hashed collections that contain hashed large integers."
+ [:c| | f |
+ f := (c includesBehavior: Set)
+ ifTrue: [[:i| i]]
+ ifFalse: [[:i| i keys]].
+ [:h|
+ [h halt rehash]]]'!
Is there a reason for that #halt to be there?

Levente
Post by c***@source.squeak.org
- ((ByteArray subclasses includes: CompiledMethod)
- [ByteArray removeSubclass: CompiledMethod].
- [:fbc|
Eliot Miranda
2018-11-24 23:18:22 UTC
Permalink
Post by c***@source.squeak.org
Post by c***@source.squeak.org
http://source.squeak.org/trunk/Kernel-eem.1198.mcz
==================== Summary ====================
Name: Kernel-eem.1198
Author: eem
Time: 24 November 2018, 1:44:47.526422 pm
UUID: 100137c4-2514-4b7f-9064-3dcdfe7d8cc9
Ancestors: Kernel-eem.1197
Redefine LargePositiveInteger hash for compatibility between 32-bit and
64-bit systems.
Post by c***@source.squeak.org
=============== Diff against Kernel-eem.1197 ===============
----- Method: LargePositiveInteger>>hash (in category 'comparing') -----
hash
+ "Answer an integer value that is related to the value of the
receiver.
Post by c***@source.squeak.org
+ Take care that the hash value is the same in both 32-bit and
64-bit versions.
Post by c***@source.squeak.org
+ Since the integers are by definition perfectly distributed a
SmallInteger's hash is itself
Post by c***@source.squeak.org
+ (it is impossible to derive a hash function that is better
distributed than the SmallIntegers
Post by c***@source.squeak.org
+ themselves). Therefore, for integers that could possibly fit in
the SmallInteger range, answer
Post by c***@source.squeak.org
+ self. For values well outside of the SmallInteger range on
64-bits answer a hash that avoids
Post by c***@source.squeak.org
+ large integer arithmetic."
+ ^self digitLength <= 8
+ ifTrue: [self]
+ [ByteArray
+ hashBytes: self
+ startingWith: self species hash]!
-
- ^ByteArray
- hashBytes: self
- startingWith: self species hash!
----- Method: SmallInteger>>hash (in category 'comparing') -----
hash
+ "Answer an integer value that is related to the value of the
receiver.
Post by c***@source.squeak.org
+ Since the integers are by definition perfectly distributed answer
self
Post by c***@source.squeak.org
+ (it is impossible to derive a hash function that is better
distributed
Post by c***@source.squeak.org
+ than the SmallIntegers themselves). c.f. LargePositiveInteger
hash."
Post by c***@source.squeak.org
^self!
(PackageInfo named: 'Kernel') postscript: '"below, add code to be run
after the loading of this package"
Post by c***@source.squeak.org
+ "Since Kernel-eem.1198 redefines LargePositiveInteger hash,
+ rehash all hashed collections that contain hashed large integers."
+ [:c| | f |
+ f := (c includesBehavior: Set)
+ ifTrue: [[:i| i]]
+ ifFalse: [[:i| i keys]].
+ [:h|
+ ((f value: h) detect: [:e| e isInteger and: [e class ~~
+ [h halt rehash]]]'!
Is there a reason for that #halt to be there?
Damn. I was debugging the script to make sure it would work (there are no
such dictionaries or sets in a normal image), and I forgot to remove the
halt. I shall submit a new version...
Post by c***@source.squeak.org
Levente
Post by c***@source.squeak.org
- ((ByteArray subclasses includes: CompiledMethod)
- [ByteArray removeSubclass: CompiledMethod].
- [:fbc|
- [fbc tryPrimitive: 161 withArgs: #(38 true)]]'!
--
_,,,^..^,,,_
best, Eliot
Bob Arning
2018-11-24 23:14:43 UTC
Permalink
just curious, but what is the halt for?
Post by c***@source.squeak.org
http://source.squeak.org/trunk/Kernel-eem.1198.mcz
==================== Summary ====================
Name: Kernel-eem.1198
Author: eem
Time: 24 November 2018, 1:44:47.526422 pm
UUID: 100137c4-2514-4b7f-9064-3dcdfe7d8cc9
Ancestors: Kernel-eem.1197
Redefine LargePositiveInteger hash for compatibility between 32-bit and 64-bit systems.
=============== Diff against Kernel-eem.1197 ===============
----- Method: LargePositiveInteger>>hash (in category 'comparing') -----
hash
+ "Answer an integer value that is related to the value of the receiver.
+ Take care that the hash value is the same in both 32-bit and 64-bit versions.
+ Since the integers are by definition perfectly distributed a SmallInteger's hash is itself
+ (it is impossible to derive a hash function that is better distributed than the SmallIntegers
+ themselves). Therefore, for integers that could possibly fit in the SmallInteger range, answer
+ self. For values well outside of the SmallInteger range on 64-bits answer a hash that avoids
+ large integer arithmetic."
+ ^self digitLength <= 8
+ ifTrue: [self]
+ [ByteArray
+ hashBytes: self
+ startingWith: self species hash]!
-
- ^ByteArray
- hashBytes: self
- startingWith: self species hash!
----- Method: SmallInteger>>hash (in category 'comparing') -----
hash
+ "Answer an integer value that is related to the value of the receiver.
+ Since the integers are by definition perfectly distributed answer self
+ (it is impossible to derive a hash function that is better distributed
+ than the SmallIntegers themselves). c.f. LargePositiveInteger hash."
^self!
(PackageInfo named: 'Kernel') postscript: '"below, add code to be run after the loading of this package"
+ "Since Kernel-eem.1198 redefines LargePositiveInteger hash,
+ rehash all hashed collections that contain hashed large integers."
+ [:c| | f |
+ f := (c includesBehavior: Set)
+ ifTrue: [[:i| i]]
+ ifFalse: [[:i| i keys]].
+ [:h|
+ [h halt rehash]]]'!
- ((ByteArray subclasses includes: CompiledMethod)
- [ByteArray removeSubclass: CompiledMethod].
- [:fbc|
- [fbc tryPrimitive: 161 withArgs: #(38 true)]]'!
Loading...