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

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

Issue 2139183002: [turbofan] Unify BooleanToNumber, StringToNumber and PlainPrimitiveToNumber. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/simplified-lowering.h ('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 d1f6c8743bbe466d850ca74493daaa6f8b09f425..7119d94d6f4355407db142167eb5b02402bce39e 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -1245,24 +1245,6 @@ class RepresentationSelector {
}
return;
}
- case IrOpcode::kBooleanToNumber: {
- if (lower()) {
- NodeInfo* input_info = GetInfo(node->InputAt(0));
- if (input_info->representation() == MachineRepresentation::kBit) {
- // BooleanToNumber(x: kRepBit) => x
- DeferReplacement(node, node->InputAt(0));
- } else {
- // BooleanToNumber(x: kRepTagged) => WordEqual(x, #true)
- node->AppendInput(jsgraph_->zone(), jsgraph_->TrueConstant());
- NodeProperties::ChangeOp(node, lowering->machine()->WordEqual());
- }
- } else {
- // No input representation requirement; adapt during lowering.
- ProcessInput(node, 0, UseInfo::AnyTruncatingToBool());
- SetOutput(node, MachineRepresentation::kWord32);
- }
- return;
- }
case IrOpcode::kNumberEqual:
case IrOpcode::kNumberLessThan:
case IrOpcode::kNumberLessThanOrEqual: {
@@ -1790,24 +1772,6 @@ class RepresentationSelector {
MachineRepresentation::kTagged);
return;
}
- case IrOpcode::kStringToNumber: {
- VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
- if (lower()) {
- // StringToNumber(x) => Call(StringToNumber, x, no-context)
- Operator::Properties properties = Operator::kEliminatable;
- Callable callable = CodeFactory::StringToNumber(jsgraph_->isolate());
- CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
- CallDescriptor* desc = Linkage::GetStubCallDescriptor(
- jsgraph_->isolate(), jsgraph_->zone(), callable.descriptor(), 0,
- flags, properties);
- node->InsertInput(jsgraph_->zone(), 0,
- jsgraph_->HeapConstant(callable.code()));
- node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant());
- node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start());
- NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
- }
- return;
- }
case IrOpcode::kCheckBounds: {
if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32())) {
@@ -1995,8 +1959,14 @@ class RepresentationSelector {
}
return;
}
- case IrOpcode::kPlainPrimitiveToNumber:
- if (truncation.TruncatesToWord32()) {
+ case IrOpcode::kPlainPrimitiveToNumber: {
+ if (InputIs(node, Type::Boolean())) {
+ VisitUnop(node, UseInfo::Bool(), MachineRepresentation::kWord32);
+ if (lower()) DeferReplacement(node, node->InputAt(0));
+ } else if (InputIs(node, Type::String())) {
+ VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
+ if (lower()) lowering->DoStringToNumber(node);
+ } else if (truncation.TruncatesToWord32()) {
// TODO(jarin): Extend this to Number \/ Oddball
if (InputIs(node, Type::NumberOrUndefined())) {
VisitUnop(node, UseInfo::TruncatingWord32(),
@@ -2028,6 +1998,7 @@ class RepresentationSelector {
VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
}
return;
+ }
case IrOpcode::kObjectIsCallable:
case IrOpcode::kObjectIsNumber:
case IrOpcode::kObjectIsReceiver:
@@ -3270,6 +3241,19 @@ void SimplifiedLowering::DoShift(Node* node, Operator const* op,
NodeProperties::ChangeOp(node, op);
}
+void SimplifiedLowering::DoStringToNumber(Node* node) {
+ Operator::Properties properties = Operator::kEliminatable;
+ Callable callable = CodeFactory::StringToNumber(isolate());
+ CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
+ CallDescriptor* desc = Linkage::GetStubCallDescriptor(
+ isolate(), graph()->zone(), callable.descriptor(), 0, flags, properties);
+ node->InsertInput(graph()->zone(), 0,
+ jsgraph()->HeapConstant(callable.code()));
+ node->AppendInput(graph()->zone(), jsgraph()->NoContextConstant());
+ node->AppendInput(graph()->zone(), graph()->start());
+ NodeProperties::ChangeOp(node, common()->Call(desc));
+}
+
Node* SimplifiedLowering::ToNumberCode() {
if (!to_number_code_.is_set()) {
Callable callable = CodeFactory::ToNumber(isolate());
« no previous file with comments | « src/compiler/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698