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
parent f7c49baf
...@@ -16,12 +16,10 @@ namespace v8 { ...@@ -16,12 +16,10 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
AstGraphBuilder::AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph, AstGraphBuilder::AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph)
SourcePositionTable* source_positions)
: StructuredGraphBuilder(jsgraph->graph(), jsgraph->common()), : StructuredGraphBuilder(jsgraph->graph(), jsgraph->common()),
info_(info), info_(info),
jsgraph_(jsgraph), jsgraph_(jsgraph),
source_positions_(source_positions),
globals_(0, info->zone()), globals_(0, info->zone()),
breakable_(NULL), breakable_(NULL),
execution_context_(NULL) { execution_context_(NULL) {
...@@ -55,13 +53,9 @@ bool AstGraphBuilder::CreateGraph() { ...@@ -55,13 +53,9 @@ bool AstGraphBuilder::CreateGraph() {
Scope* scope = info()->scope(); Scope* scope = info()->scope();
DCHECK(graph() != NULL); DCHECK(graph() != NULL);
SourcePositionTable::Scope start_pos(
source_positions(),
SourcePosition(info()->shared_info()->start_position()));
// Set up the basic structure of the graph. // Set up the basic structure of the graph.
graph()->SetStart( int parameter_count = info()->num_parameters();
graph()->NewNode(common()->Start(info()->num_parameters()))); graph()->SetStart(graph()->NewNode(common()->Start(parameter_count)));
// Initialize the top-level environment. // Initialize the top-level environment.
Environment env(this, scope, graph()->start()); Environment env(this, scope, graph()->start());
...@@ -98,10 +92,6 @@ bool AstGraphBuilder::CreateGraph() { ...@@ -98,10 +92,6 @@ bool AstGraphBuilder::CreateGraph() {
VisitStatements(info()->function()->body()); VisitStatements(info()->function()->body());
if (HasStackOverflow()) return false; 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. // Emit tracing call if requested to do so.
if (FLAG_trace) { if (FLAG_trace) {
// TODO(mstarzinger): Only traces implicit return. // TODO(mstarzinger): Only traces implicit return.
...@@ -1958,10 +1948,9 @@ Node* AstGraphBuilder::BuildBinaryOp(Node* left, Node* right, Token::Value op) { ...@@ -1958,10 +1948,9 @@ Node* AstGraphBuilder::BuildBinaryOp(Node* left, Node* right, Token::Value op) {
void AstGraphBuilder::BuildLazyBailout(Node* node, BailoutId ast_id) { void AstGraphBuilder::BuildLazyBailout(Node* node, BailoutId ast_id) {
if (OperatorProperties::CanLazilyDeoptimize(node->op())) { if (OperatorProperties::CanLazilyDeoptimize(node->op())) {
// The deopting node should have an outgoing control dependency. // The deopting node should have an outgoing control dependency.
DCHECK(GetControlDependency() == node); DCHECK(environment()->GetControlDependency() == node);
StructuredGraphBuilder::Environment* continuation_env = StructuredGraphBuilder::Environment* continuation_env = environment();
environment_internal();
// Create environment for the deoptimization block, and build the block. // Create environment for the deoptimization block, and build the block.
StructuredGraphBuilder::Environment* deopt_env = StructuredGraphBuilder::Environment* deopt_env =
CopyEnvironment(continuation_env); CopyEnvironment(continuation_env);
......
...@@ -25,8 +25,7 @@ class Graph; ...@@ -25,8 +25,7 @@ class Graph;
// of function inlining. // of function inlining.
class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor { class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
public: public:
AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph, AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph);
SourcePositionTable* source_positions_);
// Creates a graph by visiting the entire AST. // Creates a graph by visiting the entire AST.
bool CreateGraph(); bool CreateGraph();
...@@ -41,7 +40,8 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor { ...@@ -41,7 +40,8 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
class Environment; class Environment;
Environment* environment() { Environment* environment() {
return reinterpret_cast<Environment*>(environment_internal()); return reinterpret_cast<Environment*>(
StructuredGraphBuilder::environment());
} }
AstContext* ast_context() const { return ast_context_; } AstContext* ast_context() const { return ast_context_; }
...@@ -57,8 +57,6 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor { ...@@ -57,8 +57,6 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
typedef StructuredGraphBuilder::Environment BaseEnvironment; typedef StructuredGraphBuilder::Environment BaseEnvironment;
virtual BaseEnvironment* CopyEnvironment(BaseEnvironment* env); virtual BaseEnvironment* CopyEnvironment(BaseEnvironment* env);
SourcePositionTable* source_positions() { return source_positions_; }
// TODO(mstarzinger): The pipeline only needs to be a friend to access the // TODO(mstarzinger): The pipeline only needs to be a friend to access the
// function context. Remove as soon as the context is a parameter. // function context. Remove as soon as the context is a parameter.
friend class Pipeline; friend class Pipeline;
...@@ -114,7 +112,6 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor { ...@@ -114,7 +112,6 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
CompilationInfo* info_; CompilationInfo* info_;
AstContext* ast_context_; AstContext* ast_context_;
JSGraph* jsgraph_; JSGraph* jsgraph_;
SourcePositionTable* source_positions_;
// List of global declarations for functions and variables. // List of global declarations for functions and variables.
ZoneList<Handle<Object> > globals_; ZoneList<Handle<Object> > globals_;
......
...@@ -33,7 +33,7 @@ class ControlBuilder { ...@@ -33,7 +33,7 @@ class ControlBuilder {
typedef StructuredGraphBuilder::Environment Environment; typedef StructuredGraphBuilder::Environment Environment;
Zone* zone() const { return builder_->zone(); } 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); } void set_environment(Environment* env) { builder_->set_environment(env); }
Builder* builder_; Builder* builder_;
......
...@@ -56,15 +56,15 @@ Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count, ...@@ -56,15 +56,15 @@ Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count,
*current_input++ = environment_->GetEffectDependency(); *current_input++ = environment_->GetEffectDependency();
} }
if (has_control) { if (has_control) {
*current_input++ = GetControlDependency(); *current_input++ = environment_->GetControlDependency();
} }
result = graph()->NewNode(op, input_count_with_deps, buffer); result = graph()->NewNode(op, input_count_with_deps, buffer);
if (has_effect) { if (has_effect) {
environment_->UpdateEffectDependency(result); environment_->UpdateEffectDependency(result);
} }
if (OperatorProperties::HasControlOutput(result->op()) && if (OperatorProperties::HasControlOutput(result->op()) &&
!environment_internal()->IsMarkedAsUnreachable()) { !environment()->IsMarkedAsUnreachable()) {
UpdateControlDependency(result); environment_->UpdateControlDependency(result);
} }
} }
...@@ -72,23 +72,13 @@ Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count, ...@@ -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( void StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction(
Node* exit) { Node* exit) {
if (environment_internal()->IsMarkedAsUnreachable()) return; if (environment()->IsMarkedAsUnreachable()) return;
if (exit_control() != NULL) { if (exit_control() != NULL) {
exit = MergeControl(exit_control(), exit); exit = MergeControl(exit_control(), exit);
} }
environment_internal()->MarkAsUnreachable(); environment()->MarkAsUnreachable();
set_exit_control(exit); set_exit_control(exit);
} }
......
...@@ -109,7 +109,7 @@ class StructuredGraphBuilder : public GraphBuilder { ...@@ -109,7 +109,7 @@ class StructuredGraphBuilder : public GraphBuilder {
virtual Node* MakeNode(Operator* op, int value_input_count, virtual Node* MakeNode(Operator* op, int value_input_count,
Node** value_inputs); Node** value_inputs);
Environment* environment_internal() const { return environment_; } Environment* environment() const { return environment_; }
void set_environment(Environment* env) { environment_ = env; } void set_environment(Environment* env) { environment_ = env; }
Node* current_context() const { return current_context_; } Node* current_context() const { return current_context_; }
...@@ -135,12 +135,6 @@ class StructuredGraphBuilder : public GraphBuilder { ...@@ -135,12 +135,6 @@ class StructuredGraphBuilder : public GraphBuilder {
// depends on the graph builder, but environments themselves are not virtual. // depends on the graph builder, but environments themselves are not virtual.
virtual Environment* CopyEnvironment(Environment* env); 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. // Helper to indicate a node exits the function body.
void UpdateControlDependencyToLeaveFunction(Node* exit); void UpdateControlDependencyToLeaveFunction(Node* exit);
......
...@@ -85,16 +85,25 @@ class AstGraphBuilderWithPositions : public AstGraphBuilder { ...@@ -85,16 +85,25 @@ class AstGraphBuilderWithPositions : public AstGraphBuilder {
public: public:
explicit AstGraphBuilderWithPositions(CompilationInfo* info, JSGraph* jsgraph, explicit AstGraphBuilderWithPositions(CompilationInfo* info, JSGraph* jsgraph,
SourcePositionTable* source_positions) 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) \ #define DEF_VISIT(type) \
virtual void Visit##type(type* node) V8_OVERRIDE { \ virtual void Visit##type(type* node) V8_OVERRIDE { \
SourcePositionTable::Scope pos(source_positions(), \ SourcePositionTable::Scope pos(source_positions_, \
SourcePosition(node->position())); \ SourcePosition(node->position())); \
AstGraphBuilder::Visit##type(node); \ AstGraphBuilder::Visit##type(node); \
} }
AST_NODE_LIST(DEF_VISIT) AST_NODE_LIST(DEF_VISIT)
#undef DEF_VISIT #undef DEF_VISIT
private:
SourcePositionTable* source_positions_;
}; };
......
...@@ -49,7 +49,8 @@ class SimplifiedGraphBuilder ...@@ -49,7 +49,8 @@ class SimplifiedGraphBuilder
MachineOperatorBuilder* machine() const { return machine_; } MachineOperatorBuilder* machine() const { return machine_; }
SimplifiedOperatorBuilder* simplified() const { return simplified_; } SimplifiedOperatorBuilder* simplified() const { return simplified_; }
Environment* environment() { Environment* environment() {
return reinterpret_cast<Environment*>(environment_internal()); return reinterpret_cast<Environment*>(
StructuredGraphBuilder::environment());
} }
// Initialize graph and builder. // Initialize graph and builder.
......
...@@ -66,8 +66,6 @@ ...@@ -66,8 +66,6 @@
# Some tests are over-restrictive about object layout. # Some tests are over-restrictive about object layout.
'array-constructor-feedback': [PASS, NO_VARIANTS], 'array-constructor-feedback': [PASS, NO_VARIANTS],
'array-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. # Some tests are just too slow to run for now.
'big-object-literal': [PASS, NO_VARIANTS], 'big-object-literal': [PASS, NO_VARIANTS],
......
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