OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/load-elimination.h" | 5 #include "src/compiler/load-elimination.h" |
6 | 6 |
7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 case IrOpcode::kTransitionElementsKind: | 56 case IrOpcode::kTransitionElementsKind: |
57 return ReduceTransitionElementsKind(node); | 57 return ReduceTransitionElementsKind(node); |
58 case IrOpcode::kLoadField: | 58 case IrOpcode::kLoadField: |
59 return ReduceLoadField(node); | 59 return ReduceLoadField(node); |
60 case IrOpcode::kStoreField: | 60 case IrOpcode::kStoreField: |
61 return ReduceStoreField(node); | 61 return ReduceStoreField(node); |
62 case IrOpcode::kLoadElement: | 62 case IrOpcode::kLoadElement: |
63 return ReduceLoadElement(node); | 63 return ReduceLoadElement(node); |
64 case IrOpcode::kStoreElement: | 64 case IrOpcode::kStoreElement: |
65 return ReduceStoreElement(node); | 65 return ReduceStoreElement(node); |
| 66 case IrOpcode::kStoreTypedElement: |
| 67 return ReduceStoreTypedElement(node); |
66 case IrOpcode::kEffectPhi: | 68 case IrOpcode::kEffectPhi: |
67 return ReduceEffectPhi(node); | 69 return ReduceEffectPhi(node); |
68 case IrOpcode::kDead: | 70 case IrOpcode::kDead: |
69 break; | 71 break; |
70 case IrOpcode::kStart: | 72 case IrOpcode::kStart: |
71 return ReduceStart(node); | 73 return ReduceStart(node); |
72 default: | 74 default: |
73 return ReduceOtherNode(node); | 75 return ReduceOtherNode(node); |
74 } | 76 } |
75 return NoChange(); | 77 return NoChange(); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 break; | 450 break; |
449 case MachineRepresentation::kFloat64: | 451 case MachineRepresentation::kFloat64: |
450 case MachineRepresentation::kSimd128: | 452 case MachineRepresentation::kSimd128: |
451 case MachineRepresentation::kTagged: | 453 case MachineRepresentation::kTagged: |
452 state = state->AddElement(object, index, new_value, zone()); | 454 state = state->AddElement(object, index, new_value, zone()); |
453 break; | 455 break; |
454 } | 456 } |
455 return UpdateState(node, state); | 457 return UpdateState(node, state); |
456 } | 458 } |
457 | 459 |
| 460 Reduction LoadElimination::ReduceStoreTypedElement(Node* node) { |
| 461 Node* const effect = NodeProperties::GetEffectInput(node); |
| 462 AbstractState const* state = node_states_.Get(effect); |
| 463 if (state == nullptr) return NoChange(); |
| 464 return UpdateState(node, state); |
| 465 } |
| 466 |
458 Reduction LoadElimination::ReduceEffectPhi(Node* node) { | 467 Reduction LoadElimination::ReduceEffectPhi(Node* node) { |
459 Node* const effect0 = NodeProperties::GetEffectInput(node, 0); | 468 Node* const effect0 = NodeProperties::GetEffectInput(node, 0); |
460 Node* const control = NodeProperties::GetControlInput(node); | 469 Node* const control = NodeProperties::GetControlInput(node); |
461 AbstractState const* state0 = node_states_.Get(effect0); | 470 AbstractState const* state0 = node_states_.Get(effect0); |
462 if (state0 == nullptr) return NoChange(); | 471 if (state0 == nullptr) return NoChange(); |
463 if (control->opcode() == IrOpcode::kLoop) { | 472 if (control->opcode() == IrOpcode::kLoop) { |
464 // Here we rely on having only reducible loops: | 473 // Here we rely on having only reducible loops: |
465 // The loop entry edge always dominates the header, so we can just take | 474 // The loop entry edge always dominates the header, so we can just take |
466 // the state from the first input, and compute the loop state based on it. | 475 // the state from the first input, and compute the loop state based on it. |
467 AbstractState const* state = ComputeLoopState(node, state0); | 476 AbstractState const* state = ComputeLoopState(node, state0); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 for (int i = 0; i < current->op()->EffectInputCount(); ++i) { | 573 for (int i = 0; i < current->op()->EffectInputCount(); ++i) { |
565 queue.push(NodeProperties::GetEffectInput(current, i)); | 574 queue.push(NodeProperties::GetEffectInput(current, i)); |
566 } | 575 } |
567 } | 576 } |
568 } | 577 } |
569 return state; | 578 return state; |
570 } | 579 } |
571 | 580 |
572 // static | 581 // static |
573 int LoadElimination::FieldIndexOf(FieldAccess const& access) { | 582 int LoadElimination::FieldIndexOf(FieldAccess const& access) { |
574 switch (access.machine_type.representation()) { | 583 MachineRepresentation rep = access.machine_type.representation(); |
| 584 switch (rep) { |
575 case MachineRepresentation::kNone: | 585 case MachineRepresentation::kNone: |
576 case MachineRepresentation::kBit: | 586 case MachineRepresentation::kBit: |
577 UNREACHABLE(); | 587 UNREACHABLE(); |
578 break; | 588 break; |
| 589 case MachineRepresentation::kWord32: |
| 590 case MachineRepresentation::kWord64: |
| 591 if (rep != MachineType::PointerRepresentation()) { |
| 592 return -1; // We currently only track pointer size fields. |
| 593 } |
| 594 break; |
579 case MachineRepresentation::kWord8: | 595 case MachineRepresentation::kWord8: |
580 case MachineRepresentation::kWord16: | 596 case MachineRepresentation::kWord16: |
581 case MachineRepresentation::kWord32: | |
582 case MachineRepresentation::kWord64: | |
583 case MachineRepresentation::kFloat32: | 597 case MachineRepresentation::kFloat32: |
584 return -1; // Currently untracked. | 598 return -1; // Currently untracked. |
585 case MachineRepresentation::kFloat64: | 599 case MachineRepresentation::kFloat64: |
586 case MachineRepresentation::kSimd128: | 600 case MachineRepresentation::kSimd128: |
587 case MachineRepresentation::kTagged: | 601 case MachineRepresentation::kTagged: |
588 // TODO(bmeurer): Check that we never do overlapping load/stores of | 602 // TODO(bmeurer): Check that we never do overlapping load/stores of |
589 // individual parts of Float64/Simd128 values. | 603 // individual parts of Float64/Simd128 values. |
590 break; | 604 break; |
591 } | 605 } |
592 DCHECK_EQ(kTaggedBase, access.base_is_tagged); | 606 DCHECK_EQ(kTaggedBase, access.base_is_tagged); |
593 DCHECK_EQ(0, access.offset % kPointerSize); | 607 DCHECK_EQ(0, access.offset % kPointerSize); |
594 int field_index = access.offset / kPointerSize; | 608 int field_index = access.offset / kPointerSize; |
595 if (field_index >= static_cast<int>(kMaxTrackedFields)) return -1; | 609 if (field_index >= static_cast<int>(kMaxTrackedFields)) return -1; |
596 return field_index; | 610 return field_index; |
597 } | 611 } |
598 | 612 |
599 } // namespace compiler | 613 } // namespace compiler |
600 } // namespace internal | 614 } // namespace internal |
601 } // namespace v8 | 615 } // namespace v8 |
OLD | NEW |