Commit 2379d34b authored by titzer's avatar titzer Committed by Commit bot

[turbofan] Put StructuredGraphBuilder out of its misery and merge its remnants...

[turbofan] Put StructuredGraphBuilder out of its misery and merge its remnants back into the AstGraphBuilder.

R=mstarzinger@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#26387}
parent 246a749a
......@@ -536,7 +536,6 @@ source_set("v8_base") {
"src/compiler/gap-resolver.cc",
"src/compiler/gap-resolver.h",
"src/compiler/generic-algorithm.h",
"src/compiler/graph-builder.cc",
"src/compiler/graph-builder.h",
"src/compiler/graph-inl.h",
"src/compiler/graph-reducer.cc",
......
This diff is collapsed.
This diff is collapsed.
......@@ -7,7 +7,7 @@
#include "src/v8.h"
#include "src/compiler/graph-builder.h"
#include "src/compiler/ast-graph-builder.h"
#include "src/compiler/node.h"
namespace v8 {
......@@ -19,8 +19,7 @@ namespace compiler {
// used to model breakable statements.
class ControlBuilder {
public:
explicit ControlBuilder(StructuredGraphBuilder* builder)
: builder_(builder) {}
explicit ControlBuilder(AstGraphBuilder* builder) : builder_(builder) {}
virtual ~ControlBuilder() {}
// Interface for break and continue.
......@@ -28,8 +27,8 @@ class ControlBuilder {
virtual void Continue() { UNREACHABLE(); }
protected:
typedef StructuredGraphBuilder Builder;
typedef StructuredGraphBuilder::Environment Environment;
typedef AstGraphBuilder Builder;
typedef AstGraphBuilder::Environment Environment;
Zone* zone() const { return builder_->local_zone(); }
Environment* environment() { return builder_->environment(); }
......@@ -42,7 +41,7 @@ class ControlBuilder {
// Tracks control flow for a conditional statement.
class IfBuilder FINAL : public ControlBuilder {
public:
explicit IfBuilder(StructuredGraphBuilder* builder)
explicit IfBuilder(AstGraphBuilder* builder)
: ControlBuilder(builder),
then_environment_(NULL),
else_environment_(NULL) {}
......@@ -62,7 +61,7 @@ class IfBuilder FINAL : public ControlBuilder {
// Tracks control flow for an iteration statement.
class LoopBuilder FINAL : public ControlBuilder {
public:
explicit LoopBuilder(StructuredGraphBuilder* builder)
explicit LoopBuilder(AstGraphBuilder* builder)
: ControlBuilder(builder),
loop_environment_(NULL),
continue_environment_(NULL),
......@@ -91,7 +90,7 @@ class LoopBuilder FINAL : public ControlBuilder {
// Tracks control flow for a switch statement.
class SwitchBuilder FINAL : public ControlBuilder {
public:
explicit SwitchBuilder(StructuredGraphBuilder* builder, int case_count)
explicit SwitchBuilder(AstGraphBuilder* builder, int case_count)
: ControlBuilder(builder),
body_environment_(NULL),
label_environment_(NULL),
......@@ -124,7 +123,7 @@ class SwitchBuilder FINAL : public ControlBuilder {
// Tracks control flow for a block statement.
class BlockBuilder FINAL : public ControlBuilder {
public:
explicit BlockBuilder(StructuredGraphBuilder* builder)
explicit BlockBuilder(AstGraphBuilder* builder)
: ControlBuilder(builder), break_environment_(NULL) {}
// Primitive control commands.
......
This diff is collapsed.
......@@ -15,13 +15,8 @@
namespace v8 {
namespace internal {
class BitVector;
namespace compiler {
class Node;
// A common base class for anything that creates nodes in a graph.
class GraphBuilder {
public:
......@@ -82,168 +77,6 @@ class GraphBuilder {
Graph* graph_;
};
// The StructuredGraphBuilder produces a high-level IR graph. It is used as the
// base class for concrete implementations (e.g the AstGraphBuilder or the
// StubGraphBuilder).
class StructuredGraphBuilder : public GraphBuilder {
public:
StructuredGraphBuilder(Isolate* isolate, Zone* zone, Graph* graph,
CommonOperatorBuilder* common);
~StructuredGraphBuilder() OVERRIDE {}
// Creates a new Phi node having {count} input values.
Node* NewPhi(int count, Node* input, Node* control);
Node* NewEffectPhi(int count, Node* input, Node* control);
// Helpers for merging control, effect or value dependencies.
Node* MergeControl(Node* control, Node* other);
Node* MergeEffect(Node* value, Node* other, Node* control);
Node* MergeValue(Node* value, Node* other, Node* control);
// Helpers to create new control nodes.
Node* NewIfTrue() { return NewNode(common()->IfTrue()); }
Node* NewIfFalse() { return NewNode(common()->IfFalse()); }
Node* NewMerge() { return NewNode(common()->Merge(1), true); }
Node* NewLoop() { return NewNode(common()->Loop(1), true); }
Node* NewBranch(Node* condition, BranchHint hint = BranchHint::kNone) {
return NewNode(common()->Branch(hint), condition);
}
protected:
class Environment;
friend class Environment;
friend class ControlBuilder;
// The following method creates a new node having the specified operator and
// ensures effect and control dependencies are wired up. The dependencies
// tracked by the environment might be mutated.
Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs,
bool incomplete) FINAL;
Environment* environment() const { return environment_; }
void set_environment(Environment* env) { environment_ = env; }
Node* current_context() const { return current_context_; }
void set_current_context(Node* context) { current_context_ = context; }
Node* exit_control() const { return exit_control_; }
void set_exit_control(Node* node) { exit_control_ = node; }
Node* dead_control();
Zone* graph_zone() const { return graph()->zone(); }
Zone* local_zone() const { return local_zone_; }
CommonOperatorBuilder* common() const { return common_; }
// Helper to wrap a Handle<T> into a Unique<T>.
template <class T>
Unique<T> MakeUnique(Handle<T> object) {
return Unique<T>::CreateUninitialized(object);
}
// Support for control flow builders. The concrete type of the environment
// depends on the graph builder, but environments themselves are not virtual.
virtual Environment* CopyEnvironment(Environment* env);
// Helper to indicate a node exits the function body.
void UpdateControlDependencyToLeaveFunction(Node* exit);
private:
CommonOperatorBuilder* common_;
Environment* environment_;
// Zone local to the builder for data not leaking into the graph.
Zone* local_zone_;
// Temporary storage for building node input lists.
int input_buffer_size_;
Node** input_buffer_;
// Node representing the control dependency for dead code.
SetOncePointer<Node> dead_control_;
// Node representing the current context within the function body.
Node* current_context_;
// Merge of all control nodes that exit the function body.
Node* exit_control_;
// Growth increment for the temporary buffer used to construct input lists to
// new nodes.
static const int kInputBufferSizeIncrement = 64;
Node** EnsureInputBufferSize(int size);
DISALLOW_COPY_AND_ASSIGN(StructuredGraphBuilder);
};
// The abstract execution environment contains static knowledge about
// execution state at arbitrary control-flow points. It allows for
// simulation of the control-flow at compile time.
class StructuredGraphBuilder::Environment : public ZoneObject {
public:
Environment(StructuredGraphBuilder* builder, Node* control_dependency);
Environment(const Environment& copy);
// Control dependency tracked by this environment.
Node* GetControlDependency() { return control_dependency_; }
void UpdateControlDependency(Node* dependency) {
control_dependency_ = dependency;
}
// Effect dependency tracked by this environment.
Node* GetEffectDependency() { return effect_dependency_; }
void UpdateEffectDependency(Node* dependency) {
effect_dependency_ = dependency;
}
// Mark this environment as being unreachable.
void MarkAsUnreachable() {
UpdateControlDependency(builder()->dead_control());
}
bool IsMarkedAsUnreachable() {
return GetControlDependency()->opcode() == IrOpcode::kDead;
}
// Merge another environment into this one.
void Merge(Environment* other);
// Copies this environment at a control-flow split point.
Environment* CopyForConditional() { return builder()->CopyEnvironment(this); }
// Copies this environment to a potentially unreachable control-flow point.
Environment* CopyAsUnreachable() {
Environment* env = builder()->CopyEnvironment(this);
env->MarkAsUnreachable();
return env;
}
// Copies this environment at a loop header control-flow point.
Environment* CopyForLoop(BitVector* assigned, bool is_osr = false) {
PrepareForLoop(assigned, is_osr);
return builder()->CopyEnvironment(this);
}
Node* GetContext() { return builder_->current_context(); }
protected:
Zone* zone() const { return builder_->local_zone(); }
Graph* graph() const { return builder_->graph(); }
StructuredGraphBuilder* builder() const { return builder_; }
CommonOperatorBuilder* common() { return builder_->common(); }
NodeVector* values() { return &values_; }
// Prepare environment to be used as loop header.
void PrepareForLoop(BitVector* assigned, bool is_osr = false);
private:
StructuredGraphBuilder* builder_;
Node* control_dependency_;
Node* effect_dependency_;
NodeVector values_;
};
}
}
} // namespace v8::internal::compiler
......
......@@ -441,7 +441,6 @@
'../../src/compiler/gap-resolver.cc',
'../../src/compiler/gap-resolver.h',
'../../src/compiler/generic-algorithm.h',
'../../src/compiler/graph-builder.cc',
'../../src/compiler/graph-builder.h',
'../../src/compiler/graph-inl.h',
'../../src/compiler/graph-reducer.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment