OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if (r.BothInputsAre(Type::Number())) { | 364 if (r.BothInputsAre(Type::Number())) { |
365 // JSAdd(x:number, y:number) => NumberAdd(x, y) | 365 // JSAdd(x:number, y:number) => NumberAdd(x, y) |
366 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); | 366 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); |
367 } | 367 } |
368 if (r.NeitherInputCanBe(Type::StringOrReceiver())) { | 368 if (r.NeitherInputCanBe(Type::StringOrReceiver())) { |
369 // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y)) | 369 // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y)) |
370 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); | 370 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); |
371 r.ConvertInputsToNumber(frame_state); | 371 r.ConvertInputsToNumber(frame_state); |
372 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); | 372 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); |
373 } | 373 } |
374 if (r.BothInputsAre(Type::String())) { | 374 if (r.OneInputIs(Type::String())) { |
375 // JSAdd(x:string, y:string) => CallStub[StringAdd](x, y) | 375 StringAddFlags flags = STRING_ADD_CHECK_NONE; |
| 376 if (!r.LeftInputIs(Type::String())) { |
| 377 flags = STRING_ADD_CONVERT_LEFT; |
| 378 } else if (!r.RightInputIs(Type::String())) { |
| 379 flags = STRING_ADD_CONVERT_RIGHT; |
| 380 } |
| 381 // JSAdd(x:string, y) => CallStub[StringAdd](x, y) |
| 382 // JSAdd(x, y:string) => CallStub[StringAdd](x, y) |
376 Callable const callable = | 383 Callable const callable = |
377 CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED); | 384 CodeFactory::StringAdd(isolate(), flags, NOT_TENURED); |
378 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( | 385 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( |
379 isolate(), graph()->zone(), callable.descriptor(), 0, | 386 isolate(), graph()->zone(), callable.descriptor(), 0, |
380 CallDescriptor::kNeedsFrameState, node->op()->properties()); | 387 CallDescriptor::kNeedsFrameState, node->op()->properties()); |
381 DCHECK_EQ(2, OperatorProperties::GetFrameStateInputCount(node->op())); | 388 DCHECK_EQ(2, OperatorProperties::GetFrameStateInputCount(node->op())); |
382 node->RemoveInput(NodeProperties::FirstFrameStateIndex(node) + 1); | 389 node->RemoveInput(NodeProperties::FirstFrameStateIndex(node) + 1); |
383 node->InsertInput(graph()->zone(), 0, | 390 node->InsertInput(graph()->zone(), 0, |
384 jsgraph()->HeapConstant(callable.code())); | 391 jsgraph()->HeapConstant(callable.code())); |
385 NodeProperties::ChangeOp(node, common()->Call(desc)); | 392 NodeProperties::ChangeOp(node, common()->Call(desc)); |
386 return Changed(node); | 393 return Changed(node); |
387 } | 394 } |
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 } | 1814 } |
1808 | 1815 |
1809 | 1816 |
1810 CompilationDependencies* JSTypedLowering::dependencies() const { | 1817 CompilationDependencies* JSTypedLowering::dependencies() const { |
1811 return dependencies_; | 1818 return dependencies_; |
1812 } | 1819 } |
1813 | 1820 |
1814 } // namespace compiler | 1821 } // namespace compiler |
1815 } // namespace internal | 1822 } // namespace internal |
1816 } // namespace v8 | 1823 } // namespace v8 |
OLD | NEW |