Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/parsing/parser.cc

Issue 2112163002: Block-scoped functions in evals are now only conditionally hoisted out. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: more tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/block-eval-var-over-let.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-expression-rewriter.h" 9 #include "src/ast/ast-expression-rewriter.h"
10 #include "src/ast/ast-expression-visitor.h" 10 #include "src/ast/ast-expression-visitor.h"
(...skipping 5215 matching lines...) Expand 10 before | Expand all | Expand 10 after
5226 continue; 5226 continue;
5227 } 5227 }
5228 } 5228 }
5229 5229
5230 bool var_created = false; 5230 bool var_created = false;
5231 5231
5232 // Write in assignments to var for each block-scoped function declaration 5232 // Write in assignments to var for each block-scoped function declaration
5233 auto delegates = static_cast<SloppyBlockFunctionMap::Vector*>(p->value); 5233 auto delegates = static_cast<SloppyBlockFunctionMap::Vector*>(p->value);
5234 for (SloppyBlockFunctionStatement* delegate : *delegates) { 5234 for (SloppyBlockFunctionStatement* delegate : *delegates) {
5235 // Check if there's a conflict with a lexical declaration 5235 // Check if there's a conflict with a lexical declaration
5236 Scope* outer_scope = scope->outer_scope(); 5236 Scope* decl_scope = scope;
5237 while (decl_scope->is_eval_scope()) {
5238 decl_scope = decl_scope->outer_scope()->DeclarationScope();
5239 }
5240 Scope* outer_scope = decl_scope->outer_scope();
5237 Scope* query_scope = delegate->scope()->outer_scope(); 5241 Scope* query_scope = delegate->scope()->outer_scope();
5238 Variable* var = nullptr; 5242 Variable* var = nullptr;
5239 bool should_hoist = true; 5243 bool should_hoist = true;
5240 5244
5241 // Note that we perform this loop for each delegate named 'name', 5245 // Note that we perform this loop for each delegate named 'name',
5242 // which may duplicate work if those delegates share scopes. 5246 // which may duplicate work if those delegates share scopes.
5243 // It is not sufficient to just do a Lookup on query_scope: for 5247 // It is not sufficient to just do a Lookup on query_scope: for
5244 // example, that does not prevent hoisting of the function in 5248 // example, that does not prevent hoisting of the function in
5245 // `{ let e; try {} catch (e) { function e(){} } }` 5249 // `{ let e; try {} catch (e) { function e(){} } }`
5246 do { 5250 do {
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after
7046 7050
7047 #ifdef DEBUG 7051 #ifdef DEBUG
7048 void Parser::Print(AstNode* node) { 7052 void Parser::Print(AstNode* node) {
7049 ast_value_factory()->Internalize(Isolate::Current()); 7053 ast_value_factory()->Internalize(Isolate::Current());
7050 node->Print(Isolate::Current()); 7054 node->Print(Isolate::Current());
7051 } 7055 }
7052 #endif // DEBUG 7056 #endif // DEBUG
7053 7057
7054 } // namespace internal 7058 } // namespace internal
7055 } // namespace v8 7059 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/block-eval-var-over-let.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698