Reviewers: fschneider, Steven,

Message:
We don't need this anymore.

Description:
Remove ExitContextStatement.

All the constructs that used it are now properly bracketed in the AST and we
handle abrupt exits without try/finally.  We can treat normal context exit
as occurring implicitly at the end of a body.


Please review this at http://codereview.chromium.org/7837025/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/ast.h
  M src/ast.cc
  M src/full-codegen.cc
  M src/hydrogen.cc
  M src/parser.cc
  M src/prettyprinter.cc
  M src/rewriter.cc


Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index 8b8a2a884ec8c7eda051c7884b13be7f135ce9dc..a44d9ee460edf3b12585bcddb8099694e351a514 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -404,11 +404,6 @@ bool WithStatement::IsInlineable() const {
 }


-bool ExitContextStatement::IsInlineable() const {
-  return false;
-}
-
-
 bool SwitchStatement::IsInlineable() const {
   return false;
 }
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 0eacb421029431f2907e348f3558509b732b4112..2b32cdfa91ff7bd4ff7b194f3529670e1c474975 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -62,7 +62,6 @@ namespace internal {
   V(BreakStatement)                             \
   V(ReturnStatement)                            \
   V(WithStatement)                              \
-  V(ExitContextStatement)                       \
   V(SwitchStatement)                            \
   V(DoWhileStatement)                           \
   V(WhileStatement)                             \
@@ -681,14 +680,6 @@ class WithStatement: public Statement {
 };


-class ExitContextStatement: public Statement {
- public:
-  virtual bool IsInlineable() const;
-
-  DECLARE_NODE_TYPE(ExitContextStatement)
-};
-
-
 class CaseClause: public ZoneObject {
  public:
   CaseClause(Isolate* isolate,
Index: src/full-codegen.cc
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index d810bb3dc0823a661d740708408c34e98462e332..53ace82fe7a28b7bb28b3ba60708b2dfdc5c5070 100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -96,11 +96,6 @@ void BreakableStatementChecker::VisitWithStatement(WithStatement* stmt) {
 }


-void BreakableStatementChecker::VisitExitContextStatement(
-    ExitContextStatement* stmt) {
-}
-
-
void BreakableStatementChecker::VisitSwitchStatement(SwitchStatement* stmt) {
   // Switch statements breakable if the tag expression is.
   Visit(stmt->tag());
@@ -989,17 +984,6 @@ void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) {
 }


-void FullCodeGenerator::VisitExitContextStatement(ExitContextStatement* stmt) {
-  Comment cmnt(masm_, "[ ExitContextStatement");
-  SetStatementPosition(stmt);
-
-  // Pop context.
-  LoadContextField(context_register(), Context::PREVIOUS_INDEX);
-  // Update local stack frame context field.
- StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
-}
-
-
 void FullCodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) {
   Comment cmnt(masm_, "[ DoWhileStatement");
   SetStatementPosition(stmt);
@@ -1147,6 +1131,9 @@ void FullCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
   { WithOrCatch body(this);
     Visit(stmt->catch_block());
   }
+  // Restore the context.
+  LoadContextField(context_register(), Context::PREVIOUS_INDEX);
+ StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
   scope_ = saved_scope;
   __ jmp(&done);

Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 01046bf9bfe52438cfe2f7c65dbc6469a0d92b29..8c937c04b85d99844b2f718833ab0d3ae787b4bd 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -2652,14 +2652,6 @@ void HGraphBuilder::VisitWithStatement(WithStatement* stmt) {
 }


-void HGraphBuilder::VisitExitContextStatement(ExitContextStatement* stmt) {
-  ASSERT(!HasStackOverflow());
-  ASSERT(current_block() != NULL);
-  ASSERT(current_block()->HasPredecessor());
-  return Bailout("ExitContextStatement");
-}
-
-
 void HGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
   ASSERT(!HasStackOverflow());
   ASSERT(current_block() != NULL);
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 056133449cd4ef342780f9b7cf8d8db8f4545347..31c5dc818cabe629255203e7a661cd3f4e1a2897 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2216,8 +2216,6 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
     Expect(Token::RPAREN, CHECK_OK);

     if (peek() == Token::LBRACE) {
-      // Rewrite the catch body { B } to a block:
-      // { { B } ExitContext; }.
       Target target(&this->target_stack_, &catch_collector);
catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE, inside_with());
       if (top_scope_->is_strict_mode()) {
@@ -2226,14 +2224,11 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
       Variable::Mode mode = harmony_block_scoping_
           ? Variable::LET : Variable::VAR;
       catch_variable = catch_scope->DeclareLocal(name, mode);
-      catch_block = new(zone()) Block(isolate(), NULL, 2, false);

       Scope* saved_scope = top_scope_;
       top_scope_ = catch_scope;
-      Block* catch_body = ParseBlock(NULL, CHECK_OK);
+      catch_block = ParseBlock(NULL, CHECK_OK);
       top_scope_ = saved_scope;
-      catch_block->AddStatement(catch_body);
-      catch_block->AddStatement(new(zone()) ExitContextStatement());
     } else {
       Expect(Token::LBRACE, CHECK_OK);
     }
Index: src/prettyprinter.cc
diff --git a/src/prettyprinter.cc b/src/prettyprinter.cc
index 2a415923312bd6713d79ac770095da3824a64e45..36860a36f922d684d1d0f9929d5d112d2a133a51 100644
--- a/src/prettyprinter.cc
+++ b/src/prettyprinter.cc
@@ -131,11 +131,6 @@ void PrettyPrinter::VisitWithStatement(WithStatement* node) {
 }


-void PrettyPrinter::VisitExitContextStatement(ExitContextStatement* node) {
-  Print("<exit context>");
-}
-
-
 void PrettyPrinter::VisitSwitchStatement(SwitchStatement* node) {
   PrintLabels(node->labels());
   Print("switch (");
@@ -783,11 +778,6 @@ void AstPrinter::VisitWithStatement(WithStatement* node) {
 }


-void AstPrinter::VisitExitContextStatement(ExitContextStatement* node) {
-  PrintIndented("EXIT CONTEXT\n");
-}
-
-
 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) {
   IndentedScope indent(this, "SWITCH");
   PrintLabelsIndented(NULL, node->labels());
@@ -1187,11 +1177,6 @@ void JsonAstBuilder::VisitWithStatement(WithStatement* stmt) {
 }


-void JsonAstBuilder::VisitExitContextStatement(ExitContextStatement* stmt) {
-  TagScope tag(this, "ExitContextStatement");
-}
-
-
 void JsonAstBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
   TagScope tag(this, "SwitchStatement");
 }
Index: src/rewriter.cc
diff --git a/src/rewriter.cc b/src/rewriter.cc
index ad6ce056b2c85228a3772af4a3daa3a444f66b79..3d4c2dcc126a8129d26a2376bfdb2fffb38b7da8 100644
--- a/src/rewriter.cc
+++ b/src/rewriter.cc
@@ -208,7 +208,6 @@ void Processor::VisitWithStatement(WithStatement* node) {
 void Processor::VisitDeclaration(Declaration* node) {}
 void Processor::VisitEmptyStatement(EmptyStatement* node) {}
 void Processor::VisitReturnStatement(ReturnStatement* node) {}
-void Processor::VisitExitContextStatement(ExitContextStatement* node) {}
 void Processor::VisitDebuggerStatement(DebuggerStatement* node) {}




--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to