| 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/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 if (r.BothInputsAre(Type::Number())) { | 363 if (r.BothInputsAre(Type::Number())) { |
| 364 // JSAdd(x:number, y:number) => NumberAdd(x, y) | 364 // JSAdd(x:number, y:number) => NumberAdd(x, y) |
| 365 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); | 365 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); |
| 366 } | 366 } |
| 367 if (r.NeitherInputCanBe(Type::StringOrReceiver()) && !r.IsStrong()) { | 367 if (r.NeitherInputCanBe(Type::StringOrReceiver()) && !r.IsStrong()) { |
| 368 // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y)) | 368 // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y)) |
| 369 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); | 369 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); |
| 370 r.ConvertInputsToNumber(frame_state); | 370 r.ConvertInputsToNumber(frame_state); |
| 371 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); | 371 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); |
| 372 } | 372 } |
| 373 #if 0 | 373 if (r.BothInputsAre(Type::String())) { |
| 374 // TODO(turbofan): Lowering of StringAdd is disabled for now because: | 374 // JSAdd(x:string, y:string) => CallStub[StringAdd](x, y) |
| 375 // a) The inserted ToString operation screws up valueOf vs. toString order. | 375 Callable const callable = |
| 376 // b) Deoptimization at ToString doesn't have corresponding bailout id. | 376 CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED); |
| 377 // c) Our current StringAddStub is actually non-pure and requires context. | 377 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( |
| 378 if ((r.OneInputIs(Type::String()) && !r.IsStrong()) || | 378 isolate(), graph()->zone(), callable.descriptor(), 0, |
| 379 r.BothInputsAre(Type::String())) { | 379 CallDescriptor::kNeedsFrameState, node->op()->properties()); |
| 380 // JSAdd(x:string, y:string) => StringAdd(x, y) | 380 DCHECK_EQ(2, OperatorProperties::GetFrameStateInputCount(node->op())); |
| 381 // JSAdd(x:string, y) => StringAdd(x, ToString(y)) | 381 node->RemoveInput(NodeProperties::FirstFrameStateIndex(node) + 1); |
| 382 // JSAdd(x, y:string) => StringAdd(ToString(x), y) | 382 node->InsertInput(graph()->zone(), 0, |
| 383 r.ConvertInputsToString(); | 383 jsgraph()->HeapConstant(callable.code())); |
| 384 return r.ChangeToPureOperator(simplified()->StringAdd()); | 384 node->set_op(common()->Call(desc)); |
| 385 return Changed(node); |
| 385 } | 386 } |
| 386 #endif | |
| 387 return NoChange(); | 387 return NoChange(); |
| 388 } | 388 } |
| 389 | 389 |
| 390 | 390 |
| 391 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, | 391 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, |
| 392 const Operator* numberOp) { | 392 const Operator* numberOp) { |
| 393 JSBinopReduction r(this, node); | 393 JSBinopReduction r(this, node); |
| 394 if (r.IsStrong()) { | 394 if (r.IsStrong()) { |
| 395 if (r.BothInputsAre(Type::Number())) { | 395 if (r.BothInputsAre(Type::Number())) { |
| 396 return r.ChangeToPureOperator(numberOp, Type::Number()); | 396 return r.ChangeToPureOperator(numberOp, Type::Number()); |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1460 jsgraph()->Int32Constant(rhs)); | 1460 jsgraph()->Int32Constant(rhs)); |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 | 1463 |
| 1464 Factory* JSTypedLowering::factory() const { return jsgraph()->factory(); } | 1464 Factory* JSTypedLowering::factory() const { return jsgraph()->factory(); } |
| 1465 | 1465 |
| 1466 | 1466 |
| 1467 Graph* JSTypedLowering::graph() const { return jsgraph()->graph(); } | 1467 Graph* JSTypedLowering::graph() const { return jsgraph()->graph(); } |
| 1468 | 1468 |
| 1469 | 1469 |
| 1470 Isolate* JSTypedLowering::isolate() const { return jsgraph()->isolate(); } |
| 1471 |
| 1472 |
| 1470 JSOperatorBuilder* JSTypedLowering::javascript() const { | 1473 JSOperatorBuilder* JSTypedLowering::javascript() const { |
| 1471 return jsgraph()->javascript(); | 1474 return jsgraph()->javascript(); |
| 1472 } | 1475 } |
| 1473 | 1476 |
| 1474 | 1477 |
| 1475 CommonOperatorBuilder* JSTypedLowering::common() const { | 1478 CommonOperatorBuilder* JSTypedLowering::common() const { |
| 1476 return jsgraph()->common(); | 1479 return jsgraph()->common(); |
| 1477 } | 1480 } |
| 1478 | 1481 |
| 1479 | 1482 |
| 1480 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1483 MachineOperatorBuilder* JSTypedLowering::machine() const { |
| 1481 return jsgraph()->machine(); | 1484 return jsgraph()->machine(); |
| 1482 } | 1485 } |
| 1483 | 1486 |
| 1484 } // namespace compiler | 1487 } // namespace compiler |
| 1485 } // namespace internal | 1488 } // namespace internal |
| 1486 } // namespace v8 | 1489 } // namespace v8 |
| OLD | NEW |