| 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/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
| 10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 : AdvancedReducer(editor), | 103 : AdvancedReducer(editor), |
| 104 dependencies_(dependencies), | 104 dependencies_(dependencies), |
| 105 flags_(flags), | 105 flags_(flags), |
| 106 jsgraph_(jsgraph), | 106 jsgraph_(jsgraph), |
| 107 native_context_(native_context), | 107 native_context_(native_context), |
| 108 type_cache_(TypeCache::Get()) {} | 108 type_cache_(TypeCache::Get()) {} |
| 109 | 109 |
| 110 namespace { | 110 namespace { |
| 111 | 111 |
| 112 MaybeHandle<Map> GetMapWitness(Node* node) { | 112 MaybeHandle<Map> GetMapWitness(Node* node) { |
| 113 ZoneHandleSet<Map> maps; |
| 113 Node* receiver = NodeProperties::GetValueInput(node, 1); | 114 Node* receiver = NodeProperties::GetValueInput(node, 1); |
| 114 Node* effect = NodeProperties::GetEffectInput(node); | 115 Node* effect = NodeProperties::GetEffectInput(node); |
| 115 // Check if the {node} is dominated by a CheckMaps with a single map | 116 if (NodeProperties::InferReceiverMaps(receiver, effect, &maps)) { |
| 116 // for the {receiver}, and if so use that map for the lowering below. | 117 if (maps.size() == 1) return MaybeHandle<Map>(maps[0]); |
| 117 for (Node* dominator = effect;;) { | |
| 118 if (dominator->opcode() == IrOpcode::kCheckMaps && | |
| 119 NodeProperties::IsSame(dominator->InputAt(0), receiver)) { | |
| 120 ZoneHandleSet<Map> const& maps = | |
| 121 CheckMapsParametersOf(dominator->op()).maps(); | |
| 122 return (maps.size() == 1) ? MaybeHandle<Map>(maps[0]) | |
| 123 : MaybeHandle<Map>(); | |
| 124 } | |
| 125 DCHECK_EQ(1, dominator->op()->EffectOutputCount()); | |
| 126 if (dominator->op()->EffectInputCount() != 1 || | |
| 127 !dominator->op()->HasProperty(Operator::kNoWrite)) { | |
| 128 // Didn't find any appropriate CheckMaps node. | |
| 129 return MaybeHandle<Map>(); | |
| 130 } | |
| 131 dominator = NodeProperties::GetEffectInput(dominator); | |
| 132 } | 118 } |
| 119 return MaybeHandle<Map>(); |
| 133 } | 120 } |
| 134 | 121 |
| 135 // TODO(turbofan): This was copied from Crankshaft, might be too restrictive. | 122 // TODO(turbofan): This was copied from Crankshaft, might be too restrictive. |
| 136 bool IsReadOnlyLengthDescriptor(Handle<Map> jsarray_map) { | 123 bool IsReadOnlyLengthDescriptor(Handle<Map> jsarray_map) { |
| 137 DCHECK(!jsarray_map->is_dictionary_map()); | 124 DCHECK(!jsarray_map->is_dictionary_map()); |
| 138 Isolate* isolate = jsarray_map->GetIsolate(); | 125 Isolate* isolate = jsarray_map->GetIsolate(); |
| 139 Handle<Name> length_string = isolate->factory()->length_string(); | 126 Handle<Name> length_string = isolate->factory()->length_string(); |
| 140 DescriptorArray* descriptors = jsarray_map->instance_descriptors(); | 127 DescriptorArray* descriptors = jsarray_map->instance_descriptors(); |
| 141 int number = | 128 int number = |
| 142 descriptors->SearchWithCache(isolate, *length_string, *jsarray_map); | 129 descriptors->SearchWithCache(isolate, *length_string, *jsarray_map); |
| (...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 return jsgraph()->simplified(); | 2178 return jsgraph()->simplified(); |
| 2192 } | 2179 } |
| 2193 | 2180 |
| 2194 JSOperatorBuilder* JSBuiltinReducer::javascript() const { | 2181 JSOperatorBuilder* JSBuiltinReducer::javascript() const { |
| 2195 return jsgraph()->javascript(); | 2182 return jsgraph()->javascript(); |
| 2196 } | 2183 } |
| 2197 | 2184 |
| 2198 } // namespace compiler | 2185 } // namespace compiler |
| 2199 } // namespace internal | 2186 } // namespace internal |
| 2200 } // namespace v8 | 2187 } // namespace v8 |
| OLD | NEW |