Reviewers: titzer,

Description:
Simplify handling of stack overflows in AstGraphBuilder.

[email protected]

Please review this at https://codereview.chromium.org/935033002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+10, -14 lines):
  M src/compiler/ast-graph-builder.h
  M src/compiler/ast-graph-builder.cc


Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index c33cc60ce573afa4b9270c3f83a8588e3f085421..30bdcfb29702987ee000983ae7aa011ae28c19d1 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -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;
 }


Index: src/compiler/ast-graph-builder.h
diff --git a/src/compiler/ast-graph-builder.h b/src/compiler/ast-graph-builder.h index 4bf06d820f01bfa78165df90e6b4d628c08d7874..515283fc8a48fabde62cce0b7959e3e1552b98fa 100644
--- a/src/compiler/ast-graph-builder.h
+++ b/src/compiler/ast-graph-builder.h
@@ -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);


--
--
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.

Reply via email to