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

Unified Diff: src/ast/scopes.cc

Issue 1784893003: ParameterInitializerRewriter must maintain temporary variable order (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nikolaos comments Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parameter-initializer-rewriter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 5b91bb6b7edee3be392a05077e73537a448a2a2c..39ae8d450d9b69791d3de091b2989cf292a8dd3f 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -558,17 +558,19 @@ Variable* Scope::NewTemporary(const AstRawString* name) {
return var;
}
-
-bool Scope::RemoveTemporary(Variable* var) {
+int Scope::RemoveTemporary(Variable* var) {
+ DCHECK_NOT_NULL(var);
// Most likely (always?) any temporary variable we want to remove
// was just added before, so we search backwards.
for (int i = temps_.length(); i-- > 0;) {
if (temps_[i] == var) {
- temps_.Remove(i);
- return true;
+ // Don't shrink temps_, as callers of this method expect
+ // the returned indices to be unique per-scope.
+ temps_[i] = nullptr;
+ return i;
}
}
- return false;
+ return -1;
}
@@ -635,6 +637,7 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
// context as a whole has forced context allocation.
for (int i = 0; i < temps_.length(); i++) {
Variable* var = temps_[i];
+ if (var == nullptr) continue;
if (var->is_used()) {
if (var->IsContextSlot()) {
DCHECK(has_forced_context_allocation());
@@ -984,9 +987,15 @@ void Scope::Print(int n) {
}
if (temps_.length() > 0) {
- Indent(n1, "// temporary vars:\n");
+ bool printed_header = false;
for (int i = 0; i < temps_.length(); i++) {
- PrintVar(n1, temps_[i]);
+ if (temps_[i] != nullptr) {
+ if (!printed_header) {
+ printed_header = true;
+ Indent(n1, "// temporary vars:\n");
+ }
+ PrintVar(n1, temps_[i]);
+ }
}
}
@@ -1416,6 +1425,7 @@ void Scope::AllocateDeclaredGlobal(Isolate* isolate, Variable* var) {
void Scope::AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate) {
// All variables that have no rewrite yet are non-parameter locals.
for (int i = 0; i < temps_.length(); i++) {
+ if (temps_[i] == nullptr) continue;
AllocateNonParameterLocal(isolate, temps_[i]);
}
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parameter-initializer-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698