| 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 | |
| 473 case IrOpcode::kPhi: { | 461 case IrOpcode::kPhi: { |
| 474 new_type = TypePhi(node); | 462 new_type = TypePhi(node); |
| 475 if (type != nullptr) { | 463 if (type != nullptr) { |
| 476 new_type = Weaken(node, type, new_type); | 464 new_type = Weaken(node, type, new_type); |
| 477 } | 465 } |
| 478 break; | 466 break; |
| 479 } | 467 } |
| 480 | 468 |
| 481 case IrOpcode::kTypeGuard: { | 469 case IrOpcode::kTypeGuard: { |
| 482 new_type = op_typer_.TypeTypeGuard(node->op(), | 470 new_type = op_typer_.TypeTypeGuard(node->op(), |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 int value_count = node->op()->ValueInputCount() + | 802 int value_count = node->op()->ValueInputCount() + |
| 815 OperatorProperties::GetContextInputCount(node->op()) + | 803 OperatorProperties::GetContextInputCount(node->op()) + |
| 816 OperatorProperties::GetFrameStateInputCount(node->op()); | 804 OperatorProperties::GetFrameStateInputCount(node->op()); |
| 817 for (int i = 0; i < value_count; i++) { | 805 for (int i = 0; i < value_count; i++) { |
| 818 ProcessInput(node, i, UseInfo::None()); | 806 ProcessInput(node, i, UseInfo::None()); |
| 819 } | 807 } |
| 820 ProcessRemainingInputs(node, value_count); | 808 ProcessRemainingInputs(node, value_count); |
| 821 if (lower()) Kill(node); | 809 if (lower()) Kill(node); |
| 822 } | 810 } |
| 823 | 811 |
| 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 | |
| 833 // Helper for binops of the R x L -> O variety. | 812 // Helper for binops of the R x L -> O variety. |
| 834 void VisitBinop(Node* node, UseInfo left_use, UseInfo right_use, | 813 void VisitBinop(Node* node, UseInfo left_use, UseInfo right_use, |
| 835 MachineRepresentation output, | 814 MachineRepresentation output, |
| 836 Type* restriction_type = Type::Any()) { | 815 Type* restriction_type = Type::Any()) { |
| 837 DCHECK_EQ(2, node->op()->ValueInputCount()); | 816 DCHECK_EQ(2, node->op()->ValueInputCount()); |
| 838 ProcessInput(node, 0, left_use); | 817 ProcessInput(node, 0, left_use); |
| 839 ProcessInput(node, 1, right_use); | 818 ProcessInput(node, 1, right_use); |
| 840 for (int i = 2; i < node->InputCount(); i++) { | 819 for (int i = 2; i < node->InputCount(); i++) { |
| 841 EnqueueInput(node, i); | 820 EnqueueInput(node, i); |
| 842 } | 821 } |
| (...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 VisitUnop(node, UseInfo::AnyTagged(), | 2308 VisitUnop(node, UseInfo::AnyTagged(), |
| 2330 MachineRepresentation::kTaggedPointer); | 2309 MachineRepresentation::kTaggedPointer); |
| 2331 if (lower()) DeferReplacement(node, node->InputAt(0)); | 2310 if (lower()) DeferReplacement(node, node->InputAt(0)); |
| 2332 } else { | 2311 } else { |
| 2333 VisitUnop(node, UseInfo::CheckedHeapObjectAsTaggedPointer(), | 2312 VisitUnop(node, UseInfo::CheckedHeapObjectAsTaggedPointer(), |
| 2334 MachineRepresentation::kTaggedPointer); | 2313 MachineRepresentation::kTaggedPointer); |
| 2335 } | 2314 } |
| 2336 return; | 2315 return; |
| 2337 } | 2316 } |
| 2338 case IrOpcode::kCheckNumber: { | 2317 case IrOpcode::kCheckNumber: { |
| 2339 Type* const input_type = TypeOf(node->InputAt(0)); | 2318 if (InputIs(node, Type::Number())) { |
| 2340 if (input_type->Is(Type::Number())) { | 2319 if (truncation.IsUsedAsWord32()) { |
| 2341 VisitNoop(node, truncation); | 2320 VisitUnop(node, UseInfo::TruncatingWord32(), |
| 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)); |
| 2342 } else { | 2331 } else { |
| 2343 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); | 2332 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); |
| 2344 } | 2333 } |
| 2345 return; | 2334 return; |
| 2346 } | 2335 } |
| 2347 case IrOpcode::kCheckReceiver: { | 2336 case IrOpcode::kCheckReceiver: { |
| 2348 if (InputIs(node, Type::Receiver())) { | 2337 if (InputIs(node, Type::Receiver())) { |
| 2349 VisitUnop(node, UseInfo::AnyTagged(), | 2338 VisitUnop(node, UseInfo::AnyTagged(), |
| 2350 MachineRepresentation::kTaggedPointer); | 2339 MachineRepresentation::kTaggedPointer); |
| 2351 if (lower()) DeferReplacement(node, node->InputAt(0)); | 2340 if (lower()) DeferReplacement(node, node->InputAt(0)); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 case IrOpcode::kNewUnmappedArgumentsElements: { | 2574 case IrOpcode::kNewUnmappedArgumentsElements: { |
| 2586 ProcessRemainingInputs(node, 0); | 2575 ProcessRemainingInputs(node, 0); |
| 2587 SetOutput(node, MachineRepresentation::kTaggedPointer); | 2576 SetOutput(node, MachineRepresentation::kTaggedPointer); |
| 2588 return; | 2577 return; |
| 2589 } | 2578 } |
| 2590 case IrOpcode::kArrayBufferWasNeutered: { | 2579 case IrOpcode::kArrayBufferWasNeutered: { |
| 2591 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit); | 2580 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit); |
| 2592 return; | 2581 return; |
| 2593 } | 2582 } |
| 2594 case IrOpcode::kCheckFloat64Hole: { | 2583 case IrOpcode::kCheckFloat64Hole: { |
| 2595 Type* const input_type = TypeOf(node->InputAt(0)); | 2584 CheckFloat64HoleMode mode = CheckFloat64HoleModeOf(node->op()); |
| 2596 if (input_type->Is(Type::Number())) { | 2585 ProcessInput(node, 0, UseInfo::TruncatingFloat64()); |
| 2597 VisitNoop(node, truncation); | 2586 ProcessRemainingInputs(node, 1); |
| 2598 } else { | 2587 SetOutput(node, MachineRepresentation::kFloat64); |
| 2599 CheckFloat64HoleMode mode = CheckFloat64HoleModeOf(node->op()); | 2588 if (truncation.IsUsedAsFloat64() && |
| 2600 switch (mode) { | 2589 mode == CheckFloat64HoleMode::kAllowReturnHole) { |
| 2601 case CheckFloat64HoleMode::kAllowReturnHole: | 2590 if (lower()) DeferReplacement(node, node->InputAt(0)); |
| 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 } | |
| 2621 } | 2591 } |
| 2622 return; | 2592 return; |
| 2623 } | 2593 } |
| 2624 case IrOpcode::kCheckTaggedHole: { | 2594 case IrOpcode::kCheckTaggedHole: { |
| 2625 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); | 2595 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); |
| 2626 return; | 2596 return; |
| 2627 } | 2597 } |
| 2628 case IrOpcode::kConvertTaggedHoleToUndefined: { | 2598 case IrOpcode::kConvertTaggedHoleToUndefined: { |
| 2629 if (InputIs(node, Type::NumberOrOddball()) && | 2599 if (InputIs(node, Type::NumberOrOddball()) && |
| 2630 truncation.IsUsedAsWord32()) { | 2600 truncation.IsUsedAsWord32()) { |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3562 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3532 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
| 3563 Operator::kNoProperties); | 3533 Operator::kNoProperties); |
| 3564 to_number_operator_.set(common()->Call(desc)); | 3534 to_number_operator_.set(common()->Call(desc)); |
| 3565 } | 3535 } |
| 3566 return to_number_operator_.get(); | 3536 return to_number_operator_.get(); |
| 3567 } | 3537 } |
| 3568 | 3538 |
| 3569 } // namespace compiler | 3539 } // namespace compiler |
| 3570 } // namespace internal | 3540 } // namespace internal |
| 3571 } // namespace v8 | 3541 } // namespace v8 |
| OLD | NEW |