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

Side by Side Diff: test/unittests/compiler/graph-reducer-unittest.cc

Issue 1179543002: [turbofan] Make IfException projections consume effects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
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/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/node.h" 7 #include "src/compiler/node.h"
8 #include "src/compiler/operator.h" 8 #include "src/compiler/operator.h"
9 #include "test/unittests/compiler/graph-reducer-unittest.h" 9 #include "test/unittests/compiler/graph-reducer-unittest.h"
10 #include "test/unittests/test-utils.h" 10 #include "test/unittests/test-utils.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 EXPECT_EQ(0, node->UseCount()); 333 EXPECT_EQ(0, node->UseCount());
334 EXPECT_EQ(2, start->UseCount()); 334 EXPECT_EQ(2, start->UseCount());
335 EXPECT_EQ(0, replacement->UseCount()); 335 EXPECT_EQ(0, replacement->UseCount());
336 EXPECT_THAT(start->uses(), UnorderedElementsAre(use_control, node)); 336 EXPECT_THAT(start->uses(), UnorderedElementsAre(use_control, node));
337 } 337 }
338 338
339 339
340 TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse2) { 340 TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse2) {
341 CommonOperatorBuilder common(zone()); 341 CommonOperatorBuilder common(zone());
342 Node* start = graph()->NewNode(common.Start(1)); 342 Node* start = graph()->NewNode(common.Start(1));
343 Node* effect = graph()->NewNode(&kMockOperator);
343 Node* dead = graph()->NewNode(&kMockOperator); 344 Node* dead = graph()->NewNode(&kMockOperator);
344 Node* node = graph()->NewNode(&kMockOpControl, start); 345 Node* node = graph()->NewNode(&kMockOpControl, start);
345 Node* success = graph()->NewNode(common.IfSuccess(), node); 346 Node* success = graph()->NewNode(common.IfSuccess(), node);
346 Node* exception = graph()->NewNode(common.IfException(kNoHint), node); 347 Node* exception = graph()->NewNode(common.IfException(kNoHint), effect, node);
347 Node* use_control = graph()->NewNode(common.Merge(1), success); 348 Node* use_control = graph()->NewNode(common.Merge(1), success);
348 Node* use_exception_control = graph()->NewNode(common.Merge(1), exception); 349 Node* use_exception_control = graph()->NewNode(common.Merge(1), exception);
349 Node* replacement = graph()->NewNode(&kMockOperator); 350 Node* replacement = graph()->NewNode(&kMockOperator);
350 GraphReducer graph_reducer(zone(), graph(), nullptr, dead); 351 GraphReducer graph_reducer(zone(), graph(), nullptr, dead);
351 ReplaceWithValueReducer r(&graph_reducer); 352 ReplaceWithValueReducer r(&graph_reducer);
352 r.ReplaceWithValue(node, replacement); 353 r.ReplaceWithValue(node, replacement);
353 EXPECT_EQ(start, use_control->InputAt(0)); 354 EXPECT_EQ(start, use_control->InputAt(0));
354 EXPECT_EQ(dead, use_exception_control->InputAt(0)); 355 EXPECT_EQ(dead, use_exception_control->InputAt(0));
355 EXPECT_EQ(0, node->UseCount()); 356 EXPECT_EQ(0, node->UseCount());
356 EXPECT_EQ(2, start->UseCount()); 357 EXPECT_EQ(2, start->UseCount());
357 EXPECT_EQ(1, dead->UseCount()); 358 EXPECT_EQ(1, dead->UseCount());
358 EXPECT_EQ(0, replacement->UseCount()); 359 EXPECT_EQ(0, replacement->UseCount());
359 EXPECT_THAT(start->uses(), UnorderedElementsAre(use_control, node)); 360 EXPECT_THAT(start->uses(), UnorderedElementsAre(use_control, node));
360 EXPECT_THAT(dead->uses(), ElementsAre(use_exception_control)); 361 EXPECT_THAT(dead->uses(), ElementsAre(use_exception_control));
361 } 362 }
362 363
363 364
364 TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse3) { 365 TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse3) {
365 CommonOperatorBuilder common(zone()); 366 CommonOperatorBuilder common(zone());
366 Node* start = graph()->NewNode(common.Start(1)); 367 Node* start = graph()->NewNode(common.Start(1));
368 Node* effect = graph()->NewNode(&kMockOperator);
367 Node* dead = graph()->NewNode(&kMockOperator); 369 Node* dead = graph()->NewNode(&kMockOperator);
368 Node* node = graph()->NewNode(&kMockOpControl, start); 370 Node* node = graph()->NewNode(&kMockOpControl, start);
369 Node* success = graph()->NewNode(common.IfSuccess(), node); 371 Node* success = graph()->NewNode(common.IfSuccess(), node);
370 Node* exception = graph()->NewNode(common.IfException(kNoHint), node); 372 Node* exception = graph()->NewNode(common.IfException(kNoHint), effect, node);
371 Node* use_control = graph()->NewNode(common.Merge(1), success); 373 Node* use_control = graph()->NewNode(common.Merge(1), success);
372 Node* use_exception_value = graph()->NewNode(common.Return(), exception); 374 Node* use_exception_value = graph()->NewNode(common.Return(), exception);
373 Node* replacement = graph()->NewNode(&kMockOperator); 375 Node* replacement = graph()->NewNode(&kMockOperator);
374 GraphReducer graph_reducer(zone(), graph(), dead, nullptr); 376 GraphReducer graph_reducer(zone(), graph(), dead, nullptr);
375 ReplaceWithValueReducer r(&graph_reducer); 377 ReplaceWithValueReducer r(&graph_reducer);
376 r.ReplaceWithValue(node, replacement); 378 r.ReplaceWithValue(node, replacement);
377 EXPECT_EQ(start, use_control->InputAt(0)); 379 EXPECT_EQ(start, use_control->InputAt(0));
378 EXPECT_EQ(dead, use_exception_value->InputAt(0)); 380 EXPECT_EQ(dead, use_exception_value->InputAt(0));
379 EXPECT_EQ(0, node->UseCount()); 381 EXPECT_EQ(0, node->UseCount());
380 EXPECT_EQ(2, start->UseCount()); 382 EXPECT_EQ(2, start->UseCount());
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 EXPECT_EQ(&kOpC0, n1->op()); 850 EXPECT_EQ(&kOpC0, n1->op());
849 EXPECT_EQ(&kOpC1, end->op()); 851 EXPECT_EQ(&kOpC1, end->op());
850 EXPECT_EQ(n1, end->InputAt(0)); 852 EXPECT_EQ(n1, end->InputAt(0));
851 } 853 }
852 } 854 }
853 } 855 }
854 856
855 } // namespace compiler 857 } // namespace compiler
856 } // namespace internal 858 } // namespace internal
857 } // namespace v8 859 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/common-operator-unittest.cc ('k') | test/unittests/compiler/node-properties-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698