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
3 // found in the LICENSE file.
5 #include "test/unittests/compiler/graph-unittest.h"
7 #include <ostream> // NOLINT(readability/streams)
9 #include "src/compiler/node-properties-inl.h"
10 #include "test/unittests/compiler/node-test-utils.h"
16 GraphTest::GraphTest(int num_parameters) : common_(zone()), graph_(zone()) {
17 graph()->SetStart(graph()->NewNode(common()->Start(num_parameters)));
21 GraphTest::~GraphTest() {}
24 Node* GraphTest::Parameter(int32_t index) {
25 return graph()->NewNode(common()->Parameter(index), graph()->start());
29 Node* GraphTest::Float32Constant(volatile float value) {
30 return graph()->NewNode(common()->Float32Constant(value));
34 Node* GraphTest::Float64Constant(volatile double value) {
35 return graph()->NewNode(common()->Float64Constant(value));
39 Node* GraphTest::Int32Constant(int32_t value) {
40 return graph()->NewNode(common()->Int32Constant(value));
44 Node* GraphTest::Int64Constant(int64_t value) {
45 return graph()->NewNode(common()->Int64Constant(value));
49 Node* GraphTest::NumberConstant(volatile double value) {
50 return graph()->NewNode(common()->NumberConstant(value));
54 Node* GraphTest::HeapConstant(const Handle<HeapObject>& value) {
55 return HeapConstant(Unique<HeapObject>::CreateUninitialized(value));
59 Node* GraphTest::HeapConstant(const Unique<HeapObject>& value) {
60 Node* node = graph()->NewNode(common()->HeapConstant(value));
61 Type* type = Type::Constant(value.handle(), zone());
62 NodeProperties::SetBounds(node, Bounds(type));
67 Node* GraphTest::FalseConstant() {
69 Unique<HeapObject>::CreateImmovable(factory()->false_value()));
73 Node* GraphTest::TrueConstant() {
75 Unique<HeapObject>::CreateImmovable(factory()->true_value()));
79 Node* GraphTest::UndefinedConstant() {
81 Unique<HeapObject>::CreateImmovable(factory()->undefined_value()));
85 Matcher<Node*> GraphTest::IsFalseConstant() {
86 return IsHeapConstant(
87 Unique<HeapObject>::CreateImmovable(factory()->false_value()));
91 Matcher<Node*> GraphTest::IsTrueConstant() {
92 return IsHeapConstant(
93 Unique<HeapObject>::CreateImmovable(factory()->true_value()));
96 } // namespace compiler
97 } // namespace internal