[runtime] Sets kScopeInfoMaxInlinedLocalNamesSize

- This enables a hash table for local names in ScopeInfo.
- Drive by fix iterating local names in FinalizeReparsedClassScope

Bug: v8:12315
Change-Id: I02c22bfdc4f1d91f19f368885fca24b2a577d26e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3422632
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78876}
This commit is contained in:
Victor Gomes 2022-01-28 10:25:29 +01:00 committed by V8 LUCI CQ
parent 302cbdb962
commit f126c9238b
2 changed files with 4 additions and 9 deletions

View File

@ -2778,16 +2778,14 @@ void ClassScope::FinalizeReparsedClassScope(
DCHECK_EQ(scope_info->scope_type(), CLASS_SCOPE);
DCHECK_EQ(scope_info->StartPosition(), start_position_);
int context_local_count = scope_info->ContextLocalCount();
int context_header_length = scope_info->ContextHeaderLength();
DisallowGarbageCollection no_gc;
for (int i = 0; i < context_local_count; ++i) {
int slot_index = context_header_length + i;
for (auto it : ScopeInfo::IterateLocalNames(scope_info)) {
int slot_index = context_header_length + it->index();
DCHECK_LT(slot_index, scope_info->ContextLength());
String name = scope_info->ContextInlinedLocalName(i);
const AstRawString* string = ast_value_factory->GetString(
name, SharedStringAccessGuardIfNeeded(isolate));
it->name(), SharedStringAccessGuardIfNeeded(isolate));
Variable* var = string->IsPrivateName() ? LookupLocalPrivateName(string)
: LookupLocal(string);
DCHECK_NOT_NULL(var);

View File

@ -1153,10 +1153,7 @@ inline std::ostream& operator<<(std::ostream& os, CreateArgumentsType type) {
UNREACHABLE();
}
// TODO(victorgomes, v8:12315): Local names are currently always inlined, so we
// choose the maximum int value as threshold.
constexpr int kScopeInfoMaxInlinedLocalNamesSize =
std::numeric_limits<int>::max();
constexpr int kScopeInfoMaxInlinedLocalNamesSize = 32;
enum ScopeType : uint8_t {
CLASS_SCOPE, // The scope introduced by a class.