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

Side by Side Diff: src/objects.cc

Issue 1298603002: [runtime] Unify and fix the strict equality comparison. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (IsSmi()) return Smi::cast(this)->value() != 0; 95 if (IsSmi()) return Smi::cast(this)->value() != 0;
96 if (IsUndefined() || IsNull()) return false; 96 if (IsUndefined() || IsNull()) return false;
97 if (IsUndetectableObject()) return false; // Undetectable object is false. 97 if (IsUndetectableObject()) return false; // Undetectable object is false.
98 if (IsString()) return String::cast(this)->length() != 0; 98 if (IsString()) return String::cast(this)->length() != 0;
99 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue(); 99 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue();
100 if (IsSimd128Value()) return true; // Simd value types evaluate to true. 100 if (IsSimd128Value()) return true; // Simd value types evaluate to true.
101 return true; 101 return true;
102 } 102 }
103 103
104 104
105 bool Object::StrictEquals(Object* that) {
106 if (this->IsNumber()) {
107 if (!that->IsNumber()) return false;
108 double const x = this->Number();
109 double const y = that->Number();
110 // Must check explicitly for NaN:s on Windows, but -0 works fine.
111 return x == y && !std::isnan(x) && !std::isnan(y);
112 } else if (this->IsString()) {
113 if (!that->IsString()) return false;
114 return String::cast(this)->Equals(String::cast(that));
115 } else if (this->IsSimd128Value()) {
116 if (!that->IsSimd128Value()) return false;
117 return Simd128Value::cast(this)->Equals(Simd128Value::cast(that));
118 }
119 return this == that;
120 }
121
122
105 bool Object::IsCallable() const { 123 bool Object::IsCallable() const {
106 const Object* fun = this; 124 const Object* fun = this;
107 while (fun->IsJSFunctionProxy()) { 125 while (fun->IsJSFunctionProxy()) {
108 fun = JSFunctionProxy::cast(fun)->call_trap(); 126 fun = JSFunctionProxy::cast(fun)->call_trap();
109 } 127 }
110 return fun->IsJSFunction() || 128 return fun->IsJSFunction() ||
111 (fun->IsHeapObject() && 129 (fun->IsHeapObject() &&
112 HeapObject::cast(fun)->map()->has_instance_call_handler()); 130 HeapObject::cast(fun)->map()->has_instance_call_handler());
113 } 131 }
114 132
(...skipping 15584 matching lines...) Expand 10 before | Expand all | Expand 10 after
15699 if (cell->value() != *new_value) { 15717 if (cell->value() != *new_value) {
15700 cell->set_value(*new_value); 15718 cell->set_value(*new_value);
15701 Isolate* isolate = cell->GetIsolate(); 15719 Isolate* isolate = cell->GetIsolate();
15702 cell->dependent_code()->DeoptimizeDependentCodeGroup( 15720 cell->dependent_code()->DeoptimizeDependentCodeGroup(
15703 isolate, DependentCode::kPropertyCellChangedGroup); 15721 isolate, DependentCode::kPropertyCellChangedGroup);
15704 } 15722 }
15705 } 15723 }
15706 15724
15707 } // namespace internal 15725 } // namespace internal
15708 } // namespace v8 15726 } // namespace v8
OLDNEW
« src/api.cc ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698