Commit 50d3de02 authored by Toon Verwaest's avatar Toon Verwaest Committed by V8 LUCI CQ

[parser] Simply receiver handling in scopes

By adding the receiver variable to the locals we'll automatically create
a proper scope info entry. The receiver is allocated before we allocate
other locals anyway, so it'll be properly allocated.

Change-Id: Ic1d57257d26473f3a50cce27c335565bcb6e06c3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3211995Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77302}
parent 08aa49eb
......@@ -679,6 +679,7 @@ void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) {
THIS_VARIABLE,
derived_constructor ? kNeedsInitialization : kCreatedInitialized,
kNotAssigned);
locals_.Add(receiver_);
}
void DeclarationScope::DeclareArguments(AstValueFactory* ast_value_factory) {
......
......@@ -817,7 +817,6 @@ bool ScopeIterator::VisitLocals(const Visitor& visitor, Mode mode,
}
for (Variable* var : *current_scope_->locals()) {
DCHECK(!var->is_this());
if (ScopeInfo::VariableIsSynthetic(*var->name())) continue;
int index = var->index();
......
......@@ -89,7 +89,6 @@ Handle<ScopeInfo> ScopeInfo::Create(IsolateT* isolate, Zone* zone, Scope* scope,
receiver_info = VariableAllocationInfo::UNUSED;
} else if (var->IsContextSlot()) {
receiver_info = VariableAllocationInfo::CONTEXT;
context_local_count++;
} else {
DCHECK(var->IsParameter());
receiver_info = VariableAllocationInfo::STACK;
......@@ -308,23 +307,6 @@ Handle<ScopeInfo> ScopeInfo::Create(IsolateT* isolate, Zone* zone, Scope* scope,
info = ParameterNumberBits::update(info, i);
scope_info.set(info_index, Smi::FromInt(info));
}
// TODO(verwaest): Remove this unnecessary entry.
if (scope->AsDeclarationScope()->has_this_declaration()) {
Variable* var = scope->AsDeclarationScope()->receiver();
if (var->location() == VariableLocation::CONTEXT) {
int local_index = var->index() - scope->ContextHeaderLength();
uint32_t info =
VariableModeBits::encode(var->mode()) |
InitFlagBit::encode(var->initialization_flag()) |
MaybeAssignedFlagBit::encode(var->maybe_assigned()) |
ParameterNumberBits::encode(ParameterNumberBits::kMax) |
IsStaticFlagBit::encode(var->is_static_flag());
scope_info.set(context_local_base + local_index, *var->name(), mode);
scope_info.set(context_local_info_base + local_index,
Smi::FromInt(info));
}
}
}
index += 2 * context_local_count;
......
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