v8/test/cctest/compiler/simplified-graph-builder.cc
bmeurer@chromium.org d07a2eb806 Rename ASSERT* to DCHECK*.
This way we don't clash with the ASSERT* macros
defined by GoogleTest, and we are one step closer
to being able to replace our homegrown base/ with
base/ from Chrome.

R=jochen@chromium.org, svenpanne@chromium.org

Review URL: https://codereview.chromium.org/430503007

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22812 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-08-04 11:34:54 +00:00

79 lines
2.0 KiB
C++

// 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.
#include "test/cctest/compiler/simplified-graph-builder.h"
namespace v8 {
namespace internal {
namespace compiler {
SimplifiedGraphBuilder::SimplifiedGraphBuilder(
Graph* graph, CommonOperatorBuilder* common,
MachineOperatorBuilder* machine, SimplifiedOperatorBuilder* simplified)
: StructuredGraphBuilder(graph, common),
machine_(machine),
simplified_(simplified) {}
void SimplifiedGraphBuilder::Begin() {
DCHECK(graph()->start() == NULL);
Node* start = graph()->NewNode(common()->Start());
graph()->SetStart(start);
set_environment(new (zone()) Environment(this, start));
}
void SimplifiedGraphBuilder::Return(Node* value) {
Node* control = NewNode(common()->Return(), value);
UpdateControlDependencyToLeaveFunction(control);
}
void SimplifiedGraphBuilder::End() {
environment()->UpdateControlDependency(exit_control());
graph()->SetEnd(NewNode(common()->End()));
}
SimplifiedGraphBuilder::Environment::Environment(
SimplifiedGraphBuilder* builder, Node* control_dependency)
: StructuredGraphBuilder::Environment(builder, control_dependency) {}
Node* SimplifiedGraphBuilder::Environment::Top() {
DCHECK(!values()->empty());
return values()->back();
}
void SimplifiedGraphBuilder::Environment::Push(Node* node) {
values()->push_back(node);
}
Node* SimplifiedGraphBuilder::Environment::Pop() {
DCHECK(!values()->empty());
Node* back = values()->back();
values()->pop_back();
return back;
}
void SimplifiedGraphBuilder::Environment::Poke(size_t depth, Node* node) {
DCHECK(depth < values()->size());
size_t index = values()->size() - depth - 1;
values()->at(index) = node;
}
Node* SimplifiedGraphBuilder::Environment::Peek(size_t depth) {
DCHECK(depth < values()->size());
size_t index = values()->size() - depth - 1;
return values()->at(index);
}
} // namespace compiler
} // namespace internal
} // namespace v8