Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Unified Diff: src/objects.cc

Issue 897593002: Compute the same hash for all NaN values. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-3859.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 8d7244b6a91511a6c511f9bd956de99bd99a8d1f..28c6ebb47ed393300ff5e9a73de2b6b5b06f51d4 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -717,7 +717,9 @@ Object* Object::GetHash() {
// The object is either a number, a name, an odd-ball,
// a real JS object, or a Harmony proxy.
if (IsNumber()) {
- uint32_t hash = ComputeLongHash(double_to_uint64(Number()));
+ uint32_t hash = std::isnan(Number())
+ ? Smi::kMaxValue
+ : ComputeLongHash(double_to_uint64(Number()));
return Smi::FromInt(hash & Smi::kMaxValue);
}
if (IsName()) {
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-3859.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698