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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
7 #include "src/compiler/js-builtin-reducer.h" | 7 #include "src/compiler/js-builtin-reducer.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/node-aux-data-inl.h" | 9 #include "src/compiler/node-aux-data-inl.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 node->ReplaceInput(4, effect); | 795 node->ReplaceInput(4, effect); |
796 DCHECK_EQ(control, node->InputAt(5)); | 796 DCHECK_EQ(control, node->InputAt(5)); |
797 DCHECK_EQ(6, node->InputCount()); | 797 DCHECK_EQ(6, node->InputCount()); |
798 return Changed(node); | 798 return Changed(node); |
799 } | 799 } |
800 } | 800 } |
801 return NoChange(); | 801 return NoChange(); |
802 } | 802 } |
803 | 803 |
804 | 804 |
| 805 Reduction JSTypedLowering::ReduceJSLoadContext(Node* node) { |
| 806 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode()); |
| 807 ContextAccess const& access = ContextAccessOf(node->op()); |
| 808 Node* const effect = NodeProperties::GetEffectInput(node); |
| 809 Node* const control = graph()->start(); |
| 810 for (size_t i = 0; i < access.depth(); ++i) { |
| 811 node->ReplaceInput( |
| 812 0, graph()->NewNode( |
| 813 simplified()->LoadField( |
| 814 AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX)), |
| 815 NodeProperties::GetValueInput(node, 0), effect, control)); |
| 816 } |
| 817 node->set_op( |
| 818 simplified()->LoadField(AccessBuilder::ForContextSlot(access.index()))); |
| 819 node->ReplaceInput(1, effect); |
| 820 node->ReplaceInput(2, control); |
| 821 DCHECK_EQ(3, node->InputCount()); |
| 822 return Changed(node); |
| 823 } |
| 824 |
| 825 |
| 826 Reduction JSTypedLowering::ReduceJSStoreContext(Node* node) { |
| 827 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); |
| 828 ContextAccess const& access = ContextAccessOf(node->op()); |
| 829 Node* const effect = NodeProperties::GetEffectInput(node); |
| 830 Node* const control = graph()->start(); |
| 831 for (size_t i = 0; i < access.depth(); ++i) { |
| 832 node->ReplaceInput( |
| 833 0, graph()->NewNode( |
| 834 simplified()->LoadField( |
| 835 AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX)), |
| 836 NodeProperties::GetValueInput(node, 0), effect, control)); |
| 837 } |
| 838 node->set_op( |
| 839 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); |
| 840 node->RemoveInput(2); |
| 841 DCHECK_EQ(4, node->InputCount()); |
| 842 return Changed(node); |
| 843 } |
| 844 |
| 845 |
805 static Reduction ReplaceWithReduction(Node* node, Reduction reduction) { | 846 static Reduction ReplaceWithReduction(Node* node, Reduction reduction) { |
806 if (reduction.Changed()) { | 847 if (reduction.Changed()) { |
807 NodeProperties::ReplaceWithValue(node, reduction.replacement()); | 848 NodeProperties::ReplaceWithValue(node, reduction.replacement()); |
808 return reduction; | 849 return reduction; |
809 } | 850 } |
810 return Reducer::NoChange(); | 851 return Reducer::NoChange(); |
811 } | 852 } |
812 | 853 |
813 | 854 |
814 Reduction JSTypedLowering::Reduce(Node* node) { | 855 Reduction JSTypedLowering::Reduce(Node* node) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 return ReduceJSToBoolean(node); | 922 return ReduceJSToBoolean(node); |
882 case IrOpcode::kJSToNumber: | 923 case IrOpcode::kJSToNumber: |
883 return ReduceJSToNumber(node); | 924 return ReduceJSToNumber(node); |
884 case IrOpcode::kJSToString: | 925 case IrOpcode::kJSToString: |
885 return ReplaceWithReduction(node, | 926 return ReplaceWithReduction(node, |
886 ReduceJSToStringInput(node->InputAt(0))); | 927 ReduceJSToStringInput(node->InputAt(0))); |
887 case IrOpcode::kJSLoadProperty: | 928 case IrOpcode::kJSLoadProperty: |
888 return ReduceJSLoadProperty(node); | 929 return ReduceJSLoadProperty(node); |
889 case IrOpcode::kJSStoreProperty: | 930 case IrOpcode::kJSStoreProperty: |
890 return ReduceJSStoreProperty(node); | 931 return ReduceJSStoreProperty(node); |
| 932 case IrOpcode::kJSLoadContext: |
| 933 return ReduceJSLoadContext(node); |
| 934 case IrOpcode::kJSStoreContext: |
| 935 return ReduceJSStoreContext(node); |
891 case IrOpcode::kJSCallFunction: | 936 case IrOpcode::kJSCallFunction: |
892 return JSBuiltinReducer(jsgraph()).Reduce(node); | 937 return JSBuiltinReducer(jsgraph()).Reduce(node); |
893 default: | 938 default: |
894 break; | 939 break; |
895 } | 940 } |
896 return NoChange(); | 941 return NoChange(); |
897 } | 942 } |
898 | 943 |
899 | 944 |
900 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { | 945 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { |
901 if (rhs == 0) return lhs; | 946 if (rhs == 0) return lhs; |
902 return graph()->NewNode(machine()->Word32Shl(), lhs, | 947 return graph()->NewNode(machine()->Word32Shl(), lhs, |
903 jsgraph()->Int32Constant(rhs)); | 948 jsgraph()->Int32Constant(rhs)); |
904 } | 949 } |
905 | 950 |
906 } // namespace compiler | 951 } // namespace compiler |
907 } // namespace internal | 952 } // namespace internal |
908 } // namespace v8 | 953 } // namespace v8 |
OLD | NEW |