// Copyright 2012 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. #ifndef V8_OBJECTS_KEYS_H_ #define V8_OBJECTS_KEYS_H_ #include "include/v8-object.h" #include "src/objects/hash-table.h" #include "src/objects/js-objects.h" #include "src/objects/objects.h" namespace v8 { namespace internal { class AccessCheckInfo; class FastKeyAccumulator; class JSProxy; enum AddKeyConversion { … }; enum class GetKeysConversion { … }; enum class KeyCollectionMode { … }; // This is a helper class for JSReceiver::GetKeys which collects and sorts keys. // GetKeys needs to sort keys per prototype level, first showing the integer // indices from elements then the strings from the properties. However, this // does not apply to proxies which are in full control of how the keys are // sorted. // // For performance reasons the KeyAccumulator internally separates integer keys // in |elements_| into sorted lists per prototype level. String keys are // collected in |string_properties_|, a single OrderedHashSet (similar for // Symbols in |symbol_properties_|. To separate the keys per level later when // assembling the final list, |levelLengths_| keeps track of the number of // String and Symbol keys per level. // // Only unique keys are kept by the KeyAccumulator, strings are stored in a // HashSet for inexpensive lookups. Integer keys are kept in sorted lists which // are more compact and allow for reasonably fast includes check. class KeyAccumulator final { … }; // The FastKeyAccumulator handles the cases where there are no elements on the // prototype chain and forwards the complex/slow cases to the normal // KeyAccumulator. This significantly speeds up the cases where the OWN_ONLY // case where we do not have to walk the prototype chain. class FastKeyAccumulator { … }; } // namespace internal } // namespace v8 #endif // V8_OBJECTS_KEYS_H_