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

Unified 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 side-by-side diff with in-line comments
Download patch
« src/api.cc ('K') | « src/objects.h ('k') | src/objects-inl.h » ('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 2cfc82df1a84b7402681a340fb5578f2c99e83ea..1f25a5d11b7dcd788a6541e41781eb98e826f6b7 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -102,6 +102,24 @@ bool Object::BooleanValue() {
}
+bool Object::StrictEquals(Object* that) {
+ if (this->IsNumber()) {
+ if (!that->IsNumber()) return false;
+ double const x = this->Number();
+ double const y = that->Number();
+ // Must check explicitly for NaN:s on Windows, but -0 works fine.
+ return x == y && !std::isnan(x) && !std::isnan(y);
+ } else if (this->IsString()) {
+ if (!that->IsString()) return false;
+ return String::cast(this)->Equals(String::cast(that));
+ } else if (this->IsSimd128Value()) {
+ if (!that->IsSimd128Value()) return false;
+ return Simd128Value::cast(this)->Equals(Simd128Value::cast(that));
+ }
+ return this == that;
+}
+
+
bool Object::IsCallable() const {
const Object* fun = this;
while (fun->IsJSFunctionProxy()) {
« 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