Commit b023875e authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Simplify handling of stack overflows in AstGraphBuilder.

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#26714}
parent e22194ea
...@@ -451,31 +451,30 @@ bool AstGraphBuilder::CreateGraph() { ...@@ -451,31 +451,30 @@ bool AstGraphBuilder::CreateGraph() {
Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver); Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver);
env.Bind(scope->receiver(), patched_receiver); env.Bind(scope->receiver(), patched_receiver);
bool ok; // Build function context only if there are context allocated variables.
int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
if (heap_slots > 0) { if (heap_slots > 0) {
// Push a new inner context scope for the function. // Push a new inner context scope for the function.
Node* closure = GetFunctionClosure(); Node* closure = GetFunctionClosure();
Node* inner_context = BuildLocalFunctionContext(function_context_, closure); Node* inner_context = BuildLocalFunctionContext(function_context_, closure);
ContextScope top_context(this, scope, inner_context); ContextScope top_context(this, scope, inner_context);
ok = CreateGraphBody(); CreateGraphBody();
} else { } else {
// Simply use the outer function context in building the graph. // Simply use the outer function context in building the graph.
ok = CreateGraphBody(); CreateGraphBody();
} }
// Finish the basic structure of the graph. // Finish the basic structure of the graph.
if (ok) { graph()->SetEnd(graph()->NewNode(common()->End(), exit_control()));
environment()->UpdateControlDependency(exit_control());
graph()->SetEnd(NewNode(common()->End()));
}
return ok; // Failures indicated by stack overflow.
return !HasStackOverflow();
} }
bool AstGraphBuilder::CreateGraphBody() { void AstGraphBuilder::CreateGraphBody() {
Scope* scope = info()->scope(); Scope* scope = info()->scope();
// Build the arguments object if it is used. // Build the arguments object if it is used.
BuildArgumentsObject(scope->arguments()); BuildArgumentsObject(scope->arguments());
...@@ -503,7 +502,6 @@ bool AstGraphBuilder::CreateGraphBody() { ...@@ -503,7 +502,6 @@ bool AstGraphBuilder::CreateGraphBody() {
// Visit statements in the function body. // Visit statements in the function body.
VisitStatements(info()->function()->body()); VisitStatements(info()->function()->body());
if (HasStackOverflow()) return false;
// Emit tracing call if requested to do so. // Emit tracing call if requested to do so.
if (FLAG_trace) { if (FLAG_trace) {
...@@ -514,8 +512,6 @@ bool AstGraphBuilder::CreateGraphBody() { ...@@ -514,8 +512,6 @@ bool AstGraphBuilder::CreateGraphBody() {
// Return 'undefined' in case we can fall off the end. // Return 'undefined' in case we can fall off the end.
BuildReturn(jsgraph()->UndefinedConstant()); BuildReturn(jsgraph()->UndefinedConstant());
return true;
} }
......
...@@ -77,8 +77,6 @@ class AstGraphBuilder : public AstVisitor { ...@@ -77,8 +77,6 @@ class AstGraphBuilder : public AstVisitor {
Environment* environment_; Environment* environment_;
AstContext* ast_context_; AstContext* ast_context_;
bool CreateGraphBody();
// List of global declarations for functions and variables. // List of global declarations for functions and variables.
ZoneVector<Handle<Object>> globals_; ZoneVector<Handle<Object>> globals_;
...@@ -129,6 +127,8 @@ class AstGraphBuilder : public AstVisitor { ...@@ -129,6 +127,8 @@ class AstGraphBuilder : public AstVisitor {
void set_execution_context(ContextScope* ctx) { execution_context_ = ctx; } void set_execution_context(ContextScope* ctx) { execution_context_ = ctx; }
void set_exit_control(Node* exit) { exit_control_ = exit; } void set_exit_control(Node* exit) { exit_control_ = exit; }
void CreateGraphBody();
// Node creation helpers. // Node creation helpers.
Node* NewNode(const Operator* op, bool incomplete = false) { Node* NewNode(const Operator* op, bool incomplete = false) {
return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete);
......
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