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

Unified Diff: src/scopes.cc

Issue 1263563002: Correct handling of temporaries as parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/variables.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index 1473b2471f59ebbd87acf6cebdbd5f3c114cfc42..b8c81fc0897bcfcae474490ec2afde8efe9a1605 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -465,16 +465,14 @@ Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode,
bool is_rest, bool* is_duplicate) {
DCHECK(!already_resolved());
DCHECK(is_function_scope());
-
Variable* var;
- if (!name->IsEmpty()) {
+ if (mode == TEMPORARY) {
+ var = NewTemporary(name);
+ } else {
var = variables_.Declare(this, name, mode, Variable::NORMAL,
kCreatedInitialized);
// TODO(wingo): Avoid O(n^2) check.
*is_duplicate = IsDeclaredParameter(name);
- } else {
- var = new (zone())
- Variable(this, name, TEMPORARY, Variable::NORMAL, kCreatedInitialized);
}
if (is_rest) {
DCHECK_NULL(rest_parameter_);
@@ -620,9 +618,10 @@ void Scope::CollectStackAndContextLocals(
if (var->IsContextSlot()) {
DCHECK(has_forced_context_allocation());
context_locals->Add(var, zone());
- } else {
- DCHECK(var->IsStackLocal());
+ } else if (var->IsStackLocal()) {
stack_locals->Add(var, zone());
+ } else {
+ DCHECK(var->IsParameter());
}
}
}
@@ -862,7 +861,10 @@ static void PrintVar(int indent, Variable* var) {
if (var->is_used() || !var->IsUnallocated()) {
Indent(indent, Variable::Mode2String(var->mode()));
PrintF(" ");
- PrintName(var->raw_name());
+ if (var->raw_name()->IsEmpty())
+ PrintF(".%p", var);
+ else
+ PrintName(var->raw_name());
PrintF("; // ");
PrintLocation(var);
bool comma = !var->IsUnallocated();
@@ -908,7 +910,11 @@ void Scope::Print(int n) {
PrintF(" (");
for (int i = 0; i < params_.length(); i++) {
if (i > 0) PrintF(", ");
- PrintName(params_[i]->raw_name());
+ const AstRawString* name = params_[i]->raw_name();
+ if (name->IsEmpty())
+ PrintF(".%p", params_[i]);
+ else
+ PrintName(name);
}
PrintF(")");
}
« no previous file with comments | « src/parser.h ('k') | src/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698