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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 1881413002: [turbofan] Use StringAddStub if either input to JSAdd is a string. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index 7e1a0dc24e7b0c91195e710b98f8b670fd4679da..bde4af1f03ad4672aa0fe1f3e6335cecb3f7f5b5 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -371,10 +371,17 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
r.ConvertInputsToNumber(frame_state);
return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number());
}
- if (r.BothInputsAre(Type::String())) {
- // JSAdd(x:string, y:string) => CallStub[StringAdd](x, y)
+ if (r.OneInputIs(Type::String())) {
+ StringAddFlags flags = STRING_ADD_CHECK_NONE;
+ if (!r.LeftInputIs(Type::String())) {
+ flags = STRING_ADD_CONVERT_LEFT;
+ } else if (!r.RightInputIs(Type::String())) {
+ flags = STRING_ADD_CONVERT_RIGHT;
+ }
+ // JSAdd(x:string, y) => CallStub[StringAdd](x, y)
+ // JSAdd(x, y:string) => CallStub[StringAdd](x, y)
Callable const callable =
- CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED);
+ CodeFactory::StringAdd(isolate(), flags, NOT_TENURED);
CallDescriptor const* const desc = Linkage::GetStubCallDescriptor(
isolate(), graph()->zone(), callable.descriptor(), 0,
CallDescriptor::kNeedsFrameState, node->op()->properties());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698