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

Unified Diff: src/ast/scopes.cc

Issue 2275573002: Remove rest_parameter_ cache on DeclarationScope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Could be we shouldn't allocate Created 4 years, 4 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') | no next file » | 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 a1d31c6005222910b545b46417ddd30b093ca196..11718f133cb5fa25876e9cc53b86f787a65d833a 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -205,7 +205,6 @@ void DeclarationScope::SetDefaults() {
arguments_ = nullptr;
this_function_ = nullptr;
arity_ = 0;
- rest_parameter_ = nullptr;
rest_index_ = -1;
}
@@ -695,11 +694,7 @@ Variable* DeclarationScope::DeclareParameter(
if (!is_optional && !is_rest && arity_ == params_.length()) {
++arity_;
}
- if (is_rest) {
- DCHECK_NULL(rest_parameter_);
- rest_parameter_ = var;
- rest_index_ = num_parameters();
- }
+ if (is_rest) rest_index_ = num_parameters();
params_.Add(var, zone());
if (name == ast_value_factory->arguments_string()) {
has_arguments_parameter_ = true;
@@ -1544,17 +1539,13 @@ void DeclarationScope::AllocateParameterLocals() {
DCHECK(is_arrow_scope());
}
- if (rest_parameter_ && !MustAllocate(rest_parameter_)) {
- rest_parameter_ = nullptr;
- }
-
// The same parameter may occur multiple times in the parameters_ list.
// If it does, and if it is not copied into the context object, it must
// receive the highest parameter index for that parameter; thus iteration
// order is relevant!
for (int i = params_.length() - 1; i >= 0; --i) {
+ if (i == rest_index_) continue;
Variable* var = params_[i];
- if (var == rest_parameter_) continue;
DCHECK(var->scope() == this);
if (uses_sloppy_arguments) {
@@ -1648,7 +1639,8 @@ void DeclarationScope::AllocateLocals() {
AllocateNonParameterLocal(function_);
}
- DCHECK(rest_parameter_ == nullptr || !rest_parameter_->IsUnallocated());
+ DCHECK(!has_rest_parameter() || !MustAllocate(params_[rest_index_]) ||
+ !params_[rest_index_]->IsUnallocated());
if (new_target_ != nullptr && !MustAllocate(new_target_)) {
new_target_ = nullptr;
« no previous file with comments | « src/ast/scopes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698