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

Unified Diff: test/cctest/compiler/test-operator.cc

Issue 680313003: Move input/output counts directly into Operators, simplying OperatorProperties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: yes Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/compiler/test-node-algorithm.cc ('k') | test/cctest/compiler/test-schedule.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-operator.cc
diff --git a/test/cctest/compiler/test-operator.cc b/test/cctest/compiler/test-operator.cc
index 37cf3a349aa51b9bf60ce377980cb84b4e203bef..8675bd54576a80f4e77787014836b2a4193a97ac 100644
--- a/test/cctest/compiler/test-operator.cc
+++ b/test/cctest/compiler/test-operator.cc
@@ -12,41 +12,45 @@
using namespace v8::internal;
using namespace v8::internal::compiler;
-TEST(TestOperatorMnemonic) {
- SimpleOperator op1(10, Operator::kNoProperties, 0, 0, "ThisOne");
+static const Operator::Properties N = Operator::kNoProperties;
+static const Operator::Properties F = Operator::kFoldable;
+
+
+TEST(TestOperator_Mnemonic) {
+ Operator op1(10, N, "ThisOne", 0, 0, 0, 0, 0, 0);
CHECK_EQ(0, strcmp(op1.mnemonic(), "ThisOne"));
- SimpleOperator op2(11, Operator::kNoProperties, 0, 0, "ThatOne");
+ Operator op2(11, N, "ThatOne", 0, 0, 0, 0, 0, 0);
CHECK_EQ(0, strcmp(op2.mnemonic(), "ThatOne"));
- Operator1<int> op3(12, Operator::kNoProperties, 0, 1, "Mnemonic1", 12333);
+ Operator1<int> op3(12, N, "Mnemonic1", 0, 0, 0, 1, 0, 0, 12333);
CHECK_EQ(0, strcmp(op3.mnemonic(), "Mnemonic1"));
- Operator1<double> op4(13, Operator::kNoProperties, 0, 1, "TheOther", 99.9);
+ Operator1<double> op4(13, N, "TheOther", 0, 0, 0, 1, 0, 0, 99.9);
CHECK_EQ(0, strcmp(op4.mnemonic(), "TheOther"));
}
-TEST(TestSimpleOperatorHash) {
- SimpleOperator op1(17, Operator::kNoProperties, 0, 0, "Another");
+TEST(TestOperator_Hash) {
+ Operator op1(17, N, "Another", 0, 0, 0, 0, 0, 0);
CHECK_EQ(17, static_cast<int>(op1.HashCode()));
- SimpleOperator op2(18, Operator::kNoProperties, 0, 0, "Falsch");
+ Operator op2(18, N, "Falsch", 0, 0, 0, 0, 0, 0);
CHECK_EQ(18, static_cast<int>(op2.HashCode()));
}
-TEST(TestSimpleOperatorEquals) {
- SimpleOperator op1a(19, Operator::kNoProperties, 0, 0, "Another1");
- SimpleOperator op1b(19, Operator::kFoldable, 2, 2, "Another2");
+TEST(TestOperator_Equals) {
+ Operator op1a(19, N, "Another1", 0, 0, 0, 0, 0, 0);
+ Operator op1b(19, F, "Another2", 2, 0, 0, 2, 0, 0);
CHECK(op1a.Equals(&op1a));
CHECK(op1a.Equals(&op1b));
CHECK(op1b.Equals(&op1a));
CHECK(op1b.Equals(&op1b));
- SimpleOperator op2a(20, Operator::kNoProperties, 0, 0, "Falsch1");
- SimpleOperator op2b(20, Operator::kFoldable, 1, 1, "Falsch2");
+ Operator op2a(20, N, "Falsch1", 0, 0, 0, 0, 0, 0);
+ Operator op2b(20, F, "Falsch2", 1, 0, 0, 1, 0, 0);
CHECK(op2a.Equals(&op2a));
CHECK(op2a.Equals(&op2b));
@@ -72,46 +76,46 @@ static SmartArrayPointer<const char> OperatorToString(Operator* op) {
}
-TEST(TestSimpleOperatorPrint) {
- SimpleOperator op1a(19, Operator::kNoProperties, 0, 0, "Another1");
- SimpleOperator op1b(19, Operator::kFoldable, 2, 2, "Another2");
+TEST(TestOperator_Print) {
+ Operator op1a(19, N, "Another1", 0, 0, 0, 0, 0, 0);
+ Operator op1b(19, F, "Another2", 2, 0, 0, 2, 0, 0);
CHECK_EQ("Another1", OperatorToString(&op1a).get());
CHECK_EQ("Another2", OperatorToString(&op1b).get());
- SimpleOperator op2a(20, Operator::kNoProperties, 0, 0, "Flog1");
- SimpleOperator op2b(20, Operator::kFoldable, 1, 1, "Flog2");
+ Operator op2a(20, N, "Flog1", 0, 0, 0, 0, 0, 0);
+ Operator op2b(20, F, "Flog2", 1, 0, 0, 1, 0, 0);
CHECK_EQ("Flog1", OperatorToString(&op2a).get());
CHECK_EQ("Flog2", OperatorToString(&op2b).get());
}
-TEST(TestOperator1intHash) {
- Operator1<int> op1a(23, Operator::kNoProperties, 0, 0, "Wolfie", 11);
- Operator1<int> op1b(23, Operator::kFoldable, 2, 2, "Doggie", 11);
+TEST(TestOperator1int_Hash) {
+ Operator1<int> op1a(23, N, "Wolfie", 0, 0, 0, 0, 0, 0, 11);
+ Operator1<int> op1b(23, F, "Doggie", 2, 0, 0, 2, 0, 0, 11);
CHECK(op1a.HashCode() == op1b.HashCode());
- Operator1<int> op2a(24, Operator::kNoProperties, 0, 0, "Arfie", 3);
- Operator1<int> op2b(24, Operator::kNoProperties, 0, 0, "Arfie", 4);
+ Operator1<int> op2a(24, N, "Arfie", 0, 0, 0, 0, 0, 0, 3);
+ Operator1<int> op2b(24, N, "Arfie", 0, 0, 0, 0, 0, 0, 4);
CHECK(op1a.HashCode() != op2a.HashCode());
CHECK(op2a.HashCode() != op2b.HashCode());
}
-TEST(TestOperator1intEquals) {
- Operator1<int> op1a(23, Operator::kNoProperties, 0, 0, "Scratchy", 11);
- Operator1<int> op1b(23, Operator::kFoldable, 2, 2, "Scratchy", 11);
+TEST(TestOperator1int_Equals) {
+ Operator1<int> op1a(23, N, "Scratchy", 0, 0, 0, 0, 0, 0, 11);
+ Operator1<int> op1b(23, F, "Scratchy", 2, 0, 0, 2, 0, 0, 11);
CHECK(op1a.Equals(&op1a));
CHECK(op1a.Equals(&op1b));
CHECK(op1b.Equals(&op1a));
CHECK(op1b.Equals(&op1b));
- Operator1<int> op2a(24, Operator::kNoProperties, 0, 0, "Im", 3);
- Operator1<int> op2b(24, Operator::kNoProperties, 0, 0, "Im", 4);
+ Operator1<int> op2a(24, N, "Im", 0, 0, 0, 0, 0, 0, 3);
+ Operator1<int> op2b(24, N, "Im", 0, 0, 0, 0, 0, 0, 4);
CHECK(op2a.Equals(&op2a));
CHECK(!op2a.Equals(&op2b));
@@ -128,7 +132,7 @@ TEST(TestOperator1intEquals) {
CHECK(!op2b.Equals(&op1a));
CHECK(!op2b.Equals(&op1b));
- SimpleOperator op3(25, Operator::kNoProperties, 0, 0, "Weepy");
+ Operator op3(25, N, "Weepy", 0, 0, 0, 0, 0, 0);
CHECK(!op1a.Equals(&op3));
CHECK(!op1b.Equals(&op3));
@@ -142,46 +146,55 @@ TEST(TestOperator1intEquals) {
}
-TEST(TestOperator1intPrint) {
- Operator1<int> op1(12, Operator::kNoProperties, 0, 1, "Op1Test", 0);
+TEST(TestOperator1int_Print) {
+ Operator1<int> op1(12, N, "Op1Test", 0, 0, 0, 1, 0, 0, 0);
CHECK_EQ("Op1Test[0]", OperatorToString(&op1).get());
- Operator1<int> op2(12, Operator::kNoProperties, 0, 1, "Op1Test", 66666666);
+ Operator1<int> op2(12, N, "Op1Test", 0, 0, 0, 1, 0, 0, 66666666);
CHECK_EQ("Op1Test[66666666]", OperatorToString(&op2).get());
- Operator1<int> op3(12, Operator::kNoProperties, 0, 1, "FooBar", 2347);
+ Operator1<int> op3(12, N, "FooBar", 0, 0, 0, 1, 0, 0, 2347);
CHECK_EQ("FooBar[2347]", OperatorToString(&op3).get());
- Operator1<int> op4(12, Operator::kNoProperties, 0, 1, "BarFoo", -879);
+ Operator1<int> op4(12, N, "BarFoo", 0, 0, 0, 1, 0, 0, -879);
CHECK_EQ("BarFoo[-879]", OperatorToString(&op4).get());
}
-TEST(TestOperator1doubleHash) {
- Operator1<double> op1a(23, Operator::kNoProperties, 0, 0, "Wolfie", 11.77);
- Operator1<double> op1b(23, Operator::kFoldable, 2, 2, "Doggie", 11.77);
+TEST(TestOperator1double_Hash) {
+ Operator1<double> op1a(23, N, "Wolfie", 0, 0, 0, 0, 0, 0, 11.77);
+ Operator1<double> op1b(23, F, "Doggie", 2, 0, 0, 2, 0, 0, 11.77);
CHECK(op1a.HashCode() == op1b.HashCode());
- Operator1<double> op2a(24, Operator::kNoProperties, 0, 0, "Arfie", -6.7);
- Operator1<double> op2b(24, Operator::kNoProperties, 0, 0, "Arfie", -6.8);
+ Operator1<double> op2a(24, N, "Arfie", 0, 0, 0, 0, 0, 0, -6.7);
+ Operator1<double> op2b(24, N, "Arfie", 0, 0, 0, 0, 0, 0, -6.8);
CHECK(op1a.HashCode() != op2a.HashCode());
CHECK(op2a.HashCode() != op2b.HashCode());
}
-TEST(TestOperator1doubleEquals) {
- Operator1<double> op1a(23, Operator::kNoProperties, 0, 0, "Scratchy", 11.77);
- Operator1<double> op1b(23, Operator::kFoldable, 2, 2, "Scratchy", 11.77);
+TEST(TestOperator1doublePrint) {
+ Operator1<double> op1a(23, N, "Canary", 0, 0, 0, 0, 0, 0, 0.5);
+ Operator1<double> op1b(23, F, "Finch", 2, 0, 0, 2, 0, 0, -1.5);
+
+ CHECK_EQ("Canary[0.5]", OperatorToString(&op1a).get());
+ CHECK_EQ("Finch[-1.5]", OperatorToString(&op1b).get());
+}
+
+
+TEST(TestOperator1double_Equals) {
+ Operator1<double> op1a(23, N, "Scratchy", 0, 0, 0, 0, 0, 0, 11.77);
+ Operator1<double> op1b(23, F, "Scratchy", 2, 0, 0, 2, 0, 0, 11.77);
CHECK(op1a.Equals(&op1a));
CHECK(op1a.Equals(&op1b));
CHECK(op1b.Equals(&op1a));
CHECK(op1b.Equals(&op1b));
- Operator1<double> op2a(24, Operator::kNoProperties, 0, 0, "Im", 3.1);
- Operator1<double> op2b(24, Operator::kNoProperties, 0, 0, "Im", 3.2);
+ Operator1<double> op2a(24, N, "Im", 0, 0, 0, 0, 0, 0, 3.1);
+ Operator1<double> op2b(24, N, "Im", 0, 0, 0, 0, 0, 0, 3.2);
CHECK(op2a.Equals(&op2a));
CHECK(!op2a.Equals(&op2b));
@@ -198,7 +211,7 @@ TEST(TestOperator1doubleEquals) {
CHECK(!op2b.Equals(&op1a));
CHECK(!op2b.Equals(&op1b));
- SimpleOperator op3(25, Operator::kNoProperties, 0, 0, "Weepy");
+ Operator op3(25, N, "Weepy", 0, 0, 0, 0, 0, 0);
CHECK(!op1a.Equals(&op3));
CHECK(!op1b.Equals(&op3));
@@ -210,8 +223,8 @@ TEST(TestOperator1doubleEquals) {
CHECK(!op3.Equals(&op2a));
CHECK(!op3.Equals(&op2b));
- Operator1<double> op4a(24, Operator::kNoProperties, 0, 0, "Bashful", 1.0);
- Operator1<double> op4b(24, Operator::kNoProperties, 0, 0, "Bashful", 1.0);
+ Operator1<double> op4a(24, N, "Bashful", 0, 0, 0, 0, 0, 0, 1.0);
+ Operator1<double> op4b(24, N, "Bashful", 0, 0, 0, 0, 0, 0, 1.0);
CHECK(op4a.Equals(&op4a));
CHECK(op4a.Equals(&op4b));
@@ -223,3 +236,45 @@ TEST(TestOperator1doubleEquals) {
CHECK(!op3.Equals(&op4a));
CHECK(!op3.Equals(&op4b));
}
+
+
+TEST(TestOpParameter_Operator1double) {
+ double values[] = {7777.5, -66, 0, 11, 0.1};
+
+ for (size_t i = 0; i < arraysize(values); i++) {
+ Operator1<double> op(33, N, "Scurvy", 0, 0, 0, 0, 0, 0, values[i]);
+ CHECK_EQ(values[i], OpParameter<double>(&op));
+ }
+}
+
+
+TEST(TestOpParameter_Operator1float) {
+ float values[] = {7777.5, -66, 0, 11, 0.1};
+
+ for (size_t i = 0; i < arraysize(values); i++) {
+ Operator1<float> op(33, N, "Scurvy", 0, 0, 0, 0, 0, 0, values[i]);
+ CHECK_EQ(values[i], OpParameter<float>(&op));
+ }
+}
+
+
+TEST(TestOpParameter_Operator1int) {
+ int values[] = {7777, -66, 0, 11, 1, 0x666aff};
+
+ for (size_t i = 0; i < arraysize(values); i++) {
+ Operator1<int> op(33, N, "Scurvy", 0, 0, 0, 0, 0, 0, values[i]);
+ CHECK_EQ(values[i], OpParameter<int>(&op));
+ }
+}
+
+
+TEST(Operator_CountsOrder) {
+ Operator op(29, N, "Flashy", 11, 22, 33, 44, 55, 66);
+ CHECK_EQ(11, op.ValueInputCount());
+ CHECK_EQ(22, op.EffectInputCount());
+ CHECK_EQ(33, op.ControlInputCount());
+
+ CHECK_EQ(44, op.ValueOutputCount());
+ CHECK_EQ(55, op.EffectOutputCount());
+ CHECK_EQ(66, op.ControlOutputCount());
+}
« no previous file with comments | « test/cctest/compiler/test-node-algorithm.cc ('k') | test/cctest/compiler/test-schedule.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698