Commit 76f88936 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Create arrow function scopes while parsing the head

This simplifies NextArrowFunctionInfo, allows us to Scope::Snapshot::Reparent
directly rather than moving it, and allows us to skip reparenting in the simple
parameter arrow function cases.

This is a reland of https://chromium-review.googlesource.com/c/v8/v8/+/1397664,
simply splitting out the arrow-function-name-inferring part.

Change-Id: I640d911a9607edc3bbb0e5ff3bf992094e4159e4
Reviewed-on: https://chromium-review.googlesource.com/c/1397701Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58570}
parent b962c071
......@@ -888,11 +888,15 @@ void Scope::Snapshot::Reparent(DeclarationScope* new_parent) {
outer_closure->locals_.Rewind(top_local_);
// Move eval calls since Snapshot's creation into new_parent.
if (outer_scope_and_calls_eval_.GetPayload()) {
if (outer_scope_and_calls_eval_->scope_calls_eval_) {
new_parent->scope_calls_eval_ = true;
new_parent->inner_scope_calls_eval_ = true;
}
// We are in the arrow function case. The calls eval we may have recorded
// is intended for the inner scope and we should simply restore the
// original "calls eval" flag of the outer scope.
RestoreEvalFlag();
Clear();
}
......
......@@ -147,24 +147,6 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
outer_scope_and_calls_eval_.GetPayload();
}
Snapshot& operator=(Snapshot&& source) V8_NOEXCEPT {
outer_scope_and_calls_eval_.SetPointer(
source.outer_scope_and_calls_eval_.GetPointer());
outer_scope_and_calls_eval_.SetPayload(
outer_scope_and_calls_eval_->scope_calls_eval_);
top_inner_scope_ = source.top_inner_scope_;
top_unresolved_ = source.top_unresolved_;
top_local_ = source.top_local_;
// We are in the arrow function case. The calls eval we may have recorded
// is intended for the inner scope and we should simply restore the
// original "calls eval" flag of the outer scope.
source.RestoreEvalFlag();
source.Clear();
return *this;
}
void Reparent(DeclarationScope* new_parent);
bool IsCleared() const {
return outer_scope_and_calls_eval_.GetPointer() == nullptr;
......
This diff is collapsed.
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