2014-08-12 08:24:20 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-10-01 08:34:25 +00:00
|
|
|
#ifndef V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_
|
|
|
|
#define V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_
|
2014-08-12 08:24:20 +00:00
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
#include "src/compiler/common-operator.h"
|
2014-08-18 06:54:07 +00:00
|
|
|
#include "src/compiler/graph.h"
|
2014-10-15 11:38:04 +00:00
|
|
|
#include "src/compiler/typer.h"
|
2014-10-01 08:34:25 +00:00
|
|
|
#include "test/unittests/test-utils.h"
|
2014-08-12 08:24:20 +00:00
|
|
|
#include "testing/gmock/include/gmock/gmock.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// Forward declarations.
|
2014-10-07 07:36:21 +00:00
|
|
|
template <class T>
|
|
|
|
class Handle;
|
2014-08-12 08:24:20 +00:00
|
|
|
class HeapObject;
|
|
|
|
|
|
|
|
namespace compiler {
|
|
|
|
|
2014-08-22 04:47:55 +00:00
|
|
|
using ::testing::Matcher;
|
|
|
|
|
2016-10-10 05:53:31 +00:00
|
|
|
class GraphTest : public virtual TestWithNativeContext,
|
|
|
|
public virtual TestWithIsolateAndZone {
|
2014-08-18 06:54:07 +00:00
|
|
|
public:
|
2014-12-22 14:37:16 +00:00
|
|
|
explicit GraphTest(int num_parameters = 1);
|
2015-04-20 13:08:11 +00:00
|
|
|
~GraphTest() override;
|
2014-08-18 06:54:07 +00:00
|
|
|
|
2015-01-20 09:45:02 +00:00
|
|
|
Node* start() { return graph()->start(); }
|
2015-02-17 13:29:31 +00:00
|
|
|
Node* end() { return graph()->end(); }
|
|
|
|
|
2014-12-22 14:37:16 +00:00
|
|
|
Node* Parameter(int32_t index = 0);
|
2014-09-22 11:42:10 +00:00
|
|
|
Node* Float32Constant(volatile float value);
|
|
|
|
Node* Float64Constant(volatile double value);
|
2014-08-22 04:47:55 +00:00
|
|
|
Node* Int32Constant(int32_t value);
|
2014-10-09 12:20:45 +00:00
|
|
|
Node* Uint32Constant(uint32_t value) {
|
|
|
|
return Int32Constant(bit_cast<int32_t>(value));
|
|
|
|
}
|
2014-08-22 07:54:09 +00:00
|
|
|
Node* Int64Constant(int64_t value);
|
2014-09-22 11:42:10 +00:00
|
|
|
Node* NumberConstant(volatile double value);
|
2014-10-07 07:36:21 +00:00
|
|
|
Node* HeapConstant(const Handle<HeapObject>& value);
|
2014-08-22 04:47:55 +00:00
|
|
|
Node* FalseConstant();
|
|
|
|
Node* TrueConstant();
|
2014-10-07 07:36:21 +00:00
|
|
|
Node* UndefinedConstant();
|
2014-08-22 04:47:55 +00:00
|
|
|
|
2015-05-28 09:12:50 +00:00
|
|
|
Node* EmptyFrameState();
|
|
|
|
|
2016-06-08 07:11:41 +00:00
|
|
|
Matcher<Node*> IsBooleanConstant(bool value) {
|
|
|
|
return value ? IsTrueConstant() : IsFalseConstant();
|
|
|
|
}
|
2014-08-22 04:47:55 +00:00
|
|
|
Matcher<Node*> IsFalseConstant();
|
|
|
|
Matcher<Node*> IsTrueConstant();
|
2016-11-24 06:36:46 +00:00
|
|
|
Matcher<Node*> IsNullConstant();
|
2015-01-27 14:02:21 +00:00
|
|
|
Matcher<Node*> IsUndefinedConstant();
|
2014-08-22 04:47:55 +00:00
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
CommonOperatorBuilder* common() { return &common_; }
|
2014-08-18 06:54:07 +00:00
|
|
|
Graph* graph() { return &graph_; }
|
|
|
|
|
|
|
|
private:
|
2014-09-01 10:26:12 +00:00
|
|
|
CommonOperatorBuilder common_;
|
2014-08-18 06:54:07 +00:00
|
|
|
Graph graph_;
|
2014-10-15 11:38:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TypedGraphTest : public GraphTest {
|
|
|
|
public:
|
2014-12-22 14:37:16 +00:00
|
|
|
explicit TypedGraphTest(int num_parameters = 1);
|
2015-04-20 13:08:11 +00:00
|
|
|
~TypedGraphTest() override;
|
2014-10-15 11:38:04 +00:00
|
|
|
|
|
|
|
protected:
|
2014-12-22 14:37:16 +00:00
|
|
|
Node* Parameter(int32_t index = 0) { return GraphTest::Parameter(index); }
|
|
|
|
Node* Parameter(Type* type, int32_t index = 0);
|
|
|
|
|
2014-10-15 11:38:04 +00:00
|
|
|
Typer* typer() { return &typer_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Typer typer_;
|
2014-08-18 06:54:07 +00:00
|
|
|
};
|
|
|
|
|
2014-08-12 08:24:20 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
2014-10-01 08:34:25 +00:00
|
|
|
#endif // V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_
|