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.

Review URL: http://codereview.chromium.org/7837025

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9189 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ca67c5a2
......@@ -404,11 +404,6 @@ bool WithStatement::IsInlineable() const {
}
bool ExitContextStatement::IsInlineable() const {
return false;
}
bool SwitchStatement::IsInlineable() const {
return false;
}
......
......@@ -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,
......
......@@ -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);
......
......@@ -2654,14 +2654,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);
......
......@@ -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);
}
......
......@@ -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");
}
......
......@@ -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) {}
......
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