Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
deps: V8: cherry-pick f93055fbd5aa
Original commit message:

    [runtime] Fastcase for empty getOwnPropertySymbols()

    Since symbols are not enumerable we can rule them out in case all
    properties are in the enum cache.

    Bug: 447154198
    Change-Id: Ib2d58b67e5058d98323fcebaef3daba88c6304b5
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6983286
    Commit-Queue: Olivier Flückiger <olivf@chromium.org>
    Reviewed-by: Toon Verwaest <verwaest@chromium.org>
    Auto-Submit: Olivier Flückiger <olivf@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#102878}

Refs: v8/v8@f93055f
  • Loading branch information
o- authored and BridgeAR committed Oct 2, 2025
commit 36bac6b84d31494af30b6cd6e93153c128ffff3a
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.21',
'v8_embedder_string': '-node.22',

##### V8 defaults for Node.js #####

Expand Down
30 changes: 30 additions & 0 deletions deps/v8/src/objects/keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
return keys;
}
if (isolate_->has_exception()) return MaybeHandle<FixedArray>();
} else if (filter_ == SKIP_STRINGS && !MayHaveSymbols()) {
return isolate_->factory()->empty_fixed_array();
}

if (try_prototype_info_cache_) {
Expand All @@ -472,6 +474,34 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
return GetKeysSlow(keys_conversion);
}

bool FastKeyAccumulator::MayHaveSymbols() {
bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly;
Tagged<Map> map = receiver_->map();
if (!own_only || IsCustomElementsReceiverMap(map)) {
return true;
}

// From this point on we are certain to only collect own keys.
DCHECK(IsJSObject(*receiver_));

if (map->is_dictionary_map()) {
// TODO(olivf): Keep a bit in the dictionary to remember if we have any
// symbols.
return true;
}
int num = map->NumberOfOwnDescriptors();
if (num == 0) {
return false;
}
int enum_length = receiver_->map()->EnumLength();
if (enum_length != kInvalidEnumCacheSentinel) {
return enum_length != num;
}
// TODO(olivf): Keep a bit in the descriptor to remember if we have any
// symbols.
return true;
}

MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysFast(
GetKeysConversion keys_conversion) {
bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly;
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/objects/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class FastKeyAccumulator {
bool is_receiver_simple_enum() { return is_receiver_simple_enum_; }
bool has_empty_prototype() { return has_empty_prototype_; }
bool may_have_elements() { return may_have_elements_; }
bool MayHaveSymbols();

MaybeHandle<FixedArray> GetKeys(
GetKeysConversion convert = GetKeysConversion::kKeepNumbers);
Expand Down
Loading