[squeak-dev] The Trunk: Kernel-dtl.1096.mcz
Levente Uzonyi
leves at caesar.elte.hu
Thu Apr 20 21:08:13 UTC 2017
Hi Chris,
The recent mails of Andres Valloud answer your questions[1][2].
Now that I took a deeper look at the function, I found the following
issues:
1. It'll overflow into LargeIntegers during computation for some
SmallInteger input. That can and should be fixed by adding a bitAnd:
16r3FFF.
2. It will accept negative integers, but I'm not sure if it will work the
same way the primitive does.
Levente
[1] http://lists.squeakfoundation.org/pipermail/vm-dev/2017-April/024826.html
[2] http://lists.squeakfoundation.org/pipermail/vm-dev/2017-April/024831.html
On Thu, 20 Apr 2017, Chris Muller wrote:
> Okay, but it's a given that hash functions are desired to be fast, so
> one can always assume optimized code in them. I was hoping for a
> comment that would refer to the origin of this hash function, so one
> could research and possibly understand it...
>
>
> On Tue, Apr 18, 2017 at 10:59 AM, <commits at source.squeak.org> wrote:
>> David T. Lewis uploaded a new version of Kernel to project The Trunk:
>> http://source.squeak.org/trunk/Kernel-dtl.1096.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Kernel-dtl.1096
>> Author: dtl
>> Time: 18 April 2017, 11:59:08.257358 am
>> UUID: 877ab97f-9ebe-4405-af31-fe9caab25eb6
>> Ancestors: Kernel-eem.1095
>>
>> SmallInteger>>hashMultiply comment provided by Andres Valloud
>>
>> =============== Diff against Kernel-eem.1095 ===============
>>
>> Item was changed:
>> ----- Method: SmallInteger>>hashMultiply (in category 'bit manipulation') -----
>> hashMultiply
>> + "Multiply by 1664525 mod 2^28 without overflowing into large integers."
>> | low |
>> -
>> low := self bitAnd: 16383.
>> ^(16r260D * low + ((16r260D * (self bitShift: -14) + (16r0065 * low) bitAnd: 16383) * 16384))
>> bitAnd: 16r0FFFFFFF!
>>
>>
More information about the Squeak-dev
mailing list
|