Skip to content

Commit 3db2f58

Browse files
o-targos
authored andcommitted
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 <[email protected]> Reviewed-by: Toon Verwaest <[email protected]> Auto-Submit: Olivier Flückiger <[email protected]> Cr-Commit-Position: refs/heads/main@{#102878} Refs: v8/v8@f93055f PR-URL: #60105 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 4a7fbb6 commit 3db2f58

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.6',
41+
'v8_embedder_string': '-node.7',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/objects/keys.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
463463
return keys;
464464
}
465465
if (isolate_->has_exception()) return MaybeHandle<FixedArray>();
466+
} else if (filter_ == SKIP_STRINGS && !MayHaveSymbols()) {
467+
return isolate_->factory()->empty_fixed_array();
466468
}
467469

468470
if (try_prototype_info_cache_) {
@@ -471,6 +473,34 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
471473
return GetKeysSlow(keys_conversion);
472474
}
473475

476+
bool FastKeyAccumulator::MayHaveSymbols() {
477+
bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly;
478+
Tagged<Map> map = receiver_->map();
479+
if (!own_only || IsCustomElementsReceiverMap(map)) {
480+
return true;
481+
}
482+
483+
// From this point on we are certain to only collect own keys.
484+
DCHECK(IsJSObject(*receiver_));
485+
486+
if (map->is_dictionary_map()) {
487+
// TODO(olivf): Keep a bit in the dictionary to remember if we have any
488+
// symbols.
489+
return true;
490+
}
491+
int num = map->NumberOfOwnDescriptors();
492+
if (num == 0) {
493+
return false;
494+
}
495+
int enum_length = receiver_->map()->EnumLength();
496+
if (enum_length != kInvalidEnumCacheSentinel) {
497+
return enum_length != num;
498+
}
499+
// TODO(olivf): Keep a bit in the descriptor to remember if we have any
500+
// symbols.
501+
return true;
502+
}
503+
474504
MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysFast(
475505
GetKeysConversion keys_conversion) {
476506
bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly;

deps/v8/src/objects/keys.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class FastKeyAccumulator {
197197
bool is_receiver_simple_enum() { return is_receiver_simple_enum_; }
198198
bool has_empty_prototype() { return has_empty_prototype_; }
199199
bool may_have_elements() { return may_have_elements_; }
200+
bool MayHaveSymbols();
200201

201202
MaybeHandle<FixedArray> GetKeys(
202203
GetKeysConversion convert = GetKeysConversion::kKeepNumbers);

0 commit comments

Comments
 (0)