Commit 9f4c8b74 authored by verwaest's avatar verwaest Committed by Commit bot

Remove rest_parameter_ cache on DeclarationScope

We anyway have its index in params_, so just always access through params_.

BUG=v8:5209

Review-Url: https://codereview.chromium.org/2275573002
Cr-Commit-Position: refs/heads/master@{#38836}
parent c4874b2f
......@@ -206,7 +206,6 @@ void DeclarationScope::SetDefaults() {
arguments_ = nullptr;
this_function_ = nullptr;
arity_ = 0;
rest_parameter_ = nullptr;
rest_index_ = -1;
}
......@@ -694,11 +693,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;
......@@ -1543,17 +1538,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) {
......@@ -1647,7 +1638,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;
......
......@@ -770,8 +770,8 @@ class DeclarationScope : public Scope {
// A function can have at most one rest parameter. Returns Variable* or NULL.
Variable* rest_parameter(int* index) const {
*index = rest_index_;
if (rest_index_ < 0) return NULL;
return rest_parameter_;
if (rest_index_ < 0) return nullptr;
return params_[rest_index_];
}
bool has_rest_parameter() const { return rest_index_ >= 0; }
......@@ -890,7 +890,6 @@ class DeclarationScope : public Scope {
// Info about the parameter list of a function.
int arity_;
int rest_index_;
Variable* rest_parameter_;
// Compiler-allocated (user-invisible) temporaries.
ZoneList<Variable*> temps_;
// Parameter list in source order.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment