OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/effect-control-linearizer.h" | 5 #include "src/compiler/effect-control-linearizer.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 break; | 715 break; |
716 case IrOpcode::kPlainPrimitiveToWord32: | 716 case IrOpcode::kPlainPrimitiveToWord32: |
717 state = LowerPlainPrimitiveToWord32(node, *effect, *control); | 717 state = LowerPlainPrimitiveToWord32(node, *effect, *control); |
718 break; | 718 break; |
719 case IrOpcode::kPlainPrimitiveToFloat64: | 719 case IrOpcode::kPlainPrimitiveToFloat64: |
720 state = LowerPlainPrimitiveToFloat64(node, *effect, *control); | 720 state = LowerPlainPrimitiveToFloat64(node, *effect, *control); |
721 break; | 721 break; |
722 case IrOpcode::kTransitionElementsKind: | 722 case IrOpcode::kTransitionElementsKind: |
723 state = LowerTransitionElementsKind(node, *effect, *control); | 723 state = LowerTransitionElementsKind(node, *effect, *control); |
724 break; | 724 break; |
| 725 case IrOpcode::kLoadTypedElement: |
| 726 state = LowerLoadTypedElement(node, *effect, *control); |
| 727 break; |
| 728 case IrOpcode::kStoreTypedElement: |
| 729 state = LowerStoreTypedElement(node, *effect, *control); |
| 730 break; |
725 default: | 731 default: |
726 return false; | 732 return false; |
727 } | 733 } |
728 NodeProperties::ReplaceUses(node, state.value, state.effect, state.control); | 734 NodeProperties::ReplaceUses(node, state.value, state.effect, state.control); |
729 *effect = state.effect; | 735 *effect = state.effect; |
730 *control = state.control; | 736 *control = state.control; |
731 return true; | 737 return true; |
732 } | 738 } |
733 | 739 |
734 EffectControlLinearizer::ValueEffectControl | 740 EffectControlLinearizer::ValueEffectControl |
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2612 // Nothing to do if the {object} doesn't have the {source_map}. | 2618 // Nothing to do if the {object} doesn't have the {source_map}. |
2613 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 2619 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
2614 Node* efalse = effect; | 2620 Node* efalse = effect; |
2615 | 2621 |
2616 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 2622 control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
2617 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 2623 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
2618 | 2624 |
2619 return ValueEffectControl(nullptr, effect, control); | 2625 return ValueEffectControl(nullptr, effect, control); |
2620 } | 2626 } |
2621 | 2627 |
| 2628 EffectControlLinearizer::ValueEffectControl |
| 2629 EffectControlLinearizer::LowerLoadTypedElement(Node* node, Node* effect, |
| 2630 Node* control) { |
| 2631 ExternalArrayType array_type = ExternalArrayTypeOf(node->op()); |
| 2632 Node* buffer = node->InputAt(0); |
| 2633 Node* base = node->InputAt(1); |
| 2634 Node* external = node->InputAt(2); |
| 2635 Node* index = node->InputAt(3); |
| 2636 |
| 2637 // We need to keep the {buffer} alive so that the GC will not release the |
| 2638 // ArrayBuffer (if there's any) as long as we are still operating on it. |
| 2639 effect = graph()->NewNode(common()->Retain(), buffer, effect); |
| 2640 |
| 2641 // Compute the effective storage pointer. |
| 2642 Node* storage = effect = graph()->NewNode(machine()->UnsafePointerAdd(), base, |
| 2643 external, effect, control); |
| 2644 |
| 2645 // Perform the actual typed element access. |
| 2646 Node* value = effect = graph()->NewNode( |
| 2647 simplified()->LoadElement( |
| 2648 AccessBuilder::ForTypedArrayElement(array_type, true)), |
| 2649 storage, index, effect, control); |
| 2650 |
| 2651 return ValueEffectControl(value, effect, control); |
| 2652 } |
| 2653 |
| 2654 EffectControlLinearizer::ValueEffectControl |
| 2655 EffectControlLinearizer::LowerStoreTypedElement(Node* node, Node* effect, |
| 2656 Node* control) { |
| 2657 ExternalArrayType array_type = ExternalArrayTypeOf(node->op()); |
| 2658 Node* buffer = node->InputAt(0); |
| 2659 Node* base = node->InputAt(1); |
| 2660 Node* external = node->InputAt(2); |
| 2661 Node* index = node->InputAt(3); |
| 2662 Node* value = node->InputAt(4); |
| 2663 |
| 2664 // We need to keep the {buffer} alive so that the GC will not release the |
| 2665 // ArrayBuffer (if there's any) as long as we are still operating on it. |
| 2666 effect = graph()->NewNode(common()->Retain(), buffer, effect); |
| 2667 |
| 2668 // Compute the effective storage pointer. |
| 2669 Node* storage = effect = graph()->NewNode(machine()->UnsafePointerAdd(), base, |
| 2670 external, effect, control); |
| 2671 |
| 2672 // Perform the actual typed element access. |
| 2673 effect = graph()->NewNode( |
| 2674 simplified()->StoreElement( |
| 2675 AccessBuilder::ForTypedArrayElement(array_type, true)), |
| 2676 storage, index, value, effect, control); |
| 2677 |
| 2678 return ValueEffectControl(nullptr, effect, control); |
| 2679 } |
| 2680 |
2622 Factory* EffectControlLinearizer::factory() const { | 2681 Factory* EffectControlLinearizer::factory() const { |
2623 return isolate()->factory(); | 2682 return isolate()->factory(); |
2624 } | 2683 } |
2625 | 2684 |
2626 Isolate* EffectControlLinearizer::isolate() const { | 2685 Isolate* EffectControlLinearizer::isolate() const { |
2627 return jsgraph()->isolate(); | 2686 return jsgraph()->isolate(); |
2628 } | 2687 } |
2629 | 2688 |
2630 Operator const* EffectControlLinearizer::ToNumberOperator() { | 2689 Operator const* EffectControlLinearizer::ToNumberOperator() { |
2631 if (!to_number_operator_.is_set()) { | 2690 if (!to_number_operator_.is_set()) { |
2632 Callable callable = CodeFactory::ToNumber(isolate()); | 2691 Callable callable = CodeFactory::ToNumber(isolate()); |
2633 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; | 2692 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; |
2634 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 2693 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
2635 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 2694 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
2636 Operator::kNoThrow); | 2695 Operator::kNoThrow); |
2637 to_number_operator_.set(common()->Call(desc)); | 2696 to_number_operator_.set(common()->Call(desc)); |
2638 } | 2697 } |
2639 return to_number_operator_.get(); | 2698 return to_number_operator_.get(); |
2640 } | 2699 } |
2641 | 2700 |
2642 } // namespace compiler | 2701 } // namespace compiler |
2643 } // namespace internal | 2702 } // namespace internal |
2644 } // namespace v8 | 2703 } // namespace v8 |
OLD | NEW |