Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Side by Side Diff: src/compiler/machine-graph-verifier.cc

Issue 2573573004: [stubs] Enable graph verification for builtins. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | src/ic/accessor-assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 public: 23 public:
24 MachineRepresentationInferrer(Schedule const* schedule, Graph const* graph, 24 MachineRepresentationInferrer(Schedule const* schedule, Graph const* graph,
25 Linkage* linkage, Zone* zone) 25 Linkage* linkage, Zone* zone)
26 : schedule_(schedule), 26 : schedule_(schedule),
27 linkage_(linkage), 27 linkage_(linkage),
28 representation_vector_(graph->NodeCount(), MachineRepresentation::kNone, 28 representation_vector_(graph->NodeCount(), MachineRepresentation::kNone,
29 zone) { 29 zone) {
30 Run(); 30 Run();
31 } 31 }
32 32
33 CallDescriptor* call_descriptor() const {
34 return linkage_->GetIncomingDescriptor();
35 }
36
33 MachineRepresentation GetRepresentation(Node const* node) const { 37 MachineRepresentation GetRepresentation(Node const* node) const {
34 return representation_vector_.at(node->id()); 38 return representation_vector_.at(node->id());
35 } 39 }
36 40
37 private: 41 private:
38 MachineRepresentation GetProjectionType(Node const* projection) { 42 MachineRepresentation GetProjectionType(Node const* projection) {
39 size_t index = ProjectionIndexOf(projection->op()); 43 size_t index = ProjectionIndexOf(projection->op());
40 Node* input = projection->InputAt(0); 44 Node* input = projection->InputAt(0);
41 switch (input->opcode()) { 45 switch (input->opcode()) {
42 case IrOpcode::kInt32AddWithOverflow: 46 case IrOpcode::kInt32AddWithOverflow:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 if (node == nullptr) { 91 if (node == nullptr) {
88 DCHECK_EQ(block->NodeCount(), i); 92 DCHECK_EQ(block->NodeCount(), i);
89 break; 93 break;
90 } 94 }
91 switch (node->opcode()) { 95 switch (node->opcode()) {
92 case IrOpcode::kParameter: 96 case IrOpcode::kParameter:
93 representation_vector_[node->id()] = 97 representation_vector_[node->id()] =
94 linkage_->GetParameterType(ParameterIndexOf(node->op())) 98 linkage_->GetParameterType(ParameterIndexOf(node->op()))
95 .representation(); 99 .representation();
96 break; 100 break;
101 case IrOpcode::kReturn: {
102 representation_vector_[node->id()] = PromoteRepresentation(
103 linkage_->GetReturnType().representation());
104 break;
105 }
97 case IrOpcode::kProjection: { 106 case IrOpcode::kProjection: {
98 representation_vector_[node->id()] = GetProjectionType(node); 107 representation_vector_[node->id()] = GetProjectionType(node);
99 } break; 108 } break;
100 case IrOpcode::kTypedStateValues: 109 case IrOpcode::kTypedStateValues:
101 representation_vector_[node->id()] = MachineRepresentation::kNone; 110 representation_vector_[node->id()] = MachineRepresentation::kNone;
102 break; 111 break;
103 case IrOpcode::kAtomicLoad: 112 case IrOpcode::kAtomicLoad:
104 case IrOpcode::kLoad: 113 case IrOpcode::kLoad:
105 case IrOpcode::kProtectedLoad: 114 case IrOpcode::kProtectedLoad:
106 representation_vector_[node->id()] = PromoteRepresentation( 115 representation_vector_[node->id()] = PromoteRepresentation(
(...skipping 22 matching lines...) Expand all
129 if (desc->ReturnCount() > 0) { 138 if (desc->ReturnCount() > 0) {
130 representation_vector_[node->id()] = 139 representation_vector_[node->id()] =
131 desc->GetReturnType(0).representation(); 140 desc->GetReturnType(0).representation();
132 } else { 141 } else {
133 representation_vector_[node->id()] = 142 representation_vector_[node->id()] =
134 MachineRepresentation::kTagged; 143 MachineRepresentation::kTagged;
135 } 144 }
136 break; 145 break;
137 } 146 }
138 case IrOpcode::kAtomicStore: 147 case IrOpcode::kAtomicStore:
148 representation_vector_[node->id()] =
149 PromoteRepresentation(AtomicStoreRepresentationOf(node->op()));
150 break;
139 case IrOpcode::kStore: 151 case IrOpcode::kStore:
140 case IrOpcode::kProtectedStore: 152 case IrOpcode::kProtectedStore:
141 representation_vector_[node->id()] = PromoteRepresentation( 153 representation_vector_[node->id()] = PromoteRepresentation(
142 StoreRepresentationOf(node->op()).representation()); 154 StoreRepresentationOf(node->op()).representation());
143 break; 155 break;
144 case IrOpcode::kCheckedStore: 156 case IrOpcode::kCheckedStore:
145 representation_vector_[node->id()] = 157 representation_vector_[node->id()] =
146 PromoteRepresentation(CheckedStoreRepresentationOf(node->op())); 158 PromoteRepresentation(CheckedStoreRepresentationOf(node->op()));
147 break; 159 break;
148 case IrOpcode::kUnalignedStore: 160 case IrOpcode::kUnalignedStore:
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 break; 461 break;
450 case IrOpcode::kPhi: 462 case IrOpcode::kPhi:
451 switch (inferrer_->GetRepresentation(node)) { 463 switch (inferrer_->GetRepresentation(node)) {
452 case MachineRepresentation::kTagged: 464 case MachineRepresentation::kTagged:
453 case MachineRepresentation::kTaggedPointer: 465 case MachineRepresentation::kTaggedPointer:
454 case MachineRepresentation::kTaggedSigned: 466 case MachineRepresentation::kTaggedSigned:
455 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { 467 for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
456 CheckValueInputIsTagged(node, i); 468 CheckValueInputIsTagged(node, i);
457 } 469 }
458 break; 470 break;
471 case MachineRepresentation::kWord32:
472 for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
473 CheckValueInputForInt32Op(node, i);
474 }
475 break;
459 default: 476 default:
460 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { 477 for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
461 CheckValueInputRepresentationIs( 478 CheckValueInputRepresentationIs(
462 node, i, inferrer_->GetRepresentation(node)); 479 node, i, inferrer_->GetRepresentation(node));
463 } 480 }
464 break; 481 break;
465 } 482 }
466 break; 483 break;
467 case IrOpcode::kBranch: 484 case IrOpcode::kBranch:
468 case IrOpcode::kSwitch: 485 case IrOpcode::kSwitch:
469 CheckValueInputForInt32Op(node, 0); 486 CheckValueInputForInt32Op(node, 0);
470 break; 487 break;
471 case IrOpcode::kReturn: 488 case IrOpcode::kReturn: {
472 // TODO(epertoso): use the linkage to determine which tipe we 489 // TODO(ishell): enable once the pop count parameter type becomes
473 // should have here. 490 // MachineType::PointerRepresentation(). Currently it's int32 or
491 // word-size.
492 // CheckValueInputRepresentationIs(
493 // node, 0, MachineType::PointerRepresentation()); // Pop count
494 size_t return_count = inferrer_->call_descriptor()->ReturnCount();
495 for (size_t i = 0; i < return_count; i++) {
496 MachineType type = inferrer_->call_descriptor()->GetReturnType(i);
497 int input_index = static_cast<int>(i + 1);
498 switch (type.representation()) {
499 case MachineRepresentation::kTagged:
500 case MachineRepresentation::kTaggedPointer:
501 case MachineRepresentation::kTaggedSigned:
502 CheckValueInputIsTagged(node, input_index);
503 break;
504 case MachineRepresentation::kWord32:
505 CheckValueInputForInt32Op(node, input_index);
506 break;
507 default:
508 CheckValueInputRepresentationIs(
509 node, 2, inferrer_->GetRepresentation(node));
510 }
511 break;
Nico 2017/09/15 19:28:25 This break is probably supposed to go in the defau
Igor Sheludko 2017/09/20 15:15:20 Nice catch! Thank you! The fix: https://chromium-r
512 }
474 break; 513 break;
514 }
475 case IrOpcode::kTypedStateValues: 515 case IrOpcode::kTypedStateValues:
476 case IrOpcode::kFrameState: 516 case IrOpcode::kFrameState:
477 break; 517 break;
478 default: 518 default:
479 if (node->op()->ValueInputCount() != 0) { 519 if (node->op()->ValueInputCount() != 0) {
480 std::stringstream str; 520 std::stringstream str;
481 str << "Node #" << node->id() << ":" << *node->op() 521 str << "Node #" << node->id() << ":" << *node->op()
482 << " in the machine graph is not being checked."; 522 << " in the machine graph is not being checked.";
483 FATAL(str.str().c_str()); 523 FATAL(str.str().c_str());
484 } 524 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 MachineRepresentationInferrer representation_inferrer(schedule, graph, 778 MachineRepresentationInferrer representation_inferrer(schedule, graph,
739 linkage, temp_zone); 779 linkage, temp_zone);
740 MachineRepresentationChecker checker(schedule, &representation_inferrer, 780 MachineRepresentationChecker checker(schedule, &representation_inferrer,
741 is_stub); 781 is_stub);
742 checker.Run(); 782 checker.Run();
743 } 783 }
744 784
745 } // namespace compiler 785 } // namespace compiler
746 } // namespace internal 786 } // namespace internal
747 } // namespace v8 787 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | src/ic/accessor-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698