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

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: fix test 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 5095 matching lines...) Expand 10 before | Expand all | Expand 10 after
5106 continue; 5106 continue;
5107 } 5107 }
5108 } 5108 }
5109 5109
5110 bool var_created = false; 5110 bool var_created = false;
5111 5111
5112 // Write in assignments to var for each block-scoped function declaration 5112 // Write in assignments to var for each block-scoped function declaration
5113 auto delegates = static_cast<SloppyBlockFunctionMap::Vector*>(p->value); 5113 auto delegates = static_cast<SloppyBlockFunctionMap::Vector*>(p->value);
5114 for (SloppyBlockFunctionStatement* delegate : *delegates) { 5114 for (SloppyBlockFunctionStatement* delegate : *delegates) {
5115 // Check if there's a conflict with a lexical declaration 5115 // Check if there's a conflict with a lexical declaration
5116 Scope* outer_scope = scope->outer_scope(); 5116 Scope* decl_scope = scope;
5117 while (decl_scope->is_eval_scope()) {
5118 decl_scope = decl_scope->outer_scope()->DeclarationScope();
Dan Ehrenberg 2016/07/01 23:55:53 It feels like this will search a little too far. D
5119 }
5120 Scope* outer_scope = decl_scope->outer_scope();
5117 Scope* query_scope = delegate->scope()->outer_scope(); 5121 Scope* query_scope = delegate->scope()->outer_scope();
5118 Variable* var = nullptr; 5122 Variable* var = nullptr;
5119 bool should_hoist = true; 5123 bool should_hoist = true;
5120 5124
5121 // Note that we perform this loop for each delegate named 'name', 5125 // Note that we perform this loop for each delegate named 'name',
5122 // which may duplicate work if those delegates share scopes. 5126 // which may duplicate work if those delegates share scopes.
5123 // It is not sufficient to just do a Lookup on query_scope: for 5127 // It is not sufficient to just do a Lookup on query_scope: for
5124 // example, that does not prevent hoisting of the function in 5128 // example, that does not prevent hoisting of the function in
5125 // `{ let e; try {} catch (e) { function e(){} } }` 5129 // `{ let e; try {} catch (e) { function e(){} } }`
5126 do { 5130 do {
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
6997 try_block, target); 7001 try_block, target);
6998 final_loop = target; 7002 final_loop = target;
6999 } 7003 }
7000 7004
7001 return final_loop; 7005 return final_loop;
7002 } 7006 }
7003 7007
7004 7008
7005 } // namespace internal 7009 } // namespace internal
7006 } // namespace v8 7010 } // 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