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

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

Issue 1347353003: [turbofan] Checking of input counts on node creation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Split the CL (no node editor yet) Created 5 years, 3 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <functional> 5 #include <functional>
6 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "src/compiler/operator-properties.h"
10 #include "test/cctest/types-fuzz.h" 11 #include "test/cctest/types-fuzz.h"
11 #include "test/unittests/compiler/graph-unittest.h" 12 #include "test/unittests/compiler/graph-unittest.h"
12 13
13 using namespace v8::internal; 14 using namespace v8::internal;
14 using namespace v8::internal::compiler; 15 using namespace v8::internal::compiler;
15 16
16 17
17 // TODO(titzer): generate a large set of deterministic inputs for these tests. 18 // TODO(titzer): generate a large set of deterministic inputs for these tests.
18 class TyperTest : public TypedGraphTest { 19 class TyperTest : public TypedGraphTest {
19 public: 20 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 Node* context_node_; 54 Node* context_node_;
54 v8::base::RandomNumberGenerator* rng_; 55 v8::base::RandomNumberGenerator* rng_;
55 std::vector<double> integers; 56 std::vector<double> integers;
56 std::vector<double> int32s; 57 std::vector<double> int32s;
57 58
58 Type* TypeBinaryOp(const Operator* op, Type* lhs, Type* rhs) { 59 Type* TypeBinaryOp(const Operator* op, Type* lhs, Type* rhs) {
59 Node* p0 = Parameter(0); 60 Node* p0 = Parameter(0);
60 Node* p1 = Parameter(1); 61 Node* p1 = Parameter(1);
61 NodeProperties::SetType(p0, lhs); 62 NodeProperties::SetType(p0, lhs);
62 NodeProperties::SetType(p1, rhs); 63 NodeProperties::SetType(p1, rhs);
63 Node* n = graph()->NewNode(op, p0, p1, context_node_, graph()->start(), 64 std::vector<Node*> inputs;
64 graph()->start()); 65 inputs.push_back(p0);
66 inputs.push_back(p1);
67 if (OperatorProperties::HasContextInput(op)) {
68 inputs.push_back(context_node_);
69 }
70 for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(op); i++) {
71 inputs.push_back(EmptyFrameState());
72 }
73 for (int i = 0; i < op->EffectInputCount(); i++) {
74 inputs.push_back(graph()->start());
75 }
76 for (int i = 0; i < op->ControlInputCount(); i++) {
77 inputs.push_back(graph()->start());
78 }
79 Node* n = graph()->NewNode(op, static_cast<int>(inputs.size()),
80 &(inputs.front()));
65 return NodeProperties::GetType(n); 81 return NodeProperties::GetType(n);
66 } 82 }
67 83
68 Type* RandomRange(bool int32 = false) { 84 Type* RandomRange(bool int32 = false) {
69 std::vector<double>& numbers = int32 ? int32s : integers; 85 std::vector<double>& numbers = int32 ? int32s : integers;
70 double i = numbers[rng_->NextInt(static_cast<int>(numbers.size()))]; 86 double i = numbers[rng_->NextInt(static_cast<int>(numbers.size()))];
71 double j = numbers[rng_->NextInt(static_cast<int>(numbers.size()))]; 87 double j = numbers[rng_->NextInt(static_cast<int>(numbers.size()))];
72 return NewRange(i, j); 88 return NewRange(i, j);
73 } 89 }
74 90
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 412
397 413
398 TEST_F(TyperTest, TypeRegressInt32Constant) { 414 TEST_F(TyperTest, TypeRegressInt32Constant) {
399 int values[] = {-5, 10}; 415 int values[] = {-5, 10};
400 for (auto i : values) { 416 for (auto i : values) {
401 Node* c = graph()->NewNode(common()->Int32Constant(i)); 417 Node* c = graph()->NewNode(common()->Int32Constant(i));
402 Type* type = NodeProperties::GetType(c); 418 Type* type = NodeProperties::GetType(c);
403 EXPECT_TRUE(type->Is(NewRange(i, i))); 419 EXPECT_TRUE(type->Is(NewRange(i, i)));
404 } 420 }
405 } 421 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698