Reviewers: jarin,
Description:
[turbofan] Enable typed lowering of string addition.
Unfortunately StringAdd is not pure in V8 because we might throw an
exception if the resulting string length is outside the valid bounds, so
there's no point in having a simplified StringAdd operator.
[email protected]
Please review this at https://codereview.chromium.org/1164743002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+18, -51 lines):
M src/compiler/js-typed-lowering.h
M src/compiler/js-typed-lowering.cc
M src/compiler/opcodes.h
M src/compiler/simplified-lowering.h
M src/compiler/simplified-lowering.cc
M src/compiler/simplified-operator.h
M src/compiler/simplified-operator.cc
M src/compiler/typer.cc
M src/compiler/verifier.cc
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc
b/src/compiler/js-typed-lowering.cc
index
61f23ca82ac7c7b897f841b3622886472f8f94f8..4a4bcbfd6516c8d4c992afc4b84544d530e83f87
100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -370,20 +370,20 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
r.ConvertInputsToNumber(frame_state);
return r.ChangeToPureOperator(simplified()->NumberAdd(),
Type::Number());
}
-#if 0
- // TODO(turbofan): Lowering of StringAdd is disabled for now because:
- // a) The inserted ToString operation screws up valueOf vs. toString
order.
- // b) Deoptimization at ToString doesn't have corresponding bailout id.
- // c) Our current StringAddStub is actually non-pure and requires
context.
- if ((r.OneInputIs(Type::String()) && !r.IsStrong()) ||
- r.BothInputsAre(Type::String())) {
- // JSAdd(x:string, y:string) => StringAdd(x, y)
- // JSAdd(x:string, y) => StringAdd(x, ToString(y))
- // JSAdd(x, y:string) => StringAdd(ToString(x), y)
- r.ConvertInputsToString();
- return r.ChangeToPureOperator(simplified()->StringAdd());
- }
-#endif
+ if (r.BothInputsAre(Type::String())) {
+ // JSAdd(x:string, y:string) => CallStub[StringAdd](x, y)
+ Callable const callable =
+ CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE,
NOT_TENURED);
+ CallDescriptor const* const desc = Linkage::GetStubCallDescriptor(
+ isolate(), graph()->zone(), callable.descriptor(), 0,
+ CallDescriptor::kNeedsFrameState, node->op()->properties());
+ DCHECK_EQ(2, OperatorProperties::GetFrameStateInputCount(node->op()));
+ node->RemoveInput(NodeProperties::FirstFrameStateIndex(node) + 1);
+ node->InsertInput(graph()->zone(), 0,
+ jsgraph()->HeapConstant(callable.code()));
+ node->set_op(common()->Call(desc));
+ return Changed(node);
+ }
return NoChange();
}
@@ -1467,6 +1467,9 @@ Factory* JSTypedLowering::factory() const { return
jsgraph()->factory(); }
Graph* JSTypedLowering::graph() const { return jsgraph()->graph(); }
+Isolate* JSTypedLowering::isolate() const { return jsgraph()->isolate(); }
+
+
JSOperatorBuilder* JSTypedLowering::javascript() const {
return jsgraph()->javascript();
}
Index: src/compiler/js-typed-lowering.h
diff --git a/src/compiler/js-typed-lowering.h
b/src/compiler/js-typed-lowering.h
index
64931e1a0105774566749e0506e192ba2af25715..add45ce216a06da29f6419c04cfbe913d4c8e91b
100644
--- a/src/compiler/js-typed-lowering.h
+++ b/src/compiler/js-typed-lowering.h
@@ -72,6 +72,7 @@ class JSTypedLowering final : public AdvancedReducer {
Factory* factory() const;
Graph* graph() const;
JSGraph* jsgraph() const { return jsgraph_; }
+ Isolate* isolate() const;
JSOperatorBuilder* javascript() const;
CommonOperatorBuilder* common() const;
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
Index: src/compiler/opcodes.h
diff --git a/src/compiler/opcodes.h b/src/compiler/opcodes.h
index
4a1e85f2acb792d45eb46229b9013bc42942d048..d38f24d5d055236e3b0a6fb44a59cae8ad32fbdf
100644
--- a/src/compiler/opcodes.h
+++ b/src/compiler/opcodes.h
@@ -172,7 +172,6 @@
V(NumberToInt32) \
V(NumberToUint32) \
V(PlainPrimitiveToNumber) \
- V(StringAdd) \
V(ChangeTaggedToInt32) \
V(ChangeTaggedToUint32) \
V(ChangeTaggedToFloat64) \
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc
b/src/compiler/simplified-lowering.cc
index
929f8fdc405e2ba7fb45680d335cd2c7257cc43e..64f7e2249d4099a98414fa1a4c47a0fb5d62ed7b
100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -782,11 +782,6 @@ class RepresentationSelector {
if (lower()) lowering->DoStringLessThanOrEqual(node);
break;
}
- case IrOpcode::kStringAdd: {
- VisitBinop(node, kMachAnyTagged, kMachAnyTagged);
- if (lower()) lowering->DoStringAdd(node);
- break;
- }
case IrOpcode::kAllocate: {
ProcessInput(node, 0, kMachAnyTagged);
ProcessRemainingInputs(node, 1);
@@ -1313,23 +1308,6 @@ void SimplifiedLowering::DoStoreElement(Node* node) {
}
-void SimplifiedLowering::DoStringAdd(Node* node) {
- Operator::Properties properties = node->op()->properties();
- Callable callable = CodeFactory::StringAdd(
- jsgraph()->isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED);
- CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
- CallDescriptor* desc = Linkage::GetStubCallDescriptor(
- jsgraph()->isolate(), zone(), callable.descriptor(), 0, flags,
- properties);
- node->set_op(common()->Call(desc));
- node->InsertInput(graph()->zone(), 0,
- jsgraph()->HeapConstant(callable.code()));
- node->AppendInput(graph()->zone(), jsgraph()->UndefinedConstant());
- node->AppendInput(graph()->zone(), graph()->start());
- node->AppendInput(graph()->zone(), graph()->start());
-}
-
-
Node* SimplifiedLowering::StringComparison(Node* node, bool
requires_ordering) {
Runtime::FunctionId f =
requires_ordering ? Runtime::kStringCompareRT :
Runtime::kStringEquals;
Index: src/compiler/simplified-lowering.h
diff --git a/src/compiler/simplified-lowering.h
b/src/compiler/simplified-lowering.h
index
124090efb5d0b6c8d022c25e3db5f67cbf7b639f..d6e17e778fe72dca567061a956c55f92f4d6ed3f
100644
--- a/src/compiler/simplified-lowering.h
+++ b/src/compiler/simplified-lowering.h
@@ -38,7 +38,6 @@ class SimplifiedLowering final {
void DoStoreBuffer(Node* node);
void DoLoadElement(Node* node);
void DoStoreElement(Node* node);
- void DoStringAdd(Node* node);
void DoStringEqual(Node* node);
void DoStringLessThan(Node* node);
void DoStringLessThanOrEqual(Node* node);
Index: src/compiler/simplified-operator.cc
diff --git a/src/compiler/simplified-operator.cc
b/src/compiler/simplified-operator.cc
index
9b34668d5c4e43466364237260116646d75ef4ff..33cedd0eb59b3b28ac7ec7591bd02725ba025d9e
100644
--- a/src/compiler/simplified-operator.cc
+++ b/src/compiler/simplified-operator.cc
@@ -174,7 +174,6 @@ const ElementAccess& ElementAccessOf(const Operator*
op) {
V(StringEqual, Operator::kCommutative, 2) \
V(StringLessThan, Operator::kNoProperties, 2) \
V(StringLessThanOrEqual, Operator::kNoProperties, 2) \
- V(StringAdd, Operator::kNoProperties, 2) \
V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \
V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \
V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \
Index: src/compiler/simplified-operator.h
diff --git a/src/compiler/simplified-operator.h
b/src/compiler/simplified-operator.h
index
484b39b18c7b7c71cd06005b0287139671d08384..8f271f63ed0a0294c84d433bd3da6c55bf1abfd4
100644
--- a/src/compiler/simplified-operator.h
+++ b/src/compiler/simplified-operator.h
@@ -149,7 +149,6 @@ class SimplifiedOperatorBuilder final {
const Operator* StringEqual();
const Operator* StringLessThan();
const Operator* StringLessThanOrEqual();
- const Operator* StringAdd();
const Operator* ChangeTaggedToInt32();
const Operator* ChangeTaggedToUint32();
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index
83d444ccfdf8c22af9f4fe17554bbf50e7eab7a2..f0835e7e552ccceda27a7046a06834f0f4563457
100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -1729,11 +1729,6 @@ Bounds
Typer::Visitor::TypeStringLessThanOrEqual(Node* node) {
}
-Bounds Typer::Visitor::TypeStringAdd(Node* node) {
- return Bounds(Type::None(zone()), Type::String(zone()));
-}
-
-
namespace {
Type* ChangeRepresentation(Type* type, Type* rep, Zone* zone) {
Index: src/compiler/verifier.cc
diff --git a/src/compiler/verifier.cc b/src/compiler/verifier.cc
index
4e8c23a2873a788666d87b118e53216458636a10..6424fa6334bd3e7f212cb64b162e8da34bf37266
100644
--- a/src/compiler/verifier.cc
+++ b/src/compiler/verifier.cc
@@ -644,12 +644,6 @@ void Verifier::Visitor::Check(Node* node) {
CheckValueInputIs(node, 1, Type::String());
CheckUpperIs(node, Type::Boolean());
break;
- case IrOpcode::kStringAdd:
- // (String, String) -> String
- CheckValueInputIs(node, 0, Type::String());
- CheckValueInputIs(node, 1, Type::String());
- CheckUpperIs(node, Type::String());
- break;
case IrOpcode::kReferenceEqual: {
// (Unique, Any) -> Boolean and
// (Any, Unique) -> Boolean
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.