Reviewers: Toon Verwaest,
Description:
Compute the same hash for all NaN values.
Both SameValue and SameValueZero consider different NaNs equal, so we
better assign the same hash value to all NaNs.
BUG=v8:3859
LOG=y
[email protected]
Please review this at https://codereview.chromium.org/897593002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+5, -9 lines):
M src/objects.cc
A + test/mjsunit/regress/regress-3859.js
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()) {
Index: test/mjsunit/regress/regress-3859.js
diff --git a/test/mjsunit/compiler/regress-451012.js
b/test/mjsunit/regress/regress-3859.js
similarity index 63%
copy from test/mjsunit/compiler/regress-451012.js
copy to test/mjsunit/regress/regress-3859.js
index
bffc8bc5bdfac32bb561a24153d00157b26ac3a5..3248ef14ac721ebfdedbd97923a90e7a83a0efe4
100644
--- a/test/mjsunit/compiler/regress-451012.js
+++ b/test/mjsunit/regress/regress-3859.js
@@ -2,11 +2,5 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-"use strict";
-function f() {
- for (let v; v; ) {
- let x;
- }
-}
-
-f();
+assertEquals(1, new Set([NaN, NaN, NaN]).size);
+assertEquals(42, new Map([[NaN, 42]]).get(NaN));
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.