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

Unified Diff: src/objects.cc

Issue 947443005: Fix issue with -0 in Maps (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove extra file Created 5 years, 10 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/es6/map-minus-zero.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 100cbf90b3493860d8bd0c5c5b4246d8f57e495d..99b0ab70de998065185c0d504ba487f31b6a08a7 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -798,10 +798,16 @@ Map* Object::GetRootMap(Isolate* isolate) {
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 = std::isnan(Number())
- ? Smi::kMaxValue
- : ComputeLongHash(double_to_uint64(Number()));
+ if (IsSmi()) {
+ int num = Smi::cast(this)->value();
+ uint32_t hash = ComputeLongHash(double_to_uint64(static_cast<double>(num)));
+ return Smi::FromInt(hash & Smi::kMaxValue);
+ }
+ if (IsHeapNumber()) {
+ double num = HeapNumber::cast(this)->value();
+ if (std::isnan(num)) return Smi::FromInt(Smi::kMaxValue);
+ if (i::IsMinusZero(num)) num = 0;
+ uint32_t hash = ComputeLongHash(double_to_uint64(num));
return Smi::FromInt(hash & Smi::kMaxValue);
}
if (IsName()) {
« no previous file with comments | « no previous file | test/mjsunit/es6/map-minus-zero.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698