| 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/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 new_type = op_typer_.Name(FeedbackTypeOf(node->InputAt(0))); \ | 451 new_type = op_typer_.Name(FeedbackTypeOf(node->InputAt(0))); \ |
| 452 break; \ | 452 break; \ |
| 453 } | 453 } |
| 454 SIMPLIFIED_NUMBER_UNOP_LIST(DECLARE_CASE) | 454 SIMPLIFIED_NUMBER_UNOP_LIST(DECLARE_CASE) |
| 455 #undef DECLARE_CASE | 455 #undef DECLARE_CASE |
| 456 | 456 |
| 457 case IrOpcode::kPlainPrimitiveToNumber: | 457 case IrOpcode::kPlainPrimitiveToNumber: |
| 458 new_type = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0))); | 458 new_type = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0))); |
| 459 break; | 459 break; |
| 460 | 460 |
| 461 case IrOpcode::kCheckFloat64Hole: |
| 462 new_type = Type::Intersect( |
| 463 op_typer_.CheckFloat64Hole(FeedbackTypeOf(node->InputAt(0))), |
| 464 info->restriction_type(), graph_zone()); |
| 465 break; |
| 466 |
| 467 case IrOpcode::kCheckNumber: |
| 468 new_type = Type::Intersect( |
| 469 op_typer_.CheckNumber(FeedbackTypeOf(node->InputAt(0))), |
| 470 info->restriction_type(), graph_zone()); |
| 471 break; |
| 472 |
| 461 case IrOpcode::kPhi: { | 473 case IrOpcode::kPhi: { |
| 462 new_type = TypePhi(node); | 474 new_type = TypePhi(node); |
| 463 if (type != nullptr) { | 475 if (type != nullptr) { |
| 464 new_type = Weaken(node, type, new_type); | 476 new_type = Weaken(node, type, new_type); |
| 465 } | 477 } |
| 466 break; | 478 break; |
| 467 } | 479 } |
| 468 | 480 |
| 469 case IrOpcode::kTypeGuard: { | 481 case IrOpcode::kTypeGuard: { |
| 470 new_type = op_typer_.TypeTypeGuard(node->op(), | 482 new_type = op_typer_.TypeTypeGuard(node->op(), |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 int value_count = node->op()->ValueInputCount() + | 814 int value_count = node->op()->ValueInputCount() + |
| 803 OperatorProperties::GetContextInputCount(node->op()) + | 815 OperatorProperties::GetContextInputCount(node->op()) + |
| 804 OperatorProperties::GetFrameStateInputCount(node->op()); | 816 OperatorProperties::GetFrameStateInputCount(node->op()); |
| 805 for (int i = 0; i < value_count; i++) { | 817 for (int i = 0; i < value_count; i++) { |
| 806 ProcessInput(node, i, UseInfo::None()); | 818 ProcessInput(node, i, UseInfo::None()); |
| 807 } | 819 } |
| 808 ProcessRemainingInputs(node, value_count); | 820 ProcessRemainingInputs(node, value_count); |
| 809 if (lower()) Kill(node); | 821 if (lower()) Kill(node); |
| 810 } | 822 } |
| 811 | 823 |
| 824 // Helper for no-op node. |
| 825 void VisitNoop(Node* node, Truncation truncation) { |
| 826 if (truncation.IsUnused()) return VisitUnused(node); |
| 827 MachineRepresentation representation = |
| 828 GetOutputInfoForPhi(node, TypeOf(node), truncation); |
| 829 VisitUnop(node, UseInfo(representation, truncation), representation); |
| 830 if (lower()) DeferReplacement(node, node->InputAt(0)); |
| 831 } |
| 832 |
| 812 // Helper for binops of the R x L -> O variety. | 833 // Helper for binops of the R x L -> O variety. |
| 813 void VisitBinop(Node* node, UseInfo left_use, UseInfo right_use, | 834 void VisitBinop(Node* node, UseInfo left_use, UseInfo right_use, |
| 814 MachineRepresentation output, | 835 MachineRepresentation output, |
| 815 Type* restriction_type = Type::Any()) { | 836 Type* restriction_type = Type::Any()) { |
| 816 DCHECK_EQ(2, node->op()->ValueInputCount()); | 837 DCHECK_EQ(2, node->op()->ValueInputCount()); |
| 817 ProcessInput(node, 0, left_use); | 838 ProcessInput(node, 0, left_use); |
| 818 ProcessInput(node, 1, right_use); | 839 ProcessInput(node, 1, right_use); |
| 819 for (int i = 2; i < node->InputCount(); i++) { | 840 for (int i = 2; i < node->InputCount(); i++) { |
| 820 EnqueueInput(node, i); | 841 EnqueueInput(node, i); |
| 821 } | 842 } |
| (...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2308 VisitUnop(node, UseInfo::AnyTagged(), | 2329 VisitUnop(node, UseInfo::AnyTagged(), |
| 2309 MachineRepresentation::kTaggedPointer); | 2330 MachineRepresentation::kTaggedPointer); |
| 2310 if (lower()) DeferReplacement(node, node->InputAt(0)); | 2331 if (lower()) DeferReplacement(node, node->InputAt(0)); |
| 2311 } else { | 2332 } else { |
| 2312 VisitUnop(node, UseInfo::CheckedHeapObjectAsTaggedPointer(), | 2333 VisitUnop(node, UseInfo::CheckedHeapObjectAsTaggedPointer(), |
| 2313 MachineRepresentation::kTaggedPointer); | 2334 MachineRepresentation::kTaggedPointer); |
| 2314 } | 2335 } |
| 2315 return; | 2336 return; |
| 2316 } | 2337 } |
| 2317 case IrOpcode::kCheckNumber: { | 2338 case IrOpcode::kCheckNumber: { |
| 2318 if (InputIs(node, Type::Number())) { | 2339 Type* const input_type = TypeOf(node->InputAt(0)); |
| 2319 if (truncation.IsUsedAsWord32()) { | 2340 if (input_type->Is(Type::Number())) { |
| 2320 VisitUnop(node, UseInfo::TruncatingWord32(), | 2341 VisitNoop(node, truncation); |
| 2321 MachineRepresentation::kWord32); | |
| 2322 } else { | |
| 2323 // TODO(jarin,bmeurer): We need to go to Tagged here, because | |
| 2324 // otherwise we cannot distinguish the hole NaN (which might need to | |
| 2325 // be treated as undefined). We should have a dedicated Type for | |
| 2326 // that at some point, and maybe even a dedicated truncation. | |
| 2327 VisitUnop(node, UseInfo::AnyTagged(), | |
| 2328 MachineRepresentation::kTagged); | |
| 2329 } | |
| 2330 if (lower()) DeferReplacement(node, node->InputAt(0)); | |
| 2331 } else { | 2342 } else { |
| 2332 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); | 2343 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); |
| 2333 } | 2344 } |
| 2334 return; | 2345 return; |
| 2335 } | 2346 } |
| 2336 case IrOpcode::kCheckReceiver: { | 2347 case IrOpcode::kCheckReceiver: { |
| 2337 if (InputIs(node, Type::Receiver())) { | 2348 if (InputIs(node, Type::Receiver())) { |
| 2338 VisitUnop(node, UseInfo::AnyTagged(), | 2349 VisitUnop(node, UseInfo::AnyTagged(), |
| 2339 MachineRepresentation::kTaggedPointer); | 2350 MachineRepresentation::kTaggedPointer); |
| 2340 if (lower()) DeferReplacement(node, node->InputAt(0)); | 2351 if (lower()) DeferReplacement(node, node->InputAt(0)); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2574 case IrOpcode::kNewUnmappedArgumentsElements: { | 2585 case IrOpcode::kNewUnmappedArgumentsElements: { |
| 2575 ProcessRemainingInputs(node, 0); | 2586 ProcessRemainingInputs(node, 0); |
| 2576 SetOutput(node, MachineRepresentation::kTaggedPointer); | 2587 SetOutput(node, MachineRepresentation::kTaggedPointer); |
| 2577 return; | 2588 return; |
| 2578 } | 2589 } |
| 2579 case IrOpcode::kArrayBufferWasNeutered: { | 2590 case IrOpcode::kArrayBufferWasNeutered: { |
| 2580 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit); | 2591 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit); |
| 2581 return; | 2592 return; |
| 2582 } | 2593 } |
| 2583 case IrOpcode::kCheckFloat64Hole: { | 2594 case IrOpcode::kCheckFloat64Hole: { |
| 2584 CheckFloat64HoleMode mode = CheckFloat64HoleModeOf(node->op()); | 2595 Type* const input_type = TypeOf(node->InputAt(0)); |
| 2585 ProcessInput(node, 0, UseInfo::TruncatingFloat64()); | 2596 if (input_type->Is(Type::Number())) { |
| 2586 ProcessRemainingInputs(node, 1); | 2597 VisitNoop(node, truncation); |
| 2587 SetOutput(node, MachineRepresentation::kFloat64); | 2598 } else { |
| 2588 if (truncation.IsUsedAsFloat64() && | 2599 CheckFloat64HoleMode mode = CheckFloat64HoleModeOf(node->op()); |
| 2589 mode == CheckFloat64HoleMode::kAllowReturnHole) { | 2600 switch (mode) { |
| 2590 if (lower()) DeferReplacement(node, node->InputAt(0)); | 2601 case CheckFloat64HoleMode::kAllowReturnHole: |
| 2602 if (truncation.IsUnused()) return VisitUnused(node); |
| 2603 if (truncation.IsUsedAsFloat64()) { |
| 2604 VisitUnop(node, UseInfo::TruncatingFloat64(), |
| 2605 MachineRepresentation::kFloat64); |
| 2606 if (lower()) DeferReplacement(node, node->InputAt(0)); |
| 2607 } else { |
| 2608 VisitUnop( |
| 2609 node, |
| 2610 UseInfo(MachineRepresentation::kFloat64, Truncation::Any()), |
| 2611 MachineRepresentation::kFloat64, Type::Number()); |
| 2612 } |
| 2613 break; |
| 2614 case CheckFloat64HoleMode::kNeverReturnHole: |
| 2615 VisitUnop( |
| 2616 node, |
| 2617 UseInfo(MachineRepresentation::kFloat64, Truncation::Any()), |
| 2618 MachineRepresentation::kFloat64, Type::Number()); |
| 2619 break; |
| 2620 } |
| 2591 } | 2621 } |
| 2592 return; | 2622 return; |
| 2593 } | 2623 } |
| 2594 case IrOpcode::kCheckTaggedHole: { | 2624 case IrOpcode::kCheckTaggedHole: { |
| 2595 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); | 2625 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); |
| 2596 return; | 2626 return; |
| 2597 } | 2627 } |
| 2598 case IrOpcode::kConvertTaggedHoleToUndefined: { | 2628 case IrOpcode::kConvertTaggedHoleToUndefined: { |
| 2599 if (InputIs(node, Type::NumberOrOddball()) && | 2629 if (InputIs(node, Type::NumberOrOddball()) && |
| 2600 truncation.IsUsedAsWord32()) { | 2630 truncation.IsUsedAsWord32()) { |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3532 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3562 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
| 3533 Operator::kNoProperties); | 3563 Operator::kNoProperties); |
| 3534 to_number_operator_.set(common()->Call(desc)); | 3564 to_number_operator_.set(common()->Call(desc)); |
| 3535 } | 3565 } |
| 3536 return to_number_operator_.get(); | 3566 return to_number_operator_.get(); |
| 3537 } | 3567 } |
| 3538 | 3568 |
| 3539 } // namespace compiler | 3569 } // namespace compiler |
| 3540 } // namespace internal | 3570 } // namespace internal |
| 3541 } // namespace v8 | 3571 } // namespace v8 |
| OLD | NEW |