From eaef361791a827df365292b14c271d861dc76d39 Mon Sep 17 00:00:00 2001 From: bmeurer Date: Fri, 18 Sep 2015 03:18:41 -0700 Subject: [PATCH] [turbofan] Use StringCompareStub for string comparisons. R=jarin@chromium.org Review URL: https://codereview.chromium.org/1353103002 Cr-Commit-Position: refs/heads/master@{#30821} --- src/compiler/simplified-lowering.cc | 31 +++++++++++++------------------ src/compiler/simplified-lowering.h | 3 ++- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc index 1b2a944..3f4b5b2 100644 --- a/src/compiler/simplified-lowering.cc +++ b/src/compiler/simplified-lowering.cc @@ -1344,21 +1344,16 @@ void SimplifiedLowering::DoStoreElement(Node* node) { } -Node* SimplifiedLowering::StringComparison(Node* node, bool requires_ordering) { - Runtime::FunctionId f = - requires_ordering ? Runtime::kStringCompare : Runtime::kStringEquals; - ExternalReference ref(f, jsgraph()->isolate()); - Operator::Properties props = node->op()->properties(); - // TODO(mstarzinger): We should call StringCompareStub here instead, once an - // interface descriptor is available for it. - CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(zone(), f, 2, props); - return graph()->NewNode(common()->Call(desc), - jsgraph()->CEntryStubConstant(1), - NodeProperties::GetValueInput(node, 0), - NodeProperties::GetValueInput(node, 1), - jsgraph()->ExternalConstant(ref), - jsgraph()->Int32Constant(2), - jsgraph()->NoContextConstant()); +Node* SimplifiedLowering::StringComparison(Node* node) { + Operator::Properties properties = node->op()->properties(); + Callable callable = CodeFactory::StringCompare(isolate()); + CallDescriptor::Flags flags = CallDescriptor::kNoFlags; + CallDescriptor* desc = Linkage::GetStubCallDescriptor( + isolate(), zone(), callable.descriptor(), 0, flags, properties); + return graph()->NewNode( + common()->Call(desc), jsgraph()->HeapConstant(callable.code()), + NodeProperties::GetValueInput(node, 0), + NodeProperties::GetValueInput(node, 1), jsgraph()->NoContextConstant()); } @@ -1624,21 +1619,21 @@ void SimplifiedLowering::DoShift(Node* node, Operator const* op) { void SimplifiedLowering::DoStringEqual(Node* node) { node->set_op(machine()->WordEqual()); - node->ReplaceInput(0, StringComparison(node, false)); + node->ReplaceInput(0, StringComparison(node)); node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); } void SimplifiedLowering::DoStringLessThan(Node* node) { node->set_op(machine()->IntLessThan()); - node->ReplaceInput(0, StringComparison(node, true)); + node->ReplaceInput(0, StringComparison(node)); node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); } void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { node->set_op(machine()->IntLessThanOrEqual()); - node->ReplaceInput(0, StringComparison(node, true)); + node->ReplaceInput(0, StringComparison(node)); node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); } diff --git a/src/compiler/simplified-lowering.h b/src/compiler/simplified-lowering.h index 302908d..4b9e86b 100644 --- a/src/compiler/simplified-lowering.h +++ b/src/compiler/simplified-lowering.h @@ -59,7 +59,7 @@ class SimplifiedLowering final { Node* Untag(Node* node); Node* OffsetMinusTagConstant(int32_t offset); Node* ComputeIndex(const ElementAccess& access, Node* const key); - Node* StringComparison(Node* node, bool requires_ordering); + Node* StringComparison(Node* node); Node* Int32Div(Node* const node); Node* Int32Mod(Node* const node); Node* Uint32Div(Node* const node); @@ -67,6 +67,7 @@ class SimplifiedLowering final { friend class RepresentationSelector; + Isolate* isolate() { return jsgraph_->isolate(); } Zone* zone() { return jsgraph_->zone(); } JSGraph* jsgraph() { return jsgraph_; } Graph* graph() { return jsgraph()->graph(); } -- 2.7.4