OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/load-elimination.h" | 5 #include "src/compiler/load-elimination.h" |
6 | 6 |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 Node* const effect = NodeProperties::GetEffectInput(node); | 714 Node* const effect = NodeProperties::GetEffectInput(node); |
715 Node* const control = NodeProperties::GetControlInput(node); | 715 Node* const control = NodeProperties::GetControlInput(node); |
716 AbstractState const* state = node_states_.Get(effect); | 716 AbstractState const* state = node_states_.Get(effect); |
717 if (state == nullptr) return NoChange(); | 717 if (state == nullptr) return NoChange(); |
718 if (access.offset == HeapObject::kMapOffset && | 718 if (access.offset == HeapObject::kMapOffset && |
719 access.base_is_tagged == kTaggedBase) { | 719 access.base_is_tagged == kTaggedBase) { |
720 DCHECK(IsAnyTagged(access.machine_type.representation())); | 720 DCHECK(IsAnyTagged(access.machine_type.representation())); |
721 ZoneHandleSet<Map> object_maps; | 721 ZoneHandleSet<Map> object_maps; |
722 if (state->LookupMaps(object, &object_maps) && object_maps.size() == 1) { | 722 if (state->LookupMaps(object, &object_maps) && object_maps.size() == 1) { |
723 Node* value = jsgraph()->HeapConstant(object_maps[0]); | 723 Node* value = jsgraph()->HeapConstant(object_maps[0]); |
| 724 NodeProperties::SetType(value, Type::OtherInternal()); |
724 ReplaceWithValue(node, value, effect); | 725 ReplaceWithValue(node, value, effect); |
725 return Replace(value); | 726 return Replace(value); |
726 } | 727 } |
727 } else { | 728 } else { |
728 int field_index = FieldIndexOf(access); | 729 int field_index = FieldIndexOf(access); |
729 if (field_index >= 0) { | 730 if (field_index >= 0) { |
730 if (Node* replacement = state->LookupField(object, field_index)) { | 731 if (Node* replacement = state->LookupField(object, field_index)) { |
731 // Make sure we don't resurrect dead {replacement} nodes. | 732 // Make sure we don't resurrect dead {replacement} nodes. |
732 if (!replacement->IsDead()) { | 733 if (!replacement->IsDead()) { |
733 // We might need to guard the {replacement} if the type of the | 734 // We might need to guard the {replacement} if the type of the |
734 // {node} is more precise than the type of the {replacement}. | 735 // {node} is more precise than the type of the {replacement}. |
735 Type* const node_type = NodeProperties::GetType(node); | 736 Type* const node_type = NodeProperties::GetType(node); |
736 if (!NodeProperties::GetType(replacement)->Is(node_type)) { | 737 if (!NodeProperties::GetType(replacement)->Is(node_type)) { |
737 replacement = graph()->NewNode(common()->TypeGuard(node_type), | 738 replacement = graph()->NewNode(common()->TypeGuard(node_type), |
738 replacement, control); | 739 replacement, control); |
| 740 NodeProperties::SetType(replacement, node_type); |
739 } | 741 } |
740 ReplaceWithValue(node, replacement, effect); | 742 ReplaceWithValue(node, replacement, effect); |
741 return Replace(replacement); | 743 return Replace(replacement); |
742 } | 744 } |
743 } | 745 } |
744 state = state->AddField(object, field_index, node, zone()); | 746 state = state->AddField(object, field_index, node, zone()); |
745 } | 747 } |
746 } | 748 } |
747 Handle<Map> field_map; | 749 Handle<Map> field_map; |
748 if (access.map.ToHandle(&field_map)) { | 750 if (access.map.ToHandle(&field_map)) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 if (state == nullptr) return NoChange(); | 800 if (state == nullptr) return NoChange(); |
799 if (Node* replacement = state->LookupElement(object, index)) { | 801 if (Node* replacement = state->LookupElement(object, index)) { |
800 // Make sure we don't resurrect dead {replacement} nodes. | 802 // Make sure we don't resurrect dead {replacement} nodes. |
801 if (!replacement->IsDead()) { | 803 if (!replacement->IsDead()) { |
802 // We might need to guard the {replacement} if the type of the | 804 // We might need to guard the {replacement} if the type of the |
803 // {node} is more precise than the type of the {replacement}. | 805 // {node} is more precise than the type of the {replacement}. |
804 Type* const node_type = NodeProperties::GetType(node); | 806 Type* const node_type = NodeProperties::GetType(node); |
805 if (!NodeProperties::GetType(replacement)->Is(node_type)) { | 807 if (!NodeProperties::GetType(replacement)->Is(node_type)) { |
806 replacement = graph()->NewNode(common()->TypeGuard(node_type), | 808 replacement = graph()->NewNode(common()->TypeGuard(node_type), |
807 replacement, control); | 809 replacement, control); |
| 810 NodeProperties::SetType(replacement, node_type); |
808 } | 811 } |
809 ReplaceWithValue(node, replacement, effect); | 812 ReplaceWithValue(node, replacement, effect); |
810 return Replace(replacement); | 813 return Replace(replacement); |
811 } | 814 } |
812 } | 815 } |
813 state = state->AddElement(object, index, node, zone()); | 816 state = state->AddElement(object, index, node, zone()); |
814 return UpdateState(node, state); | 817 return UpdateState(node, state); |
815 } | 818 } |
816 | 819 |
817 Reduction LoadElimination::ReduceStoreElement(Node* node) { | 820 Reduction LoadElimination::ReduceStoreElement(Node* node) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 return jsgraph()->common(); | 1071 return jsgraph()->common(); |
1069 } | 1072 } |
1070 | 1073 |
1071 Graph* LoadElimination::graph() const { return jsgraph()->graph(); } | 1074 Graph* LoadElimination::graph() const { return jsgraph()->graph(); } |
1072 | 1075 |
1073 Factory* LoadElimination::factory() const { return jsgraph()->factory(); } | 1076 Factory* LoadElimination::factory() const { return jsgraph()->factory(); } |
1074 | 1077 |
1075 } // namespace compiler | 1078 } // namespace compiler |
1076 } // namespace internal | 1079 } // namespace internal |
1077 } // namespace v8 | 1080 } // namespace v8 |
OLD | NEW |