11cb0ef41Sopenharmony_ci// Copyright 2018 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_OBJECTS_JS_OBJECTS_H_
61cb0ef41Sopenharmony_ci#define V8_OBJECTS_JS_OBJECTS_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/objects/embedder-data-slot.h"
91cb0ef41Sopenharmony_ci// TODO(jkummerow): Consider forward-declaring instead.
101cb0ef41Sopenharmony_ci#include "src/objects/internal-index.h"
111cb0ef41Sopenharmony_ci#include "src/objects/objects.h"
121cb0ef41Sopenharmony_ci#include "src/objects/property-array.h"
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci// Has to be the last include (doesn't have include guards):
151cb0ef41Sopenharmony_ci#include "src/objects/object-macros.h"
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cinamespace v8 {
181cb0ef41Sopenharmony_cinamespace internal {
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci// Enum for functions that offer a second mode that does not cause allocations.
211cb0ef41Sopenharmony_ci// Used in conjunction with LookupIterator and unboxed double fields.
221cb0ef41Sopenharmony_cienum class AllocationPolicy { kAllocationAllowed, kAllocationDisallowed };
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_cienum InstanceType : uint16_t;
251cb0ef41Sopenharmony_ciclass JSGlobalObject;
261cb0ef41Sopenharmony_ciclass JSGlobalProxy;
271cb0ef41Sopenharmony_ciclass LookupIterator;
281cb0ef41Sopenharmony_ciclass PropertyKey;
291cb0ef41Sopenharmony_ciclass NativeContext;
301cb0ef41Sopenharmony_ciclass IsCompiledScope;
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci#include "torque-generated/src/objects/js-objects-tq.inc"
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci// JSReceiver includes types on which properties can be defined, i.e.,
351cb0ef41Sopenharmony_ci// JSObject and JSProxy.
361cb0ef41Sopenharmony_ciclass JSReceiver : public TorqueGeneratedJSReceiver<JSReceiver, HeapObject> {
371cb0ef41Sopenharmony_ci public:
381cb0ef41Sopenharmony_ci  NEVER_READ_ONLY_SPACE
391cb0ef41Sopenharmony_ci  // Returns true if there is no slow (ie, dictionary) backing store.
401cb0ef41Sopenharmony_ci  DECL_GETTER(HasFastProperties, bool)
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci  // Returns the properties array backing store if it
431cb0ef41Sopenharmony_ci  // exists. Otherwise, returns an empty_property_array when there's a
441cb0ef41Sopenharmony_ci  // Smi (hash code) or an empty_fixed_array for a fast properties
451cb0ef41Sopenharmony_ci  // map.
461cb0ef41Sopenharmony_ci  DECL_GETTER(property_array, PropertyArray)
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci  // Gets slow properties for non-global objects (if
491cb0ef41Sopenharmony_ci  // v8_enable_swiss_name_dictionary is not set).
501cb0ef41Sopenharmony_ci  DECL_GETTER(property_dictionary, NameDictionary)
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci  // Gets slow properties for non-global objects (if
531cb0ef41Sopenharmony_ci  // v8_enable_swiss_name_dictionary is set).
541cb0ef41Sopenharmony_ci  DECL_GETTER(property_dictionary_swiss, SwissNameDictionary)
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ci  // Sets the properties backing store and makes sure any existing hash is moved
571cb0ef41Sopenharmony_ci  // to the new properties store. To clear out the properties store, pass in the
581cb0ef41Sopenharmony_ci  // empty_fixed_array(), the hash will be maintained in this case as well.
591cb0ef41Sopenharmony_ci  void SetProperties(HeapObject properties);
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci  // There are five possible values for the properties offset.
621cb0ef41Sopenharmony_ci  // 1) EmptyFixedArray/EmptyPropertyDictionary - This is the standard
631cb0ef41Sopenharmony_ci  // placeholder.
641cb0ef41Sopenharmony_ci  //
651cb0ef41Sopenharmony_ci  // 2) Smi - This is the hash code of the object.
661cb0ef41Sopenharmony_ci  //
671cb0ef41Sopenharmony_ci  // 3) PropertyArray - This is similar to a FixedArray but stores
681cb0ef41Sopenharmony_ci  // the hash code of the object in its length field. This is a fast
691cb0ef41Sopenharmony_ci  // backing store.
701cb0ef41Sopenharmony_ci  //
711cb0ef41Sopenharmony_ci  // 4) NameDictionary - This is the dictionary-mode backing store.
721cb0ef41Sopenharmony_ci  //
731cb0ef41Sopenharmony_ci  // 4) GlobalDictionary - This is the backing store for the
741cb0ef41Sopenharmony_ci  // GlobalObject.
751cb0ef41Sopenharmony_ci  //
761cb0ef41Sopenharmony_ci  // This is used only in the deoptimizer and heap. Please use the
771cb0ef41Sopenharmony_ci  // above typed getters and setters to access the properties.
781cb0ef41Sopenharmony_ci  DECL_ACCESSORS(raw_properties_or_hash, Object)
791cb0ef41Sopenharmony_ci  DECL_RELAXED_ACCESSORS(raw_properties_or_hash, Object)
801cb0ef41Sopenharmony_ci
811cb0ef41Sopenharmony_ci  inline void initialize_properties(Isolate* isolate);
821cb0ef41Sopenharmony_ci
831cb0ef41Sopenharmony_ci  // Deletes an existing named property in a normalized object.
841cb0ef41Sopenharmony_ci  static void DeleteNormalizedProperty(Handle<JSReceiver> object,
851cb0ef41Sopenharmony_ci                                       InternalIndex entry);
861cb0ef41Sopenharmony_ci
871cb0ef41Sopenharmony_ci  // ES6 section 7.1.1 ToPrimitive
881cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ToPrimitive(
891cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> receiver,
901cb0ef41Sopenharmony_ci      ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
911cb0ef41Sopenharmony_ci
921cb0ef41Sopenharmony_ci  // ES6 section 7.1.1.1 OrdinaryToPrimitive
931cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> OrdinaryToPrimitive(
941cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> receiver,
951cb0ef41Sopenharmony_ci      OrdinaryToPrimitiveHint hint);
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ci  static MaybeHandle<NativeContext> GetFunctionRealm(
981cb0ef41Sopenharmony_ci      Handle<JSReceiver> receiver);
991cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static MaybeHandle<NativeContext> GetContextForMicrotask(
1001cb0ef41Sopenharmony_ci      Handle<JSReceiver> receiver);
1011cb0ef41Sopenharmony_ci
1021cb0ef41Sopenharmony_ci  // Get the first non-hidden prototype.
1031cb0ef41Sopenharmony_ci  static inline MaybeHandle<HeapObject> GetPrototype(
1041cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> receiver);
1051cb0ef41Sopenharmony_ci
1061cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> HasInPrototypeChain(
1071cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> object, Handle<Object> proto);
1081cb0ef41Sopenharmony_ci
1091cb0ef41Sopenharmony_ci  // Reads all enumerable own properties of source and adds them to
1101cb0ef41Sopenharmony_ci  // target, using either Set or CreateDataProperty depending on the
1111cb0ef41Sopenharmony_ci  // use_set argument. This only copies values not present in the
1121cb0ef41Sopenharmony_ci  // maybe_excluded_properties list.
1131cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> SetOrCopyDataProperties(
1141cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> target, Handle<Object> source,
1151cb0ef41Sopenharmony_ci      PropertiesEnumerationMode mode,
1161cb0ef41Sopenharmony_ci      const base::ScopedVector<Handle<Object>>* excluded_properties = nullptr,
1171cb0ef41Sopenharmony_ci      bool use_set = true);
1181cb0ef41Sopenharmony_ci
1191cb0ef41Sopenharmony_ci  // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6.
1201cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool> HasProperty(
1211cb0ef41Sopenharmony_ci      LookupIterator* it);
1221cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline Maybe<bool> HasProperty(
1231cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> object, Handle<Name> name);
1241cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline Maybe<bool> HasElement(
1251cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> object, uint32_t index);
1261cb0ef41Sopenharmony_ci
1271cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool> HasOwnProperty(
1281cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> object, Handle<Name> name);
1291cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline Maybe<bool> HasOwnProperty(
1301cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> object, uint32_t index);
1311cb0ef41Sopenharmony_ci
1321cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetProperty(
1331cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> receiver, const char* key);
1341cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetProperty(
1351cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> receiver, Handle<Name> name);
1361cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetElement(
1371cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> receiver, uint32_t index);
1381cb0ef41Sopenharmony_ci
1391cb0ef41Sopenharmony_ci  // Implementation of ES6 [[Delete]]
1401cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool>
1411cb0ef41Sopenharmony_ci  DeletePropertyOrElement(Handle<JSReceiver> object, Handle<Name> name,
1421cb0ef41Sopenharmony_ci                          LanguageMode language_mode = LanguageMode::kSloppy);
1431cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool> DeleteProperty(
1441cb0ef41Sopenharmony_ci      Handle<JSReceiver> object, Handle<Name> name,
1451cb0ef41Sopenharmony_ci      LanguageMode language_mode = LanguageMode::kSloppy);
1461cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> DeleteProperty(
1471cb0ef41Sopenharmony_ci      LookupIterator* it, LanguageMode language_mode);
1481cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> DeleteElement(
1491cb0ef41Sopenharmony_ci      Handle<JSReceiver> object, uint32_t index,
1501cb0ef41Sopenharmony_ci      LanguageMode language_mode = LanguageMode::kSloppy);
1511cb0ef41Sopenharmony_ci
1521cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Object DefineProperty(Isolate* isolate,
1531cb0ef41Sopenharmony_ci                                                     Handle<Object> object,
1541cb0ef41Sopenharmony_ci                                                     Handle<Object> name,
1551cb0ef41Sopenharmony_ci                                                     Handle<Object> attributes);
1561cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> DefineProperties(
1571cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<Object> object, Handle<Object> properties);
1581cb0ef41Sopenharmony_ci
1591cb0ef41Sopenharmony_ci  // "virtual" dispatcher to the correct [[DefineOwnProperty]] implementation.
1601cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> DefineOwnProperty(
1611cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key,
1621cb0ef41Sopenharmony_ci      PropertyDescriptor* desc, Maybe<ShouldThrow> should_throw);
1631cb0ef41Sopenharmony_ci
1641cb0ef41Sopenharmony_ci  // Check if private name property can be store on the object. It will return
1651cb0ef41Sopenharmony_ci  // false with an error when it cannot.
1661cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static bool CheckPrivateNameStore(LookupIterator* it,
1671cb0ef41Sopenharmony_ci                                                          bool is_define);
1681cb0ef41Sopenharmony_ci
1691cb0ef41Sopenharmony_ci  // Check if a data property can be created on the object. It will fail with
1701cb0ef41Sopenharmony_ci  // an error when it cannot.
1711cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> CheckIfCanDefine(
1721cb0ef41Sopenharmony_ci      Isolate* isolate, LookupIterator* it, Handle<Object> value,
1731cb0ef41Sopenharmony_ci      Maybe<ShouldThrow> should_throw);
1741cb0ef41Sopenharmony_ci
1751cb0ef41Sopenharmony_ci  // ES6 7.3.4 (when passed kDontThrow)
1761cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> CreateDataProperty(
1771cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> object, Handle<Name> key,
1781cb0ef41Sopenharmony_ci      Handle<Object> value, Maybe<ShouldThrow> should_throw);
1791cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> CreateDataProperty(
1801cb0ef41Sopenharmony_ci      LookupIterator* it, Handle<Object> value,
1811cb0ef41Sopenharmony_ci      Maybe<ShouldThrow> should_throw);
1821cb0ef41Sopenharmony_ci
1831cb0ef41Sopenharmony_ci  // Add private fields to the receiver, ignoring extensibility and the
1841cb0ef41Sopenharmony_ci  // traps. The caller should check that the private field does not already
1851cb0ef41Sopenharmony_ci  // exist on the receiver before calling this method.
1861cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> AddPrivateField(
1871cb0ef41Sopenharmony_ci      LookupIterator* it, Handle<Object> value,
1881cb0ef41Sopenharmony_ci      Maybe<ShouldThrow> should_throw);
1891cb0ef41Sopenharmony_ci
1901cb0ef41Sopenharmony_ci  // ES6 9.1.6.1
1911cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> OrdinaryDefineOwnProperty(
1921cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSObject> object, Handle<Object> key,
1931cb0ef41Sopenharmony_ci      PropertyDescriptor* desc, Maybe<ShouldThrow> should_throw);
1941cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> OrdinaryDefineOwnProperty(
1951cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSObject> object, const PropertyKey& key,
1961cb0ef41Sopenharmony_ci      PropertyDescriptor* desc, Maybe<ShouldThrow> should_throw);
1971cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> OrdinaryDefineOwnProperty(
1981cb0ef41Sopenharmony_ci      LookupIterator* it, PropertyDescriptor* desc,
1991cb0ef41Sopenharmony_ci      Maybe<ShouldThrow> should_throw);
2001cb0ef41Sopenharmony_ci  // ES6 9.1.6.2
2011cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> IsCompatiblePropertyDescriptor(
2021cb0ef41Sopenharmony_ci      Isolate* isolate, bool extensible, PropertyDescriptor* desc,
2031cb0ef41Sopenharmony_ci      PropertyDescriptor* current, Handle<Name> property_name,
2041cb0ef41Sopenharmony_ci      Maybe<ShouldThrow> should_throw);
2051cb0ef41Sopenharmony_ci  // ES6 9.1.6.3
2061cb0ef41Sopenharmony_ci  // |it| can be NULL in cases where the ES spec passes |undefined| as the
2071cb0ef41Sopenharmony_ci  // receiver. Exactly one of |it| and |property_name| must be provided.
2081cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> ValidateAndApplyPropertyDescriptor(
2091cb0ef41Sopenharmony_ci      Isolate* isolate, LookupIterator* it, bool extensible,
2101cb0ef41Sopenharmony_ci      PropertyDescriptor* desc, PropertyDescriptor* current,
2111cb0ef41Sopenharmony_ci      Maybe<ShouldThrow> should_throw, Handle<Name> property_name);
2121cb0ef41Sopenharmony_ci
2131cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool>
2141cb0ef41Sopenharmony_ci  GetOwnPropertyDescriptor(Isolate* isolate, Handle<JSReceiver> object,
2151cb0ef41Sopenharmony_ci                           Handle<Object> key, PropertyDescriptor* desc);
2161cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> GetOwnPropertyDescriptor(
2171cb0ef41Sopenharmony_ci      LookupIterator* it, PropertyDescriptor* desc);
2181cb0ef41Sopenharmony_ci
2191cb0ef41Sopenharmony_ci  using IntegrityLevel = PropertyAttributes;
2201cb0ef41Sopenharmony_ci
2211cb0ef41Sopenharmony_ci  // ES6 7.3.14 (when passed kDontThrow)
2221cb0ef41Sopenharmony_ci  // 'level' must be SEALED or FROZEN.
2231cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> SetIntegrityLevel(
2241cb0ef41Sopenharmony_ci      Handle<JSReceiver> object, IntegrityLevel lvl, ShouldThrow should_throw);
2251cb0ef41Sopenharmony_ci
2261cb0ef41Sopenharmony_ci  // ES6 7.3.15
2271cb0ef41Sopenharmony_ci  // 'level' must be SEALED or FROZEN.
2281cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> TestIntegrityLevel(
2291cb0ef41Sopenharmony_ci      Handle<JSReceiver> object, IntegrityLevel lvl);
2301cb0ef41Sopenharmony_ci
2311cb0ef41Sopenharmony_ci  // ES6 [[PreventExtensions]] (when passed kDontThrow)
2321cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> PreventExtensions(
2331cb0ef41Sopenharmony_ci      Handle<JSReceiver> object, ShouldThrow should_throw);
2341cb0ef41Sopenharmony_ci
2351cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> IsExtensible(
2361cb0ef41Sopenharmony_ci      Handle<JSReceiver> object);
2371cb0ef41Sopenharmony_ci
2381cb0ef41Sopenharmony_ci  // Returns the class name.
2391cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE String class_name();
2401cb0ef41Sopenharmony_ci
2411cb0ef41Sopenharmony_ci  // Returns the constructor (the function that was used to instantiate the
2421cb0ef41Sopenharmony_ci  // object).
2431cb0ef41Sopenharmony_ci  static MaybeHandle<JSFunction> GetConstructor(Isolate* isolate,
2441cb0ef41Sopenharmony_ci                                                Handle<JSReceiver> receiver);
2451cb0ef41Sopenharmony_ci
2461cb0ef41Sopenharmony_ci  // Returns the constructor name (the (possibly inferred) name of the function
2471cb0ef41Sopenharmony_ci  // that was used to instantiate the object), if any. If a FunctionTemplate is
2481cb0ef41Sopenharmony_ci  // used to instantiate the object, the class_name of the FunctionTemplate is
2491cb0ef41Sopenharmony_ci  // returned instead.
2501cb0ef41Sopenharmony_ci  static Handle<String> GetConstructorName(Isolate* isolate,
2511cb0ef41Sopenharmony_ci                                           Handle<JSReceiver> receiver);
2521cb0ef41Sopenharmony_ci
2531cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE MaybeHandle<NativeContext> GetCreationContext();
2541cb0ef41Sopenharmony_ci
2551cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline Maybe<PropertyAttributes>
2561cb0ef41Sopenharmony_ci  GetPropertyAttributes(Handle<JSReceiver> object, Handle<Name> name);
2571cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline Maybe<PropertyAttributes>
2581cb0ef41Sopenharmony_ci  GetOwnPropertyAttributes(Handle<JSReceiver> object, Handle<Name> name);
2591cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline Maybe<PropertyAttributes>
2601cb0ef41Sopenharmony_ci  GetOwnPropertyAttributes(Handle<JSReceiver> object, uint32_t index);
2611cb0ef41Sopenharmony_ci
2621cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline Maybe<PropertyAttributes>
2631cb0ef41Sopenharmony_ci  GetElementAttributes(Handle<JSReceiver> object, uint32_t index);
2641cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline Maybe<PropertyAttributes>
2651cb0ef41Sopenharmony_ci  GetOwnElementAttributes(Handle<JSReceiver> object, uint32_t index);
2661cb0ef41Sopenharmony_ci
2671cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes(
2681cb0ef41Sopenharmony_ci      LookupIterator* it);
2691cb0ef41Sopenharmony_ci
2701cb0ef41Sopenharmony_ci  // Set the object's prototype (only JSReceiver and null are allowed values).
2711cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool> SetPrototype(
2721cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSReceiver> object, Handle<Object> value,
2731cb0ef41Sopenharmony_ci      bool from_javascript, ShouldThrow should_throw);
2741cb0ef41Sopenharmony_ci
2751cb0ef41Sopenharmony_ci  inline static Handle<Object> GetDataProperty(Isolate* isolate,
2761cb0ef41Sopenharmony_ci                                               Handle<JSReceiver> object,
2771cb0ef41Sopenharmony_ci                                               Handle<Name> name);
2781cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static Handle<Object> GetDataProperty(
2791cb0ef41Sopenharmony_ci      LookupIterator* it, AllocationPolicy allocation_policy =
2801cb0ef41Sopenharmony_ci                              AllocationPolicy::kAllocationAllowed);
2811cb0ef41Sopenharmony_ci
2821cb0ef41Sopenharmony_ci  // Retrieves a permanent object identity hash code. The undefined value might
2831cb0ef41Sopenharmony_ci  // be returned in case no hash was created yet.
2841cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE Object GetIdentityHash();
2851cb0ef41Sopenharmony_ci
2861cb0ef41Sopenharmony_ci  // Retrieves a permanent object identity hash code. May create and store a
2871cb0ef41Sopenharmony_ci  // hash code if needed and none exists.
2881cb0ef41Sopenharmony_ci  static Smi CreateIdentityHash(Isolate* isolate, JSReceiver key);
2891cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE Smi GetOrCreateIdentityHash(Isolate* isolate);
2901cb0ef41Sopenharmony_ci
2911cb0ef41Sopenharmony_ci  // Stores the hash code. The hash passed in must be masked with
2921cb0ef41Sopenharmony_ci  // JSReceiver::kHashMask.
2931cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE void SetIdentityHash(int masked_hash);
2941cb0ef41Sopenharmony_ci
2951cb0ef41Sopenharmony_ci  // ES6 [[OwnPropertyKeys]] (modulo return type)
2961cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static inline MaybeHandle<FixedArray> OwnPropertyKeys(
2971cb0ef41Sopenharmony_ci      Handle<JSReceiver> object);
2981cb0ef41Sopenharmony_ci
2991cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<FixedArray> GetOwnValues(
3001cb0ef41Sopenharmony_ci      Handle<JSReceiver> object, PropertyFilter filter,
3011cb0ef41Sopenharmony_ci      bool try_fast_path = true);
3021cb0ef41Sopenharmony_ci
3031cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<FixedArray> GetOwnEntries(
3041cb0ef41Sopenharmony_ci      Handle<JSReceiver> object, PropertyFilter filter,
3051cb0ef41Sopenharmony_ci      bool try_fast_path = true);
3061cb0ef41Sopenharmony_ci
3071cb0ef41Sopenharmony_ci  static const int kHashMask = PropertyArray::HashField::kMask;
3081cb0ef41Sopenharmony_ci
3091cb0ef41Sopenharmony_ci  bool HasProxyInPrototype(Isolate* isolate);
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_ci  // TC39 "Dynamic Code Brand Checks"
3121cb0ef41Sopenharmony_ci  bool IsCodeLike(Isolate* isolate) const;
3131cb0ef41Sopenharmony_ci
3141cb0ef41Sopenharmony_ci private:
3151cb0ef41Sopenharmony_ci  // Hide generated accessors; custom accessors are called
3161cb0ef41Sopenharmony_ci  // "raw_properties_or_hash".
3171cb0ef41Sopenharmony_ci  DECL_ACCESSORS(properties_or_hash, Object)
3181cb0ef41Sopenharmony_ci
3191cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSReceiver)
3201cb0ef41Sopenharmony_ci};
3211cb0ef41Sopenharmony_ci
3221cb0ef41Sopenharmony_ci// The JSObject describes real heap allocated JavaScript objects with
3231cb0ef41Sopenharmony_ci// properties.
3241cb0ef41Sopenharmony_ci// Note that the map of JSObject changes during execution to enable inline
3251cb0ef41Sopenharmony_ci// caching.
3261cb0ef41Sopenharmony_ciclass JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> {
3271cb0ef41Sopenharmony_ci public:
3281cb0ef41Sopenharmony_ci  static bool IsUnmodifiedApiObject(FullObjectSlot o);
3291cb0ef41Sopenharmony_ci
3301cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle<JSObject> New(
3311cb0ef41Sopenharmony_ci      Handle<JSFunction> constructor, Handle<JSReceiver> new_target,
3321cb0ef41Sopenharmony_ci      Handle<AllocationSite> site);
3331cb0ef41Sopenharmony_ci
3341cb0ef41Sopenharmony_ci  // 9.1.12 ObjectCreate ( proto [ , internalSlotsList ] )
3351cb0ef41Sopenharmony_ci  // Notice: This is NOT 19.1.2.2 Object.create ( O, Properties )
3361cb0ef41Sopenharmony_ci  static V8_WARN_UNUSED_RESULT MaybeHandle<JSObject> ObjectCreate(
3371cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<Object> prototype);
3381cb0ef41Sopenharmony_ci
3391cb0ef41Sopenharmony_ci  DECL_ACCESSORS(elements, FixedArrayBase)
3401cb0ef41Sopenharmony_ci  DECL_RELAXED_GETTER(elements, FixedArrayBase)
3411cb0ef41Sopenharmony_ci
3421cb0ef41Sopenharmony_ci  // Acquire/release semantics on this field are explicitly forbidden to avoid
3431cb0ef41Sopenharmony_ci  // confusion, since the default setter uses relaxed semantics. If
3441cb0ef41Sopenharmony_ci  // acquire/release semantics ever become necessary, the default setter should
3451cb0ef41Sopenharmony_ci  // be reverted to non-atomic behavior, and setters with explicit tags
3461cb0ef41Sopenharmony_ci  // introduced and used when required.
3471cb0ef41Sopenharmony_ci  FixedArrayBase elements(PtrComprCageBase cage_base,
3481cb0ef41Sopenharmony_ci                          AcquireLoadTag tag) const = delete;
3491cb0ef41Sopenharmony_ci  void set_elements(FixedArrayBase value, ReleaseStoreTag tag,
3501cb0ef41Sopenharmony_ci                    WriteBarrierMode mode = UPDATE_WRITE_BARRIER) = delete;
3511cb0ef41Sopenharmony_ci
3521cb0ef41Sopenharmony_ci  inline void initialize_elements();
3531cb0ef41Sopenharmony_ci  static inline void SetMapAndElements(Handle<JSObject> object, Handle<Map> map,
3541cb0ef41Sopenharmony_ci                                       Handle<FixedArrayBase> elements);
3551cb0ef41Sopenharmony_ci  DECL_GETTER(GetElementsKind, ElementsKind)
3561cb0ef41Sopenharmony_ci  DECL_GETTER(GetElementsAccessor, ElementsAccessor*)
3571cb0ef41Sopenharmony_ci
3581cb0ef41Sopenharmony_ci  // Returns true if an object has elements of PACKED_SMI_ELEMENTS or
3591cb0ef41Sopenharmony_ci  // HOLEY_SMI_ELEMENTS ElementsKind.
3601cb0ef41Sopenharmony_ci  DECL_GETTER(HasSmiElements, bool)
3611cb0ef41Sopenharmony_ci  // Returns true if an object has elements of PACKED_ELEMENTS or
3621cb0ef41Sopenharmony_ci  // HOLEY_ELEMENTS ElementsKind.
3631cb0ef41Sopenharmony_ci  DECL_GETTER(HasObjectElements, bool)
3641cb0ef41Sopenharmony_ci  // Returns true if an object has elements of PACKED_SMI_ELEMENTS,
3651cb0ef41Sopenharmony_ci  // HOLEY_SMI_ELEMENTS, PACKED_ELEMENTS, or HOLEY_ELEMENTS.
3661cb0ef41Sopenharmony_ci  DECL_GETTER(HasSmiOrObjectElements, bool)
3671cb0ef41Sopenharmony_ci  // Returns true if an object has any of the "fast" elements kinds.
3681cb0ef41Sopenharmony_ci  DECL_GETTER(HasFastElements, bool)
3691cb0ef41Sopenharmony_ci  // Returns true if an object has any of the PACKED elements kinds.
3701cb0ef41Sopenharmony_ci  DECL_GETTER(HasFastPackedElements, bool)
3711cb0ef41Sopenharmony_ci  // Returns true if an object has elements of PACKED_DOUBLE_ELEMENTS or
3721cb0ef41Sopenharmony_ci  // HOLEY_DOUBLE_ELEMENTS ElementsKind.
3731cb0ef41Sopenharmony_ci  DECL_GETTER(HasDoubleElements, bool)
3741cb0ef41Sopenharmony_ci  // Returns true if an object has elements of HOLEY_SMI_ELEMENTS,
3751cb0ef41Sopenharmony_ci  // HOLEY_DOUBLE_ELEMENTS, or HOLEY_ELEMENTS ElementsKind.
3761cb0ef41Sopenharmony_ci  DECL_GETTER(HasHoleyElements, bool)
3771cb0ef41Sopenharmony_ci  DECL_GETTER(HasSloppyArgumentsElements, bool)
3781cb0ef41Sopenharmony_ci  DECL_GETTER(HasStringWrapperElements, bool)
3791cb0ef41Sopenharmony_ci  DECL_GETTER(HasDictionaryElements, bool)
3801cb0ef41Sopenharmony_ci
3811cb0ef41Sopenharmony_ci  // Returns true if an object has elements of PACKED_ELEMENTS
3821cb0ef41Sopenharmony_ci  DECL_GETTER(HasPackedElements, bool)
3831cb0ef41Sopenharmony_ci  DECL_GETTER(HasAnyNonextensibleElements, bool)
3841cb0ef41Sopenharmony_ci  DECL_GETTER(HasSealedElements, bool)
3851cb0ef41Sopenharmony_ci  DECL_GETTER(HasNonextensibleElements, bool)
3861cb0ef41Sopenharmony_ci
3871cb0ef41Sopenharmony_ci  DECL_GETTER(HasTypedArrayOrRabGsabTypedArrayElements, bool)
3881cb0ef41Sopenharmony_ci
3891cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedUint8ClampedElements, bool)
3901cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedArrayElements, bool)
3911cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedInt8Elements, bool)
3921cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedUint8Elements, bool)
3931cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedInt16Elements, bool)
3941cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedUint16Elements, bool)
3951cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedInt32Elements, bool)
3961cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedUint32Elements, bool)
3971cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedFloat32Elements, bool)
3981cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedFloat64Elements, bool)
3991cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedBigInt64Elements, bool)
4001cb0ef41Sopenharmony_ci  DECL_GETTER(HasFixedBigUint64Elements, bool)
4011cb0ef41Sopenharmony_ci
4021cb0ef41Sopenharmony_ci  DECL_GETTER(HasFastArgumentsElements, bool)
4031cb0ef41Sopenharmony_ci  DECL_GETTER(HasSlowArgumentsElements, bool)
4041cb0ef41Sopenharmony_ci  DECL_GETTER(HasFastStringWrapperElements, bool)
4051cb0ef41Sopenharmony_ci  DECL_GETTER(HasSlowStringWrapperElements, bool)
4061cb0ef41Sopenharmony_ci  bool HasEnumerableElements();
4071cb0ef41Sopenharmony_ci
4081cb0ef41Sopenharmony_ci  // Gets slow elements.
4091cb0ef41Sopenharmony_ci  DECL_GETTER(element_dictionary, NumberDictionary)
4101cb0ef41Sopenharmony_ci
4111cb0ef41Sopenharmony_ci  // Requires: HasFastElements().
4121cb0ef41Sopenharmony_ci  static void EnsureWritableFastElements(Handle<JSObject> object);
4131cb0ef41Sopenharmony_ci
4141cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyWithInterceptor(
4151cb0ef41Sopenharmony_ci      LookupIterator* it, Maybe<ShouldThrow> should_throw,
4161cb0ef41Sopenharmony_ci      Handle<Object> value);
4171cb0ef41Sopenharmony_ci
4181cb0ef41Sopenharmony_ci  // The API currently still wants DefineOwnPropertyIgnoreAttributes to convert
4191cb0ef41Sopenharmony_ci  // AccessorInfo objects to data fields. We allow FORCE_FIELD as an exception
4201cb0ef41Sopenharmony_ci  // to the default behavior that calls the setter.
4211cb0ef41Sopenharmony_ci  enum AccessorInfoHandling { FORCE_FIELD, DONT_FORCE_FIELD };
4221cb0ef41Sopenharmony_ci
4231cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
4241cb0ef41Sopenharmony_ci  DefineOwnPropertyIgnoreAttributes(
4251cb0ef41Sopenharmony_ci      LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
4261cb0ef41Sopenharmony_ci      AccessorInfoHandling handling = DONT_FORCE_FIELD,
4271cb0ef41Sopenharmony_ci      EnforceDefineSemantics semantics = EnforceDefineSemantics::kSet);
4281cb0ef41Sopenharmony_ci
4291cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> DefineOwnPropertyIgnoreAttributes(
4301cb0ef41Sopenharmony_ci      LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
4311cb0ef41Sopenharmony_ci      Maybe<ShouldThrow> should_throw,
4321cb0ef41Sopenharmony_ci      AccessorInfoHandling handling = DONT_FORCE_FIELD,
4331cb0ef41Sopenharmony_ci      EnforceDefineSemantics semantics = EnforceDefineSemantics::kSet,
4341cb0ef41Sopenharmony_ci      StoreOrigin store_origin = StoreOrigin::kNamed);
4351cb0ef41Sopenharmony_ci
4361cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> V8_EXPORT_PRIVATE
4371cb0ef41Sopenharmony_ci  SetOwnPropertyIgnoreAttributes(Handle<JSObject> object, Handle<Name> name,
4381cb0ef41Sopenharmony_ci                                 Handle<Object> value,
4391cb0ef41Sopenharmony_ci                                 PropertyAttributes attributes);
4401cb0ef41Sopenharmony_ci
4411cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
4421cb0ef41Sopenharmony_ci  SetOwnElementIgnoreAttributes(Handle<JSObject> object, size_t index,
4431cb0ef41Sopenharmony_ci                                Handle<Object> value,
4441cb0ef41Sopenharmony_ci                                PropertyAttributes attributes);
4451cb0ef41Sopenharmony_ci
4461cb0ef41Sopenharmony_ci  // Equivalent to one of the above depending on whether |name| can be converted
4471cb0ef41Sopenharmony_ci  // to an array index.
4481cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
4491cb0ef41Sopenharmony_ci  DefinePropertyOrElementIgnoreAttributes(Handle<JSObject> object,
4501cb0ef41Sopenharmony_ci                                          Handle<Name> name,
4511cb0ef41Sopenharmony_ci                                          Handle<Object> value,
4521cb0ef41Sopenharmony_ci                                          PropertyAttributes attributes = NONE);
4531cb0ef41Sopenharmony_ci
4541cb0ef41Sopenharmony_ci  // Adds or reconfigures a property to attributes NONE. It will fail when it
4551cb0ef41Sopenharmony_ci  // cannot.
4561cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> CreateDataProperty(
4571cb0ef41Sopenharmony_ci      LookupIterator* it, Handle<Object> value,
4581cb0ef41Sopenharmony_ci      Maybe<ShouldThrow> should_throw = Just(kDontThrow));
4591cb0ef41Sopenharmony_ci
4601cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static void AddProperty(Isolate* isolate,
4611cb0ef41Sopenharmony_ci                                            Handle<JSObject> object,
4621cb0ef41Sopenharmony_ci                                            Handle<Name> name,
4631cb0ef41Sopenharmony_ci                                            Handle<Object> value,
4641cb0ef41Sopenharmony_ci                                            PropertyAttributes attributes);
4651cb0ef41Sopenharmony_ci
4661cb0ef41Sopenharmony_ci  // {name} must be a UTF-8 encoded, null-terminated string.
4671cb0ef41Sopenharmony_ci  static void AddProperty(Isolate* isolate, Handle<JSObject> object,
4681cb0ef41Sopenharmony_ci                          const char* name, Handle<Object> value,
4691cb0ef41Sopenharmony_ci                          PropertyAttributes attributes);
4701cb0ef41Sopenharmony_ci
4711cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static Maybe<bool> AddDataElement(
4721cb0ef41Sopenharmony_ci      Handle<JSObject> receiver, uint32_t index, Handle<Object> value,
4731cb0ef41Sopenharmony_ci      PropertyAttributes attributes);
4741cb0ef41Sopenharmony_ci
4751cb0ef41Sopenharmony_ci  // Extend the receiver with a single fast property appeared first in the
4761cb0ef41Sopenharmony_ci  // passed map. This also extends the property backing store if necessary.
4771cb0ef41Sopenharmony_ci  static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map);
4781cb0ef41Sopenharmony_ci
4791cb0ef41Sopenharmony_ci  // Migrates the given object to a map whose field representations are the
4801cb0ef41Sopenharmony_ci  // lowest upper bound of all known representations for that field.
4811cb0ef41Sopenharmony_ci  static void MigrateInstance(Isolate* isolate, Handle<JSObject> instance);
4821cb0ef41Sopenharmony_ci
4831cb0ef41Sopenharmony_ci  // Migrates the given object only if the target map is already available,
4841cb0ef41Sopenharmony_ci  // or returns false if such a map is not yet available.
4851cb0ef41Sopenharmony_ci  static bool TryMigrateInstance(Isolate* isolate, Handle<JSObject> instance);
4861cb0ef41Sopenharmony_ci
4871cb0ef41Sopenharmony_ci  // Sets the property value in a normalized object given (key, value, details).
4881cb0ef41Sopenharmony_ci  // Handles the special representation of JS global objects.
4891cb0ef41Sopenharmony_ci  static void SetNormalizedProperty(Handle<JSObject> object, Handle<Name> name,
4901cb0ef41Sopenharmony_ci                                    Handle<Object> value,
4911cb0ef41Sopenharmony_ci                                    PropertyDetails details);
4921cb0ef41Sopenharmony_ci  static void SetNormalizedElement(Handle<JSObject> object, uint32_t index,
4931cb0ef41Sopenharmony_ci                                   Handle<Object> value,
4941cb0ef41Sopenharmony_ci                                   PropertyDetails details);
4951cb0ef41Sopenharmony_ci
4961cb0ef41Sopenharmony_ci  static void OptimizeAsPrototype(Handle<JSObject> object,
4971cb0ef41Sopenharmony_ci                                  bool enable_setup_mode = true);
4981cb0ef41Sopenharmony_ci  static void ReoptimizeIfPrototype(Handle<JSObject> object);
4991cb0ef41Sopenharmony_ci  static void MakePrototypesFast(Handle<Object> receiver,
5001cb0ef41Sopenharmony_ci                                 WhereToStart where_to_start, Isolate* isolate);
5011cb0ef41Sopenharmony_ci  static void LazyRegisterPrototypeUser(Handle<Map> user, Isolate* isolate);
5021cb0ef41Sopenharmony_ci  static void UpdatePrototypeUserRegistration(Handle<Map> old_map,
5031cb0ef41Sopenharmony_ci                                              Handle<Map> new_map,
5041cb0ef41Sopenharmony_ci                                              Isolate* isolate);
5051cb0ef41Sopenharmony_ci  static bool UnregisterPrototypeUser(Handle<Map> user, Isolate* isolate);
5061cb0ef41Sopenharmony_ci  static Map InvalidatePrototypeChains(Map map);
5071cb0ef41Sopenharmony_ci  static void InvalidatePrototypeValidityCell(JSGlobalObject global);
5081cb0ef41Sopenharmony_ci
5091cb0ef41Sopenharmony_ci  // Updates prototype chain tracking information when an object changes its
5101cb0ef41Sopenharmony_ci  // map from |old_map| to |new_map|.
5111cb0ef41Sopenharmony_ci  static void NotifyMapChange(Handle<Map> old_map, Handle<Map> new_map,
5121cb0ef41Sopenharmony_ci                              Isolate* isolate);
5131cb0ef41Sopenharmony_ci
5141cb0ef41Sopenharmony_ci  // Utility used by many Array builtins and runtime functions
5151cb0ef41Sopenharmony_ci  static inline bool PrototypeHasNoElements(Isolate* isolate, JSObject object);
5161cb0ef41Sopenharmony_ci
5171cb0ef41Sopenharmony_ci  // To be passed to PrototypeUsers::Compact.
5181cb0ef41Sopenharmony_ci  static void PrototypeRegistryCompactionCallback(HeapObject value,
5191cb0ef41Sopenharmony_ci                                                  int old_index, int new_index);
5201cb0ef41Sopenharmony_ci
5211cb0ef41Sopenharmony_ci  // Retrieve interceptors.
5221cb0ef41Sopenharmony_ci  DECL_GETTER(GetNamedInterceptor, InterceptorInfo)
5231cb0ef41Sopenharmony_ci  DECL_GETTER(GetIndexedInterceptor, InterceptorInfo)
5241cb0ef41Sopenharmony_ci
5251cb0ef41Sopenharmony_ci  // Used from JSReceiver.
5261cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<PropertyAttributes>
5271cb0ef41Sopenharmony_ci  GetPropertyAttributesWithInterceptor(LookupIterator* it);
5281cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<PropertyAttributes>
5291cb0ef41Sopenharmony_ci  GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it);
5301cb0ef41Sopenharmony_ci
5311cb0ef41Sopenharmony_ci  // Defines an AccessorPair property on the given object.
5321cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static MaybeHandle<Object> DefineAccessor(
5331cb0ef41Sopenharmony_ci      Handle<JSObject> object, Handle<Name> name, Handle<Object> getter,
5341cb0ef41Sopenharmony_ci      Handle<Object> setter, PropertyAttributes attributes);
5351cb0ef41Sopenharmony_ci  static MaybeHandle<Object> DefineAccessor(LookupIterator* it,
5361cb0ef41Sopenharmony_ci                                            Handle<Object> getter,
5371cb0ef41Sopenharmony_ci                                            Handle<Object> setter,
5381cb0ef41Sopenharmony_ci                                            PropertyAttributes attributes);
5391cb0ef41Sopenharmony_ci
5401cb0ef41Sopenharmony_ci  // Defines an AccessorInfo property on the given object.
5411cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SetAccessor(
5421cb0ef41Sopenharmony_ci      Handle<JSObject> object, Handle<Name> name, Handle<AccessorInfo> info,
5431cb0ef41Sopenharmony_ci      PropertyAttributes attributes);
5441cb0ef41Sopenharmony_ci
5451cb0ef41Sopenharmony_ci  // The result must be checked first for exceptions. If there's no exception,
5461cb0ef41Sopenharmony_ci  // the output parameter |done| indicates whether the interceptor has a result
5471cb0ef41Sopenharmony_ci  // or not.
5481cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetPropertyWithInterceptor(
5491cb0ef41Sopenharmony_ci      LookupIterator* it, bool* done);
5501cb0ef41Sopenharmony_ci
5511cb0ef41Sopenharmony_ci  static void ValidateElements(JSObject object);
5521cb0ef41Sopenharmony_ci
5531cb0ef41Sopenharmony_ci  // Makes sure that this object can contain HeapObject as elements.
5541cb0ef41Sopenharmony_ci  static inline void EnsureCanContainHeapObjectElements(Handle<JSObject> obj);
5551cb0ef41Sopenharmony_ci
5561cb0ef41Sopenharmony_ci  // Makes sure that this object can contain the specified elements.
5571cb0ef41Sopenharmony_ci  // TSlot here is either ObjectSlot or FullObjectSlot.
5581cb0ef41Sopenharmony_ci  template <typename TSlot>
5591cb0ef41Sopenharmony_ci  static inline void EnsureCanContainElements(Handle<JSObject> object,
5601cb0ef41Sopenharmony_ci                                              TSlot elements, uint32_t count,
5611cb0ef41Sopenharmony_ci                                              EnsureElementsMode mode);
5621cb0ef41Sopenharmony_ci  static inline void EnsureCanContainElements(Handle<JSObject> object,
5631cb0ef41Sopenharmony_ci                                              Handle<FixedArrayBase> elements,
5641cb0ef41Sopenharmony_ci                                              uint32_t length,
5651cb0ef41Sopenharmony_ci                                              EnsureElementsMode mode);
5661cb0ef41Sopenharmony_ci  static void EnsureCanContainElements(Handle<JSObject> object,
5671cb0ef41Sopenharmony_ci                                       JavaScriptArguments* arguments,
5681cb0ef41Sopenharmony_ci                                       uint32_t arg_count,
5691cb0ef41Sopenharmony_ci                                       EnsureElementsMode mode);
5701cb0ef41Sopenharmony_ci
5711cb0ef41Sopenharmony_ci  // Would we convert a fast elements array to dictionary mode given
5721cb0ef41Sopenharmony_ci  // an access at key?
5731cb0ef41Sopenharmony_ci  bool WouldConvertToSlowElements(uint32_t index);
5741cb0ef41Sopenharmony_ci
5751cb0ef41Sopenharmony_ci  static const uint32_t kMinAddedElementsCapacity = 16;
5761cb0ef41Sopenharmony_ci
5771cb0ef41Sopenharmony_ci  // Computes the new capacity when expanding the elements of a JSObject.
5781cb0ef41Sopenharmony_ci  static uint32_t NewElementsCapacity(uint32_t old_capacity) {
5791cb0ef41Sopenharmony_ci    // (old_capacity + 50%) + kMinAddedElementsCapacity
5801cb0ef41Sopenharmony_ci    return old_capacity + (old_capacity >> 1) + kMinAddedElementsCapacity;
5811cb0ef41Sopenharmony_ci  }
5821cb0ef41Sopenharmony_ci
5831cb0ef41Sopenharmony_ci  // These methods do not perform access checks!
5841cb0ef41Sopenharmony_ci  template <AllocationSiteUpdateMode update_or_check =
5851cb0ef41Sopenharmony_ci                AllocationSiteUpdateMode::kUpdate>
5861cb0ef41Sopenharmony_ci  static bool UpdateAllocationSite(Handle<JSObject> object,
5871cb0ef41Sopenharmony_ci                                   ElementsKind to_kind);
5881cb0ef41Sopenharmony_ci
5891cb0ef41Sopenharmony_ci  // Lookup interceptors are used for handling properties controlled by host
5901cb0ef41Sopenharmony_ci  // objects.
5911cb0ef41Sopenharmony_ci  DECL_GETTER(HasNamedInterceptor, bool)
5921cb0ef41Sopenharmony_ci  DECL_GETTER(HasIndexedInterceptor, bool)
5931cb0ef41Sopenharmony_ci
5941cb0ef41Sopenharmony_ci  // Support functions for v8 api (needed for correct interceptor behavior).
5951cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> HasRealNamedProperty(
5961cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSObject> object, Handle<Name> name);
5971cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> HasRealElementProperty(
5981cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSObject> object, uint32_t index);
5991cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> HasRealNamedCallbackProperty(
6001cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSObject> object, Handle<Name> name);
6011cb0ef41Sopenharmony_ci
6021cb0ef41Sopenharmony_ci  // Get the header size for a JSObject.  Used to compute the index of
6031cb0ef41Sopenharmony_ci  // embedder fields as well as the number of embedder fields.
6041cb0ef41Sopenharmony_ci  // The |function_has_prototype_slot| parameter is needed only for
6051cb0ef41Sopenharmony_ci  // JSFunction objects.
6061cb0ef41Sopenharmony_ci  static V8_EXPORT_PRIVATE int GetHeaderSize(
6071cb0ef41Sopenharmony_ci      InstanceType instance_type, bool function_has_prototype_slot = false);
6081cb0ef41Sopenharmony_ci  static inline int GetHeaderSize(Map map);
6091cb0ef41Sopenharmony_ci
6101cb0ef41Sopenharmony_ci  static inline bool MayHaveEmbedderFields(Map map);
6111cb0ef41Sopenharmony_ci  inline bool MayHaveEmbedderFields() const;
6121cb0ef41Sopenharmony_ci
6131cb0ef41Sopenharmony_ci  static inline int GetEmbedderFieldsStartOffset(Map map);
6141cb0ef41Sopenharmony_ci  inline int GetEmbedderFieldsStartOffset();
6151cb0ef41Sopenharmony_ci
6161cb0ef41Sopenharmony_ci  static inline int GetEmbedderFieldCount(Map map);
6171cb0ef41Sopenharmony_ci  inline int GetEmbedderFieldCount() const;
6181cb0ef41Sopenharmony_ci  inline int GetEmbedderFieldOffset(int index);
6191cb0ef41Sopenharmony_ci  inline Object GetEmbedderField(int index);
6201cb0ef41Sopenharmony_ci  inline void SetEmbedderField(int index, Object value);
6211cb0ef41Sopenharmony_ci  inline void SetEmbedderField(int index, Smi value);
6221cb0ef41Sopenharmony_ci
6231cb0ef41Sopenharmony_ci  // Returns true if this object is an Api object which can, if unmodified, be
6241cb0ef41Sopenharmony_ci  // dropped during minor GC because the embedder can recreate it again later.
6251cb0ef41Sopenharmony_ci  inline bool IsDroppableApiObject() const;
6261cb0ef41Sopenharmony_ci
6271cb0ef41Sopenharmony_ci  // Returns a new map with all transitions dropped from the object's current
6281cb0ef41Sopenharmony_ci  // map and the ElementsKind set.
6291cb0ef41Sopenharmony_ci  static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
6301cb0ef41Sopenharmony_ci                                              ElementsKind to_kind);
6311cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static void TransitionElementsKind(Handle<JSObject> object,
6321cb0ef41Sopenharmony_ci                                                       ElementsKind to_kind);
6331cb0ef41Sopenharmony_ci
6341cb0ef41Sopenharmony_ci  // Always use this to migrate an object to a new map.
6351cb0ef41Sopenharmony_ci  // |expected_additional_properties| is only used for fast-to-slow transitions
6361cb0ef41Sopenharmony_ci  // and ignored otherwise.
6371cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static void MigrateToMap(
6381cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSObject> object, Handle<Map> new_map,
6391cb0ef41Sopenharmony_ci      int expected_additional_properties = 0);
6401cb0ef41Sopenharmony_ci
6411cb0ef41Sopenharmony_ci  // Forces a prototype without any of the checks that the regular SetPrototype
6421cb0ef41Sopenharmony_ci  // would do.
6431cb0ef41Sopenharmony_ci  static void ForceSetPrototype(Isolate* isolate, Handle<JSObject> object,
6441cb0ef41Sopenharmony_ci                                Handle<HeapObject> proto);
6451cb0ef41Sopenharmony_ci
6461cb0ef41Sopenharmony_ci  // Convert the object to use the canonical dictionary
6471cb0ef41Sopenharmony_ci  // representation. If the object is expected to have additional properties
6481cb0ef41Sopenharmony_ci  // added this number can be indicated to have the backing store allocated to
6491cb0ef41Sopenharmony_ci  // an initial capacity for holding these properties.
6501cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static void NormalizeProperties(
6511cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSObject> object, PropertyNormalizationMode mode,
6521cb0ef41Sopenharmony_ci      int expected_additional_properties, const char* reason);
6531cb0ef41Sopenharmony_ci
6541cb0ef41Sopenharmony_ci  // Convert and update the elements backing store to be a
6551cb0ef41Sopenharmony_ci  // NumberDictionary dictionary.  Returns the backing after conversion.
6561cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static Handle<NumberDictionary> NormalizeElements(
6571cb0ef41Sopenharmony_ci      Handle<JSObject> object);
6581cb0ef41Sopenharmony_ci
6591cb0ef41Sopenharmony_ci  void RequireSlowElements(NumberDictionary dictionary);
6601cb0ef41Sopenharmony_ci
6611cb0ef41Sopenharmony_ci  // Transform slow named properties to fast variants.
6621cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE static void MigrateSlowToFast(Handle<JSObject> object,
6631cb0ef41Sopenharmony_ci                                                  int unused_property_fields,
6641cb0ef41Sopenharmony_ci                                                  const char* reason);
6651cb0ef41Sopenharmony_ci
6661cb0ef41Sopenharmony_ci  // Access property in dictionary mode object at the given dictionary index.
6671cb0ef41Sopenharmony_ci  static Handle<Object> DictionaryPropertyAt(Isolate* isolate,
6681cb0ef41Sopenharmony_ci                                             Handle<JSObject> object,
6691cb0ef41Sopenharmony_ci                                             InternalIndex dict_index);
6701cb0ef41Sopenharmony_ci  // Same as above, but it will return {} if we would be reading out of the
6711cb0ef41Sopenharmony_ci  // bounds of the object or if the dictionary is pending allocation. Use this
6721cb0ef41Sopenharmony_ci  // version for concurrent access.
6731cb0ef41Sopenharmony_ci  static base::Optional<Object> DictionaryPropertyAt(Handle<JSObject> object,
6741cb0ef41Sopenharmony_ci                                                     InternalIndex dict_index,
6751cb0ef41Sopenharmony_ci                                                     Heap* heap);
6761cb0ef41Sopenharmony_ci
6771cb0ef41Sopenharmony_ci  // Access fast-case object properties at index.
6781cb0ef41Sopenharmony_ci  static Handle<Object> FastPropertyAt(Isolate* isolate,
6791cb0ef41Sopenharmony_ci                                       Handle<JSObject> object,
6801cb0ef41Sopenharmony_ci                                       Representation representation,
6811cb0ef41Sopenharmony_ci                                       FieldIndex index);
6821cb0ef41Sopenharmony_ci  static Handle<Object> FastPropertyAt(Isolate* isolate,
6831cb0ef41Sopenharmony_ci                                       Handle<JSObject> object,
6841cb0ef41Sopenharmony_ci                                       Representation representation,
6851cb0ef41Sopenharmony_ci                                       FieldIndex index, SeqCstAccessTag tag);
6861cb0ef41Sopenharmony_ci  inline Object RawFastPropertyAt(FieldIndex index) const;
6871cb0ef41Sopenharmony_ci  inline Object RawFastPropertyAt(PtrComprCageBase cage_base,
6881cb0ef41Sopenharmony_ci                                  FieldIndex index) const;
6891cb0ef41Sopenharmony_ci  inline Object RawFastPropertyAt(FieldIndex index, SeqCstAccessTag tag) const;
6901cb0ef41Sopenharmony_ci  inline Object RawFastPropertyAt(PtrComprCageBase cage_base, FieldIndex index,
6911cb0ef41Sopenharmony_ci                                  SeqCstAccessTag tag) const;
6921cb0ef41Sopenharmony_ci
6931cb0ef41Sopenharmony_ci  // See comment in the body of the method to understand the conditions
6941cb0ef41Sopenharmony_ci  // in which this method is meant to be used, and what guarantees it
6951cb0ef41Sopenharmony_ci  // provides against invalid reads from another thread during object
6961cb0ef41Sopenharmony_ci  // mutation.
6971cb0ef41Sopenharmony_ci  inline base::Optional<Object> RawInobjectPropertyAt(
6981cb0ef41Sopenharmony_ci      PtrComprCageBase cage_base, Map original_map, FieldIndex index) const;
6991cb0ef41Sopenharmony_ci
7001cb0ef41Sopenharmony_ci  inline void FastPropertyAtPut(FieldIndex index, Object value,
7011cb0ef41Sopenharmony_ci                                WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
7021cb0ef41Sopenharmony_ci  inline void FastPropertyAtPut(FieldIndex index, Object value,
7031cb0ef41Sopenharmony_ci                                SeqCstAccessTag tag);
7041cb0ef41Sopenharmony_ci  inline void RawFastInobjectPropertyAtPut(
7051cb0ef41Sopenharmony_ci      FieldIndex index, Object value,
7061cb0ef41Sopenharmony_ci      WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
7071cb0ef41Sopenharmony_ci  inline void RawFastInobjectPropertyAtPut(FieldIndex index, Object value,
7081cb0ef41Sopenharmony_ci                                           SeqCstAccessTag tag);
7091cb0ef41Sopenharmony_ci  inline void WriteToField(InternalIndex descriptor, PropertyDetails details,
7101cb0ef41Sopenharmony_ci                           Object value);
7111cb0ef41Sopenharmony_ci
7121cb0ef41Sopenharmony_ci  inline Object RawFastPropertyAtSwap(FieldIndex index, Object value,
7131cb0ef41Sopenharmony_ci                                      SeqCstAccessTag tag);
7141cb0ef41Sopenharmony_ci  inline Object RawFastPropertyAtSwap(PtrComprCageBase cage_base,
7151cb0ef41Sopenharmony_ci                                      FieldIndex index, Object value,
7161cb0ef41Sopenharmony_ci                                      SeqCstAccessTag tag);
7171cb0ef41Sopenharmony_ci
7181cb0ef41Sopenharmony_ci  // Access to in object properties.
7191cb0ef41Sopenharmony_ci  inline int GetInObjectPropertyOffset(int index);
7201cb0ef41Sopenharmony_ci  inline Object InObjectPropertyAt(int index);
7211cb0ef41Sopenharmony_ci  inline Object InObjectPropertyAtPut(
7221cb0ef41Sopenharmony_ci      int index, Object value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
7231cb0ef41Sopenharmony_ci
7241cb0ef41Sopenharmony_ci  // Set the object's prototype (only JSReceiver and null are allowed values).
7251cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> SetPrototype(
7261cb0ef41Sopenharmony_ci      Isolate* isolate, Handle<JSObject> object, Handle<Object> value,
7271cb0ef41Sopenharmony_ci      bool from_javascript, ShouldThrow should_throw);
7281cb0ef41Sopenharmony_ci
7291cb0ef41Sopenharmony_ci  // Makes the object prototype immutable
7301cb0ef41Sopenharmony_ci  // Never called from JavaScript
7311cb0ef41Sopenharmony_ci  static void SetImmutableProto(Handle<JSObject> object);
7321cb0ef41Sopenharmony_ci
7331cb0ef41Sopenharmony_ci  // Initializes the body starting at |start_offset|. It is responsibility of
7341cb0ef41Sopenharmony_ci  // the caller to initialize object header. Fill the pre-allocated fields with
7351cb0ef41Sopenharmony_ci  // undefined_value and the rest with filler_map.
7361cb0ef41Sopenharmony_ci  // Note: this call does not update write barrier, the caller is responsible
7371cb0ef41Sopenharmony_ci  // to ensure that |filler_map| can be collected without WB here.
7381cb0ef41Sopenharmony_ci  inline void InitializeBody(Map map, int start_offset,
7391cb0ef41Sopenharmony_ci                             bool is_slack_tracking_in_progress,
7401cb0ef41Sopenharmony_ci                             MapWord filler_map, Object undefined_value);
7411cb0ef41Sopenharmony_ci
7421cb0ef41Sopenharmony_ci  // Check whether this object references another object
7431cb0ef41Sopenharmony_ci  bool ReferencesObject(Object obj);
7441cb0ef41Sopenharmony_ci
7451cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> TestIntegrityLevel(
7461cb0ef41Sopenharmony_ci      Handle<JSObject> object, IntegrityLevel lvl);
7471cb0ef41Sopenharmony_ci
7481cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> PreventExtensions(
7491cb0ef41Sopenharmony_ci      Handle<JSObject> object, ShouldThrow should_throw);
7501cb0ef41Sopenharmony_ci
7511cb0ef41Sopenharmony_ci  static bool IsExtensible(Handle<JSObject> object);
7521cb0ef41Sopenharmony_ci
7531cb0ef41Sopenharmony_ci  static MaybeHandle<Object> ReadFromOptionsBag(Handle<Object> options,
7541cb0ef41Sopenharmony_ci                                                Handle<String> option_name,
7551cb0ef41Sopenharmony_ci                                                Isolate* isolate);
7561cb0ef41Sopenharmony_ci
7571cb0ef41Sopenharmony_ci  // Dispatched behavior.
7581cb0ef41Sopenharmony_ci  void JSObjectShortPrint(StringStream* accumulator);
7591cb0ef41Sopenharmony_ci  DECL_PRINTER(JSObject)
7601cb0ef41Sopenharmony_ci  DECL_VERIFIER(JSObject)
7611cb0ef41Sopenharmony_ci#ifdef OBJECT_PRINT
7621cb0ef41Sopenharmony_ci  bool PrintProperties(std::ostream& os);
7631cb0ef41Sopenharmony_ci  void PrintElements(std::ostream& os);
7641cb0ef41Sopenharmony_ci#endif
7651cb0ef41Sopenharmony_ci#if defined(DEBUG) || defined(OBJECT_PRINT)
7661cb0ef41Sopenharmony_ci  void PrintTransitions(std::ostream& os);
7671cb0ef41Sopenharmony_ci#endif
7681cb0ef41Sopenharmony_ci
7691cb0ef41Sopenharmony_ci  static void PrintElementsTransition(FILE* file, Handle<JSObject> object,
7701cb0ef41Sopenharmony_ci                                      ElementsKind from_kind,
7711cb0ef41Sopenharmony_ci                                      Handle<FixedArrayBase> from_elements,
7721cb0ef41Sopenharmony_ci                                      ElementsKind to_kind,
7731cb0ef41Sopenharmony_ci                                      Handle<FixedArrayBase> to_elements);
7741cb0ef41Sopenharmony_ci
7751cb0ef41Sopenharmony_ci  void PrintInstanceMigration(FILE* file, Map original_map, Map new_map);
7761cb0ef41Sopenharmony_ci
7771cb0ef41Sopenharmony_ci#ifdef DEBUG
7781cb0ef41Sopenharmony_ci  // Structure for collecting spill information about JSObjects.
7791cb0ef41Sopenharmony_ci  class SpillInformation {
7801cb0ef41Sopenharmony_ci   public:
7811cb0ef41Sopenharmony_ci    void Clear();
7821cb0ef41Sopenharmony_ci    void Print();
7831cb0ef41Sopenharmony_ci    int number_of_objects_;
7841cb0ef41Sopenharmony_ci    int number_of_objects_with_fast_properties_;
7851cb0ef41Sopenharmony_ci    int number_of_objects_with_fast_elements_;
7861cb0ef41Sopenharmony_ci    int number_of_fast_used_fields_;
7871cb0ef41Sopenharmony_ci    int number_of_fast_unused_fields_;
7881cb0ef41Sopenharmony_ci    int number_of_slow_used_properties_;
7891cb0ef41Sopenharmony_ci    int number_of_slow_unused_properties_;
7901cb0ef41Sopenharmony_ci    int number_of_fast_used_elements_;
7911cb0ef41Sopenharmony_ci    int number_of_fast_unused_elements_;
7921cb0ef41Sopenharmony_ci    int number_of_slow_used_elements_;
7931cb0ef41Sopenharmony_ci    int number_of_slow_unused_elements_;
7941cb0ef41Sopenharmony_ci  };
7951cb0ef41Sopenharmony_ci
7961cb0ef41Sopenharmony_ci  void IncrementSpillStatistics(Isolate* isolate, SpillInformation* info);
7971cb0ef41Sopenharmony_ci#endif
7981cb0ef41Sopenharmony_ci
7991cb0ef41Sopenharmony_ci#ifdef VERIFY_HEAP
8001cb0ef41Sopenharmony_ci  // If a GC was caused while constructing this object, the elements pointer
8011cb0ef41Sopenharmony_ci  // may point to a one pointer filler map. The object won't be rooted, but
8021cb0ef41Sopenharmony_ci  // our heap verification code could stumble across it.
8031cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE bool ElementsAreSafeToExamine(
8041cb0ef41Sopenharmony_ci      PtrComprCageBase cage_base) const;
8051cb0ef41Sopenharmony_ci#endif
8061cb0ef41Sopenharmony_ci
8071cb0ef41Sopenharmony_ci  Object SlowReverseLookup(Object value);
8081cb0ef41Sopenharmony_ci
8091cb0ef41Sopenharmony_ci  // Maximal number of elements (numbered 0 .. kMaxElementCount - 1).
8101cb0ef41Sopenharmony_ci  // Also maximal value of JSArray's length property.
8111cb0ef41Sopenharmony_ci  static constexpr uint32_t kMaxElementCount = kMaxUInt32;
8121cb0ef41Sopenharmony_ci  static constexpr uint32_t kMaxElementIndex = kMaxElementCount - 1;
8131cb0ef41Sopenharmony_ci
8141cb0ef41Sopenharmony_ci  // Constants for heuristics controlling conversion of fast elements
8151cb0ef41Sopenharmony_ci  // to slow elements.
8161cb0ef41Sopenharmony_ci
8171cb0ef41Sopenharmony_ci  // Maximal gap that can be introduced by adding an element beyond
8181cb0ef41Sopenharmony_ci  // the current elements length.
8191cb0ef41Sopenharmony_ci  static const uint32_t kMaxGap = 1024;
8201cb0ef41Sopenharmony_ci
8211cb0ef41Sopenharmony_ci  // Maximal length of fast elements array that won't be checked for
8221cb0ef41Sopenharmony_ci  // being dense enough on expansion.
8231cb0ef41Sopenharmony_ci  static const int kMaxUncheckedFastElementsLength = 5000;
8241cb0ef41Sopenharmony_ci
8251cb0ef41Sopenharmony_ci  // Same as above but for old arrays. This limit is more strict. We
8261cb0ef41Sopenharmony_ci  // don't want to be wasteful with long lived objects.
8271cb0ef41Sopenharmony_ci  static const int kMaxUncheckedOldFastElementsLength = 500;
8281cb0ef41Sopenharmony_ci
8291cb0ef41Sopenharmony_ci  // This constant applies only to the initial map of "global.Object" and
8301cb0ef41Sopenharmony_ci  // not to arbitrary other JSObject maps.
8311cb0ef41Sopenharmony_ci  static const int kInitialGlobalObjectUnusedPropertiesCount = 4;
8321cb0ef41Sopenharmony_ci
8331cb0ef41Sopenharmony_ci  static const int kMaxInstanceSize = 255 * kTaggedSize;
8341cb0ef41Sopenharmony_ci
8351cb0ef41Sopenharmony_ci  static const int kMapCacheSize = 128;
8361cb0ef41Sopenharmony_ci
8371cb0ef41Sopenharmony_ci  // When extending the backing storage for property values, we increase
8381cb0ef41Sopenharmony_ci  // its size by more than the 1 entry necessary, so sequentially adding fields
8391cb0ef41Sopenharmony_ci  // to the same object requires fewer allocations and copies.
8401cb0ef41Sopenharmony_ci  static const int kFieldsAdded = 3;
8411cb0ef41Sopenharmony_ci  STATIC_ASSERT(kMaxNumberOfDescriptors + kFieldsAdded <=
8421cb0ef41Sopenharmony_ci                PropertyArray::kMaxLength);
8431cb0ef41Sopenharmony_ci
8441cb0ef41Sopenharmony_ci  STATIC_ASSERT(kHeaderSize == Internals::kJSObjectHeaderSize);
8451cb0ef41Sopenharmony_ci  static const int kMaxInObjectProperties =
8461cb0ef41Sopenharmony_ci      (kMaxInstanceSize - kHeaderSize) >> kTaggedSizeLog2;
8471cb0ef41Sopenharmony_ci  STATIC_ASSERT(kMaxInObjectProperties <= kMaxNumberOfDescriptors);
8481cb0ef41Sopenharmony_ci
8491cb0ef41Sopenharmony_ci  static const int kMaxFirstInobjectPropertyOffset =
8501cb0ef41Sopenharmony_ci      (1 << kFirstInobjectPropertyOffsetBitCount) - 1;
8511cb0ef41Sopenharmony_ci  static const int kMaxEmbedderFields =
8521cb0ef41Sopenharmony_ci      (kMaxFirstInobjectPropertyOffset - kHeaderSize) / kEmbedderDataSlotSize;
8531cb0ef41Sopenharmony_ci  STATIC_ASSERT(kHeaderSize +
8541cb0ef41Sopenharmony_ci                    kMaxEmbedderFields * kEmbedderDataSlotSizeInTaggedSlots <=
8551cb0ef41Sopenharmony_ci                kMaxInstanceSize);
8561cb0ef41Sopenharmony_ci
8571cb0ef41Sopenharmony_ci  class BodyDescriptor;
8581cb0ef41Sopenharmony_ci
8591cb0ef41Sopenharmony_ci  class FastBodyDescriptor;
8601cb0ef41Sopenharmony_ci
8611cb0ef41Sopenharmony_ci  // Gets the number of currently used elements.
8621cb0ef41Sopenharmony_ci  int GetFastElementsUsage();
8631cb0ef41Sopenharmony_ci
8641cb0ef41Sopenharmony_ci  static bool AllCanRead(LookupIterator* it);
8651cb0ef41Sopenharmony_ci  static bool AllCanWrite(LookupIterator* it);
8661cb0ef41Sopenharmony_ci
8671cb0ef41Sopenharmony_ci  template <typename Dictionary>
8681cb0ef41Sopenharmony_ci  static void ApplyAttributesToDictionary(Isolate* isolate, ReadOnlyRoots roots,
8691cb0ef41Sopenharmony_ci                                          Handle<Dictionary> dictionary,
8701cb0ef41Sopenharmony_ci                                          const PropertyAttributes attributes);
8711cb0ef41Sopenharmony_ci
8721cb0ef41Sopenharmony_ci private:
8731cb0ef41Sopenharmony_ci  friend class JSReceiver;
8741cb0ef41Sopenharmony_ci  friend class Object;
8751cb0ef41Sopenharmony_ci
8761cb0ef41Sopenharmony_ci  // Used from Object::GetProperty().
8771cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
8781cb0ef41Sopenharmony_ci  GetPropertyWithFailedAccessCheck(LookupIterator* it);
8791cb0ef41Sopenharmony_ci
8801cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyWithFailedAccessCheck(
8811cb0ef41Sopenharmony_ci      LookupIterator* it, Handle<Object> value,
8821cb0ef41Sopenharmony_ci      Maybe<ShouldThrow> should_throw);
8831cb0ef41Sopenharmony_ci
8841cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> DeletePropertyWithInterceptor(
8851cb0ef41Sopenharmony_ci      LookupIterator* it, ShouldThrow should_throw);
8861cb0ef41Sopenharmony_ci
8871cb0ef41Sopenharmony_ci  bool ReferencesObjectFromElements(FixedArray elements, ElementsKind kind,
8881cb0ef41Sopenharmony_ci                                    Object object);
8891cb0ef41Sopenharmony_ci
8901cb0ef41Sopenharmony_ci  // Helper for fast versions of preventExtensions, seal, and freeze.
8911cb0ef41Sopenharmony_ci  // attrs is one of NONE, SEALED, or FROZEN (depending on the operation).
8921cb0ef41Sopenharmony_ci  template <PropertyAttributes attrs>
8931cb0ef41Sopenharmony_ci  V8_WARN_UNUSED_RESULT static Maybe<bool> PreventExtensionsWithTransition(
8941cb0ef41Sopenharmony_ci      Handle<JSObject> object, ShouldThrow should_throw);
8951cb0ef41Sopenharmony_ci
8961cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSObject)
8971cb0ef41Sopenharmony_ci};
8981cb0ef41Sopenharmony_ci
8991cb0ef41Sopenharmony_ci// A JSObject created through the public api which wraps an external pointer.
9001cb0ef41Sopenharmony_ci// See v8::External.
9011cb0ef41Sopenharmony_ciclass JSExternalObject
9021cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSExternalObject<JSExternalObject, JSObject> {
9031cb0ef41Sopenharmony_ci public:
9041cb0ef41Sopenharmony_ci  inline void AllocateExternalPointerEntries(Isolate* isolate);
9051cb0ef41Sopenharmony_ci
9061cb0ef41Sopenharmony_ci  // [value]: field containing the pointer value.
9071cb0ef41Sopenharmony_ci  DECL_GETTER(value, void*)
9081cb0ef41Sopenharmony_ci
9091cb0ef41Sopenharmony_ci  inline void set_value(Isolate* isolate, void* value);
9101cb0ef41Sopenharmony_ci
9111cb0ef41Sopenharmony_ci  static constexpr int kEndOfTaggedFieldsOffset = JSObject::kHeaderSize;
9121cb0ef41Sopenharmony_ci
9131cb0ef41Sopenharmony_ci  class BodyDescriptor;
9141cb0ef41Sopenharmony_ci
9151cb0ef41Sopenharmony_ci private:
9161cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSExternalObject)
9171cb0ef41Sopenharmony_ci};
9181cb0ef41Sopenharmony_ci
9191cb0ef41Sopenharmony_ci// An abstract superclass for JSObjects that may contain EmbedderDataSlots.
9201cb0ef41Sopenharmony_ciclass JSObjectWithEmbedderSlots
9211cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSObjectWithEmbedderSlots<JSObjectWithEmbedderSlots,
9221cb0ef41Sopenharmony_ci                                                      JSObject> {
9231cb0ef41Sopenharmony_ci public:
9241cb0ef41Sopenharmony_ci  STATIC_ASSERT(kHeaderSize == JSObject::kHeaderSize);
9251cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSObjectWithEmbedderSlots)
9261cb0ef41Sopenharmony_ci};
9271cb0ef41Sopenharmony_ci
9281cb0ef41Sopenharmony_ci// An abstract superclass for JSObjects that may have elements while having an
9291cb0ef41Sopenharmony_ci// empty fixed array as elements backing store. It doesn't carry any
9301cb0ef41Sopenharmony_ci// functionality but allows function classes to be identified in the type
9311cb0ef41Sopenharmony_ci// system.
9321cb0ef41Sopenharmony_ciclass JSCustomElementsObject
9331cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSCustomElementsObject<JSCustomElementsObject,
9341cb0ef41Sopenharmony_ci                                                   JSObject> {
9351cb0ef41Sopenharmony_ci public:
9361cb0ef41Sopenharmony_ci  STATIC_ASSERT(kHeaderSize == JSObject::kHeaderSize);
9371cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSCustomElementsObject)
9381cb0ef41Sopenharmony_ci};
9391cb0ef41Sopenharmony_ci
9401cb0ef41Sopenharmony_ci// An abstract superclass for JSObjects that require non-standard element
9411cb0ef41Sopenharmony_ci// access. It doesn't carry any functionality but allows function classes to be
9421cb0ef41Sopenharmony_ci// identified in the type system.
9431cb0ef41Sopenharmony_ci// These may also contain EmbedderDataSlots, but can't currently inherit from
9441cb0ef41Sopenharmony_ci// JSObjectWithEmbedderSlots due to instance_type constraints.
9451cb0ef41Sopenharmony_ciclass JSSpecialObject
9461cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSSpecialObject<JSSpecialObject,
9471cb0ef41Sopenharmony_ci                                            JSCustomElementsObject> {
9481cb0ef41Sopenharmony_ci public:
9491cb0ef41Sopenharmony_ci  STATIC_ASSERT(kHeaderSize == JSObject::kHeaderSize);
9501cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSSpecialObject)
9511cb0ef41Sopenharmony_ci};
9521cb0ef41Sopenharmony_ci
9531cb0ef41Sopenharmony_ci// JSAccessorPropertyDescriptor is just a JSObject with a specific initial
9541cb0ef41Sopenharmony_ci// map. This initial map adds in-object properties for "get", "set",
9551cb0ef41Sopenharmony_ci// "enumerable" and "configurable" properties, as assigned by the
9561cb0ef41Sopenharmony_ci// FromPropertyDescriptor function for regular accessor properties.
9571cb0ef41Sopenharmony_ciclass JSAccessorPropertyDescriptor : public JSObject {
9581cb0ef41Sopenharmony_ci public:
9591cb0ef41Sopenharmony_ci  // Layout description.
9601cb0ef41Sopenharmony_ci#define JS_ACCESSOR_PROPERTY_DESCRIPTOR_FIELDS(V) \
9611cb0ef41Sopenharmony_ci  V(kGetOffset, kTaggedSize)                      \
9621cb0ef41Sopenharmony_ci  V(kSetOffset, kTaggedSize)                      \
9631cb0ef41Sopenharmony_ci  V(kEnumerableOffset, kTaggedSize)               \
9641cb0ef41Sopenharmony_ci  V(kConfigurableOffset, kTaggedSize)             \
9651cb0ef41Sopenharmony_ci  /* Total size. */                               \
9661cb0ef41Sopenharmony_ci  V(kSize, 0)
9671cb0ef41Sopenharmony_ci
9681cb0ef41Sopenharmony_ci  DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
9691cb0ef41Sopenharmony_ci                                JS_ACCESSOR_PROPERTY_DESCRIPTOR_FIELDS)
9701cb0ef41Sopenharmony_ci#undef JS_ACCESSOR_PROPERTY_DESCRIPTOR_FIELDS
9711cb0ef41Sopenharmony_ci
9721cb0ef41Sopenharmony_ci  // Indices of in-object properties.
9731cb0ef41Sopenharmony_ci  static const int kGetIndex = 0;
9741cb0ef41Sopenharmony_ci  static const int kSetIndex = 1;
9751cb0ef41Sopenharmony_ci  static const int kEnumerableIndex = 2;
9761cb0ef41Sopenharmony_ci  static const int kConfigurableIndex = 3;
9771cb0ef41Sopenharmony_ci
9781cb0ef41Sopenharmony_ci private:
9791cb0ef41Sopenharmony_ci  DISALLOW_IMPLICIT_CONSTRUCTORS(JSAccessorPropertyDescriptor);
9801cb0ef41Sopenharmony_ci};
9811cb0ef41Sopenharmony_ci
9821cb0ef41Sopenharmony_ci// JSDataPropertyDescriptor is just a JSObject with a specific initial map.
9831cb0ef41Sopenharmony_ci// This initial map adds in-object properties for "value", "writable",
9841cb0ef41Sopenharmony_ci// "enumerable" and "configurable" properties, as assigned by the
9851cb0ef41Sopenharmony_ci// FromPropertyDescriptor function for regular data properties.
9861cb0ef41Sopenharmony_ciclass JSDataPropertyDescriptor : public JSObject {
9871cb0ef41Sopenharmony_ci public:
9881cb0ef41Sopenharmony_ci  // Layout description.
9891cb0ef41Sopenharmony_ci#define JS_DATA_PROPERTY_DESCRIPTOR_FIELDS(V) \
9901cb0ef41Sopenharmony_ci  V(kValueOffset, kTaggedSize)                \
9911cb0ef41Sopenharmony_ci  V(kWritableOffset, kTaggedSize)             \
9921cb0ef41Sopenharmony_ci  V(kEnumerableOffset, kTaggedSize)           \
9931cb0ef41Sopenharmony_ci  V(kConfigurableOffset, kTaggedSize)         \
9941cb0ef41Sopenharmony_ci  /* Total size. */                           \
9951cb0ef41Sopenharmony_ci  V(kSize, 0)
9961cb0ef41Sopenharmony_ci
9971cb0ef41Sopenharmony_ci  DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
9981cb0ef41Sopenharmony_ci                                JS_DATA_PROPERTY_DESCRIPTOR_FIELDS)
9991cb0ef41Sopenharmony_ci#undef JS_DATA_PROPERTY_DESCRIPTOR_FIELDS
10001cb0ef41Sopenharmony_ci
10011cb0ef41Sopenharmony_ci  // Indices of in-object properties.
10021cb0ef41Sopenharmony_ci  static const int kValueIndex = 0;
10031cb0ef41Sopenharmony_ci  static const int kWritableIndex = 1;
10041cb0ef41Sopenharmony_ci  static const int kEnumerableIndex = 2;
10051cb0ef41Sopenharmony_ci  static const int kConfigurableIndex = 3;
10061cb0ef41Sopenharmony_ci
10071cb0ef41Sopenharmony_ci private:
10081cb0ef41Sopenharmony_ci  DISALLOW_IMPLICIT_CONSTRUCTORS(JSDataPropertyDescriptor);
10091cb0ef41Sopenharmony_ci};
10101cb0ef41Sopenharmony_ci
10111cb0ef41Sopenharmony_ci// JSIteratorResult is just a JSObject with a specific initial map.
10121cb0ef41Sopenharmony_ci// This initial map adds in-object properties for "done" and "value",
10131cb0ef41Sopenharmony_ci// as specified by ES6 section 25.1.1.3 The IteratorResult Interface.
10141cb0ef41Sopenharmony_ciclass JSIteratorResult : public JSObject {
10151cb0ef41Sopenharmony_ci public:
10161cb0ef41Sopenharmony_ci  DECL_ACCESSORS(value, Object)
10171cb0ef41Sopenharmony_ci
10181cb0ef41Sopenharmony_ci  DECL_ACCESSORS(done, Object)
10191cb0ef41Sopenharmony_ci
10201cb0ef41Sopenharmony_ci  // Layout description.
10211cb0ef41Sopenharmony_ci#define JS_ITERATOR_RESULT_FIELDS(V) \
10221cb0ef41Sopenharmony_ci  V(kValueOffset, kTaggedSize)       \
10231cb0ef41Sopenharmony_ci  V(kDoneOffset, kTaggedSize)        \
10241cb0ef41Sopenharmony_ci  /* Total size. */                  \
10251cb0ef41Sopenharmony_ci  V(kSize, 0)
10261cb0ef41Sopenharmony_ci
10271cb0ef41Sopenharmony_ci  DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
10281cb0ef41Sopenharmony_ci                                JS_ITERATOR_RESULT_FIELDS)
10291cb0ef41Sopenharmony_ci#undef JS_ITERATOR_RESULT_FIELDS
10301cb0ef41Sopenharmony_ci
10311cb0ef41Sopenharmony_ci  // Indices of in-object properties.
10321cb0ef41Sopenharmony_ci  static const int kValueIndex = 0;
10331cb0ef41Sopenharmony_ci  static const int kDoneIndex = 1;
10341cb0ef41Sopenharmony_ci
10351cb0ef41Sopenharmony_ci  DECL_CAST(JSIteratorResult)
10361cb0ef41Sopenharmony_ci
10371cb0ef41Sopenharmony_ci  OBJECT_CONSTRUCTORS(JSIteratorResult, JSObject);
10381cb0ef41Sopenharmony_ci};
10391cb0ef41Sopenharmony_ci
10401cb0ef41Sopenharmony_ci// JSGlobalProxy's prototype must be a JSGlobalObject or null,
10411cb0ef41Sopenharmony_ci// and the prototype is hidden. JSGlobalProxy always delegates
10421cb0ef41Sopenharmony_ci// property accesses to its prototype if the prototype is not null.
10431cb0ef41Sopenharmony_ci//
10441cb0ef41Sopenharmony_ci// A JSGlobalProxy can be reinitialized which will preserve its identity.
10451cb0ef41Sopenharmony_ci//
10461cb0ef41Sopenharmony_ci// Accessing a JSGlobalProxy requires security check.
10471cb0ef41Sopenharmony_ci
10481cb0ef41Sopenharmony_ciclass JSGlobalProxy
10491cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSGlobalProxy<JSGlobalProxy, JSSpecialObject> {
10501cb0ef41Sopenharmony_ci public:
10511cb0ef41Sopenharmony_ci  inline bool IsDetachedFrom(JSGlobalObject global) const;
10521cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE bool IsDetached() const;
10531cb0ef41Sopenharmony_ci
10541cb0ef41Sopenharmony_ci  static int SizeWithEmbedderFields(int embedder_field_count);
10551cb0ef41Sopenharmony_ci
10561cb0ef41Sopenharmony_ci  // Dispatched behavior.
10571cb0ef41Sopenharmony_ci  DECL_PRINTER(JSGlobalProxy)
10581cb0ef41Sopenharmony_ci  DECL_VERIFIER(JSGlobalProxy)
10591cb0ef41Sopenharmony_ci
10601cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSGlobalProxy)
10611cb0ef41Sopenharmony_ci};
10621cb0ef41Sopenharmony_ci
10631cb0ef41Sopenharmony_ci// JavaScript global object.
10641cb0ef41Sopenharmony_ciclass JSGlobalObject
10651cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSGlobalObject<JSGlobalObject, JSSpecialObject> {
10661cb0ef41Sopenharmony_ci public:
10671cb0ef41Sopenharmony_ci  DECL_RELEASE_ACQUIRE_ACCESSORS(global_dictionary, GlobalDictionary)
10681cb0ef41Sopenharmony_ci
10691cb0ef41Sopenharmony_ci  static void InvalidatePropertyCell(Handle<JSGlobalObject> object,
10701cb0ef41Sopenharmony_ci                                     Handle<Name> name);
10711cb0ef41Sopenharmony_ci
10721cb0ef41Sopenharmony_ci  inline bool IsDetached();
10731cb0ef41Sopenharmony_ci
10741cb0ef41Sopenharmony_ci  // May be called by the concurrent GC when the global object is not
10751cb0ef41Sopenharmony_ci  // fully initialized.
10761cb0ef41Sopenharmony_ci  DECL_GETTER(native_context_unchecked, Object)
10771cb0ef41Sopenharmony_ci
10781cb0ef41Sopenharmony_ci  // Dispatched behavior.
10791cb0ef41Sopenharmony_ci  DECL_PRINTER(JSGlobalObject)
10801cb0ef41Sopenharmony_ci  DECL_VERIFIER(JSGlobalObject)
10811cb0ef41Sopenharmony_ci
10821cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSGlobalObject)
10831cb0ef41Sopenharmony_ci};
10841cb0ef41Sopenharmony_ci
10851cb0ef41Sopenharmony_ci// Representation for JS Wrapper objects, String, Number, Boolean, etc.
10861cb0ef41Sopenharmony_ciclass JSPrimitiveWrapper
10871cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSPrimitiveWrapper<JSPrimitiveWrapper,
10881cb0ef41Sopenharmony_ci                                               JSCustomElementsObject> {
10891cb0ef41Sopenharmony_ci public:
10901cb0ef41Sopenharmony_ci  // Dispatched behavior.
10911cb0ef41Sopenharmony_ci  DECL_PRINTER(JSPrimitiveWrapper)
10921cb0ef41Sopenharmony_ci
10931cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSPrimitiveWrapper)
10941cb0ef41Sopenharmony_ci};
10951cb0ef41Sopenharmony_ci
10961cb0ef41Sopenharmony_ciclass DateCache;
10971cb0ef41Sopenharmony_ci
10981cb0ef41Sopenharmony_ci// Representation for JS date objects.
10991cb0ef41Sopenharmony_ciclass JSDate : public TorqueGeneratedJSDate<JSDate, JSObject> {
11001cb0ef41Sopenharmony_ci public:
11011cb0ef41Sopenharmony_ci  static V8_WARN_UNUSED_RESULT MaybeHandle<JSDate> New(
11021cb0ef41Sopenharmony_ci      Handle<JSFunction> constructor, Handle<JSReceiver> new_target, double tv);
11031cb0ef41Sopenharmony_ci
11041cb0ef41Sopenharmony_ci  // Returns the time value (UTC) identifying the current time.
11051cb0ef41Sopenharmony_ci  static double CurrentTimeValue(Isolate* isolate);
11061cb0ef41Sopenharmony_ci
11071cb0ef41Sopenharmony_ci  // Returns the date field with the specified index.
11081cb0ef41Sopenharmony_ci  // See FieldIndex for the list of date fields.
11091cb0ef41Sopenharmony_ci  // Arguments and result are raw Address values because this is called
11101cb0ef41Sopenharmony_ci  // via ExternalReference.
11111cb0ef41Sopenharmony_ci  // {raw_date} is a tagged Object pointer.
11121cb0ef41Sopenharmony_ci  // {smi_index} is a tagged Smi.
11131cb0ef41Sopenharmony_ci  // The return value is a tagged Object pointer.
11141cb0ef41Sopenharmony_ci  static Address GetField(Isolate* isolate, Address raw_date,
11151cb0ef41Sopenharmony_ci                          Address smi_index);
11161cb0ef41Sopenharmony_ci
11171cb0ef41Sopenharmony_ci  static Handle<Object> SetValue(Handle<JSDate> date, double v);
11181cb0ef41Sopenharmony_ci
11191cb0ef41Sopenharmony_ci  void SetValue(Object value, bool is_value_nan);
11201cb0ef41Sopenharmony_ci
11211cb0ef41Sopenharmony_ci  // Dispatched behavior.
11221cb0ef41Sopenharmony_ci  DECL_PRINTER(JSDate)
11231cb0ef41Sopenharmony_ci  DECL_VERIFIER(JSDate)
11241cb0ef41Sopenharmony_ci
11251cb0ef41Sopenharmony_ci  // The order is important. It must be kept in sync with date macros
11261cb0ef41Sopenharmony_ci  // in macros.py.
11271cb0ef41Sopenharmony_ci  enum FieldIndex {
11281cb0ef41Sopenharmony_ci    kDateValue,
11291cb0ef41Sopenharmony_ci    kYear,
11301cb0ef41Sopenharmony_ci    kMonth,
11311cb0ef41Sopenharmony_ci    kDay,
11321cb0ef41Sopenharmony_ci    kWeekday,
11331cb0ef41Sopenharmony_ci    kHour,
11341cb0ef41Sopenharmony_ci    kMinute,
11351cb0ef41Sopenharmony_ci    kSecond,
11361cb0ef41Sopenharmony_ci    kFirstUncachedField,
11371cb0ef41Sopenharmony_ci    kMillisecond = kFirstUncachedField,
11381cb0ef41Sopenharmony_ci    kDays,
11391cb0ef41Sopenharmony_ci    kTimeInDay,
11401cb0ef41Sopenharmony_ci    kFirstUTCField,
11411cb0ef41Sopenharmony_ci    kYearUTC = kFirstUTCField,
11421cb0ef41Sopenharmony_ci    kMonthUTC,
11431cb0ef41Sopenharmony_ci    kDayUTC,
11441cb0ef41Sopenharmony_ci    kWeekdayUTC,
11451cb0ef41Sopenharmony_ci    kHourUTC,
11461cb0ef41Sopenharmony_ci    kMinuteUTC,
11471cb0ef41Sopenharmony_ci    kSecondUTC,
11481cb0ef41Sopenharmony_ci    kMillisecondUTC,
11491cb0ef41Sopenharmony_ci    kDaysUTC,
11501cb0ef41Sopenharmony_ci    kTimeInDayUTC,
11511cb0ef41Sopenharmony_ci    kTimezoneOffset
11521cb0ef41Sopenharmony_ci  };
11531cb0ef41Sopenharmony_ci
11541cb0ef41Sopenharmony_ci private:
11551cb0ef41Sopenharmony_ci  Object DoGetField(Isolate* isolate, FieldIndex index);
11561cb0ef41Sopenharmony_ci  Object GetUTCField(FieldIndex index, double value, DateCache* date_cache);
11571cb0ef41Sopenharmony_ci
11581cb0ef41Sopenharmony_ci  // Computes and caches the cacheable fields of the date.
11591cb0ef41Sopenharmony_ci  inline void SetCachedFields(int64_t local_time_ms, DateCache* date_cache);
11601cb0ef41Sopenharmony_ci
11611cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSDate)
11621cb0ef41Sopenharmony_ci};
11631cb0ef41Sopenharmony_ci
11641cb0ef41Sopenharmony_ci// Representation of message objects used for error reporting through
11651cb0ef41Sopenharmony_ci// the API. The messages are formatted in JavaScript so this object is
11661cb0ef41Sopenharmony_ci// a real JavaScript object. The information used for formatting the
11671cb0ef41Sopenharmony_ci// error messages are not directly accessible from JavaScript to
11681cb0ef41Sopenharmony_ci// prevent leaking information to user code called during error
11691cb0ef41Sopenharmony_ci// formatting.
11701cb0ef41Sopenharmony_ciclass JSMessageObject
11711cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSMessageObject<JSMessageObject, JSObject> {
11721cb0ef41Sopenharmony_ci public:
11731cb0ef41Sopenharmony_ci  // [type]: the type of error message.
11741cb0ef41Sopenharmony_ci  inline MessageTemplate type() const;
11751cb0ef41Sopenharmony_ci  inline void set_type(MessageTemplate value);
11761cb0ef41Sopenharmony_ci
11771cb0ef41Sopenharmony_ci  // Initializes the source positions in the object if possible. Does nothing if
11781cb0ef41Sopenharmony_ci  // called more than once. If called when stack space is exhausted, then the
11791cb0ef41Sopenharmony_ci  // source positions will be not be set and calling it again when there is more
11801cb0ef41Sopenharmony_ci  // stack space will not have any effect.
11811cb0ef41Sopenharmony_ci  static void EnsureSourcePositionsAvailable(Isolate* isolate,
11821cb0ef41Sopenharmony_ci                                             Handle<JSMessageObject> message);
11831cb0ef41Sopenharmony_ci
11841cb0ef41Sopenharmony_ci  // Gets the start and end positions for the message.
11851cb0ef41Sopenharmony_ci  // EnsureSourcePositionsAvailable must have been called before calling these.
11861cb0ef41Sopenharmony_ci  inline int GetStartPosition() const;
11871cb0ef41Sopenharmony_ci  inline int GetEndPosition() const;
11881cb0ef41Sopenharmony_ci
11891cb0ef41Sopenharmony_ci  // Returns the line number for the error message (1-based), or
11901cb0ef41Sopenharmony_ci  // Message::kNoLineNumberInfo if the line cannot be determined.
11911cb0ef41Sopenharmony_ci  // EnsureSourcePositionsAvailable must have been called before calling this.
11921cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE int GetLineNumber() const;
11931cb0ef41Sopenharmony_ci
11941cb0ef41Sopenharmony_ci  // Returns the offset of the given position within the containing line.
11951cb0ef41Sopenharmony_ci  // EnsureSourcePositionsAvailable must have been called before calling this.
11961cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE int GetColumnNumber() const;
11971cb0ef41Sopenharmony_ci
11981cb0ef41Sopenharmony_ci  // Returns the source code
11991cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE String GetSource() const;
12001cb0ef41Sopenharmony_ci
12011cb0ef41Sopenharmony_ci  // Returns the source code line containing the given source
12021cb0ef41Sopenharmony_ci  // position, or the empty string if the position is invalid.
12031cb0ef41Sopenharmony_ci  // EnsureSourcePositionsAvailable must have been called before calling this.
12041cb0ef41Sopenharmony_ci  Handle<String> GetSourceLine() const;
12051cb0ef41Sopenharmony_ci
12061cb0ef41Sopenharmony_ci  DECL_INT_ACCESSORS(error_level)
12071cb0ef41Sopenharmony_ci
12081cb0ef41Sopenharmony_ci  // Dispatched behavior.
12091cb0ef41Sopenharmony_ci  DECL_PRINTER(JSMessageObject)
12101cb0ef41Sopenharmony_ci
12111cb0ef41Sopenharmony_ci  // TODO(v8:8989): [torque] Support marker constants.
12121cb0ef41Sopenharmony_ci  static const int kPointerFieldsEndOffset = kStartPositionOffset;
12131cb0ef41Sopenharmony_ci
12141cb0ef41Sopenharmony_ci  using BodyDescriptor =
12151cb0ef41Sopenharmony_ci      FixedBodyDescriptor<HeapObject::kMapOffset, kPointerFieldsEndOffset,
12161cb0ef41Sopenharmony_ci                          kHeaderSize>;
12171cb0ef41Sopenharmony_ci
12181cb0ef41Sopenharmony_ci private:
12191cb0ef41Sopenharmony_ci  friend class Factory;
12201cb0ef41Sopenharmony_ci
12211cb0ef41Sopenharmony_ci  inline bool DidEnsureSourcePositionsAvailable() const;
12221cb0ef41Sopenharmony_ci
12231cb0ef41Sopenharmony_ci  // [shared]: optional SharedFunctionInfo that can be used to reconstruct the
12241cb0ef41Sopenharmony_ci  // source position if not available when the message was generated.
12251cb0ef41Sopenharmony_ci  DECL_ACCESSORS(shared_info, HeapObject)
12261cb0ef41Sopenharmony_ci
12271cb0ef41Sopenharmony_ci  // [bytecode_offset]: optional offset using along with |shared| to generation
12281cb0ef41Sopenharmony_ci  // source positions.
12291cb0ef41Sopenharmony_ci  DECL_ACCESSORS(bytecode_offset, Smi)
12301cb0ef41Sopenharmony_ci
12311cb0ef41Sopenharmony_ci  // [start_position]: the start position in the script for the error message.
12321cb0ef41Sopenharmony_ci  DECL_INT_ACCESSORS(start_position)
12331cb0ef41Sopenharmony_ci
12341cb0ef41Sopenharmony_ci  // [end_position]: the end position in the script for the error message.
12351cb0ef41Sopenharmony_ci  DECL_INT_ACCESSORS(end_position)
12361cb0ef41Sopenharmony_ci
12371cb0ef41Sopenharmony_ci  DECL_INT_ACCESSORS(raw_type)
12381cb0ef41Sopenharmony_ci
12391cb0ef41Sopenharmony_ci  // Hide generated accessors; custom accessors are named "raw_type".
12401cb0ef41Sopenharmony_ci  DECL_INT_ACCESSORS(message_type)
12411cb0ef41Sopenharmony_ci
12421cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSMessageObject)
12431cb0ef41Sopenharmony_ci};
12441cb0ef41Sopenharmony_ci
12451cb0ef41Sopenharmony_ci// The [Async-from-Sync Iterator] object
12461cb0ef41Sopenharmony_ci// (proposal-async-iteration/#sec-async-from-sync-iterator-objects)
12471cb0ef41Sopenharmony_ci// An object which wraps an ordinary Iterator and converts it to behave
12481cb0ef41Sopenharmony_ci// according to the Async Iterator protocol.
12491cb0ef41Sopenharmony_ci// (See https://tc39.github.io/proposal-async-iteration/#sec-iteration)
12501cb0ef41Sopenharmony_ciclass JSAsyncFromSyncIterator
12511cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSAsyncFromSyncIterator<JSAsyncFromSyncIterator,
12521cb0ef41Sopenharmony_ci                                                    JSObject> {
12531cb0ef41Sopenharmony_ci public:
12541cb0ef41Sopenharmony_ci  DECL_PRINTER(JSAsyncFromSyncIterator)
12551cb0ef41Sopenharmony_ci
12561cb0ef41Sopenharmony_ci  // Async-from-Sync Iterator instances are ordinary objects that inherit
12571cb0ef41Sopenharmony_ci  // properties from the %AsyncFromSyncIteratorPrototype% intrinsic object.
12581cb0ef41Sopenharmony_ci  // Async-from-Sync Iterator instances are initially created with the internal
12591cb0ef41Sopenharmony_ci  // slots listed in Table 4.
12601cb0ef41Sopenharmony_ci  // (proposal-async-iteration/#table-async-from-sync-iterator-internal-slots)
12611cb0ef41Sopenharmony_ci
12621cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSAsyncFromSyncIterator)
12631cb0ef41Sopenharmony_ci};
12641cb0ef41Sopenharmony_ci
12651cb0ef41Sopenharmony_ciclass JSStringIterator
12661cb0ef41Sopenharmony_ci    : public TorqueGeneratedJSStringIterator<JSStringIterator, JSObject> {
12671cb0ef41Sopenharmony_ci public:
12681cb0ef41Sopenharmony_ci  // Dispatched behavior.
12691cb0ef41Sopenharmony_ci  DECL_PRINTER(JSStringIterator)
12701cb0ef41Sopenharmony_ci  DECL_VERIFIER(JSStringIterator)
12711cb0ef41Sopenharmony_ci
12721cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(JSStringIterator)
12731cb0ef41Sopenharmony_ci};
12741cb0ef41Sopenharmony_ci
12751cb0ef41Sopenharmony_ci}  // namespace internal
12761cb0ef41Sopenharmony_ci}  // namespace v8
12771cb0ef41Sopenharmony_ci
12781cb0ef41Sopenharmony_ci#include "src/objects/object-macros-undef.h"
12791cb0ef41Sopenharmony_ci
12801cb0ef41Sopenharmony_ci#endif  // V8_OBJECTS_JS_OBJECTS_H_
1281