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_PROPERTY_ARRAY_H_ 61cb0ef41Sopenharmony_ci#define V8_OBJECTS_PROPERTY_ARRAY_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/objects/heap-object.h" 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci// Has to be the last include (doesn't have include guards): 111cb0ef41Sopenharmony_ci#include "src/objects/object-macros.h" 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cinamespace v8 { 141cb0ef41Sopenharmony_cinamespace internal { 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci#include "torque-generated/src/objects/property-array-tq.inc" 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciclass PropertyArray 191cb0ef41Sopenharmony_ci : public TorqueGeneratedPropertyArray<PropertyArray, HeapObject> { 201cb0ef41Sopenharmony_ci public: 211cb0ef41Sopenharmony_ci // [length]: length of the array. 221cb0ef41Sopenharmony_ci inline int length() const; 231cb0ef41Sopenharmony_ci inline int length(AcquireLoadTag) const; 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci // This is only used on a newly allocated PropertyArray which 261cb0ef41Sopenharmony_ci // doesn't have an existing hash. 271cb0ef41Sopenharmony_ci inline void initialize_length(int length); 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci inline void SetHash(int hash); 301cb0ef41Sopenharmony_ci inline int Hash() const; 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci inline Object get(int index) const; 331cb0ef41Sopenharmony_ci inline Object get(PtrComprCageBase cage_base, int index) const; 341cb0ef41Sopenharmony_ci inline Object get(int index, SeqCstAccessTag tag) const; 351cb0ef41Sopenharmony_ci inline Object get(PtrComprCageBase cage_base, int index, 361cb0ef41Sopenharmony_ci SeqCstAccessTag tag) const; 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci inline void set(int index, Object value); 391cb0ef41Sopenharmony_ci inline void set(int index, Object value, SeqCstAccessTag tag); 401cb0ef41Sopenharmony_ci // Setter with explicit barrier mode. 411cb0ef41Sopenharmony_ci inline void set(int index, Object value, WriteBarrierMode mode); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci inline Object Swap(int index, Object value, SeqCstAccessTag tag); 441cb0ef41Sopenharmony_ci inline Object Swap(PtrComprCageBase cage_base, int index, Object value, 451cb0ef41Sopenharmony_ci SeqCstAccessTag tag); 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ci // Signature must be in sync with FixedArray::CopyElements(). 481cb0ef41Sopenharmony_ci inline void CopyElements(Isolate* isolate, int dst_index, PropertyArray src, 491cb0ef41Sopenharmony_ci int src_index, int len, WriteBarrierMode mode); 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci // Gives access to raw memory which stores the array's data. 521cb0ef41Sopenharmony_ci inline ObjectSlot data_start(); 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ci // Garbage collection support. 551cb0ef41Sopenharmony_ci static constexpr int SizeFor(int length) { 561cb0ef41Sopenharmony_ci return kHeaderSize + length * kTaggedSize; 571cb0ef41Sopenharmony_ci } 581cb0ef41Sopenharmony_ci static constexpr int OffsetOfElementAt(int index) { return SizeFor(index); } 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci DECL_PRINTER(PropertyArray) 611cb0ef41Sopenharmony_ci DECL_VERIFIER(PropertyArray) 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci // Garbage collection support. 641cb0ef41Sopenharmony_ci using BodyDescriptor = FlexibleBodyDescriptor<kHeaderSize>; 651cb0ef41Sopenharmony_ci 661cb0ef41Sopenharmony_ci static const int kLengthFieldSize = 10; 671cb0ef41Sopenharmony_ci using LengthField = base::BitField<int, 0, kLengthFieldSize>; 681cb0ef41Sopenharmony_ci static const int kMaxLength = LengthField::kMax; 691cb0ef41Sopenharmony_ci using HashField = base::BitField<int, kLengthFieldSize, 701cb0ef41Sopenharmony_ci kSmiValueSize - kLengthFieldSize - 1>; 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci static const int kNoHashSentinel = 0; 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci private: 751cb0ef41Sopenharmony_ci DECL_INT_ACCESSORS(length_and_hash) 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ci DECL_RELEASE_ACQUIRE_INT_ACCESSORS(length_and_hash) 781cb0ef41Sopenharmony_ci 791cb0ef41Sopenharmony_ci TQ_OBJECT_CONSTRUCTORS(PropertyArray) 801cb0ef41Sopenharmony_ci}; 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci} // namespace internal 831cb0ef41Sopenharmony_ci} // namespace v8 841cb0ef41Sopenharmony_ci 851cb0ef41Sopenharmony_ci#include "src/objects/object-macros-undef.h" 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_ci#endif // V8_OBJECTS_PROPERTY_ARRAY_H_ 88