Closed Bug 885175 Opened 11 years ago Closed 11 years ago

Fix hashing of doubles

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: sunfish, Unassigned)

References

Details

Attachments

(1 file, 1 obsolete file)

DefaultHasher<double>'s hash method uses a union which causes it to return values which depend on the endianness, and its match method uses floating-point equality, so it doesn't handle negative zeros or NaNs properly.
Blocks: 876064
Attached patch a proposed fix (obsolete) — Splinter Review
This is partly based on part of the patch in bug 876064.
Attachment #765162 - Flags: review?(luke)
Could you use BitwiseCast<uint64_t> instead (see use in ion/MIR.cpp)?
Does the existing DefaultHasher stuff use mfbt/HashFunctions.h at all?  Would probably be good to add some double overloads and functions there, and use that.  (The existing code there looks like it'd hash the double as if it were a uint32_t, which is wrong in all sorts of ways.)
Luke: Updated patch using BitwiseCast<uint64_t>. It's nicer :-).

Jeff: As far as I can tell, nothing in js/public/HashTable.h uses mfbt/HashFunctions.h currently. Switching it over looks like a bigger project than I'm interested in tackling at this time.
Attachment #765162 - Attachment is obsolete: true
Attachment #765162 - Flags: review?(luke)
Attachment #765482 - Flags: review?(luke)
Comment on attachment 765482 [details] [diff] [review]
an updated patch, following review feedback

Great!  Feel free to take over bug 876064, btw.
Attachment #765482 - Flags: review?(luke) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/806a358aa8b2

Also, yes, I do plan to take over bug 876064 soon :).
https://hg.mozilla.org/mozilla-central/rev/806a358aa8b2
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: