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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 Node* const input = node->InputAt(0); | 808 Node* const input = node->InputAt(0); |
809 Reduction reduction = ReduceJSToStringInput(input); | 809 Reduction reduction = ReduceJSToStringInput(input); |
810 if (reduction.Changed()) { | 810 if (reduction.Changed()) { |
811 ReplaceWithValue(node, reduction.replacement()); | 811 ReplaceWithValue(node, reduction.replacement()); |
812 return reduction; | 812 return reduction; |
813 } | 813 } |
814 return NoChange(); | 814 return NoChange(); |
815 } | 815 } |
816 | 816 |
817 | 817 |
818 Reduction JSTypedLowering::ReduceJSLoadGlobal(Node* node) { | |
819 // Optimize global constants like "undefined", "Infinity", and "NaN". | |
820 Handle<Name> name = LoadGlobalParametersOf(node->op()).name(); | |
821 Handle<Object> constant_value = factory()->GlobalConstantFor(name); | |
822 if (!constant_value.is_null()) { | |
823 Node* constant = jsgraph()->Constant(constant_value); | |
824 ReplaceWithValue(node, constant); | |
825 return Replace(constant); | |
826 } | |
827 return NoChange(); | |
828 } | |
829 | |
830 | |
831 Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) { | 818 Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) { |
832 DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode()); | 819 DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode()); |
833 Node* receiver = NodeProperties::GetValueInput(node, 0); | 820 Node* receiver = NodeProperties::GetValueInput(node, 0); |
834 Type* receiver_type = NodeProperties::GetType(receiver); | 821 Type* receiver_type = NodeProperties::GetType(receiver); |
835 Node* effect = NodeProperties::GetEffectInput(node); | 822 Node* effect = NodeProperties::GetEffectInput(node); |
836 Node* control = NodeProperties::GetControlInput(node); | 823 Node* control = NodeProperties::GetControlInput(node); |
837 Handle<Name> name = LoadNamedParametersOf(node->op()).name(); | 824 Handle<Name> name = LoadNamedParametersOf(node->op()).name(); |
838 // Optimize "length" property of strings. | 825 // Optimize "length" property of strings. |
839 if (name.is_identical_to(factory()->length_string()) && | 826 if (name.is_identical_to(factory()->length_string()) && |
840 receiver_type->Is(Type::String())) { | 827 receiver_type->Is(Type::String())) { |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 case IrOpcode::kJSModulus: | 1752 case IrOpcode::kJSModulus: |
1766 return ReduceJSModulus(node); | 1753 return ReduceJSModulus(node); |
1767 case IrOpcode::kJSUnaryNot: | 1754 case IrOpcode::kJSUnaryNot: |
1768 return ReduceJSUnaryNot(node); | 1755 return ReduceJSUnaryNot(node); |
1769 case IrOpcode::kJSToBoolean: | 1756 case IrOpcode::kJSToBoolean: |
1770 return ReduceJSToBoolean(node); | 1757 return ReduceJSToBoolean(node); |
1771 case IrOpcode::kJSToNumber: | 1758 case IrOpcode::kJSToNumber: |
1772 return ReduceJSToNumber(node); | 1759 return ReduceJSToNumber(node); |
1773 case IrOpcode::kJSToString: | 1760 case IrOpcode::kJSToString: |
1774 return ReduceJSToString(node); | 1761 return ReduceJSToString(node); |
1775 case IrOpcode::kJSLoadGlobal: | |
1776 return ReduceJSLoadGlobal(node); | |
1777 case IrOpcode::kJSLoadNamed: | 1762 case IrOpcode::kJSLoadNamed: |
1778 return ReduceJSLoadNamed(node); | 1763 return ReduceJSLoadNamed(node); |
1779 case IrOpcode::kJSLoadProperty: | 1764 case IrOpcode::kJSLoadProperty: |
1780 return ReduceJSLoadProperty(node); | 1765 return ReduceJSLoadProperty(node); |
1781 case IrOpcode::kJSStoreProperty: | 1766 case IrOpcode::kJSStoreProperty: |
1782 return ReduceJSStoreProperty(node); | 1767 return ReduceJSStoreProperty(node); |
1783 case IrOpcode::kJSLoadContext: | 1768 case IrOpcode::kJSLoadContext: |
1784 return ReduceJSLoadContext(node); | 1769 return ReduceJSLoadContext(node); |
1785 case IrOpcode::kJSStoreContext: | 1770 case IrOpcode::kJSStoreContext: |
1786 return ReduceJSStoreContext(node); | 1771 return ReduceJSStoreContext(node); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 } | 1830 } |
1846 | 1831 |
1847 | 1832 |
1848 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1833 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1849 return jsgraph()->machine(); | 1834 return jsgraph()->machine(); |
1850 } | 1835 } |
1851 | 1836 |
1852 } // namespace compiler | 1837 } // namespace compiler |
1853 } // namespace internal | 1838 } // namespace internal |
1854 } // namespace v8 | 1839 } // namespace v8 |
OLD | NEW |