| 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/machine-graph-verifier.h" | 5 #include "src/compiler/machine-graph-verifier.h" |
| 6 | 6 |
| 7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 : MachineRepresentation::kBit; | 59 : MachineRepresentation::kBit; |
| 60 case IrOpcode::kCall: { | 60 case IrOpcode::kCall: { |
| 61 CallDescriptor const* desc = CallDescriptorOf(input->op()); | 61 CallDescriptor const* desc = CallDescriptorOf(input->op()); |
| 62 return desc->GetReturnType(index).representation(); | 62 return desc->GetReturnType(index).representation(); |
| 63 } | 63 } |
| 64 default: | 64 default: |
| 65 return MachineRepresentation::kNone; | 65 return MachineRepresentation::kNone; |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 MachineRepresentation PromoteRepresentation(MachineRepresentation rep) { |
| 70 switch (rep) { |
| 71 case MachineRepresentation::kWord8: |
| 72 case MachineRepresentation::kWord16: |
| 73 case MachineRepresentation::kWord32: |
| 74 return MachineRepresentation::kWord32; |
| 75 default: |
| 76 break; |
| 77 } |
| 78 return rep; |
| 79 } |
| 80 |
| 69 void Run() { | 81 void Run() { |
| 70 auto blocks = schedule_->all_blocks(); | 82 auto blocks = schedule_->all_blocks(); |
| 71 for (BasicBlock* block : *blocks) { | 83 for (BasicBlock* block : *blocks) { |
| 72 for (size_t i = 0; i <= block->NodeCount(); ++i) { | 84 for (size_t i = 0; i <= block->NodeCount(); ++i) { |
| 73 Node const* node = | 85 Node const* node = |
| 74 i < block->NodeCount() ? block->NodeAt(i) : block->control_input(); | 86 i < block->NodeCount() ? block->NodeAt(i) : block->control_input(); |
| 75 if (node == nullptr) { | 87 if (node == nullptr) { |
| 76 DCHECK_EQ(block->NodeCount(), i); | 88 DCHECK_EQ(block->NodeCount(), i); |
| 77 break; | 89 break; |
| 78 } | 90 } |
| 79 switch (node->opcode()) { | 91 switch (node->opcode()) { |
| 80 case IrOpcode::kParameter: | 92 case IrOpcode::kParameter: |
| 81 representation_vector_[node->id()] = | 93 representation_vector_[node->id()] = |
| 82 linkage_->GetParameterType(ParameterIndexOf(node->op())) | 94 linkage_->GetParameterType(ParameterIndexOf(node->op())) |
| 83 .representation(); | 95 .representation(); |
| 84 break; | 96 break; |
| 85 case IrOpcode::kProjection: { | 97 case IrOpcode::kProjection: { |
| 86 representation_vector_[node->id()] = GetProjectionType(node); | 98 representation_vector_[node->id()] = GetProjectionType(node); |
| 87 } break; | 99 } break; |
| 88 case IrOpcode::kTypedStateValues: | 100 case IrOpcode::kTypedStateValues: |
| 89 representation_vector_[node->id()] = MachineRepresentation::kNone; | 101 representation_vector_[node->id()] = MachineRepresentation::kNone; |
| 90 break; | 102 break; |
| 91 case IrOpcode::kAtomicLoad: | 103 case IrOpcode::kAtomicLoad: |
| 92 case IrOpcode::kLoad: | 104 case IrOpcode::kLoad: |
| 93 case IrOpcode::kProtectedLoad: | 105 case IrOpcode::kProtectedLoad: |
| 94 representation_vector_[node->id()] = | 106 representation_vector_[node->id()] = PromoteRepresentation( |
| 95 LoadRepresentationOf(node->op()).representation(); | 107 LoadRepresentationOf(node->op()).representation()); |
| 96 break; | 108 break; |
| 97 case IrOpcode::kCheckedLoad: | 109 case IrOpcode::kCheckedLoad: |
| 98 representation_vector_[node->id()] = | 110 representation_vector_[node->id()] = PromoteRepresentation( |
| 99 CheckedLoadRepresentationOf(node->op()).representation(); | 111 CheckedLoadRepresentationOf(node->op()).representation()); |
| 100 break; | 112 break; |
| 101 case IrOpcode::kLoadStackPointer: | 113 case IrOpcode::kLoadStackPointer: |
| 102 case IrOpcode::kLoadFramePointer: | 114 case IrOpcode::kLoadFramePointer: |
| 103 case IrOpcode::kLoadParentFramePointer: | 115 case IrOpcode::kLoadParentFramePointer: |
| 104 representation_vector_[node->id()] = | 116 representation_vector_[node->id()] = |
| 105 MachineType::PointerRepresentation(); | 117 MachineType::PointerRepresentation(); |
| 106 break; | 118 break; |
| 119 case IrOpcode::kUnalignedLoad: |
| 120 representation_vector_[node->id()] = PromoteRepresentation( |
| 121 UnalignedLoadRepresentationOf(node->op()).representation()); |
| 122 break; |
| 107 case IrOpcode::kPhi: | 123 case IrOpcode::kPhi: |
| 108 representation_vector_[node->id()] = | 124 representation_vector_[node->id()] = |
| 109 PhiRepresentationOf(node->op()); | 125 PhiRepresentationOf(node->op()); |
| 110 break; | 126 break; |
| 111 case IrOpcode::kCall: { | 127 case IrOpcode::kCall: { |
| 112 CallDescriptor const* desc = CallDescriptorOf(node->op()); | 128 CallDescriptor const* desc = CallDescriptorOf(node->op()); |
| 113 if (desc->ReturnCount() > 0) { | 129 if (desc->ReturnCount() > 0) { |
| 114 representation_vector_[node->id()] = | 130 representation_vector_[node->id()] = |
| 115 desc->GetReturnType(0).representation(); | 131 desc->GetReturnType(0).representation(); |
| 116 } else { | 132 } else { |
| 117 representation_vector_[node->id()] = | 133 representation_vector_[node->id()] = |
| 118 MachineRepresentation::kTagged; | 134 MachineRepresentation::kTagged; |
| 119 } | 135 } |
| 120 break; | 136 break; |
| 121 } | 137 } |
| 122 case IrOpcode::kUnalignedLoad: | 138 case IrOpcode::kAtomicStore: |
| 139 case IrOpcode::kStore: |
| 140 case IrOpcode::kProtectedStore: |
| 141 representation_vector_[node->id()] = PromoteRepresentation( |
| 142 StoreRepresentationOf(node->op()).representation()); |
| 143 break; |
| 144 case IrOpcode::kCheckedStore: |
| 123 representation_vector_[node->id()] = | 145 representation_vector_[node->id()] = |
| 124 UnalignedLoadRepresentationOf(node->op()).representation(); | 146 PromoteRepresentation(CheckedStoreRepresentationOf(node->op())); |
| 147 break; |
| 148 case IrOpcode::kUnalignedStore: |
| 149 representation_vector_[node->id()] = PromoteRepresentation( |
| 150 UnalignedStoreRepresentationOf(node->op())); |
| 125 break; | 151 break; |
| 126 case IrOpcode::kHeapConstant: | 152 case IrOpcode::kHeapConstant: |
| 127 case IrOpcode::kNumberConstant: | 153 case IrOpcode::kNumberConstant: |
| 128 case IrOpcode::kChangeBitToTagged: | 154 case IrOpcode::kChangeBitToTagged: |
| 129 case IrOpcode::kIfException: | 155 case IrOpcode::kIfException: |
| 130 case IrOpcode::kOsrValue: | 156 case IrOpcode::kOsrValue: |
| 131 case IrOpcode::kChangeInt32ToTagged: | 157 case IrOpcode::kChangeInt32ToTagged: |
| 132 case IrOpcode::kChangeUint32ToTagged: | 158 case IrOpcode::kChangeUint32ToTagged: |
| 133 case IrOpcode::kBitcastWordToTagged: | 159 case IrOpcode::kBitcastWordToTagged: |
| 134 representation_vector_[node->id()] = MachineRepresentation::kTagged; | 160 representation_vector_[node->id()] = MachineRepresentation::kTagged; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 case IrOpcode::kLoad: | 414 case IrOpcode::kLoad: |
| 389 case IrOpcode::kAtomicLoad: | 415 case IrOpcode::kAtomicLoad: |
| 390 CheckValueInputIsTaggedOrPointer(node, 0); | 416 CheckValueInputIsTaggedOrPointer(node, 0); |
| 391 CheckValueInputRepresentationIs( | 417 CheckValueInputRepresentationIs( |
| 392 node, 1, MachineType::PointerRepresentation()); | 418 node, 1, MachineType::PointerRepresentation()); |
| 393 break; | 419 break; |
| 394 case IrOpcode::kStore: | 420 case IrOpcode::kStore: |
| 395 CheckValueInputIsTaggedOrPointer(node, 0); | 421 CheckValueInputIsTaggedOrPointer(node, 0); |
| 396 CheckValueInputRepresentationIs( | 422 CheckValueInputRepresentationIs( |
| 397 node, 1, MachineType::PointerRepresentation()); | 423 node, 1, MachineType::PointerRepresentation()); |
| 398 switch (StoreRepresentationOf(node->op()).representation()) { | 424 switch (inferrer_->GetRepresentation(node)) { |
| 399 case MachineRepresentation::kTagged: | 425 case MachineRepresentation::kTagged: |
| 400 case MachineRepresentation::kTaggedPointer: | 426 case MachineRepresentation::kTaggedPointer: |
| 401 case MachineRepresentation::kTaggedSigned: | 427 case MachineRepresentation::kTaggedSigned: |
| 402 CheckValueInputIsTagged(node, 2); | 428 CheckValueInputIsTagged(node, 2); |
| 403 break; | 429 break; |
| 404 default: | 430 default: |
| 405 CheckValueInputRepresentationIs( | 431 CheckValueInputRepresentationIs( |
| 406 node, 2, | 432 node, 2, inferrer_->GetRepresentation(node)); |
| 407 StoreRepresentationOf(node->op()).representation()); | |
| 408 } | 433 } |
| 409 break; | 434 break; |
| 410 case IrOpcode::kAtomicStore: | 435 case IrOpcode::kAtomicStore: |
| 411 CheckValueInputIsTaggedOrPointer(node, 0); | 436 CheckValueInputIsTaggedOrPointer(node, 0); |
| 412 CheckValueInputRepresentationIs( | 437 CheckValueInputRepresentationIs( |
| 413 node, 1, MachineType::PointerRepresentation()); | 438 node, 1, MachineType::PointerRepresentation()); |
| 414 switch (AtomicStoreRepresentationOf(node->op())) { | 439 switch (inferrer_->GetRepresentation(node)) { |
| 415 case MachineRepresentation::kTagged: | 440 case MachineRepresentation::kTagged: |
| 416 case MachineRepresentation::kTaggedPointer: | 441 case MachineRepresentation::kTaggedPointer: |
| 417 case MachineRepresentation::kTaggedSigned: | 442 case MachineRepresentation::kTaggedSigned: |
| 418 CheckValueInputIsTagged(node, 2); | 443 CheckValueInputIsTagged(node, 2); |
| 419 break; | 444 break; |
| 420 default: | 445 default: |
| 421 CheckValueInputRepresentationIs( | 446 CheckValueInputRepresentationIs( |
| 422 node, 2, AtomicStoreRepresentationOf(node->op())); | 447 node, 2, inferrer_->GetRepresentation(node)); |
| 423 } | 448 } |
| 424 break; | 449 break; |
| 425 case IrOpcode::kPhi: | 450 case IrOpcode::kPhi: |
| 426 switch (inferrer_->GetRepresentation(node)) { | 451 switch (inferrer_->GetRepresentation(node)) { |
| 427 case MachineRepresentation::kTagged: | 452 case MachineRepresentation::kTagged: |
| 428 case MachineRepresentation::kTaggedPointer: | 453 case MachineRepresentation::kTaggedPointer: |
| 429 case MachineRepresentation::kTaggedSigned: | 454 case MachineRepresentation::kTaggedSigned: |
| 430 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { | 455 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { |
| 431 CheckValueInputIsTagged(node, i); | 456 CheckValueInputIsTagged(node, i); |
| 432 } | 457 } |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 MachineRepresentationInferrer representation_inferrer(schedule, graph, | 738 MachineRepresentationInferrer representation_inferrer(schedule, graph, |
| 714 linkage, temp_zone); | 739 linkage, temp_zone); |
| 715 MachineRepresentationChecker checker(schedule, &representation_inferrer, | 740 MachineRepresentationChecker checker(schedule, &representation_inferrer, |
| 716 is_stub); | 741 is_stub); |
| 717 checker.Run(); | 742 checker.Run(); |
| 718 } | 743 } |
| 719 | 744 |
| 720 } // namespace compiler | 745 } // namespace compiler |
| 721 } // namespace internal | 746 } // namespace internal |
| 722 } // namespace v8 | 747 } // namespace v8 |
| OLD | NEW |