mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
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: f93055fbd5
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
710105bab5
commit
de8386de4d
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
# Reset this number to 0 on major V8 upgrades.
|
# Reset this number to 0 on major V8 upgrades.
|
||||||
# Increment by one for each non-official patch applied to deps/v8.
|
# Increment by one for each non-official patch applied to deps/v8.
|
||||||
'v8_embedder_string': '-node.6',
|
'v8_embedder_string': '-node.7',
|
||||||
|
|
||||||
##### V8 defaults for Node.js #####
|
##### V8 defaults for Node.js #####
|
||||||
|
|
||||||
|
|
|
||||||
30
deps/v8/src/objects/keys.cc
vendored
30
deps/v8/src/objects/keys.cc
vendored
|
|
@ -463,6 +463,8 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
if (isolate_->has_exception()) return MaybeHandle<FixedArray>();
|
if (isolate_->has_exception()) return MaybeHandle<FixedArray>();
|
||||||
|
} else if (filter_ == SKIP_STRINGS && !MayHaveSymbols()) {
|
||||||
|
return isolate_->factory()->empty_fixed_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (try_prototype_info_cache_) {
|
if (try_prototype_info_cache_) {
|
||||||
|
|
@ -471,6 +473,34 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
|
||||||
return GetKeysSlow(keys_conversion);
|
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(
|
MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysFast(
|
||||||
GetKeysConversion keys_conversion) {
|
GetKeysConversion keys_conversion) {
|
||||||
bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly;
|
bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly;
|
||||||
|
|
|
||||||
1
deps/v8/src/objects/keys.h
vendored
1
deps/v8/src/objects/keys.h
vendored
|
|
@ -197,6 +197,7 @@ class FastKeyAccumulator {
|
||||||
bool is_receiver_simple_enum() { return is_receiver_simple_enum_; }
|
bool is_receiver_simple_enum() { return is_receiver_simple_enum_; }
|
||||||
bool has_empty_prototype() { return has_empty_prototype_; }
|
bool has_empty_prototype() { return has_empty_prototype_; }
|
||||||
bool may_have_elements() { return may_have_elements_; }
|
bool may_have_elements() { return may_have_elements_; }
|
||||||
|
bool MayHaveSymbols();
|
||||||
|
|
||||||
MaybeHandle<FixedArray> GetKeys(
|
MaybeHandle<FixedArray> GetKeys(
|
||||||
GetKeysConversion convert = GetKeysConversion::kKeepNumbers);
|
GetKeysConversion convert = GetKeysConversion::kKeepNumbers);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user