Commit 0f1f54c2 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[ast] Add DCHECKs that ensure the AST contains no dead scopes.

Until recently, it sometimes did.

BUG=

Change-Id: I8785c1865909e6f46693b71c9146d4fa17114fce
Reviewed-on: https://chromium-review.googlesource.com/444188
Commit-Queue: Adam Klein <adamk@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43291}
parent 00d6f1f8
......@@ -281,9 +281,10 @@ void AstNumberingVisitor::VisitBlock(Block* node) {
IncrementNodeCount();
node->set_base_id(ReserveIdRange(Block::num_ids()));
Scope* scope = node->scope();
DCHECK(scope == nullptr || !scope->HasBeenRemoved());
// TODO(ishell): remove scope->NeedsContext() condition once v8:5927 is fixed.
// Current logic mimics what BytecodeGenerator::VisitBlock() does.
if (scope != NULL && scope->NeedsContext()) {
if (scope != nullptr && scope->NeedsContext()) {
LanguageModeScope language_mode_scope(this, scope->language_mode());
VisitStatementsAndDeclarations(node);
} else {
......@@ -293,6 +294,7 @@ void AstNumberingVisitor::VisitBlock(Block* node) {
void AstNumberingVisitor::VisitStatementsAndDeclarations(Block* node) {
Scope* scope = node->scope();
DCHECK(scope == nullptr || !scope->HasBeenRemoved());
if (scope) VisitDeclarations(scope->declarations());
VisitStatements(node->statements());
}
......@@ -363,6 +365,7 @@ void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) {
void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) {
DCHECK(node->scope() == nullptr || !node->scope()->HasBeenRemoved());
IncrementNodeCount();
DisableFullCodegenAndCrankshaft(kTryCatchStatement);
{
......@@ -662,6 +665,8 @@ void AstNumberingVisitor::VisitRewritableExpression(
bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
DeclarationScope* scope = node->scope();
DCHECK(!scope->HasBeenRemoved());
if (scope->new_target_var() != nullptr ||
scope->this_function_var() != nullptr) {
DisableFullCodegenAndCrankshaft(kSuperReference);
......
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