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 { ...@@ -404,11 +404,6 @@ bool WithStatement::IsInlineable() const {
} }
bool ExitContextStatement::IsInlineable() const {
return false;
}
bool SwitchStatement::IsInlineable() const { bool SwitchStatement::IsInlineable() const {
return false; return false;
} }
......
...@@ -62,7 +62,6 @@ namespace internal { ...@@ -62,7 +62,6 @@ namespace internal {
V(BreakStatement) \ V(BreakStatement) \
V(ReturnStatement) \ V(ReturnStatement) \
V(WithStatement) \ V(WithStatement) \
V(ExitContextStatement) \
V(SwitchStatement) \ V(SwitchStatement) \
V(DoWhileStatement) \ V(DoWhileStatement) \
V(WhileStatement) \ V(WhileStatement) \
...@@ -681,14 +680,6 @@ class WithStatement: public Statement { ...@@ -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 { class CaseClause: public ZoneObject {
public: public:
CaseClause(Isolate* isolate, CaseClause(Isolate* isolate,
......
...@@ -96,11 +96,6 @@ void BreakableStatementChecker::VisitWithStatement(WithStatement* stmt) { ...@@ -96,11 +96,6 @@ void BreakableStatementChecker::VisitWithStatement(WithStatement* stmt) {
} }
void BreakableStatementChecker::VisitExitContextStatement(
ExitContextStatement* stmt) {
}
void BreakableStatementChecker::VisitSwitchStatement(SwitchStatement* stmt) { void BreakableStatementChecker::VisitSwitchStatement(SwitchStatement* stmt) {
// Switch statements breakable if the tag expression is. // Switch statements breakable if the tag expression is.
Visit(stmt->tag()); Visit(stmt->tag());
...@@ -989,17 +984,6 @@ void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) { ...@@ -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) { void FullCodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) {
Comment cmnt(masm_, "[ DoWhileStatement"); Comment cmnt(masm_, "[ DoWhileStatement");
SetStatementPosition(stmt); SetStatementPosition(stmt);
...@@ -1147,6 +1131,9 @@ void FullCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { ...@@ -1147,6 +1131,9 @@ void FullCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
{ WithOrCatch body(this); { WithOrCatch body(this);
Visit(stmt->catch_block()); Visit(stmt->catch_block());
} }
// Restore the context.
LoadContextField(context_register(), Context::PREVIOUS_INDEX);
StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
scope_ = saved_scope; scope_ = saved_scope;
__ jmp(&done); __ jmp(&done);
......
...@@ -2654,14 +2654,6 @@ void HGraphBuilder::VisitWithStatement(WithStatement* stmt) { ...@@ -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) { void HGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
ASSERT(!HasStackOverflow()); ASSERT(!HasStackOverflow());
ASSERT(current_block() != NULL); ASSERT(current_block() != NULL);
......
...@@ -2216,8 +2216,6 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { ...@@ -2216,8 +2216,6 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
Expect(Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
if (peek() == Token::LBRACE) { if (peek() == Token::LBRACE) {
// Rewrite the catch body { B } to a block:
// { { B } ExitContext; }.
Target target(&this->target_stack_, &catch_collector); Target target(&this->target_stack_, &catch_collector);
catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE, inside_with()); catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE, inside_with());
if (top_scope_->is_strict_mode()) { if (top_scope_->is_strict_mode()) {
...@@ -2226,14 +2224,11 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { ...@@ -2226,14 +2224,11 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
Variable::Mode mode = harmony_block_scoping_ Variable::Mode mode = harmony_block_scoping_
? Variable::LET : Variable::VAR; ? Variable::LET : Variable::VAR;
catch_variable = catch_scope->DeclareLocal(name, mode); catch_variable = catch_scope->DeclareLocal(name, mode);
catch_block = new(zone()) Block(isolate(), NULL, 2, false);
Scope* saved_scope = top_scope_; Scope* saved_scope = top_scope_;
top_scope_ = catch_scope; top_scope_ = catch_scope;
Block* catch_body = ParseBlock(NULL, CHECK_OK); catch_block = ParseBlock(NULL, CHECK_OK);
top_scope_ = saved_scope; top_scope_ = saved_scope;
catch_block->AddStatement(catch_body);
catch_block->AddStatement(new(zone()) ExitContextStatement());
} else { } else {
Expect(Token::LBRACE, CHECK_OK); Expect(Token::LBRACE, CHECK_OK);
} }
......
...@@ -131,11 +131,6 @@ void PrettyPrinter::VisitWithStatement(WithStatement* node) { ...@@ -131,11 +131,6 @@ void PrettyPrinter::VisitWithStatement(WithStatement* node) {
} }
void PrettyPrinter::VisitExitContextStatement(ExitContextStatement* node) {
Print("<exit context>");
}
void PrettyPrinter::VisitSwitchStatement(SwitchStatement* node) { void PrettyPrinter::VisitSwitchStatement(SwitchStatement* node) {
PrintLabels(node->labels()); PrintLabels(node->labels());
Print("switch ("); Print("switch (");
...@@ -783,11 +778,6 @@ void AstPrinter::VisitWithStatement(WithStatement* node) { ...@@ -783,11 +778,6 @@ void AstPrinter::VisitWithStatement(WithStatement* node) {
} }
void AstPrinter::VisitExitContextStatement(ExitContextStatement* node) {
PrintIndented("EXIT CONTEXT\n");
}
void AstPrinter::VisitSwitchStatement(SwitchStatement* node) { void AstPrinter::VisitSwitchStatement(SwitchStatement* node) {
IndentedScope indent(this, "SWITCH"); IndentedScope indent(this, "SWITCH");
PrintLabelsIndented(NULL, node->labels()); PrintLabelsIndented(NULL, node->labels());
...@@ -1187,11 +1177,6 @@ void JsonAstBuilder::VisitWithStatement(WithStatement* stmt) { ...@@ -1187,11 +1177,6 @@ void JsonAstBuilder::VisitWithStatement(WithStatement* stmt) {
} }
void JsonAstBuilder::VisitExitContextStatement(ExitContextStatement* stmt) {
TagScope tag(this, "ExitContextStatement");
}
void JsonAstBuilder::VisitSwitchStatement(SwitchStatement* stmt) { void JsonAstBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
TagScope tag(this, "SwitchStatement"); TagScope tag(this, "SwitchStatement");
} }
......
...@@ -208,7 +208,6 @@ void Processor::VisitWithStatement(WithStatement* node) { ...@@ -208,7 +208,6 @@ void Processor::VisitWithStatement(WithStatement* node) {
void Processor::VisitDeclaration(Declaration* node) {} void Processor::VisitDeclaration(Declaration* node) {}
void Processor::VisitEmptyStatement(EmptyStatement* node) {} void Processor::VisitEmptyStatement(EmptyStatement* node) {}
void Processor::VisitReturnStatement(ReturnStatement* node) {} void Processor::VisitReturnStatement(ReturnStatement* node) {}
void Processor::VisitExitContextStatement(ExitContextStatement* node) {}
void Processor::VisitDebuggerStatement(DebuggerStatement* 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