Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(734)

Side by Side Diff: src/compiler/js-builtin-reducer.cc

Issue 2635243002: [turbofan] Refactor IsSame into NodeProperties. (Closed)
Patch Set: Update. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/compiler/js-call-reducer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/js-builtin-reducer.h" 5 #include "src/compiler/js-builtin-reducer.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/compilation-dependencies.h" 8 #include "src/compilation-dependencies.h"
9 #include "src/compiler/access-builder.h" 9 #include "src/compiler/access-builder.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 Handle<Context> native_context) 101 Handle<Context> native_context)
102 : AdvancedReducer(editor), 102 : AdvancedReducer(editor),
103 dependencies_(dependencies), 103 dependencies_(dependencies),
104 flags_(flags), 104 flags_(flags),
105 jsgraph_(jsgraph), 105 jsgraph_(jsgraph),
106 native_context_(native_context), 106 native_context_(native_context),
107 type_cache_(TypeCache::Get()) {} 107 type_cache_(TypeCache::Get()) {}
108 108
109 namespace { 109 namespace {
110 110
111 // TODO(turbofan): Shall we move this to the NodeProperties? Or some (untyped)
112 // alias analyzer?
113 bool IsSame(Node* a, Node* b) {
114 if (a == b) {
115 return true;
116 } else if (a->opcode() == IrOpcode::kCheckHeapObject) {
117 return IsSame(a->InputAt(0), b);
118 } else if (b->opcode() == IrOpcode::kCheckHeapObject) {
119 return IsSame(a, b->InputAt(0));
120 }
121 return false;
122 }
123
124 MaybeHandle<Map> GetMapWitness(Node* node) { 111 MaybeHandle<Map> GetMapWitness(Node* node) {
125 Node* receiver = NodeProperties::GetValueInput(node, 1); 112 Node* receiver = NodeProperties::GetValueInput(node, 1);
126 Node* effect = NodeProperties::GetEffectInput(node); 113 Node* effect = NodeProperties::GetEffectInput(node);
127 // Check if the {node} is dominated by a CheckMaps with a single map 114 // Check if the {node} is dominated by a CheckMaps with a single map
128 // for the {receiver}, and if so use that map for the lowering below. 115 // for the {receiver}, and if so use that map for the lowering below.
129 for (Node* dominator = effect;;) { 116 for (Node* dominator = effect;;) {
130 if (dominator->opcode() == IrOpcode::kCheckMaps && 117 if (dominator->opcode() == IrOpcode::kCheckMaps &&
131 IsSame(dominator->InputAt(0), receiver)) { 118 NodeProperties::IsSame(dominator->InputAt(0), receiver)) {
132 ZoneHandleSet<Map> const& maps = 119 ZoneHandleSet<Map> const& maps =
133 CheckMapsParametersOf(dominator->op()).maps(); 120 CheckMapsParametersOf(dominator->op()).maps();
134 return (maps.size() == 1) ? MaybeHandle<Map>(maps[0]) 121 return (maps.size() == 1) ? MaybeHandle<Map>(maps[0])
135 : MaybeHandle<Map>(); 122 : MaybeHandle<Map>();
136 } 123 }
137 if (dominator->op()->EffectInputCount() != 1) { 124 if (dominator->op()->EffectInputCount() != 1) {
138 // Didn't find any appropriate CheckMaps node. 125 // Didn't find any appropriate CheckMaps node.
139 return MaybeHandle<Map>(); 126 return MaybeHandle<Map>();
140 } 127 }
141 dominator = NodeProperties::GetEffectInput(dominator); 128 dominator = NodeProperties::GetEffectInput(dominator);
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 894 }
908 return NoChange(); 895 return NoChange();
909 } 896 }
910 897
911 namespace { 898 namespace {
912 899
913 bool HasInstanceTypeWitness(Node* receiver, Node* effect, 900 bool HasInstanceTypeWitness(Node* receiver, Node* effect,
914 InstanceType instance_type) { 901 InstanceType instance_type) {
915 for (Node* dominator = effect;;) { 902 for (Node* dominator = effect;;) {
916 if (dominator->opcode() == IrOpcode::kCheckMaps && 903 if (dominator->opcode() == IrOpcode::kCheckMaps &&
917 IsSame(dominator->InputAt(0), receiver)) { 904 NodeProperties::IsSame(dominator->InputAt(0), receiver)) {
918 ZoneHandleSet<Map> const& maps = 905 ZoneHandleSet<Map> const& maps =
919 CheckMapsParametersOf(dominator->op()).maps(); 906 CheckMapsParametersOf(dominator->op()).maps();
920 // Check if all maps have the given {instance_type}. 907 // Check if all maps have the given {instance_type}.
921 for (size_t i = 0; i < maps.size(); ++i) { 908 for (size_t i = 0; i < maps.size(); ++i) {
922 if (maps[i]->instance_type() != instance_type) return false; 909 if (maps[i]->instance_type() != instance_type) return false;
923 } 910 }
924 return true; 911 return true;
925 } 912 }
926 switch (dominator->opcode()) { 913 switch (dominator->opcode()) {
927 case IrOpcode::kStoreField: { 914 case IrOpcode::kStoreField: {
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 Node* GetStringWitness(Node* node) { 1601 Node* GetStringWitness(Node* node) {
1615 Node* receiver = NodeProperties::GetValueInput(node, 1); 1602 Node* receiver = NodeProperties::GetValueInput(node, 1);
1616 Type* receiver_type = NodeProperties::GetType(receiver); 1603 Type* receiver_type = NodeProperties::GetType(receiver);
1617 Node* effect = NodeProperties::GetEffectInput(node); 1604 Node* effect = NodeProperties::GetEffectInput(node);
1618 if (receiver_type->Is(Type::String())) return receiver; 1605 if (receiver_type->Is(Type::String())) return receiver;
1619 // Check if the {node} is dominated by a CheckString renaming for 1606 // Check if the {node} is dominated by a CheckString renaming for
1620 // it's {receiver}, and if so use that renaming as {receiver} for 1607 // it's {receiver}, and if so use that renaming as {receiver} for
1621 // the lowering below. 1608 // the lowering below.
1622 for (Node* dominator = effect;;) { 1609 for (Node* dominator = effect;;) {
1623 if (dominator->opcode() == IrOpcode::kCheckString && 1610 if (dominator->opcode() == IrOpcode::kCheckString &&
1624 IsSame(dominator->InputAt(0), receiver)) { 1611 NodeProperties::IsSame(dominator->InputAt(0), receiver)) {
1625 return dominator; 1612 return dominator;
1626 } 1613 }
1627 if (dominator->op()->EffectInputCount() != 1) { 1614 if (dominator->op()->EffectInputCount() != 1) {
1628 // Didn't find any appropriate CheckString node. 1615 // Didn't find any appropriate CheckString node.
1629 return nullptr; 1616 return nullptr;
1630 } 1617 }
1631 dominator = NodeProperties::GetEffectInput(dominator); 1618 dominator = NodeProperties::GetEffectInput(dominator);
1632 } 1619 }
1633 } 1620 }
1634 1621
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
2181 return jsgraph()->simplified(); 2168 return jsgraph()->simplified();
2182 } 2169 }
2183 2170
2184 JSOperatorBuilder* JSBuiltinReducer::javascript() const { 2171 JSOperatorBuilder* JSBuiltinReducer::javascript() const {
2185 return jsgraph()->javascript(); 2172 return jsgraph()->javascript();
2186 } 2173 }
2187 2174
2188 } // namespace compiler 2175 } // namespace compiler
2189 } // namespace internal 2176 } // namespace internal
2190 } // namespace v8 2177 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/js-call-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698