Reviewers: titzer,
Description:
Minor simplification and cleanup of graph builder.
[email protected]
Please review this at https://codereview.chromium.org/448113002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+28, -50 lines):
M src/compiler/ast-graph-builder.h
M src/compiler/ast-graph-builder.cc
M src/compiler/control-builders.h
M src/compiler/graph-builder.h
M src/compiler/graph-builder.cc
M src/compiler/pipeline.cc
M test/cctest/compiler/simplified-graph-builder.h
M test/mjsunit/mjsunit.status
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc
b/src/compiler/ast-graph-builder.cc
index
ac5070869f41eee26104ef4d15452e4846432d42..2c242cbe1434c28cf76f0ef8bfb583fa277fa69e
100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -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);
Index: src/compiler/ast-graph-builder.h
diff --git a/src/compiler/ast-graph-builder.h
b/src/compiler/ast-graph-builder.h
index
ccdb7538a431dea66bf982e7170d0405b3fcb85b..950529a842db2e059e26d11ad0c43ba40aa2f0fc
100644
--- a/src/compiler/ast-graph-builder.h
+++ b/src/compiler/ast-graph-builder.h
@@ -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_;
Index: src/compiler/control-builders.h
diff --git a/src/compiler/control-builders.h
b/src/compiler/control-builders.h
index
9b604c126186026ee014ad0c6ab2ce541bc4797a..695282be8aab0901a3d252ba70aa95b4a634d3d6
100644
--- a/src/compiler/control-builders.h
+++ b/src/compiler/control-builders.h
@@ -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_;
Index: src/compiler/graph-builder.cc
diff --git a/src/compiler/graph-builder.cc b/src/compiler/graph-builder.cc
index
fe55196332b1f7a2d88062a3a162a8f0467c0a12..c6e3ad24183e2dde6e139932e2ca3c20b74f89d1
100644
--- a/src/compiler/graph-builder.cc
+++ b/src/compiler/graph-builder.cc
@@ -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 (NodeProperties::HasControlOutput(result) &&
- !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);
}
Index: src/compiler/graph-builder.h
diff --git a/src/compiler/graph-builder.h b/src/compiler/graph-builder.h
index
ac42f6e7f678e9fe93cca457a127d5710ff2e3b6..fc9000855429d1513700cfd54521d5ea98a8124c
100644
--- a/src/compiler/graph-builder.h
+++ b/src/compiler/graph-builder.h
@@ -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);
Index: src/compiler/pipeline.cc
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index
1752882779c78fe7b2f3baf11e6172a140e9083f..ca47b70bef7bc889ec94265b3f68c96ce931f467
100644
--- a/src/compiler/pipeline.cc
+++ b/src/compiler/pipeline.cc
@@ -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_;
};
Index: test/cctest/compiler/simplified-graph-builder.h
diff --git a/test/cctest/compiler/simplified-graph-builder.h
b/test/cctest/compiler/simplified-graph-builder.h
index
26a265b18ea7226e6284522e434720432b271863..fa9161e17138a51c6f0981e2a4e3f57ceb874d01
100644
--- a/test/cctest/compiler/simplified-graph-builder.h
+++ b/test/cctest/compiler/simplified-graph-builder.h
@@ -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.
Index: test/mjsunit/mjsunit.status
diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status
index
fe22d1b17a9fa963e84c7637b1c4d71bad904f03..a1f56b824c9d359717e6f612fe4a4429a8cf023f
100644
--- a/test/mjsunit/mjsunit.status
+++ b/test/mjsunit/mjsunit.status
@@ -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],
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.