chromium/v8/src/objects/keys.cc

// Copyright 2013 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/objects/keys.h"

#include <optional>

#include "src/api/api-arguments-inl.h"
#include "src/api/api.h"
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/execution/isolate-inl.h"
#include "src/handles/handles-inl.h"
#include "src/heap/factory.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/elements-inl.h"
#include "src/objects/field-index-inl.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/module-inl.h"
#include "src/objects/objects-inl.h"
#include "src/objects/ordered-hash-table-inl.h"
#include "src/objects/property-descriptor.h"
#include "src/objects/prototype-info.h"
#include "src/objects/prototype.h"
#include "src/objects/slots-atomic-inl.h"
#include "src/utils/identity-map.h"
#include "src/zone/zone-hashmap.h"

namespace v8::internal {

#define RETURN_NOTHING_IF_NOT_SUCCESSFUL

#define RETURN_FAILURE_IF_NOT_SUCCESSFUL

namespace {

static bool ContainsOnlyValidKeys(DirectHandle<FixedArray> array) {}

static int AddKey(Tagged<Object> key, DirectHandle<FixedArray> combined_keys,
                  DirectHandle<DescriptorArray> descs, int nof_descriptors,
                  int target) {}

static Handle<FixedArray> CombineKeys(Isolate* isolate,
                                      Handle<FixedArray> own_keys,
                                      Handle<FixedArray> prototype_chain_keys,
                                      DirectHandle<JSReceiver> receiver,
                                      bool may_have_elements) {}

}  // namespace

// static
MaybeHandle<FixedArray> KeyAccumulator::GetKeys(
    Isolate* isolate, Handle<JSReceiver> object, KeyCollectionMode mode,
    PropertyFilter filter, GetKeysConversion keys_conversion, bool is_for_in,
    bool skip_indices) {}

Handle<FixedArray> KeyAccumulator::GetKeys(GetKeysConversion convert) {}

Handle<OrderedHashSet> KeyAccumulator::keys() {}

ExceptionStatus KeyAccumulator::AddKey(Tagged<Object> key,
                                       AddKeyConversion convert) {}

ExceptionStatus KeyAccumulator::AddKey(Handle<Object> key,
                                       AddKeyConversion convert) {}

ExceptionStatus KeyAccumulator::AddKeys(DirectHandle<FixedArray> array,
                                        AddKeyConversion convert) {}

ExceptionStatus KeyAccumulator::AddKeys(Handle<JSObject> array_like,
                                        AddKeyConversion convert) {}

MaybeHandle<FixedArray> FilterProxyKeys(KeyAccumulator* accumulator,
                                        DirectHandle<JSProxy> owner,
                                        Handle<FixedArray> keys,
                                        PropertyFilter filter,
                                        bool skip_indices) {}

// Returns "nothing" in case of exception, "true" on success.
Maybe<bool> KeyAccumulator::AddKeysFromJSProxy(DirectHandle<JSProxy> proxy,
                                               Handle<FixedArray> keys) {}

Maybe<bool> KeyAccumulator::CollectKeys(DirectHandle<JSReceiver> receiver,
                                        Handle<JSReceiver> object) {}

bool KeyAccumulator::HasShadowingKeys() {}

bool KeyAccumulator::IsShadowed(Handle<Object> key) {}

void KeyAccumulator::AddShadowingKey(Tagged<Object> key,
                                     AllowGarbageCollection* allow_gc) {}
void KeyAccumulator::AddShadowingKey(Handle<Object> key) {}

namespace {

void TrySettingEmptyEnumCache(Tagged<JSReceiver> object) {}

bool CheckAndInitializeEmptyEnumCache(Tagged<JSReceiver> object) {}
}  // namespace

void FastKeyAccumulator::Prepare() {}

namespace {

Handle<FixedArray> ReduceFixedArrayTo(Isolate* isolate,
                                      Handle<FixedArray> array, int length) {}

// Initializes and directly returns the enum cache. Users of this function
// have to make sure to never directly leak the enum cache.
Handle<FixedArray> GetFastEnumPropertyKeys(Isolate* isolate,
                                           DirectHandle<JSObject> object) {}

template <bool fast_properties>
MaybeHandle<FixedArray> GetOwnKeysWithElements(Isolate* isolate,
                                               Handle<JSObject> object,
                                               GetKeysConversion convert,
                                               bool skip_indices) {}

}  // namespace

MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys(
    GetKeysConversion keys_conversion) {}

MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysFast(
    GetKeysConversion keys_conversion) {}

// static
Handle<FixedArray> FastKeyAccumulator::InitializeFastPropertyEnumCache(
    Isolate* isolate, DirectHandle<Map> map, int enum_length,
    AllocationType allocation) {}

MaybeHandle<FixedArray>
FastKeyAccumulator::GetOwnKeysWithUninitializedEnumLength() {}

MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysSlow(
    GetKeysConversion keys_conversion) {}

MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysWithPrototypeInfoCache(
    GetKeysConversion keys_conversion) {}

bool FastKeyAccumulator::MayHaveElements(Tagged<JSReceiver> receiver) {}

bool FastKeyAccumulator::TryPrototypeInfoCache(Handle<JSReceiver> receiver) {}

V8_WARN_UNUSED_RESULT ExceptionStatus
KeyAccumulator::FilterForEnumerableProperties(
    DirectHandle<JSReceiver> receiver, DirectHandle<JSObject> object,
    Handle<InterceptorInfo> interceptor, Handle<JSObject> result,
    IndexedOrNamed type) {}

// Returns |true| on success, |nothing| on exception.
Maybe<bool> KeyAccumulator::CollectInterceptorKeysInternal(
    DirectHandle<JSReceiver> receiver, DirectHandle<JSObject> object,
    Handle<InterceptorInfo> interceptor, IndexedOrNamed type) {}

Maybe<bool> KeyAccumulator::CollectInterceptorKeys(
    DirectHandle<JSReceiver> receiver, DirectHandle<JSObject> object,
    IndexedOrNamed type) {}

Maybe<bool> KeyAccumulator::CollectOwnElementIndices(
    DirectHandle<JSReceiver> receiver, Handle<JSObject> object) {}

namespace {

template <bool skip_symbols>
std::optional<int> CollectOwnPropertyNamesInternal(
    DirectHandle<JSObject> object, KeyAccumulator* keys,
    DirectHandle<DescriptorArray> descs, int start_index, int limit) {}

// Logic shared between different specializations of CopyEnumKeysTo.
template <typename Dictionary>
void CommonCopyEnumKeysTo(Isolate* isolate, Handle<Dictionary> dictionary,
                          DirectHandle<FixedArray> storage,
                          KeyCollectionMode mode, KeyAccumulator* accumulator) {}

// Copies enumerable keys to preallocated fixed array.
// Does not throw for uninitialized exports in module namespace objects, so
// this has to be checked separately.
template <typename Dictionary>
void CopyEnumKeysTo(Isolate* isolate, Handle<Dictionary> dictionary,
                    Handle<FixedArray> storage, KeyCollectionMode mode,
                    KeyAccumulator* accumulator) {}

template <>
void CopyEnumKeysTo(Isolate* isolate, Handle<SwissNameDictionary> dictionary,
                    Handle<FixedArray> storage, KeyCollectionMode mode,
                    KeyAccumulator* accumulator) {}

template <class T>
Handle<FixedArray> GetOwnEnumPropertyDictionaryKeys(
    Isolate* isolate, KeyCollectionMode mode, KeyAccumulator* accumulator,
    DirectHandle<JSObject> object, Tagged<T> raw_dictionary) {}

// Collect the keys from |dictionary| into |keys|, in ascending chronological
// order of property creation.
template <typename Dictionary>
ExceptionStatus CollectKeysFromDictionary(Handle<Dictionary> dictionary,
                                          KeyAccumulator* keys) {}

}  // namespace

Maybe<bool> KeyAccumulator::CollectOwnPropertyNames(
    DirectHandle<JSReceiver> receiver, Handle<JSObject> object) {}

ExceptionStatus KeyAccumulator::CollectPrivateNames(
    DirectHandle<JSReceiver> receiver, DirectHandle<JSObject> object) {}

Maybe<bool> KeyAccumulator::CollectAccessCheckInterceptorKeys(
    DirectHandle<AccessCheckInfo> access_check_info,
    DirectHandle<JSReceiver> receiver, DirectHandle<JSObject> object) {}

// Returns |true| on success, |false| if prototype walking should be stopped,
// |nothing| if an exception was thrown.
Maybe<bool> KeyAccumulator::CollectOwnKeys(DirectHandle<JSReceiver> receiver,
                                           Handle<JSObject> object) {}

// static
Handle<FixedArray> KeyAccumulator::GetOwnEnumPropertyKeys(
    Isolate* isolate, DirectHandle<JSObject> object) {}

namespace {

class NameComparator {};

}  // namespace

// ES6 #sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
// Returns |true| on success, |nothing| in case of exception.
Maybe<bool> KeyAccumulator::CollectOwnJSProxyKeys(
    DirectHandle<JSReceiver> receiver, DirectHandle<JSProxy> proxy) {}

Maybe<bool> KeyAccumulator::CollectOwnJSProxyTargetKeys(
    DirectHandle<JSProxy> proxy, Handle<JSReceiver> target) {}

#undef RETURN_NOTHING_IF_NOT_SUCCESSFUL
#undef RETURN_FAILURE_IF_NOT_SUCCESSFUL
}  // namespace v8::internal