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

Unified Diff: src/compiler/simplified-lowering.cc

Issue 2202883005: [turbofan] Unify number operation typing rules. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove useless cementation. DCHECKs instead of defensive programming are way more useful. Created 4 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 | « src/compiler/operation-typer.cc ('k') | src/compiler/typer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index 2c1d596b283925552b11d69dc2cba5eea6392f85..bf002fa5224ac05476f13470576c5f01f57c1494 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -358,85 +358,38 @@ class RepresentationSelector {
}
switch (node->opcode()) {
- case IrOpcode::kNumberAdd:
- case IrOpcode::kSpeculativeNumberAdd: {
- // TODO(jarin) The ToNumber conversion is too conservative here,
- // e.g. it will treat true as 1 even though the number check will
- // fail on a boolean. OperationTyper should have a function that
- // computes a more precise type.
- Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0)));
- Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1)));
- Type* computed_type = op_typer_.NumberAdd(lhs, rhs);
- new_type = Type::Intersect(computed_type, info->restriction_type(),
- graph_zone());
- break;
- }
-
- case IrOpcode::kNumberSubtract:
- case IrOpcode::kSpeculativeNumberSubtract: {
- // TODO(jarin) The ToNumber conversion is too conservative here,
- // e.g. it will treat true as 1 even though the number check will
- // fail on a boolean. OperationTyper should have a function that
- // computes a more precise type.
- Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0)));
- Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1)));
- Type* computed_type = op_typer_.NumberSubtract(lhs, rhs);
- new_type = Type::Intersect(computed_type, info->restriction_type(),
- graph_zone());
- break;
- }
-
- case IrOpcode::kNumberMultiply:
- case IrOpcode::kSpeculativeNumberMultiply: {
- // TODO(jarin) The ToNumber conversion is too conservative here,
- // e.g. it will treat true as 1 even though the number check will
- // fail on a boolean. OperationTyper should have a function that
- // computes a more precise type.
- Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0)));
- Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1)));
- Type* computed_type = op_typer_.NumberMultiply(lhs, rhs);
- new_type = Type::Intersect(computed_type, info->restriction_type(),
- graph_zone());
- break;
- }
-
- case IrOpcode::kNumberDivide:
- case IrOpcode::kSpeculativeNumberDivide: {
- // TODO(jarin) The ToNumber conversion is too conservative here,
- // e.g. it will treat true as 1 even though the number check will
- // fail on a boolean. OperationTyper should have a function that
- // computes a more precise type.
- Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0)));
- Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1)));
- Type* computed_type = op_typer_.NumberDivide(lhs, rhs);
- new_type = Type::Intersect(computed_type, info->restriction_type(),
- graph_zone());
- break;
- }
-
- case IrOpcode::kNumberModulus:
- case IrOpcode::kSpeculativeNumberModulus: {
- // TODO(jarin) The ToNumber conversion is too conservative here,
- // e.g. it will treat true as 1 even though the number check will
- // fail on a boolean. OperationTyper should have a function that
- // computes a more precise type.
- Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0)));
- Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1)));
- Type* computed_type = op_typer_.NumberModulus(lhs, rhs);
- new_type = Type::Intersect(computed_type, info->restriction_type(),
- graph_zone());
- break;
- }
+#define DECLARE_CASE(Name) \
+ case IrOpcode::k##Name: { \
+ new_type = op_typer_.Name(FeedbackTypeOf(node->InputAt(0)), \
+ FeedbackTypeOf(node->InputAt(1))); \
+ break; \
+ }
+ SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_CASE)
+#undef DECLARE_CASE
+
+#define DECLARE_CASE(Name) \
+ case IrOpcode::k##Name: { \
+ new_type = \
+ Type::Intersect(op_typer_.Name(FeedbackTypeOf(node->InputAt(0)), \
+ FeedbackTypeOf(node->InputAt(1))), \
+ info->restriction_type(), graph_zone()); \
+ break; \
+ }
+ SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_CASE)
+#undef DECLARE_CASE
+
+#define DECLARE_CASE(Name) \
+ case IrOpcode::k##Name: { \
+ new_type = op_typer_.Name(FeedbackTypeOf(node->InputAt(0))); \
+ break; \
+ }
+ SIMPLIFIED_NUMBER_UNOP_LIST(DECLARE_CASE)
+#undef DECLARE_CASE
case IrOpcode::kPlainPrimitiveToNumber:
new_type = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0)));
break;
- case IrOpcode::kNumberAbs: {
- new_type = op_typer_.NumberAbs(FeedbackTypeOf(node->InputAt(0)));
- break;
- }
-
case IrOpcode::kPhi: {
new_type = TypePhi(node);
if (type != nullptr) {
« no previous file with comments | « src/compiler/operation-typer.cc ('k') | src/compiler/typer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698