V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
property-array.h
1 // Copyright 2018 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_OBJECTS_PROPERTY_ARRAY_H_
6 #define V8_OBJECTS_PROPERTY_ARRAY_H_
7 
8 #include "src/objects/heap-object.h"
9 
10 // Has to be the last include (doesn't have include guards):
11 #include "src/objects/object-macros.h"
12 
13 namespace v8 {
14 namespace internal {
15 
16 class PropertyArray : public HeapObjectPtr {
17  public:
18  // [length]: length of the array.
19  inline int length() const;
20 
21  // Get the length using acquire loads.
22  inline int synchronized_length() const;
23 
24  // This is only used on a newly allocated PropertyArray which
25  // doesn't have an existing hash.
26  inline void initialize_length(int length);
27 
28  inline void SetHash(int hash);
29  inline int Hash() const;
30 
31  inline Object* get(int index) const;
32 
33  inline void set(int index, Object* value);
34  // Setter with explicit barrier mode.
35  inline void set(int index, Object* value, WriteBarrierMode mode);
36 
37  // Gives access to raw memory which stores the array's data.
38  inline ObjectSlot data_start();
39 
40  // Garbage collection support.
41  static constexpr int SizeFor(int length) {
42  return kHeaderSize + length * kPointerSize;
43  }
44 
45  DECL_CAST2(PropertyArray)
46  DECL_PRINTER(PropertyArray)
47  DECL_VERIFIER(PropertyArray)
48 
49  // Layout description.
50  static const int kLengthAndHashOffset = HeapObject::kHeaderSize;
51  static const int kHeaderSize = kLengthAndHashOffset + kPointerSize;
52 
53  // Garbage collection support.
55 
56  static const int kLengthFieldSize = 10;
57  class LengthField : public BitField<int, 0, kLengthFieldSize> {};
58  static const int kMaxLength = LengthField::kMax;
59  class HashField : public BitField<int, kLengthFieldSize,
60  kSmiValueSize - kLengthFieldSize - 1> {};
61 
62  static const int kNoHashSentinel = 0;
63 
64  OBJECT_CONSTRUCTORS(PropertyArray, HeapObjectPtr);
65 };
66 
67 } // namespace internal
68 } // namespace v8
69 
70 #include "src/objects/object-macros-undef.h"
71 
72 #endif // V8_OBJECTS_PROPERTY_ARRAY_H_
Definition: libplatform.h:13