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

Unified Diff: src/objects.cc

Issue 1693833002: Remove strong mode support from binary operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 4 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
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 680abc36ab24be64b8829aeba96155b647f98541..7f4a69c32175d9ddc4f4f488d0cf56ff27e0d2c6 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -262,14 +262,11 @@ bool NumberEquals(Handle<Object> x, Handle<Object> y) {
// static
-Maybe<ComparisonResult> Object::Compare(Handle<Object> x, Handle<Object> y,
- Strength strength) {
- if (!is_strong(strength)) {
- // ES6 section 7.2.11 Abstract Relational Comparison step 3 and 4.
- if (!Object::ToPrimitive(x, ToPrimitiveHint::kNumber).ToHandle(&x) ||
- !Object::ToPrimitive(y, ToPrimitiveHint::kNumber).ToHandle(&y)) {
- return Nothing<ComparisonResult>();
- }
+Maybe<ComparisonResult> Object::Compare(Handle<Object> x, Handle<Object> y) {
+ // ES6 section 7.2.11 Abstract Relational Comparison step 3 and 4.
+ if (!Object::ToPrimitive(x, ToPrimitiveHint::kNumber).ToHandle(&x) ||
+ !Object::ToPrimitive(y, ToPrimitiveHint::kNumber).ToHandle(&y)) {
+ return Nothing<ComparisonResult>();
}
if (x->IsString() && y->IsString()) {
// ES6 section 7.2.11 Abstract Relational Comparison step 5.
@@ -277,23 +274,8 @@ Maybe<ComparisonResult> Object::Compare(Handle<Object> x, Handle<Object> y,
String::Compare(Handle<String>::cast(x), Handle<String>::cast(y)));
}
// ES6 section 7.2.11 Abstract Relational Comparison step 6.
- if (!is_strong(strength)) {
- if (!Object::ToNumber(x).ToHandle(&x) ||
- !Object::ToNumber(y).ToHandle(&y)) {
- return Nothing<ComparisonResult>();
- }
- } else {
- if (!x->IsNumber()) {
- Isolate* const isolate = Handle<HeapObject>::cast(x)->GetIsolate();
- isolate->Throw(*isolate->factory()->NewTypeError(
- MessageTemplate::kStrongImplicitConversion));
- return Nothing<ComparisonResult>();
- } else if (!y->IsNumber()) {
- Isolate* const isolate = Handle<HeapObject>::cast(y)->GetIsolate();
- isolate->Throw(*isolate->factory()->NewTypeError(
- MessageTemplate::kStrongImplicitConversion));
- return Nothing<ComparisonResult>();
- }
+ if (!Object::ToNumber(x).ToHandle(&x) || !Object::ToNumber(y).ToHandle(&y)) {
+ return Nothing<ComparisonResult>();
}
return Just(NumberCompare(x->Number(), y->Number()));
}
@@ -431,13 +413,8 @@ Handle<String> Object::TypeOf(Isolate* isolate, Handle<Object> object) {
// static
MaybeHandle<Object> Object::Multiply(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
@@ -447,13 +424,8 @@ MaybeHandle<Object> Object::Multiply(Isolate* isolate, Handle<Object> lhs,
// static
MaybeHandle<Object> Object::Divide(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
@@ -463,13 +435,8 @@ MaybeHandle<Object> Object::Divide(Isolate* isolate, Handle<Object> lhs,
// static
MaybeHandle<Object> Object::Modulus(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
@@ -479,16 +446,12 @@ MaybeHandle<Object> Object::Modulus(Isolate* isolate, Handle<Object> lhs,
// static
MaybeHandle<Object> Object::Add(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (lhs->IsNumber() && rhs->IsNumber()) {
return isolate->factory()->NewNumber(lhs->Number() + rhs->Number());
} else if (lhs->IsString() && rhs->IsString()) {
return isolate->factory()->NewConsString(Handle<String>::cast(lhs),
Handle<String>::cast(rhs));
- } else if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
}
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToPrimitive(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToPrimitive(rhs), Object);
@@ -508,13 +471,8 @@ MaybeHandle<Object> Object::Add(Isolate* isolate, Handle<Object> lhs,
// static
MaybeHandle<Object> Object::Subtract(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
@@ -524,13 +482,8 @@ MaybeHandle<Object> Object::Subtract(Isolate* isolate, Handle<Object> lhs,
// static
MaybeHandle<Object> Object::ShiftLeft(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
@@ -541,13 +494,8 @@ MaybeHandle<Object> Object::ShiftLeft(Isolate* isolate, Handle<Object> lhs,
// static
MaybeHandle<Object> Object::ShiftRight(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
@@ -559,14 +507,8 @@ MaybeHandle<Object> Object::ShiftRight(Isolate* isolate, Handle<Object> lhs,
// static
MaybeHandle<Object> Object::ShiftRightLogical(Isolate* isolate,
Handle<Object> lhs,
- Handle<Object> rhs,
- Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
@@ -577,13 +519,8 @@ MaybeHandle<Object> Object::ShiftRightLogical(Isolate* isolate,
// static
MaybeHandle<Object> Object::BitwiseAnd(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
@@ -594,13 +531,8 @@ MaybeHandle<Object> Object::BitwiseAnd(Isolate* isolate, Handle<Object> lhs,
// static
MaybeHandle<Object> Object::BitwiseOr(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
@@ -611,13 +543,8 @@ MaybeHandle<Object> Object::BitwiseOr(Isolate* isolate, Handle<Object> lhs,
// static
MaybeHandle<Object> Object::BitwiseXor(Isolate* isolate, Handle<Object> lhs,
- Handle<Object> rhs, Strength strength) {
+ Handle<Object> rhs) {
if (!lhs->IsNumber() || !rhs->IsNumber()) {
- if (is_strong(strength)) {
- THROW_NEW_ERROR(isolate,
- NewTypeError(MessageTemplate::kStrongImplicitConversion),
- Object);
- }
ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
}
« src/crankshaft/hydrogen-instructions.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698