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/compiler/js-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
6 | 6 |
7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 namespace { | 106 namespace { |
107 | 107 |
108 MaybeHandle<Map> GetMapWitness(Node* node) { | 108 MaybeHandle<Map> GetMapWitness(Node* node) { |
109 Node* receiver = NodeProperties::GetValueInput(node, 1); | 109 Node* receiver = NodeProperties::GetValueInput(node, 1); |
110 Node* effect = NodeProperties::GetEffectInput(node); | 110 Node* effect = NodeProperties::GetEffectInput(node); |
111 // Check if the {node} is dominated by a CheckMaps with a single map | 111 // Check if the {node} is dominated by a CheckMaps with a single map |
112 // for the {receiver}, and if so use that map for the lowering below. | 112 // for the {receiver}, and if so use that map for the lowering below. |
113 for (Node* dominator = effect;;) { | 113 for (Node* dominator = effect;;) { |
114 if (dominator->opcode() == IrOpcode::kCheckMaps && | 114 if (dominator->opcode() == IrOpcode::kCheckMaps && |
115 dominator->InputAt(0) == receiver) { | 115 dominator->InputAt(0) == receiver) { |
116 if (dominator->op()->ValueInputCount() == 2) { | 116 ZoneHandleSet<Map> const& maps = |
117 HeapObjectMatcher m(dominator->InputAt(1)); | 117 CheckMapsParametersOf(dominator->op()).maps(); |
118 if (m.HasValue()) return Handle<Map>::cast(m.Value()); | 118 return (maps.size() == 1) ? MaybeHandle<Map>(maps[0]) |
119 } | 119 : MaybeHandle<Map>(); |
120 return MaybeHandle<Map>(); | |
121 } | 120 } |
122 if (dominator->op()->EffectInputCount() != 1) { | 121 if (dominator->op()->EffectInputCount() != 1) { |
123 // Didn't find any appropriate CheckMaps node. | 122 // Didn't find any appropriate CheckMaps node. |
124 return MaybeHandle<Map>(); | 123 return MaybeHandle<Map>(); |
125 } | 124 } |
126 dominator = NodeProperties::GetEffectInput(dominator); | 125 dominator = NodeProperties::GetEffectInput(dominator); |
127 } | 126 } |
128 } | 127 } |
129 | 128 |
130 // TODO(turbofan): This was copied from Crankshaft, might be too restrictive. | 129 // TODO(turbofan): This was copied from Crankshaft, might be too restrictive. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 return NoChange(); | 318 return NoChange(); |
320 } | 319 } |
321 | 320 |
322 namespace { | 321 namespace { |
323 | 322 |
324 bool HasInstanceTypeWitness(Node* receiver, Node* effect, | 323 bool HasInstanceTypeWitness(Node* receiver, Node* effect, |
325 InstanceType instance_type) { | 324 InstanceType instance_type) { |
326 for (Node* dominator = effect;;) { | 325 for (Node* dominator = effect;;) { |
327 if (dominator->opcode() == IrOpcode::kCheckMaps && | 326 if (dominator->opcode() == IrOpcode::kCheckMaps && |
328 dominator->InputAt(0) == receiver) { | 327 dominator->InputAt(0) == receiver) { |
| 328 ZoneHandleSet<Map> const& maps = |
| 329 CheckMapsParametersOf(dominator->op()).maps(); |
329 // Check if all maps have the given {instance_type}. | 330 // Check if all maps have the given {instance_type}. |
330 for (int i = 1; i < dominator->op()->ValueInputCount(); ++i) { | 331 for (size_t i = 0; i < maps.size(); ++i) { |
331 Node* const map = NodeProperties::GetValueInput(dominator, i); | 332 if (maps[i]->instance_type() != instance_type) return false; |
332 Type* const map_type = NodeProperties::GetType(map); | |
333 if (!map_type->IsConstant()) return false; | |
334 Handle<Map> const map_value = | |
335 Handle<Map>::cast(map_type->AsConstant()->Value()); | |
336 if (map_value->instance_type() != instance_type) return false; | |
337 } | 333 } |
338 return true; | 334 return true; |
339 } | 335 } |
340 switch (dominator->opcode()) { | 336 switch (dominator->opcode()) { |
341 case IrOpcode::kStoreField: { | 337 case IrOpcode::kStoreField: { |
342 FieldAccess const& access = FieldAccessOf(dominator->op()); | 338 FieldAccess const& access = FieldAccessOf(dominator->op()); |
343 if (access.base_is_tagged == kTaggedBase && | 339 if (access.base_is_tagged == kTaggedBase && |
344 access.offset == HeapObject::kMapOffset) { | 340 access.offset == HeapObject::kMapOffset) { |
345 return false; | 341 return false; |
346 } | 342 } |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 } | 1246 } |
1251 | 1247 |
1252 | 1248 |
1253 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { | 1249 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { |
1254 return jsgraph()->simplified(); | 1250 return jsgraph()->simplified(); |
1255 } | 1251 } |
1256 | 1252 |
1257 } // namespace compiler | 1253 } // namespace compiler |
1258 } // namespace internal | 1254 } // namespace internal |
1259 } // namespace v8 | 1255 } // namespace v8 |
OLD | NEW |