| 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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 // Optimize global constants like "undefined", "Infinity", and "NaN". | 788 // Optimize global constants like "undefined", "Infinity", and "NaN". |
| 789 Handle<Name> name = LoadGlobalParametersOf(node->op()).name().handle(); | 789 Handle<Name> name = LoadGlobalParametersOf(node->op()).name().handle(); |
| 790 Handle<Object> constant_value = factory()->GlobalConstantFor(name); | 790 Handle<Object> constant_value = factory()->GlobalConstantFor(name); |
| 791 if (!constant_value.is_null()) { | 791 if (!constant_value.is_null()) { |
| 792 Node* constant = jsgraph()->Constant(constant_value); | 792 Node* constant = jsgraph()->Constant(constant_value); |
| 793 ReplaceWithValue(node, constant); | 793 ReplaceWithValue(node, constant); |
| 794 return Replace(constant); | 794 return Replace(constant); |
| 795 } | 795 } |
| 796 return NoChange(); | 796 return NoChange(); |
| 797 } | 797 } |
| 798 | |
| 799 | |
| 800 Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) { | |
| 801 DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode()); | |
| 802 Node* receiver = NodeProperties::GetValueInput(node, 0); | |
| 803 Type* receiver_type = NodeProperties::GetBounds(receiver).upper; | |
| 804 Node* effect = NodeProperties::GetEffectInput(node); | |
| 805 Node* control = NodeProperties::GetControlInput(node); | |
| 806 Handle<Name> name = LoadNamedParametersOf(node->op()).name().handle(); | |
| 807 // Optimize "length" property of strings. | |
| 808 if (name.is_identical_to(factory()->length_string()) && | |
| 809 receiver_type->Is(Type::String())) { | |
| 810 Node* value = effect = | |
| 811 graph()->NewNode(simplified()->LoadField( | |
| 812 AccessBuilder::ForStringLength(graph()->zone())), | |
| 813 receiver, effect, control); | |
| 814 ReplaceWithValue(node, value, effect); | |
| 815 return Replace(value); | |
| 816 } | |
| 817 return NoChange(); | |
| 818 } | |
| 819 | 798 |
| 820 | 799 |
| 821 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { | 800 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { |
| 822 Node* key = NodeProperties::GetValueInput(node, 1); | 801 Node* key = NodeProperties::GetValueInput(node, 1); |
| 823 Node* base = NodeProperties::GetValueInput(node, 0); | 802 Node* base = NodeProperties::GetValueInput(node, 0); |
| 824 Type* key_type = NodeProperties::GetBounds(key).upper; | 803 Type* key_type = NodeProperties::GetBounds(key).upper; |
| 825 HeapObjectMatcher mbase(base); | 804 HeapObjectMatcher mbase(base); |
| 826 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { | 805 if (mbase.HasValue() && mbase.Value().handle()->IsJSTypedArray()) { |
| 827 Handle<JSTypedArray> const array = | 806 Handle<JSTypedArray> const array = |
| 828 Handle<JSTypedArray>::cast(mbase.Value().handle()); | 807 Handle<JSTypedArray>::cast(mbase.Value().handle()); |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 case IrOpcode::kJSUnaryNot: | 1614 case IrOpcode::kJSUnaryNot: |
| 1636 return ReduceJSUnaryNot(node); | 1615 return ReduceJSUnaryNot(node); |
| 1637 case IrOpcode::kJSToBoolean: | 1616 case IrOpcode::kJSToBoolean: |
| 1638 return ReduceJSToBoolean(node); | 1617 return ReduceJSToBoolean(node); |
| 1639 case IrOpcode::kJSToNumber: | 1618 case IrOpcode::kJSToNumber: |
| 1640 return ReduceJSToNumber(node); | 1619 return ReduceJSToNumber(node); |
| 1641 case IrOpcode::kJSToString: | 1620 case IrOpcode::kJSToString: |
| 1642 return ReduceJSToString(node); | 1621 return ReduceJSToString(node); |
| 1643 case IrOpcode::kJSLoadGlobal: | 1622 case IrOpcode::kJSLoadGlobal: |
| 1644 return ReduceJSLoadGlobal(node); | 1623 return ReduceJSLoadGlobal(node); |
| 1645 case IrOpcode::kJSLoadNamed: | |
| 1646 return ReduceJSLoadNamed(node); | |
| 1647 case IrOpcode::kJSLoadProperty: | 1624 case IrOpcode::kJSLoadProperty: |
| 1648 return ReduceJSLoadProperty(node); | 1625 return ReduceJSLoadProperty(node); |
| 1649 case IrOpcode::kJSStoreProperty: | 1626 case IrOpcode::kJSStoreProperty: |
| 1650 return ReduceJSStoreProperty(node); | 1627 return ReduceJSStoreProperty(node); |
| 1651 case IrOpcode::kJSLoadContext: | 1628 case IrOpcode::kJSLoadContext: |
| 1652 return ReduceJSLoadContext(node); | 1629 return ReduceJSLoadContext(node); |
| 1653 case IrOpcode::kJSStoreContext: | 1630 case IrOpcode::kJSStoreContext: |
| 1654 return ReduceJSStoreContext(node); | 1631 return ReduceJSStoreContext(node); |
| 1655 case IrOpcode::kJSLoadDynamicGlobal: | 1632 case IrOpcode::kJSLoadDynamicGlobal: |
| 1656 return ReduceJSLoadDynamicGlobal(node); | 1633 return ReduceJSLoadDynamicGlobal(node); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 } | 1686 } |
| 1710 | 1687 |
| 1711 | 1688 |
| 1712 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1689 MachineOperatorBuilder* JSTypedLowering::machine() const { |
| 1713 return jsgraph()->machine(); | 1690 return jsgraph()->machine(); |
| 1714 } | 1691 } |
| 1715 | 1692 |
| 1716 } // namespace compiler | 1693 } // namespace compiler |
| 1717 } // namespace internal | 1694 } // namespace internal |
| 1718 } // namespace v8 | 1695 } // namespace v8 |
| OLD | NEW |