@@ -464,6 +464,8 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
464464 return keys;
465465 }
466466 if (isolate_->has_exception ()) return MaybeHandle<FixedArray>();
467+ } else if (filter_ == SKIP_STRINGS && !MayHaveSymbols ()) {
468+ return isolate_->factory ()->empty_fixed_array ();
467469 }
468470
469471 if (try_prototype_info_cache_) {
@@ -472,6 +474,34 @@ MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
472474 return GetKeysSlow (keys_conversion);
473475}
474476
477+ bool FastKeyAccumulator::MayHaveSymbols () {
478+ bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly ;
479+ Tagged<Map> map = receiver_->map ();
480+ if (!own_only || IsCustomElementsReceiverMap (map)) {
481+ return true ;
482+ }
483+
484+ // From this point on we are certain to only collect own keys.
485+ DCHECK (IsJSObject (*receiver_));
486+
487+ if (map->is_dictionary_map ()) {
488+ // TODO(olivf): Keep a bit in the dictionary to remember if we have any
489+ // symbols.
490+ return true ;
491+ }
492+ int num = map->NumberOfOwnDescriptors ();
493+ if (num == 0 ) {
494+ return false ;
495+ }
496+ int enum_length = receiver_->map ()->EnumLength ();
497+ if (enum_length != kInvalidEnumCacheSentinel ) {
498+ return enum_length != num;
499+ }
500+ // TODO(olivf): Keep a bit in the descriptor to remember if we have any
501+ // symbols.
502+ return true ;
503+ }
504+
475505MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysFast (
476506 GetKeysConversion keys_conversion) {
477507 bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly ;
0 commit comments