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

Side by Side Diff: src/parsing/parameter-initializer-rewriter.cc

Issue 2086353003: Reland of write scopes of non-simple default arguments (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | src/parsing/parser.cc » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/parameter-initializer-rewriter.h" 5 #include "src/parsing/parameter-initializer-rewriter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // the class scope on their scope chain. 83 // the class scope on their scope chain.
84 DCHECK(prop->value()->IsFunctionLiteral()); 84 DCHECK(prop->value()->IsFunctionLiteral());
85 } 85 }
86 } 86 }
87 87
88 88
89 void Rewriter::VisitVariableProxy(VariableProxy* proxy) { 89 void Rewriter::VisitVariableProxy(VariableProxy* proxy) {
90 if (proxy->is_resolved()) { 90 if (proxy->is_resolved()) {
91 Variable* var = proxy->var(); 91 Variable* var = proxy->var();
92 if (var->mode() != TEMPORARY) return; 92 if (var->mode() != TEMPORARY) return;
93 // For rewriting inside the same ClosureScope (e.g., putting default
94 // parameter values in their own inner scope in certain cases), refrain
95 // from invalidly moving temporaries to a block scope.
96 if (var->scope()->ClosureScope() == new_scope_->ClosureScope()) return;
93 int index = old_scope_->RemoveTemporary(var); 97 int index = old_scope_->RemoveTemporary(var);
94 if (index >= 0) { 98 if (index >= 0) {
95 temps_.push_back(std::make_pair(var, index)); 99 temps_.push_back(std::make_pair(var, index));
96 } 100 }
97 } else if (old_scope_->RemoveUnresolved(proxy)) { 101 } else if (old_scope_->RemoveUnresolved(proxy)) {
98 new_scope_->AddUnresolved(proxy); 102 new_scope_->AddUnresolved(proxy);
99 } 103 }
100 } 104 }
101 105
102 106
(...skipping 23 matching lines...) Expand all
126 void RewriteParameterInitializerScope(uintptr_t stack_limit, 130 void RewriteParameterInitializerScope(uintptr_t stack_limit,
127 Expression* initializer, Scope* old_scope, 131 Expression* initializer, Scope* old_scope,
128 Scope* new_scope) { 132 Scope* new_scope) {
129 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope); 133 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope);
130 rewriter.Run(); 134 rewriter.Run();
131 } 135 }
132 136
133 137
134 } // namespace internal 138 } // namespace internal
135 } // namespace v8 139 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698