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