From ce6d2241bcf4647315337b60f98dee3b07ac82bd Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Mon, 20 Jul 2015 07:15:03 -0700 Subject: [PATCH] Add function literal variable to declaration list. This adds the implicit function variable for a function literal to the declarations list in scope analysis, instead of specially handling it throughout all back-ends. R=rossberg@chromium.org Review URL: https://codereview.chromium.org/1245603003 Cr-Commit-Position: refs/heads/master@{#29754} --- src/arm/full-codegen-arm.cc | 9 --------- src/arm64/full-codegen-arm64.cc | 7 ------- src/ast-numbering.cc | 4 ---- src/compiler/ast-graph-builder.cc | 5 ----- src/hydrogen.cc | 5 ----- src/ia32/full-codegen-ia32.cc | 9 --------- src/mips/full-codegen-mips.cc | 9 --------- src/mips64/full-codegen-mips64.cc | 9 --------- src/ppc/full-codegen-ppc.cc | 9 --------- src/scopes.h | 3 +++ src/typing.cc | 5 ----- src/x64/full-codegen-x64.cc | 9 --------- src/x87/full-codegen-x87.cc | 9 --------- 13 files changed, 3 insertions(+), 89 deletions(-) diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index 32845dd..d1a4faf 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -345,15 +345,6 @@ void FullCodeGenerator::Generate() { } else { PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); { Comment cmnt(masm_, "[ Declarations"); - // For named function expressions, declare the function name as a - // constant. - if (scope()->is_function_scope() && scope()->function() != NULL) { - VariableDeclaration* function = scope()->function(); - DCHECK(function->proxy()->var()->mode() == CONST || - function->proxy()->var()->mode() == CONST_LEGACY); - DCHECK(!function->proxy()->var()->IsUnallocatedOrGlobalSlot()); - VisitVariableDeclaration(function); - } VisitDeclarations(scope()->declarations()); } diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index 4b34f03..388e06a 100644 --- a/src/arm64/full-codegen-arm64.cc +++ b/src/arm64/full-codegen-arm64.cc @@ -350,13 +350,6 @@ void FullCodeGenerator::Generate() { } else { PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); { Comment cmnt(masm_, "[ Declarations"); - if (scope()->is_function_scope() && scope()->function() != NULL) { - VariableDeclaration* function = scope()->function(); - DCHECK(function->proxy()->var()->mode() == CONST || - function->proxy()->var()->mode() == CONST_LEGACY); - DCHECK(!function->proxy()->var()->IsUnallocatedOrGlobalSlot()); - VisitVariableDeclaration(function); - } VisitDeclarations(scope()->declarations()); } diff --git a/src/ast-numbering.cc b/src/ast-numbering.cc index bf0f9ba..e14b84d 100644 --- a/src/ast-numbering.cc +++ b/src/ast-numbering.cc @@ -538,10 +538,6 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { } VisitDeclarations(scope->declarations()); - if (scope->is_function_scope() && scope->function() != NULL) { - // Visit the name of the named function expression. - Visit(scope->function()); - } VisitStatements(node->body()); return Finish(node); diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 6f9371a..d6e1ceb 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -584,11 +584,6 @@ void AstGraphBuilder::CreateGraphBody(bool stack_check) { return; } - // Visit implicit declaration of the function name. - if (scope->is_function_scope() && scope->function() != NULL) { - VisitVariableDeclaration(scope->function()); - } - // Visit declarations within the function scope. VisitDeclarations(scope->declarations()); diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 7c5d7df..de5ae0c 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -4357,11 +4357,6 @@ bool HOptimizedGraphBuilder::BuildGraph() { body_entry->SetJoinId(BailoutId::FunctionEntry()); set_current_block(body_entry); - // Handle implicit declaration of the function name in named function - // expressions before other declarations. - if (scope->is_function_scope() && scope->function() != NULL) { - VisitVariableDeclaration(scope->function()); - } VisitDeclarations(scope->declarations()); Add(BailoutId::Declarations()); diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index 6060b36..7627267 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -347,15 +347,6 @@ void FullCodeGenerator::Generate() { } else { PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); { Comment cmnt(masm_, "[ Declarations"); - // For named function expressions, declare the function name as a - // constant. - if (scope()->is_function_scope() && scope()->function() != NULL) { - VariableDeclaration* function = scope()->function(); - DCHECK(function->proxy()->var()->mode() == CONST || - function->proxy()->var()->mode() == CONST_LEGACY); - DCHECK(!function->proxy()->var()->IsUnallocatedOrGlobalSlot()); - VisitVariableDeclaration(function); - } VisitDeclarations(scope()->declarations()); } diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 7258c74..beaff83 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -363,15 +363,6 @@ void FullCodeGenerator::Generate() { } else { PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); { Comment cmnt(masm_, "[ Declarations"); - // For named function expressions, declare the function name as a - // constant. - if (scope()->is_function_scope() && scope()->function() != NULL) { - VariableDeclaration* function = scope()->function(); - DCHECK(function->proxy()->var()->mode() == CONST || - function->proxy()->var()->mode() == CONST_LEGACY); - DCHECK(!function->proxy()->var()->IsUnallocatedOrGlobalSlot()); - VisitVariableDeclaration(function); - } VisitDeclarations(scope()->declarations()); } diff --git a/src/mips64/full-codegen-mips64.cc b/src/mips64/full-codegen-mips64.cc index 95fc926..94a67b5 100644 --- a/src/mips64/full-codegen-mips64.cc +++ b/src/mips64/full-codegen-mips64.cc @@ -358,15 +358,6 @@ void FullCodeGenerator::Generate() { } else { PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); { Comment cmnt(masm_, "[ Declarations"); - // For named function expressions, declare the function name as a - // constant. - if (scope()->is_function_scope() && scope()->function() != NULL) { - VariableDeclaration* function = scope()->function(); - DCHECK(function->proxy()->var()->mode() == CONST || - function->proxy()->var()->mode() == CONST_LEGACY); - DCHECK(!function->proxy()->var()->IsUnallocatedOrGlobalSlot()); - VisitVariableDeclaration(function); - } VisitDeclarations(scope()->declarations()); } { Comment cmnt(masm_, "[ Stack check"); diff --git a/src/ppc/full-codegen-ppc.cc b/src/ppc/full-codegen-ppc.cc index 5de6823..44fe92a 100644 --- a/src/ppc/full-codegen-ppc.cc +++ b/src/ppc/full-codegen-ppc.cc @@ -357,15 +357,6 @@ void FullCodeGenerator::Generate() { PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); { Comment cmnt(masm_, "[ Declarations"); - // For named function expressions, declare the function name as a - // constant. - if (scope()->is_function_scope() && scope()->function() != NULL) { - VariableDeclaration* function = scope()->function(); - DCHECK(function->proxy()->var()->mode() == CONST || - function->proxy()->var()->mode() == CONST_LEGACY); - DCHECK(!function->proxy()->var()->IsUnallocatedOrGlobalSlot()); - VisitVariableDeclaration(function); - } VisitDeclarations(scope()->declarations()); } diff --git a/src/scopes.h b/src/scopes.h index 9f91345..f935418 100644 --- a/src/scopes.h +++ b/src/scopes.h @@ -119,6 +119,9 @@ class Scope: public ZoneObject { // outer scope. Only possible for function scopes; at most one variable. void DeclareFunctionVar(VariableDeclaration* declaration) { DCHECK(is_function_scope()); + // Handle implicit declaration of the function name in named function + // expressions before other declarations. + decls_.InsertAt(0, declaration, zone()); function_ = declaration; } diff --git a/src/typing.cc b/src/typing.cc index 2f10328..3e811ca 100644 --- a/src/typing.cc +++ b/src/typing.cc @@ -36,11 +36,6 @@ void AstTyper::Run(CompilationInfo* info) { AstTyper* visitor = new(info->zone()) AstTyper(info); Scope* scope = info->scope(); - // Handle implicit declaration of the function name in named function - // expressions before other declarations. - if (scope->is_function_scope() && scope->function() != NULL) { - RECURSE(visitor->VisitVariableDeclaration(scope->function())); - } RECURSE(visitor->VisitDeclarations(scope->declarations())); RECURSE(visitor->VisitStatements(info->function()->body())); } diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index d6c3428..36a7eed 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -345,15 +345,6 @@ void FullCodeGenerator::Generate() { } else { PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); { Comment cmnt(masm_, "[ Declarations"); - // For named function expressions, declare the function name as a - // constant. - if (scope()->is_function_scope() && scope()->function() != NULL) { - VariableDeclaration* function = scope()->function(); - DCHECK(function->proxy()->var()->mode() == CONST || - function->proxy()->var()->mode() == CONST_LEGACY); - DCHECK(!function->proxy()->var()->IsUnallocatedOrGlobalSlot()); - VisitVariableDeclaration(function); - } VisitDeclarations(scope()->declarations()); } diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc index ab7bcd6..1e6a88c 100644 --- a/src/x87/full-codegen-x87.cc +++ b/src/x87/full-codegen-x87.cc @@ -344,15 +344,6 @@ void FullCodeGenerator::Generate() { } else { PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); { Comment cmnt(masm_, "[ Declarations"); - // For named function expressions, declare the function name as a - // constant. - if (scope()->is_function_scope() && scope()->function() != NULL) { - VariableDeclaration* function = scope()->function(); - DCHECK(function->proxy()->var()->mode() == CONST || - function->proxy()->var()->mode() == CONST_LEGACY); - DCHECK(!function->proxy()->var()->IsUnallocatedOrGlobalSlot()); - VisitVariableDeclaration(function); - } VisitDeclarations(scope()->declarations()); } -- 2.7.4