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

Side by Side Diff: src/compiler/verifier.cc

Issue 931623002: [turbofan] Optimize certain chains of Branch into a Switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addrssed comments. Created 5 years, 10 months 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/simplified-lowering.cc ('k') | src/compiler/x64/code-generator-x64.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 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/verifier.h" 5 #include "src/compiler/verifier.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <queue> 9 #include <queue>
10 #include <sstream> 10 #include <sstream>
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 UNREACHABLE(); 209 UNREACHABLE();
210 case IrOpcode::kBranch: { 210 case IrOpcode::kBranch: {
211 // Branch uses are IfTrue and IfFalse. 211 // Branch uses are IfTrue and IfFalse.
212 int count_true = 0, count_false = 0; 212 int count_true = 0, count_false = 0;
213 for (auto use : node->uses()) { 213 for (auto use : node->uses()) {
214 CHECK(use->opcode() == IrOpcode::kIfTrue || 214 CHECK(use->opcode() == IrOpcode::kIfTrue ||
215 use->opcode() == IrOpcode::kIfFalse); 215 use->opcode() == IrOpcode::kIfFalse);
216 if (use->opcode() == IrOpcode::kIfTrue) ++count_true; 216 if (use->opcode() == IrOpcode::kIfTrue) ++count_true;
217 if (use->opcode() == IrOpcode::kIfFalse) ++count_false; 217 if (use->opcode() == IrOpcode::kIfFalse) ++count_false;
218 } 218 }
219 CHECK(count_true == 1 && count_false == 1); 219 CHECK_EQ(1, count_true);
220 CHECK_EQ(1, count_false);
220 // Type is empty. 221 // Type is empty.
221 CheckNotTyped(node); 222 CheckNotTyped(node);
222 break; 223 break;
223 } 224 }
224 case IrOpcode::kIfTrue: 225 case IrOpcode::kIfTrue:
225 case IrOpcode::kIfFalse: 226 case IrOpcode::kIfFalse:
226 CHECK_EQ(IrOpcode::kBranch, 227 CHECK_EQ(IrOpcode::kBranch,
227 NodeProperties::GetControlInput(node, 0)->opcode()); 228 NodeProperties::GetControlInput(node, 0)->opcode());
228 // Type is empty. 229 // Type is empty.
229 CheckNotTyped(node); 230 CheckNotTyped(node);
230 break; 231 break;
231 case IrOpcode::kSwitch: { 232 case IrOpcode::kSwitch: {
232 // Switch uses are Case. 233 // Switch uses are Case and Default.
233 std::vector<bool> uses; 234 int count_case = 0, count_default = 0;
234 uses.resize(node->UseCount());
235 for (auto use : node->uses()) { 235 for (auto use : node->uses()) {
236 CHECK_EQ(IrOpcode::kCase, use->opcode()); 236 switch (use->opcode()) {
237 size_t const index = CaseIndexOf(use->op()); 237 case IrOpcode::kIfValue: {
238 CHECK_LT(index, uses.size()); 238 for (auto user : node->uses()) {
239 CHECK(!uses[index]); 239 if (user != use && user->opcode() == IrOpcode::kIfValue) {
240 uses[index] = true; 240 CHECK_NE(OpParameter<int32_t>(use->op()),
241 OpParameter<int32_t>(user->op()));
242 }
243 }
244 ++count_case;
245 break;
246 }
247 case IrOpcode::kIfDefault: {
248 ++count_default;
249 break;
250 }
251 default: {
252 UNREACHABLE();
253 break;
254 }
255 }
241 } 256 }
257 CHECK_LE(1, count_case);
258 CHECK_EQ(1, count_default);
259 CHECK_EQ(node->op()->ControlOutputCount(), count_case + count_default);
242 // Type is empty. 260 // Type is empty.
243 CheckNotTyped(node); 261 CheckNotTyped(node);
244 break; 262 break;
245 } 263 }
246 case IrOpcode::kCase: 264 case IrOpcode::kIfValue:
265 case IrOpcode::kIfDefault:
247 CHECK_EQ(IrOpcode::kSwitch, 266 CHECK_EQ(IrOpcode::kSwitch,
248 NodeProperties::GetControlInput(node)->opcode()); 267 NodeProperties::GetControlInput(node)->opcode());
249 // Type is empty. 268 // Type is empty.
250 CheckNotTyped(node); 269 CheckNotTyped(node);
251 break; 270 break;
252 case IrOpcode::kLoop: 271 case IrOpcode::kLoop:
253 case IrOpcode::kMerge: 272 case IrOpcode::kMerge:
254 CHECK_EQ(control_count, input_count); 273 CHECK_EQ(control_count, input_count);
255 // Type is empty. 274 // Type is empty.
256 CheckNotTyped(node); 275 CheckNotTyped(node);
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 // Check inputs for all nodes in the block. 1041 // Check inputs for all nodes in the block.
1023 for (size_t i = 0; i < block->NodeCount(); i++) { 1042 for (size_t i = 0; i < block->NodeCount(); i++) {
1024 Node* node = block->NodeAt(i); 1043 Node* node = block->NodeAt(i);
1025 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1); 1044 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1);
1026 } 1045 }
1027 } 1046 }
1028 } 1047 }
1029 } 1048 }
1030 } 1049 }
1031 } // namespace v8::internal::compiler 1050 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | src/compiler/x64/code-generator-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698