@@ -463,6 +463,8 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
463
463
return keys;
464
464
}
465
465
if (isolate_->has_exception ()) return MaybeHandle<FixedArray>();
466
+ } else if (filter_ == SKIP_STRINGS && !MayHaveSymbols ()) {
467
+ return isolate_->factory ()->empty_fixed_array ();
466
468
}
467
469
468
470
if (try_prototype_info_cache_) {
@@ -471,6 +473,34 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
471
473
return GetKeysSlow (keys_conversion);
472
474
}
473
475
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
+
474
504
MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysFast (
475
505
GetKeysConversion keys_conversion) {
476
506
bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly ;
0 commit comments