Reviewers: jarin,

Description:
Fix try-finally for dead AST-branches in TurboFan.

[email protected]
TEST=mjsunit/regress/regress-crbug-455644
BUG=chromium:455644
LOG=N

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

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

Affected files (+11, -10 lines):
  M src/compiler/ast-graph-builder.h
  M src/compiler/ast-graph-builder.cc
  M src/compiler/control-builders.h
  M src/compiler/control-builders.cc
  A + test/mjsunit/regress/regress-crbug-455644.js


Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index b3c40b3e2e25d7ca7bcd4ff9dcb63508f37078cf..5a87e328ace2b419caf9a6d131eaad61600bb1e2 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1194,7 +1194,6 @@ void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) {

   // Create a catch scope that binds the exception.
   Node* exception = try_control.GetExceptionNode();
-  if (exception == NULL) exception = jsgraph()->NullConstant();
   Unique<String> name = MakeUnique(stmt->variable()->name());
   const Operator* op = javascript()->CreateCatchContext(name);
   Node* context = NewNode(op, exception, GetFunctionClosure());
Index: src/compiler/ast-graph-builder.h
diff --git a/src/compiler/ast-graph-builder.h b/src/compiler/ast-graph-builder.h index 6da40f4bc79257d4fad4166275606adc1d2f64bd..658e7368d4d0e2ba54fbcc208bb54d57cd20f0e4 100644
--- a/src/compiler/ast-graph-builder.h
+++ b/src/compiler/ast-graph-builder.h
@@ -55,6 +55,7 @@ class AstGraphBuilder : public AstVisitor {

   // Get the node that represents the outer function context.
   Node* GetFunctionContext();
+
   // Get the node that represents the outer function closure.
   Node* GetFunctionClosure();

Index: src/compiler/control-builders.cc
diff --git a/src/compiler/control-builders.cc b/src/compiler/control-builders.cc index 6dba2d3ad6083756aef4fbc1e43d392b9e85465b..2ace441e61eac82a83439ed2155a599128a290fb 100644
--- a/src/compiler/control-builders.cc
+++ b/src/compiler/control-builders.cc
@@ -151,7 +151,7 @@ void BlockBuilder::EndBlock() {

 void TryCatchBuilder::BeginTry() {
   catch_environment_ = environment()->CopyAsUnreachable();
-  catch_environment_->Push(nullptr);
+  catch_environment_->Push(the_hole());
 }


@@ -178,7 +178,7 @@ void TryCatchBuilder::EndCatch() {

 void TryFinallyBuilder::BeginTry() {
   finally_environment_ = environment()->CopyAsUnreachable();
-  finally_environment_->Push(nullptr);
+  finally_environment_->Push(the_hole());
 }


Index: src/compiler/control-builders.h
diff --git a/src/compiler/control-builders.h b/src/compiler/control-builders.h index d190f61f5dc2b480b2910fbebc1bb97c6e261577..656b94a9e48e362d1020b1c34289a9fe0aa0f994 100644
--- a/src/compiler/control-builders.h
+++ b/src/compiler/control-builders.h
@@ -32,6 +32,7 @@ class ControlBuilder {
   Zone* zone() const { return builder_->local_zone(); }
   Environment* environment() { return builder_->environment(); }
void set_environment(Environment* env) { builder_->set_environment(env); }
+  Node* the_hole() const { return builder_->jsgraph()->TheHoleConstant(); }

   Builder* builder_;
 };
Index: test/mjsunit/regress/regress-crbug-455644.js
diff --git a/test/mjsunit/compiler/regress-451012.js b/test/mjsunit/regress/regress-crbug-455644.js
similarity index 60%
copy from test/mjsunit/compiler/regress-451012.js
copy to test/mjsunit/regress/regress-crbug-455644.js
index bffc8bc5bdfac32bb561a24153d00157b26ac3a5..4993d857a89f620df2b0d1f9813a2a382a77bd8d 100644
--- a/test/mjsunit/compiler/regress-451012.js
+++ b/test/mjsunit/regress/regress-crbug-455644.js
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

-"use strict";
-function f() {
-  for (let v; v; ) {
-    let x;
+(function f() {
+  do { return 23; } while(false);
+  with (0) {
+    try {
+      return 42;
+    } finally {}
   }
-}
-
-f();
+})();


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