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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 Node* const input = node->InputAt(0); | 794 Node* const input = node->InputAt(0); |
795 Reduction reduction = ReduceJSToStringInput(input); | 795 Reduction reduction = ReduceJSToStringInput(input); |
796 if (reduction.Changed()) { | 796 if (reduction.Changed()) { |
797 ReplaceWithValue(node, reduction.replacement()); | 797 ReplaceWithValue(node, reduction.replacement()); |
798 return reduction; | 798 return reduction; |
799 } | 799 } |
800 return NoChange(); | 800 return NoChange(); |
801 } | 801 } |
802 | 802 |
803 | 803 |
804 Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) { | 804 Reduction JSTypedLowering::ReduceJSLoadGlobal(Node* node) { |
805 Node* object = NodeProperties::GetValueInput(node, 0); | 805 // Optimize global constants like "undefined", "Infinity", and "NaN". |
806 Type* object_type = NodeProperties::GetBounds(object).upper; | 806 Handle<Name> name = LoadGlobalParametersOf(node->op()).name().handle(); |
807 if (object_type->Is(Type::GlobalObject())) { | 807 Handle<Object> constant_value = factory()->GlobalConstantFor(name); |
808 // Optimize global constants like "undefined", "Infinity", and "NaN". | 808 if (!constant_value.is_null()) { |
809 Handle<Name> name = LoadNamedParametersOf(node->op()).name().handle(); | 809 Node* constant = jsgraph()->Constant(constant_value); |
810 Handle<Object> constant_value = factory()->GlobalConstantFor(name); | 810 ReplaceWithValue(node, constant); |
811 if (!constant_value.is_null()) { | 811 return Replace(constant); |
812 Node* constant = jsgraph()->Constant(constant_value); | |
813 ReplaceWithValue(node, constant); | |
814 return Replace(constant); | |
815 } | |
816 } | 812 } |
817 return NoChange(); | 813 return NoChange(); |
818 } | 814 } |
819 | 815 |
820 | 816 |
821 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { | 817 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { |
822 Node* key = NodeProperties::GetValueInput(node, 1); | 818 Node* key = NodeProperties::GetValueInput(node, 1); |
823 Node* base = NodeProperties::GetValueInput(node, 0); | 819 Node* base = NodeProperties::GetValueInput(node, 0); |
824 Type* key_type = NodeProperties::GetBounds(key).upper; | 820 Type* key_type = NodeProperties::GetBounds(key).upper; |
825 HeapObjectMatcher mbase(base); | 821 HeapObjectMatcher mbase(base); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 check_false->AppendInput(graph()->zone(), if_false); | 1012 check_false->AppendInput(graph()->zone(), if_false); |
1017 check_true = if_true; | 1013 check_true = if_true; |
1018 } | 1014 } |
1019 | 1015 |
1020 // Fast case, because variable is not shadowed. Perform global object load. | 1016 // Fast case, because variable is not shadowed. Perform global object load. |
1021 Unique<Name> name = Unique<Name>::CreateUninitialized(access.name()); | 1017 Unique<Name> name = Unique<Name>::CreateUninitialized(access.name()); |
1022 Node* global = graph()->NewNode( | 1018 Node* global = graph()->NewNode( |
1023 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), context, | 1019 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), context, |
1024 context, effect); | 1020 context, effect); |
1025 Node* fast = graph()->NewNode( | 1021 Node* fast = graph()->NewNode( |
1026 javascript()->LoadNamed(name, access.feedback(), access.mode()), global, | 1022 javascript()->LoadGlobal(name, access.feedback(), access.mode()), global, |
1027 vector, context, state1, state2, global, check_true); | 1023 vector, context, state1, state2, global, check_true); |
1028 | 1024 |
1029 // Slow case, because variable potentially shadowed. Perform dynamic lookup. | 1025 // Slow case, because variable potentially shadowed. Perform dynamic lookup. |
1030 uint32_t check_bitset = DynamicGlobalAccess::kFullCheckRequired; | 1026 uint32_t check_bitset = DynamicGlobalAccess::kFullCheckRequired; |
1031 Node* slow = graph()->NewNode( | 1027 Node* slow = graph()->NewNode( |
1032 javascript()->LoadDynamicGlobal(access.name(), check_bitset, | 1028 javascript()->LoadDynamicGlobal(access.name(), check_bitset, |
1033 access.feedback(), access.mode()), | 1029 access.feedback(), access.mode()), |
1034 vector, context, context, state1, state2, effect, check_false); | 1030 vector, context, context, state1, state2, effect, check_false); |
1035 | 1031 |
1036 // Replace value, effect and control uses accordingly. | 1032 // Replace value, effect and control uses accordingly. |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 case IrOpcode::kJSModulus: | 1628 case IrOpcode::kJSModulus: |
1633 return ReduceJSModulus(node); | 1629 return ReduceJSModulus(node); |
1634 case IrOpcode::kJSUnaryNot: | 1630 case IrOpcode::kJSUnaryNot: |
1635 return ReduceJSUnaryNot(node); | 1631 return ReduceJSUnaryNot(node); |
1636 case IrOpcode::kJSToBoolean: | 1632 case IrOpcode::kJSToBoolean: |
1637 return ReduceJSToBoolean(node); | 1633 return ReduceJSToBoolean(node); |
1638 case IrOpcode::kJSToNumber: | 1634 case IrOpcode::kJSToNumber: |
1639 return ReduceJSToNumber(node); | 1635 return ReduceJSToNumber(node); |
1640 case IrOpcode::kJSToString: | 1636 case IrOpcode::kJSToString: |
1641 return ReduceJSToString(node); | 1637 return ReduceJSToString(node); |
1642 case IrOpcode::kJSLoadNamed: | 1638 case IrOpcode::kJSLoadGlobal: |
1643 return ReduceJSLoadNamed(node); | 1639 return ReduceJSLoadGlobal(node); |
1644 case IrOpcode::kJSLoadProperty: | 1640 case IrOpcode::kJSLoadProperty: |
1645 return ReduceJSLoadProperty(node); | 1641 return ReduceJSLoadProperty(node); |
1646 case IrOpcode::kJSStoreProperty: | 1642 case IrOpcode::kJSStoreProperty: |
1647 return ReduceJSStoreProperty(node); | 1643 return ReduceJSStoreProperty(node); |
1648 case IrOpcode::kJSLoadContext: | 1644 case IrOpcode::kJSLoadContext: |
1649 return ReduceJSLoadContext(node); | 1645 return ReduceJSLoadContext(node); |
1650 case IrOpcode::kJSStoreContext: | 1646 case IrOpcode::kJSStoreContext: |
1651 return ReduceJSStoreContext(node); | 1647 return ReduceJSStoreContext(node); |
1652 case IrOpcode::kJSLoadDynamicGlobal: | 1648 case IrOpcode::kJSLoadDynamicGlobal: |
1653 return ReduceJSLoadDynamicGlobal(node); | 1649 return ReduceJSLoadDynamicGlobal(node); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 } | 1702 } |
1707 | 1703 |
1708 | 1704 |
1709 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1705 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1710 return jsgraph()->machine(); | 1706 return jsgraph()->machine(); |
1711 } | 1707 } |
1712 | 1708 |
1713 } // namespace compiler | 1709 } // namespace compiler |
1714 } // namespace internal | 1710 } // namespace internal |
1715 } // namespace v8 | 1711 } // namespace v8 |
OLD | NEW |