Commit e933b091 authored by bmeurer's avatar bmeurer Committed by Commit bot

[runtime] Refactor Object::Equals to make exception cases explicit.

R=littledan@chromium.org
BUG=v8:3593
LOG=n

Review URL: https://codereview.chromium.org/1407233013

Cr-Commit-Position: refs/heads/master@{#31642}
parent 7736f474
...@@ -291,9 +291,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { ...@@ -291,9 +291,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) {
} else if (y->IsString()) { } else if (y->IsString()) {
return Just(NumberEquals(x, String::ToNumber(Handle<String>::cast(y)))); return Just(NumberEquals(x, String::ToNumber(Handle<String>::cast(y))));
} else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) {
if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) { if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
continue; .ToHandle(&y)) {
} else {
return Nothing<bool>(); return Nothing<bool>();
} }
} else { } else {
...@@ -310,9 +309,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { ...@@ -310,9 +309,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) {
x = String::ToNumber(Handle<String>::cast(x)); x = String::ToNumber(Handle<String>::cast(x));
return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number())); return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number()));
} else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) {
if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) { if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
continue; .ToHandle(&y)) {
} else {
return Nothing<bool>(); return Nothing<bool>();
} }
} else { } else {
...@@ -332,7 +330,6 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { ...@@ -332,7 +330,6 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) {
return Nothing<bool>(); return Nothing<bool>();
} }
x = Oddball::ToNumber(Handle<Oddball>::cast(x)); x = Oddball::ToNumber(Handle<Oddball>::cast(x));
continue;
} else { } else {
return Just(false); return Just(false);
} }
...@@ -340,9 +337,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { ...@@ -340,9 +337,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) {
if (y->IsSymbol()) { if (y->IsSymbol()) {
return Just(x.is_identical_to(y)); return Just(x.is_identical_to(y));
} else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) {
if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) { if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
continue; .ToHandle(&y)) {
} else {
return Nothing<bool>(); return Nothing<bool>();
} }
} else { } else {
...@@ -353,9 +349,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { ...@@ -353,9 +349,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) {
return Just(Simd128Value::Equals(Handle<Simd128Value>::cast(x), return Just(Simd128Value::Equals(Handle<Simd128Value>::cast(x),
Handle<Simd128Value>::cast(y))); Handle<Simd128Value>::cast(y)));
} else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) {
if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) { if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
continue; .ToHandle(&y)) {
} else {
return Nothing<bool>(); return Nothing<bool>();
} }
} else { } else {
...@@ -368,11 +363,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { ...@@ -368,11 +363,8 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) {
return Just(false); return Just(false);
} else if (y->IsBoolean()) { } else if (y->IsBoolean()) {
y = Oddball::ToNumber(Handle<Oddball>::cast(y)); y = Oddball::ToNumber(Handle<Oddball>::cast(y));
continue; } else if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x))
} else if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x)) .ToHandle(&x)) {
.ToHandle(&x)) {
continue;
} else {
return Nothing<bool>(); return Nothing<bool>();
} }
} else { } else {
...@@ -380,7 +372,6 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { ...@@ -380,7 +372,6 @@ Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) {
(x->IsNull() || x->IsUndefined() || x->IsUndetectableObject()) && (x->IsNull() || x->IsUndefined() || x->IsUndetectableObject()) &&
(y->IsNull() || y->IsUndefined() || y->IsUndetectableObject())); (y->IsNull() || y->IsUndefined() || y->IsUndetectableObject()));
} }
UNREACHABLE();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment