Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit de8386d

Browse filesBrowse 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 <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 PR-URL: #60105 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 710105b commit de8386d
Copy full SHA for de8386d

3 files changed

+32-1Lines changed: 32 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines 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

Collapse file

‎deps/v8/src/objects/keys.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/objects/keys.cc
+30Lines 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;
Collapse file

‎deps/v8/src/objects/keys.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/objects/keys.h
+1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.