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-inlining.h" | 5 #include "src/compiler/js-inlining.h" |
6 | 6 |
7 #include "src/ast/ast-numbering.h" | 7 #include "src/ast/ast-numbering.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 BailoutId(-1), OutputFrameStateCombine::Ignore(), state_info); | 275 BailoutId(-1), OutputFrameStateCombine::Ignore(), state_info); |
276 const Operator* op0 = common()->StateValues(0); | 276 const Operator* op0 = common()->StateValues(0); |
277 Node* node0 = graph()->NewNode(op0); | 277 Node* node0 = graph()->NewNode(op0); |
278 return graph()->NewNode(op, node0, node0, node0, | 278 return graph()->NewNode(op, node0, node0, node0, |
279 jsgraph()->UndefinedConstant(), function, | 279 jsgraph()->UndefinedConstant(), function, |
280 frame_state); | 280 frame_state); |
281 } | 281 } |
282 | 282 |
283 namespace { | 283 namespace { |
284 | 284 |
| 285 // TODO(turbofan): Shall we move this to the NodeProperties? Or some (untyped) |
| 286 // alias analyzer? |
| 287 bool IsSame(Node* a, Node* b) { |
| 288 if (a == b) { |
| 289 return true; |
| 290 } else if (a->opcode() == IrOpcode::kCheckHeapObject) { |
| 291 return IsSame(a->InputAt(0), b); |
| 292 } else if (b->opcode() == IrOpcode::kCheckHeapObject) { |
| 293 return IsSame(a, b->InputAt(0)); |
| 294 } |
| 295 return false; |
| 296 } |
| 297 |
285 // TODO(bmeurer): Unify this with the witness helper functions in the | 298 // TODO(bmeurer): Unify this with the witness helper functions in the |
286 // js-builtin-reducer.cc once we have a better understanding of the | 299 // js-builtin-reducer.cc once we have a better understanding of the |
287 // map tracking we want to do, and eventually changed the CheckMaps | 300 // map tracking we want to do, and eventually changed the CheckMaps |
288 // operator to carry map constants on the operator instead of inputs. | 301 // operator to carry map constants on the operator instead of inputs. |
289 // I.e. if the CheckMaps has some kind of SmallMapSet as operator | 302 // I.e. if the CheckMaps has some kind of SmallMapSet as operator |
290 // parameter, then this could be changed to call a generic | 303 // parameter, then this could be changed to call a generic |
291 // | 304 // |
292 // SmallMapSet NodeProperties::CollectMapWitness(receiver, effect) | 305 // SmallMapSet NodeProperties::CollectMapWitness(receiver, effect) |
293 // | 306 // |
294 // function, which either returns the map set from the CheckMaps or | 307 // function, which either returns the map set from the CheckMaps or |
295 // a singleton set from a StoreField. | 308 // a singleton set from a StoreField. |
296 bool NeedsConvertReceiver(Node* receiver, Node* effect) { | 309 bool NeedsConvertReceiver(Node* receiver, Node* effect) { |
297 for (Node* dominator = effect;;) { | 310 for (Node* dominator = effect;;) { |
298 if (dominator->opcode() == IrOpcode::kCheckMaps && | 311 if (dominator->opcode() == IrOpcode::kCheckMaps && |
299 dominator->InputAt(0) == receiver) { | 312 IsSame(dominator->InputAt(0), receiver)) { |
300 // Check if all maps have the given {instance_type}. | 313 // Check if all maps have the given {instance_type}. |
301 for (int i = 1; i < dominator->op()->ValueInputCount(); ++i) { | 314 for (int i = 1; i < dominator->op()->ValueInputCount(); ++i) { |
302 HeapObjectMatcher m(NodeProperties::GetValueInput(dominator, i)); | 315 HeapObjectMatcher m(NodeProperties::GetValueInput(dominator, i)); |
303 if (!m.HasValue()) return true; | 316 if (!m.HasValue()) return true; |
304 Handle<Map> const map = Handle<Map>::cast(m.Value()); | 317 Handle<Map> const map = Handle<Map>::cast(m.Value()); |
305 if (!map->IsJSReceiverMap()) return true; | 318 if (!map->IsJSReceiverMap()) return true; |
306 } | 319 } |
307 return false; | 320 return false; |
308 } | 321 } |
309 switch (dominator->opcode()) { | 322 switch (dominator->opcode()) { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 | 704 |
692 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } | 705 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } |
693 | 706 |
694 SimplifiedOperatorBuilder* JSInliner::simplified() const { | 707 SimplifiedOperatorBuilder* JSInliner::simplified() const { |
695 return jsgraph()->simplified(); | 708 return jsgraph()->simplified(); |
696 } | 709 } |
697 | 710 |
698 } // namespace compiler | 711 } // namespace compiler |
699 } // namespace internal | 712 } // namespace internal |
700 } // namespace v8 | 713 } // namespace v8 |
OLD | NEW |