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

Unified Diff: src/api.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
« no previous file with comments | « no previous file | src/arm/code-stubs-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 8fa2e2c30d7f3accbfab88f286194458731a2d7b..46cac758f08ba3c75a0bc0767554f7bb431ea426 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3405,33 +3405,9 @@ bool Value::Equals(Local<Value> that) const {
bool Value::StrictEquals(Local<Value> that) const {
- i::Handle<i::Object> obj = Utils::OpenHandle(this);
- i::Handle<i::Object> other = Utils::OpenHandle(*that);
- if (obj->IsSmi()) {
- return other->IsNumber() && obj->Number() == other->Number();
- }
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
- LOG_API(isolate, "StrictEquals");
- // Must check HeapNumber first, since NaN !== NaN.
- if (obj->IsHeapNumber()) {
- if (!other->IsNumber()) return false;
- double x = obj->Number();
- double y = other->Number();
- // Must check explicitly for NaN:s on Windows, but -0 works fine.
- return x == y && !std::isnan(x) && !std::isnan(y);
- } else if (*obj == *other) { // Also covers Booleans.
- return true;
- } else if (obj->IsSmi()) {
- return other->IsNumber() && obj->Number() == other->Number();
- } else if (obj->IsString()) {
- return other->IsString() &&
- i::String::Equals(i::Handle<i::String>::cast(obj),
- i::Handle<i::String>::cast(other));
- } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
- return other->IsUndefined() || other->IsUndetectableObject();
Yang 2015/08/17 07:13:32 This undetectable check is lost. I guess this is i
Benedikt Meurer 2015/08/17 07:59:49 Yes. The code stub has an explicit comment that st
- } else {
- return false;
- }
+ auto self = Utils::OpenHandle(this);
+ auto other = Utils::OpenHandle(*that);
+ return self->StrictEquals(*other);
}
« no previous file with comments | « no previous file | src/arm/code-stubs-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698