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

Unified Diff: test/cctest/compiler/simplified-graph-builder.cc

Issue 539903002: Move StructuredMachineAssembler into cctest suite. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add a TODO. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: test/cctest/compiler/simplified-graph-builder.cc
diff --git a/test/cctest/compiler/simplified-graph-builder.cc b/test/cctest/compiler/simplified-graph-builder.cc
index c688399eaec5166e9eb54d27d64dda235e79aaf4..06f6a73b831b4536433b10fd59e608f171a09f2b 100644
--- a/test/cctest/compiler/simplified-graph-builder.cc
+++ b/test/cctest/compiler/simplified-graph-builder.cc
@@ -4,6 +4,9 @@
#include "test/cctest/compiler/simplified-graph-builder.h"
+#include "src/compiler/operator-properties.h"
+#include "src/compiler/operator-properties-inl.h"
+
namespace v8 {
namespace internal {
namespace compiler {
@@ -11,7 +14,10 @@ namespace compiler {
SimplifiedGraphBuilder::SimplifiedGraphBuilder(
Graph* graph, CommonOperatorBuilder* common,
MachineOperatorBuilder* machine, SimplifiedOperatorBuilder* simplified)
- : StructuredGraphBuilder(graph, common),
+ : GraphBuilder(graph),
+ effect_(NULL),
+ return_(NULL),
+ common_(common),
machine_(machine),
simplified_(simplified) {}
@@ -20,57 +26,62 @@ void SimplifiedGraphBuilder::Begin(int num_parameters) {
DCHECK(graph()->start() == NULL);
Node* start = graph()->NewNode(common()->Start(num_parameters));
graph()->SetStart(start);
- set_environment(new (zone()) Environment(this, start));
+ effect_ = start;
}
void SimplifiedGraphBuilder::Return(Node* value) {
- Node* control = NewNode(common()->Return(), value);
- UpdateControlDependencyToLeaveFunction(control);
+ return_ =
+ graph()->NewNode(common()->Return(), value, effect_, graph()->start());
+ effect_ = NULL;
}
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* end = graph()->NewNode(common()->End(), return_);
+ graph()->SetEnd(end);
}
-Node* SimplifiedGraphBuilder::Environment::Peek(size_t depth) {
- DCHECK(depth < values()->size());
- size_t index = values()->size() - depth - 1;
- return values()->at(index);
+Node* SimplifiedGraphBuilder::MakeNode(Operator* op, int value_input_count,
+ Node** value_inputs) {
+ DCHECK(op->InputCount() == value_input_count);
+
+ DCHECK(!OperatorProperties::HasContextInput(op));
+ DCHECK(!OperatorProperties::HasFrameStateInput(op));
+ bool has_control = OperatorProperties::GetControlInputCount(op) == 1;
+ bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1;
+
+ DCHECK(OperatorProperties::GetControlInputCount(op) < 2);
+ DCHECK(OperatorProperties::GetEffectInputCount(op) < 2);
+
+ Node* result = NULL;
+ if (!has_control && !has_effect) {
+ result = graph()->NewNode(op, value_input_count, value_inputs);
+ } else {
+ int input_count_with_deps = value_input_count;
+ if (has_control) ++input_count_with_deps;
+ if (has_effect) ++input_count_with_deps;
+ Node** buffer = zone()->NewArray<Node*>(input_count_with_deps);
+ memcpy(buffer, value_inputs, kPointerSize * value_input_count);
+ Node** current_input = buffer + value_input_count;
+ if (has_effect) {
+ *current_input++ = effect_;
+ }
+ if (has_control) {
+ *current_input++ = graph()->start();
+ }
+ result = graph()->NewNode(op, input_count_with_deps, buffer);
+ if (has_effect) {
+ effect_ = result;
+ }
+ if (OperatorProperties::HasControlOutput(result->op())) {
+ // This graph builder does not support control flow.
+ UNREACHABLE();
+ }
+ }
+
+ return result;
}
} // namespace compiler
« no previous file with comments | « test/cctest/compiler/simplified-graph-builder.h ('k') | test/cctest/compiler/structured-machine-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698