Index: src/compiler/simplified-lowering.cc |
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc |
index d72fc827591350c7b4283b89ee861cb23bb340d8..7e93dc512519788e4bdc87b8392168722421563b 100644 |
--- a/src/compiler/simplified-lowering.cc |
+++ b/src/compiler/simplified-lowering.cc |
@@ -2028,6 +2028,44 @@ class RepresentationSelector { |
if (lower()) DeferReplacement(node, node->InputAt(0)); |
return; |
} |
+ case IrOpcode::kNumberToString: { |
+ Type* const rhs_type = TypeOf(node->InputAt(1)); |
+ VisitBinop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); |
+ if (lower()) { |
+ if (rhs_type->Is(type_cache_.kSingletonTen)) { |
+ // NumberToString(x, #10) => Call(NumberToStringStub, x, no-context) |
+ Operator::Properties properties = Operator::kEliminatable; |
+ Callable callable = |
+ CodeFactory::NumberToString(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->ReplaceInput(2, jsgraph_->NoContextConstant()); |
+ node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start()); |
+ NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc)); |
+ } else { |
+ // NumberToString(x, y) => %NumberToString(x, y, no-context) |
+ Operator::Properties properties = Operator::kEliminatable; |
+ CallDescriptor::Flags flags = CallDescriptor::kNoFlags; |
+ Runtime::FunctionId id = Runtime::kNumberToString; |
+ CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( |
+ jsgraph_->zone(), id, 2, properties, flags); |
+ node->InsertInput(jsgraph_->zone(), 0, |
+ jsgraph_->CEntryStubConstant(1)); |
+ node->AppendInput(jsgraph_->zone(), |
+ jsgraph_->ExternalConstant( |
+ ExternalReference(id, jsgraph_->isolate()))); |
+ node->AppendInput(jsgraph_->zone(), jsgraph_->Int32Constant(2)); |
+ node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant()); |
+ node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start()); |
+ NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc)); |
+ } |
+ } |
+ return; |
+ } |
case IrOpcode::kReferenceEqual: { |
VisitBinop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit); |
if (lower()) { |