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

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

Issue 2064953004: [turbofan] Unify the PlainPrimitive as Number treatment. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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/representation-change.cc ('k') | src/compiler/simplified-operator.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 26c399be80e060bb08b892d2dfd7030ebe8e170e..a5dbad2750171f8b7615694d9597c4a4dfef0463 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -611,16 +611,17 @@ class RepresentationSelector {
Type* GetUpperBound(Node* node) { return NodeProperties::GetType(node); }
+ bool InputIs(Node* node, Type* type) {
+ DCHECK_EQ(1, node->InputCount());
+ return GetUpperBound(node->InputAt(0))->Is(type);
+ }
+
bool BothInputsAreSigned32(Node* node) {
- DCHECK_EQ(2, node->InputCount());
- return GetUpperBound(node->InputAt(0))->Is(Type::Signed32()) &&
- GetUpperBound(node->InputAt(1))->Is(Type::Signed32());
+ return BothInputsAre(node, Type::Signed32());
}
bool BothInputsAreUnsigned32(Node* node) {
- DCHECK_EQ(2, node->InputCount());
- return GetUpperBound(node->InputAt(0))->Is(Type::Unsigned32()) &&
- GetUpperBound(node->InputAt(1))->Is(Type::Unsigned32());
+ return BothInputsAre(node, Type::Unsigned32());
}
bool BothInputsAre(Node* node, Type* type) {
@@ -1393,6 +1394,12 @@ class RepresentationSelector {
if (lower()) DeferReplacement(node, lowering->Float64Floor(node));
return;
}
+ case IrOpcode::kNumberFround: {
+ VisitUnop(node, UseInfo::TruncatingFloat64(),
+ MachineRepresentation::kFloat32);
+ if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
+ return;
+ }
case IrOpcode::kNumberAtan2: {
VisitBinop(node, UseInfo::TruncatingFloat64(),
MachineRepresentation::kFloat64);
@@ -1413,6 +1420,12 @@ class RepresentationSelector {
if (lower()) DeferReplacement(node, lowering->Float64Round(node));
return;
}
+ case IrOpcode::kNumberSqrt: {
+ VisitUnop(node, UseInfo::TruncatingFloat64(),
+ MachineRepresentation::kFloat64);
+ if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
+ return;
+ }
case IrOpcode::kNumberTrunc: {
VisitUnop(node, UseInfo::TruncatingFloat64(),
MachineRepresentation::kFloat64);
@@ -1683,21 +1696,36 @@ class RepresentationSelector {
return;
}
case IrOpcode::kPlainPrimitiveToNumber:
- ProcessInput(node, 0, UseInfo::AnyTagged());
if (truncation.TruncatesToWord32()) {
- SetOutput(node, MachineRepresentation::kWord32);
- if (lower()) {
- NodeProperties::ChangeOp(node,
- simplified()->PlainPrimitiveToWord32());
+ // TODO(jarin): Extend this to Number \/ Oddball
+ if (InputIs(node, Type::NumberOrUndefined())) {
+ VisitUnop(node, UseInfo::TruncatingWord32(),
+ MachineRepresentation::kWord32);
+ if (lower()) DeferReplacement(node, node->InputAt(0));
+ } else {
+ VisitUnop(node, UseInfo::AnyTagged(),
+ MachineRepresentation::kWord32);
+ if (lower()) {
+ NodeProperties::ChangeOp(node,
+ simplified()->PlainPrimitiveToWord32());
+ }
}
} else if (truncation.TruncatesToFloat64()) {
- SetOutput(node, MachineRepresentation::kFloat64);
- if (lower()) {
- NodeProperties::ChangeOp(node,
- simplified()->PlainPrimitiveToFloat64());
+ // TODO(jarin): Extend this to Number \/ Oddball
+ if (InputIs(node, Type::NumberOrUndefined())) {
+ VisitUnop(node, UseInfo::TruncatingFloat64(),
+ MachineRepresentation::kFloat64);
+ if (lower()) DeferReplacement(node, node->InputAt(0));
+ } else {
+ VisitUnop(node, UseInfo::AnyTagged(),
+ MachineRepresentation::kFloat64);
+ if (lower()) {
+ NodeProperties::ChangeOp(node,
+ simplified()->PlainPrimitiveToFloat64());
+ }
}
} else {
- SetOutput(node, MachineRepresentation::kTagged);
+ VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
}
return;
case IrOpcode::kObjectIsCallable:
« no previous file with comments | « src/compiler/representation-change.cc ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698