| 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/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/js-typed-lowering.h" | 7 #include "src/compiler/js-typed-lowering.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 Node* const input = node->InputAt(0); | 740 Node* const input = node->InputAt(0); |
| 741 Reduction reduction = ReduceJSToStringInput(input); | 741 Reduction reduction = ReduceJSToStringInput(input); |
| 742 if (reduction.Changed()) { | 742 if (reduction.Changed()) { |
| 743 NodeProperties::ReplaceWithValue(node, reduction.replacement()); | 743 NodeProperties::ReplaceWithValue(node, reduction.replacement()); |
| 744 return reduction; | 744 return reduction; |
| 745 } | 745 } |
| 746 return NoChange(); | 746 return NoChange(); |
| 747 } | 747 } |
| 748 | 748 |
| 749 | 749 |
| 750 static bool IsGlobalObject(Node* node) { |
| 751 return NodeProperties::IsTyped(node) && |
| 752 NodeProperties::GetBounds(node).upper->Is(Type::GlobalObject()); |
| 753 } |
| 754 |
| 755 |
| 756 Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) { |
| 757 if (IsGlobalObject(node->InputAt(0))) { |
| 758 // Optimize global constants like "undefined", "Infinity", and "NaN". |
| 759 Handle<Name> name = LoadNamedParametersOf(node->op()).name().handle(); |
| 760 Handle<Object> constant_value = factory()->GlobalConstantFor(name); |
| 761 if (!constant_value.is_null()) { |
| 762 Node* constant = jsgraph()->Constant(constant_value); |
| 763 NodeProperties::ReplaceWithValue(node, constant); |
| 764 return Replace(constant); |
| 765 } |
| 766 } |
| 767 return NoChange(); |
| 768 } |
| 769 |
| 770 |
| 750 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { | 771 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { |
| 751 Node* key = NodeProperties::GetValueInput(node, 1); | 772 Node* key = NodeProperties::GetValueInput(node, 1); |
| 752 Node* base = NodeProperties::GetValueInput(node, 0); | 773 Node* base = NodeProperties::GetValueInput(node, 0); |
| 753 Type* key_type = NodeProperties::GetBounds(key).upper; | 774 Type* key_type = NodeProperties::GetBounds(key).upper; |
| 754 // TODO(mstarzinger): This lowering is not correct if: | 775 // TODO(mstarzinger): This lowering is not correct if: |
| 755 // a) The typed array or it's buffer is neutered. | 776 // a) The typed array or it's buffer is neutered. |
| 756 HeapObjectMatcher<Object> mbase(base); | 777 HeapObjectMatcher<Object> mbase(base); |
| 757 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { | 778 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { |
| 758 Handle<JSTypedArray> const array = | 779 Handle<JSTypedArray> const array = |
| 759 Handle<JSTypedArray>::cast(mbase.Value().handle()); | 780 Handle<JSTypedArray>::cast(mbase.Value().handle()); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 case IrOpcode::kJSModulus: | 1010 case IrOpcode::kJSModulus: |
| 990 return ReduceNumberBinop(node, simplified()->NumberModulus()); | 1011 return ReduceNumberBinop(node, simplified()->NumberModulus()); |
| 991 case IrOpcode::kJSUnaryNot: | 1012 case IrOpcode::kJSUnaryNot: |
| 992 return ReduceJSUnaryNot(node); | 1013 return ReduceJSUnaryNot(node); |
| 993 case IrOpcode::kJSToBoolean: | 1014 case IrOpcode::kJSToBoolean: |
| 994 return ReduceJSToBoolean(node); | 1015 return ReduceJSToBoolean(node); |
| 995 case IrOpcode::kJSToNumber: | 1016 case IrOpcode::kJSToNumber: |
| 996 return ReduceJSToNumber(node); | 1017 return ReduceJSToNumber(node); |
| 997 case IrOpcode::kJSToString: | 1018 case IrOpcode::kJSToString: |
| 998 return ReduceJSToString(node); | 1019 return ReduceJSToString(node); |
| 1020 case IrOpcode::kJSLoadNamed: |
| 1021 return ReduceJSLoadNamed(node); |
| 999 case IrOpcode::kJSLoadProperty: | 1022 case IrOpcode::kJSLoadProperty: |
| 1000 return ReduceJSLoadProperty(node); | 1023 return ReduceJSLoadProperty(node); |
| 1001 case IrOpcode::kJSStoreProperty: | 1024 case IrOpcode::kJSStoreProperty: |
| 1002 return ReduceJSStoreProperty(node); | 1025 return ReduceJSStoreProperty(node); |
| 1003 case IrOpcode::kJSLoadContext: | 1026 case IrOpcode::kJSLoadContext: |
| 1004 return ReduceJSLoadContext(node); | 1027 return ReduceJSLoadContext(node); |
| 1005 case IrOpcode::kJSStoreContext: | 1028 case IrOpcode::kJSStoreContext: |
| 1006 return ReduceJSStoreContext(node); | 1029 return ReduceJSStoreContext(node); |
| 1007 default: | 1030 default: |
| 1008 break; | 1031 break; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 } | 1100 } |
| 1078 | 1101 |
| 1079 | 1102 |
| 1080 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1103 MachineOperatorBuilder* JSTypedLowering::machine() const { |
| 1081 return jsgraph()->machine(); | 1104 return jsgraph()->machine(); |
| 1082 } | 1105 } |
| 1083 | 1106 |
| 1084 } // namespace compiler | 1107 } // namespace compiler |
| 1085 } // namespace internal | 1108 } // namespace internal |
| 1086 } // namespace v8 | 1109 } // namespace v8 |
| OLD | NEW |