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

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

Issue 1564343002: Fix for temporaries in parameter initializers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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 | « src/ast/variables.h ('k') | test/mjsunit/harmony/regress/regress-4658.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 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 "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/ast-expression-visitor.h" 8 #include "src/ast/ast-expression-visitor.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 Visit(prop->key()); 53 Visit(prop->key());
54 } 54 }
55 // No need to visit the values, since all values are functions with 55 // No need to visit the values, since all values are functions with
56 // the class scope on their scope chain. 56 // the class scope on their scope chain.
57 DCHECK(prop->value()->IsFunctionLiteral()); 57 DCHECK(prop->value()->IsFunctionLiteral());
58 } 58 }
59 } 59 }
60 60
61 61
62 void Rewriter::VisitVariableProxy(VariableProxy* proxy) { 62 void Rewriter::VisitVariableProxy(VariableProxy* proxy) {
63 DCHECK(!proxy->is_resolved()); 63 if (proxy->is_resolved()) {
64 if (old_scope_->RemoveUnresolved(proxy)) { 64 Variable* var = proxy->var();
65 DCHECK_EQ(var->mode(), TEMPORARY);
66 if (old_scope_->RemoveTemporary(var)) {
67 var->set_scope(new_scope_);
68 new_scope_->AddTemporary(var);
69 }
70 } else if (old_scope_->RemoveUnresolved(proxy)) {
65 new_scope_->AddUnresolved(proxy); 71 new_scope_->AddUnresolved(proxy);
66 } 72 }
67 } 73 }
68 74
69 75
70 } // anonymous namespace 76 } // anonymous namespace
71 77
72 78
73 void RewriteParameterInitializerScope(uintptr_t stack_limit, 79 void RewriteParameterInitializerScope(uintptr_t stack_limit,
74 Expression* initializer, Scope* old_scope, 80 Expression* initializer, Scope* old_scope,
75 Scope* new_scope) { 81 Scope* new_scope) {
76 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope); 82 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope);
77 rewriter.Run(); 83 rewriter.Run();
78 } 84 }
79 85
80 86
81 } // namespace internal 87 } // namespace internal
82 } // namespace v8 88 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/variables.h ('k') | test/mjsunit/harmony/regress/regress-4658.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698