OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-call-reducer.h" | 5 #include "src/compiler/js-call-reducer.h" |
6 | 6 |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 NodeProperties::ChangeOp( | 184 NodeProperties::ChangeOp( |
185 node, javascript()->CallFunction(arity, p.frequency(), VectorSlotPair(), | 185 node, javascript()->CallFunction(arity, p.frequency(), VectorSlotPair(), |
186 convert_mode, p.tail_call_mode())); | 186 convert_mode, p.tail_call_mode())); |
187 // Try to further reduce the JSCallFunction {node}. | 187 // Try to further reduce the JSCallFunction {node}. |
188 Reduction const reduction = ReduceJSCallFunction(node); | 188 Reduction const reduction = ReduceJSCallFunction(node); |
189 return reduction.Changed() ? reduction : Changed(node); | 189 return reduction.Changed() ? reduction : Changed(node); |
190 } | 190 } |
191 | 191 |
192 namespace { | 192 namespace { |
193 | 193 |
| 194 // TODO(turbofan): Shall we move this to the NodeProperties? Or some (untyped) |
| 195 // alias analyzer? |
| 196 bool IsSame(Node* a, Node* b) { |
| 197 if (a == b) { |
| 198 return true; |
| 199 } else if (a->opcode() == IrOpcode::kCheckHeapObject) { |
| 200 return IsSame(a->InputAt(0), b); |
| 201 } else if (b->opcode() == IrOpcode::kCheckHeapObject) { |
| 202 return IsSame(a, b->InputAt(0)); |
| 203 } |
| 204 return false; |
| 205 } |
| 206 |
194 // TODO(turbofan): Share with similar functionality in JSInliningHeuristic | 207 // TODO(turbofan): Share with similar functionality in JSInliningHeuristic |
195 // and JSNativeContextSpecialization, i.e. move to NodeProperties helper?! | 208 // and JSNativeContextSpecialization, i.e. move to NodeProperties helper?! |
196 MaybeHandle<Map> InferReceiverMap(Node* node) { | 209 MaybeHandle<Map> InferReceiverMap(Node* node) { |
197 Node* receiver = NodeProperties::GetValueInput(node, 1); | 210 Node* receiver = NodeProperties::GetValueInput(node, 1); |
198 Node* effect = NodeProperties::GetEffectInput(node); | 211 Node* effect = NodeProperties::GetEffectInput(node); |
199 // Check if the {node} is dominated by a CheckMaps with a single map | 212 // Check if the {node} is dominated by a CheckMaps with a single map |
200 // for the {receiver}, and if so use that map for the lowering below. | 213 // for the {receiver}, and if so use that map for the lowering below. |
201 for (Node* dominator = effect;;) { | 214 for (Node* dominator = effect;;) { |
202 if (dominator->opcode() == IrOpcode::kCheckMaps && | 215 if (dominator->opcode() == IrOpcode::kCheckMaps && |
203 dominator->InputAt(0) == receiver) { | 216 IsSame(dominator->InputAt(0), receiver)) { |
204 if (dominator->op()->ValueInputCount() == 2) { | 217 if (dominator->op()->ValueInputCount() == 2) { |
205 HeapObjectMatcher m(dominator->InputAt(1)); | 218 HeapObjectMatcher m(dominator->InputAt(1)); |
206 if (m.HasValue()) return Handle<Map>::cast(m.Value()); | 219 if (m.HasValue()) return Handle<Map>::cast(m.Value()); |
207 } | 220 } |
208 return MaybeHandle<Map>(); | 221 return MaybeHandle<Map>(); |
209 } | 222 } |
210 if (dominator->op()->EffectInputCount() != 1) { | 223 if (dominator->op()->EffectInputCount() != 1) { |
211 // Didn't find any appropriate CheckMaps node. | 224 // Didn't find any appropriate CheckMaps node. |
212 return MaybeHandle<Map>(); | 225 return MaybeHandle<Map>(); |
213 } | 226 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 return jsgraph()->javascript(); | 515 return jsgraph()->javascript(); |
503 } | 516 } |
504 | 517 |
505 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { | 518 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { |
506 return jsgraph()->simplified(); | 519 return jsgraph()->simplified(); |
507 } | 520 } |
508 | 521 |
509 } // namespace compiler | 522 } // namespace compiler |
510 } // namespace internal | 523 } // namespace internal |
511 } // namespace v8 | 524 } // namespace v8 |
OLD | NEW |