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

Side by Side Diff: test/cctest/compiler/test-control-reducer.cc

Issue 686213002: Inline trivial OperatorProperties methods. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
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/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/control-reducer.h" 10 #include "src/compiler/control-reducer.h"
(...skipping 19 matching lines...) Expand all
30 if (i1 != NULL) CHECK_EQ(i1, node->InputAt(1)); 30 if (i1 != NULL) CHECK_EQ(i1, node->InputAt(1));
31 if (i2 != NULL) CHECK_EQ(i2, node->InputAt(2)); 31 if (i2 != NULL) CHECK_EQ(i2, node->InputAt(2));
32 return count; 32 return count;
33 } 33 }
34 34
35 35
36 static int CheckMerge(Node* node, Node* i0 = NULL, Node* i1 = NULL, 36 static int CheckMerge(Node* node, Node* i0 = NULL, Node* i1 = NULL,
37 Node* i2 = NULL) { 37 Node* i2 = NULL) {
38 CHECK_EQ(IrOpcode::kMerge, node->opcode()); 38 CHECK_EQ(IrOpcode::kMerge, node->opcode());
39 int count = CheckInputs(node, i0, i1, i2); 39 int count = CheckInputs(node, i0, i1, i2);
40 CHECK_EQ(count, OperatorProperties::GetControlInputCount(node->op())); 40 CHECK_EQ(count, node->op()->ControlInputCount());
41 return count; 41 return count;
42 } 42 }
43 43
44 44
45 static int CheckLoop(Node* node, Node* i0 = NULL, Node* i1 = NULL, 45 static int CheckLoop(Node* node, Node* i0 = NULL, Node* i1 = NULL,
46 Node* i2 = NULL) { 46 Node* i2 = NULL) {
47 CHECK_EQ(IrOpcode::kLoop, node->opcode()); 47 CHECK_EQ(IrOpcode::kLoop, node->opcode());
48 int count = CheckInputs(node, i0, i1, i2); 48 int count = CheckInputs(node, i0, i1, i2);
49 CHECK_EQ(count, OperatorProperties::GetControlInputCount(node->op())); 49 CHECK_EQ(count, node->op()->ControlInputCount());
50 return count; 50 return count;
51 } 51 }
52 52
53 53
54 bool IsUsedBy(Node* a, Node* b) { 54 bool IsUsedBy(Node* a, Node* b) {
55 for (UseIter i = a->uses().begin(); i != a->uses().end(); ++i) { 55 for (UseIter i = a->uses().begin(); i != a->uses().end(); ++i) {
56 if (b == *i) return true; 56 if (b == *i) return true;
57 } 57 }
58 return false; 58 return false;
59 } 59 }
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 ControlReducerTester R; 785 ControlReducerTester R;
786 786
787 for (int i = 0; i < 3; i++) { 787 for (int i = 0; i < 3; i++) {
788 Node* merge = R.graph.NewNode(R.common.Merge(3), R.start, R.start, R.start); 788 Node* merge = R.graph.NewNode(R.common.Merge(3), R.start, R.start, R.start);
789 merge->ReplaceInput(i, R.dead); 789 merge->ReplaceInput(i, R.dead);
790 Node* phi = R.graph.NewNode(R.common.EffectPhi(3), R.leaf[0], R.leaf[1], 790 Node* phi = R.graph.NewNode(R.common.EffectPhi(3), R.leaf[0], R.leaf[1],
791 R.leaf[2], merge); 791 R.leaf[2], merge);
792 R.ReduceMerge(merge, merge); 792 R.ReduceMerge(merge, merge);
793 CHECK_EQ(IrOpcode::kEffectPhi, phi->opcode()); 793 CHECK_EQ(IrOpcode::kEffectPhi, phi->opcode());
794 CHECK_EQ(0, phi->op()->InputCount()); 794 CHECK_EQ(0, phi->op()->InputCount());
795 CHECK_EQ(2, OperatorProperties::GetEffectInputCount(phi->op())); 795 CHECK_EQ(2, phi->op()->EffectInputCount());
796 CHECK_EQ(3, phi->InputCount()); 796 CHECK_EQ(3, phi->InputCount());
797 CHECK_EQ(R.leaf[i < 1 ? 1 : 0], phi->InputAt(0)); 797 CHECK_EQ(R.leaf[i < 1 ? 1 : 0], phi->InputAt(0));
798 CHECK_EQ(R.leaf[i < 2 ? 2 : 1], phi->InputAt(1)); 798 CHECK_EQ(R.leaf[i < 2 ? 2 : 1], phi->InputAt(1));
799 CHECK_EQ(merge, phi->InputAt(2)); 799 CHECK_EQ(merge, phi->InputAt(2));
800 } 800 }
801 } 801 }
802 802
803 803
804 static const int kSelectorSize = 4; 804 static const int kSelectorSize = 4;
805 805
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 } else { 878 } else {
879 // Otherwise, nodes should be edited in place. 879 // Otherwise, nodes should be edited in place.
880 CHECK_EQ(merge, result); 880 CHECK_EQ(merge, result);
881 selector.CheckNode(merge, IrOpcode::kMerge, controls, NULL); 881 selector.CheckNode(merge, IrOpcode::kMerge, controls, NULL);
882 selector.CheckNode(phi, IrOpcode::kPhi, values, merge); 882 selector.CheckNode(phi, IrOpcode::kPhi, values, merge);
883 selector.CheckNode(ephi, IrOpcode::kEffectPhi, effects, merge); 883 selector.CheckNode(ephi, IrOpcode::kEffectPhi, effects, merge);
884 CHECK_EQ(phi, phi_use->InputAt(0)); 884 CHECK_EQ(phi, phi_use->InputAt(0));
885 CHECK_EQ(ephi, ephi_use->InputAt(0)); 885 CHECK_EQ(ephi, ephi_use->InputAt(0));
886 CHECK_EQ(count, phi->op()->InputCount()); 886 CHECK_EQ(count, phi->op()->InputCount());
887 CHECK_EQ(count + 1, phi->InputCount()); 887 CHECK_EQ(count + 1, phi->InputCount());
888 CHECK_EQ(count, OperatorProperties::GetEffectInputCount(ephi->op())); 888 CHECK_EQ(count, ephi->op()->EffectInputCount());
889 CHECK_EQ(count + 1, ephi->InputCount()); 889 CHECK_EQ(count + 1, ephi->InputCount());
890 } 890 }
891 } 891 }
892 } 892 }
893 893
894 894
895 TEST(CMergeReduce_edit_many_phis1) { 895 TEST(CMergeReduce_edit_many_phis1) {
896 ControlReducerTester R; 896 ControlReducerTester R;
897 897
898 const int kPhiCount = 10; 898 const int kPhiCount = 10;
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 Node* end = R.graph.end(); 1267 Node* end = R.graph.end();
1268 end->ReplaceInput(0, b.if_false); 1268 end->ReplaceInput(0, b.if_false);
1269 1269
1270 R.ReduceGraph(); 1270 R.ReduceGraph();
1271 1271
1272 CHECK_EQ(end, R.graph.end()); 1272 CHECK_EQ(end, R.graph.end());
1273 CheckLoop(loop, R.start, loop); 1273 CheckLoop(loop, R.start, loop);
1274 Node* terminate = end->InputAt(0); 1274 Node* terminate = end->InputAt(0);
1275 CHECK_EQ(IrOpcode::kTerminate, terminate->opcode()); 1275 CHECK_EQ(IrOpcode::kTerminate, terminate->opcode());
1276 CHECK_EQ(2, terminate->InputCount()); 1276 CHECK_EQ(2, terminate->InputCount());
1277 CHECK_EQ(1, OperatorProperties::GetEffectInputCount(terminate->op())); 1277 CHECK_EQ(1, terminate->op()->EffectInputCount());
1278 CHECK_EQ(1, OperatorProperties::GetControlInputCount(terminate->op())); 1278 CHECK_EQ(1, terminate->op()->ControlInputCount());
1279 CheckInputs(terminate, effect, loop); 1279 CheckInputs(terminate, effect, loop);
1280 } 1280 }
1281 1281
1282 1282
1283 TEST(CNonTermLoop_terminate2) { 1283 TEST(CNonTermLoop_terminate2) {
1284 ControlReducerTester R; 1284 ControlReducerTester R;
1285 Node* loop = R.graph.NewNode(R.common.Loop(2), R.start, R.start); 1285 Node* loop = R.graph.NewNode(R.common.Loop(2), R.start, R.start);
1286 Node* effect1 = R.SetSelfReferences( 1286 Node* effect1 = R.SetSelfReferences(
1287 R.graph.NewNode(R.common.EffectPhi(2), R.start, R.self, loop)); 1287 R.graph.NewNode(R.common.EffectPhi(2), R.start, R.self, loop));
1288 Node* effect2 = R.SetSelfReferences( 1288 Node* effect2 = R.SetSelfReferences(
1289 R.graph.NewNode(R.common.EffectPhi(2), R.start, R.self, loop)); 1289 R.graph.NewNode(R.common.EffectPhi(2), R.start, R.self, loop));
1290 Branch b(R, R.one, loop); 1290 Branch b(R, R.one, loop);
1291 loop->ReplaceInput(1, b.if_true); 1291 loop->ReplaceInput(1, b.if_true);
1292 Node* end = R.graph.end(); 1292 Node* end = R.graph.end();
1293 end->ReplaceInput(0, b.if_false); 1293 end->ReplaceInput(0, b.if_false);
1294 1294
1295 R.ReduceGraph(); 1295 R.ReduceGraph();
1296 1296
1297 CheckLoop(loop, R.start, loop); 1297 CheckLoop(loop, R.start, loop);
1298 CHECK_EQ(end, R.graph.end()); 1298 CHECK_EQ(end, R.graph.end());
1299 Node* terminate = end->InputAt(0); 1299 Node* terminate = end->InputAt(0);
1300 CHECK_EQ(IrOpcode::kTerminate, terminate->opcode()); 1300 CHECK_EQ(IrOpcode::kTerminate, terminate->opcode());
1301 CHECK_EQ(3, terminate->InputCount()); 1301 CHECK_EQ(3, terminate->InputCount());
1302 CHECK_EQ(2, OperatorProperties::GetEffectInputCount(terminate->op())); 1302 CHECK_EQ(2, terminate->op()->EffectInputCount());
1303 CHECK_EQ(1, OperatorProperties::GetControlInputCount(terminate->op())); 1303 CHECK_EQ(1, terminate->op()->ControlInputCount());
1304 Node* e0 = terminate->InputAt(0); 1304 Node* e0 = terminate->InputAt(0);
1305 Node* e1 = terminate->InputAt(1); 1305 Node* e1 = terminate->InputAt(1);
1306 CHECK(e0 == effect1 || e1 == effect1); 1306 CHECK(e0 == effect1 || e1 == effect1);
1307 CHECK(e0 == effect2 || e1 == effect2); 1307 CHECK(e0 == effect2 || e1 == effect2);
1308 CHECK_EQ(loop, terminate->InputAt(2)); 1308 CHECK_EQ(loop, terminate->InputAt(2));
1309 } 1309 }
1310 1310
1311 1311
1312 TEST(CNonTermLoop_terminate_m1) { 1312 TEST(CNonTermLoop_terminate_m1) {
1313 ControlReducerTester R; 1313 ControlReducerTester R;
1314 Node* loop = 1314 Node* loop =
1315 R.SetSelfReferences(R.graph.NewNode(R.common.Loop(2), R.start, R.self)); 1315 R.SetSelfReferences(R.graph.NewNode(R.common.Loop(2), R.start, R.self));
1316 Node* effect = R.SetSelfReferences( 1316 Node* effect = R.SetSelfReferences(
1317 R.graph.NewNode(R.common.EffectPhi(2), R.start, R.self, loop)); 1317 R.graph.NewNode(R.common.EffectPhi(2), R.start, R.self, loop));
1318 R.ReduceGraph(); 1318 R.ReduceGraph();
1319 Node* end = R.graph.end(); 1319 Node* end = R.graph.end();
1320 CHECK_EQ(R.start, loop->InputAt(0)); 1320 CHECK_EQ(R.start, loop->InputAt(0));
1321 CHECK_EQ(loop, loop->InputAt(1)); 1321 CHECK_EQ(loop, loop->InputAt(1));
1322 Node* merge = end->InputAt(0); 1322 Node* merge = end->InputAt(0);
1323 CHECK_EQ(IrOpcode::kMerge, merge->opcode()); 1323 CHECK_EQ(IrOpcode::kMerge, merge->opcode());
1324 CHECK_EQ(2, merge->InputCount()); 1324 CHECK_EQ(2, merge->InputCount());
1325 CHECK_EQ(2, OperatorProperties::GetControlInputCount(merge->op())); 1325 CHECK_EQ(2, merge->op()->ControlInputCount());
1326 CHECK_EQ(R.start, merge->InputAt(0)); 1326 CHECK_EQ(R.start, merge->InputAt(0));
1327 1327
1328 Node* terminate = merge->InputAt(1); 1328 Node* terminate = merge->InputAt(1);
1329 CHECK_EQ(IrOpcode::kTerminate, terminate->opcode()); 1329 CHECK_EQ(IrOpcode::kTerminate, terminate->opcode());
1330 CHECK_EQ(2, terminate->InputCount()); 1330 CHECK_EQ(2, terminate->InputCount());
1331 CHECK_EQ(1, OperatorProperties::GetEffectInputCount(terminate->op())); 1331 CHECK_EQ(1, terminate->op()->EffectInputCount());
1332 CHECK_EQ(1, OperatorProperties::GetControlInputCount(terminate->op())); 1332 CHECK_EQ(1, terminate->op()->ControlInputCount());
1333 CHECK_EQ(effect, terminate->InputAt(0)); 1333 CHECK_EQ(effect, terminate->InputAt(0));
1334 CHECK_EQ(loop, terminate->InputAt(1)); 1334 CHECK_EQ(loop, terminate->InputAt(1));
1335 } 1335 }
1336 1336
1337 1337
1338 TEST(CNonTermLoop_big1) { 1338 TEST(CNonTermLoop_big1) {
1339 ControlReducerTester R; 1339 ControlReducerTester R;
1340 Branch b1(R, R.p0); 1340 Branch b1(R, R.p0);
1341 Node* rt = R.graph.NewNode(R.common.Return(), R.one, R.start, b1.if_true); 1341 Node* rt = R.graph.NewNode(R.common.Return(), R.one, R.start, b1.if_true);
1342 1342
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 1671
1672 Node* ret = R.Return(d1.phi, R.start, d1.merge); 1672 Node* ret = R.Return(d1.phi, R.start, d1.merge);
1673 1673
1674 R.ReduceGraph(); // d1 gets folded true. 1674 R.ReduceGraph(); // d1 gets folded true.
1675 1675
1676 CheckInputs(ret, y2, R.start, R.start); 1676 CheckInputs(ret, y2, R.start, R.start);
1677 CheckDeadDiamond(d1); 1677 CheckDeadDiamond(d1);
1678 CheckDeadDiamond(d2); 1678 CheckDeadDiamond(d2);
1679 CheckDeadDiamond(d3); 1679 CheckDeadDiamond(d3);
1680 } 1680 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/simplified-graph-builder.cc ('k') | test/cctest/compiler/test-js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698