Minor simplification and cleanup of graph builder.

R=rossberg@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23000 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mstarzinger@chromium.org 2014-08-08 13:51:30 +00:00
parent f7c49bafb0
commit 0e47697c18
8 changed files with 28 additions and 50 deletions

View File

@ -16,12 +16,10 @@ namespace v8 {
namespace internal {
namespace compiler {
AstGraphBuilder::AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph,
SourcePositionTable* source_positions)
AstGraphBuilder::AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph)
: StructuredGraphBuilder(jsgraph->graph(), jsgraph->common()),
info_(info),
jsgraph_(jsgraph),
source_positions_(source_positions),
globals_(0, info->zone()),
breakable_(NULL),
execution_context_(NULL) {
@ -55,13 +53,9 @@ bool AstGraphBuilder::CreateGraph() {
Scope* scope = info()->scope();
DCHECK(graph() != NULL);
SourcePositionTable::Scope start_pos(
source_positions(),
SourcePosition(info()->shared_info()->start_position()));
// Set up the basic structure of the graph.
graph()->SetStart(
graph()->NewNode(common()->Start(info()->num_parameters())));
int parameter_count = info()->num_parameters();
graph()->SetStart(graph()->NewNode(common()->Start(parameter_count)));
// Initialize the top-level environment.
Environment env(this, scope, graph()->start());
@ -98,10 +92,6 @@ bool AstGraphBuilder::CreateGraph() {
VisitStatements(info()->function()->body());
if (HasStackOverflow()) return false;
SourcePositionTable::Scope end_pos(
source_positions(),
SourcePosition(info()->shared_info()->end_position() - 1));
// Emit tracing call if requested to do so.
if (FLAG_trace) {
// TODO(mstarzinger): Only traces implicit return.
@ -1958,10 +1948,9 @@ Node* AstGraphBuilder::BuildBinaryOp(Node* left, Node* right, Token::Value op) {
void AstGraphBuilder::BuildLazyBailout(Node* node, BailoutId ast_id) {
if (OperatorProperties::CanLazilyDeoptimize(node->op())) {
// The deopting node should have an outgoing control dependency.
DCHECK(GetControlDependency() == node);
DCHECK(environment()->GetControlDependency() == node);
StructuredGraphBuilder::Environment* continuation_env =
environment_internal();
StructuredGraphBuilder::Environment* continuation_env = environment();
// Create environment for the deoptimization block, and build the block.
StructuredGraphBuilder::Environment* deopt_env =
CopyEnvironment(continuation_env);

View File

@ -25,8 +25,7 @@ class Graph;
// of function inlining.
class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
public:
AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph,
SourcePositionTable* source_positions_);
AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph);
// Creates a graph by visiting the entire AST.
bool CreateGraph();
@ -41,7 +40,8 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
class Environment;
Environment* environment() {
return reinterpret_cast<Environment*>(environment_internal());
return reinterpret_cast<Environment*>(
StructuredGraphBuilder::environment());
}
AstContext* ast_context() const { return ast_context_; }
@ -57,8 +57,6 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
typedef StructuredGraphBuilder::Environment BaseEnvironment;
virtual BaseEnvironment* CopyEnvironment(BaseEnvironment* env);
SourcePositionTable* source_positions() { return source_positions_; }
// TODO(mstarzinger): The pipeline only needs to be a friend to access the
// function context. Remove as soon as the context is a parameter.
friend class Pipeline;
@ -114,7 +112,6 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
CompilationInfo* info_;
AstContext* ast_context_;
JSGraph* jsgraph_;
SourcePositionTable* source_positions_;
// List of global declarations for functions and variables.
ZoneList<Handle<Object> > globals_;

View File

@ -33,7 +33,7 @@ class ControlBuilder {
typedef StructuredGraphBuilder::Environment Environment;
Zone* zone() const { return builder_->zone(); }
Environment* environment() { return builder_->environment_internal(); }
Environment* environment() { return builder_->environment(); }
void set_environment(Environment* env) { builder_->set_environment(env); }
Builder* builder_;

View File

@ -56,15 +56,15 @@ Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count,
*current_input++ = environment_->GetEffectDependency();
}
if (has_control) {
*current_input++ = GetControlDependency();
*current_input++ = environment_->GetControlDependency();
}
result = graph()->NewNode(op, input_count_with_deps, buffer);
if (has_effect) {
environment_->UpdateEffectDependency(result);
}
if (OperatorProperties::HasControlOutput(result->op()) &&
!environment_internal()->IsMarkedAsUnreachable()) {
UpdateControlDependency(result);
!environment()->IsMarkedAsUnreachable()) {
environment_->UpdateControlDependency(result);
}
}
@ -72,23 +72,13 @@ Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count,
}
Node* StructuredGraphBuilder::GetControlDependency() {
return environment_->GetControlDependency();
}
void StructuredGraphBuilder::UpdateControlDependency(Node* new_control) {
environment_->UpdateControlDependency(new_control);
}
void StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction(
Node* exit) {
if (environment_internal()->IsMarkedAsUnreachable()) return;
if (environment()->IsMarkedAsUnreachable()) return;
if (exit_control() != NULL) {
exit = MergeControl(exit_control(), exit);
}
environment_internal()->MarkAsUnreachable();
environment()->MarkAsUnreachable();
set_exit_control(exit);
}

View File

@ -109,7 +109,7 @@ class StructuredGraphBuilder : public GraphBuilder {
virtual Node* MakeNode(Operator* op, int value_input_count,
Node** value_inputs);
Environment* environment_internal() const { return environment_; }
Environment* environment() const { return environment_; }
void set_environment(Environment* env) { environment_ = env; }
Node* current_context() const { return current_context_; }
@ -135,12 +135,6 @@ class StructuredGraphBuilder : public GraphBuilder {
// depends on the graph builder, but environments themselves are not virtual.
virtual Environment* CopyEnvironment(Environment* env);
// Helper when creating node that depends on control.
Node* GetControlDependency();
// Helper when creating node that updates control.
void UpdateControlDependency(Node* new_control);
// Helper to indicate a node exits the function body.
void UpdateControlDependencyToLeaveFunction(Node* exit);

View File

@ -85,16 +85,25 @@ class AstGraphBuilderWithPositions : public AstGraphBuilder {
public:
explicit AstGraphBuilderWithPositions(CompilationInfo* info, JSGraph* jsgraph,
SourcePositionTable* source_positions)
: AstGraphBuilder(info, jsgraph, source_positions) {}
: AstGraphBuilder(info, jsgraph), source_positions_(source_positions) {}
bool CreateGraph() V8_OVERRIDE {
SourcePositionTable::Scope pos(source_positions_,
SourcePosition::Unknown());
return AstGraphBuilder::CreateGraph();
}
#define DEF_VISIT(type) \
virtual void Visit##type(type* node) V8_OVERRIDE { \
SourcePositionTable::Scope pos(source_positions(), \
SourcePositionTable::Scope pos(source_positions_, \
SourcePosition(node->position())); \
AstGraphBuilder::Visit##type(node); \
}
AST_NODE_LIST(DEF_VISIT)
#undef DEF_VISIT
private:
SourcePositionTable* source_positions_;
};

View File

@ -49,7 +49,8 @@ class SimplifiedGraphBuilder
MachineOperatorBuilder* machine() const { return machine_; }
SimplifiedOperatorBuilder* simplified() const { return simplified_; }
Environment* environment() {
return reinterpret_cast<Environment*>(environment_internal());
return reinterpret_cast<Environment*>(
StructuredGraphBuilder::environment());
}
// Initialize graph and builder.

View File

@ -66,8 +66,6 @@
# Some tests are over-restrictive about object layout.
'array-constructor-feedback': [PASS, NO_VARIANTS],
'array-feedback': [PASS, NO_VARIANTS],
'fast-non-keyed': [PASS, NO_VARIANTS],
'track-fields': [PASS, NO_VARIANTS],
# Some tests are just too slow to run for now.
'big-object-literal': [PASS, NO_VARIANTS],