V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
ordered-hash-table-inl.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_ORDERED_HASH_TABLE_INL_H_
6 #define V8_OBJECTS_ORDERED_HASH_TABLE_INL_H_
7 
8 #include "src/objects/ordered-hash-table.h"
9 
10 #include "src/heap/heap.h"
11 #include "src/objects/fixed-array-inl.h"
12 
13 // Has to be the last include (doesn't have include guards):
14 #include "src/objects/object-macros.h"
15 
16 namespace v8 {
17 namespace internal {
18 
19 RootIndex OrderedHashSet::GetMapRootIndex() {
20  return RootIndex::kOrderedHashSetMap;
21 }
22 
23 RootIndex OrderedHashMap::GetMapRootIndex() {
24  return RootIndex::kOrderedHashMapMap;
25 }
26 
27 RootIndex OrderedNameDictionary::GetMapRootIndex() {
28  return RootIndex::kOrderedNameDictionaryMap;
29 }
30 
31 RootIndex SmallOrderedNameDictionary::GetMapRootIndex() {
32  return RootIndex::kSmallOrderedNameDictionaryMap;
33 }
34 
35 RootIndex SmallOrderedHashMap::GetMapRootIndex() {
36  return RootIndex::kSmallOrderedHashMapMap;
37 }
38 
39 RootIndex SmallOrderedHashSet::GetMapRootIndex() {
40  return RootIndex::kSmallOrderedHashSetMap;
41 }
42 
43 inline Object* OrderedHashMap::ValueAt(int entry) {
44  DCHECK_NE(entry, kNotFound);
45  DCHECK_LT(entry, UsedCapacity());
46  return get(EntryToIndex(entry) + kValueOffset);
47 }
48 
49 inline Object* OrderedNameDictionary::ValueAt(int entry) {
50  DCHECK_NE(entry, kNotFound);
51  DCHECK_LT(entry, UsedCapacity());
52  return get(EntryToIndex(entry) + kValueOffset);
53 }
54 
55 // Set the value for entry.
56 inline void OrderedNameDictionary::ValueAtPut(int entry, Object* value) {
57  DCHECK_NE(entry, kNotFound);
58  DCHECK_LT(entry, UsedCapacity());
59  this->set(EntryToIndex(entry) + kValueOffset, value);
60 }
61 
62 // Returns the property details for the property at entry.
63 inline PropertyDetails OrderedNameDictionary::DetailsAt(int entry) {
64  DCHECK_NE(entry, kNotFound);
65  DCHECK_LT(entry, this->UsedCapacity());
66  // TODO(gsathya): Optimize the cast away.
67  return PropertyDetails(
68  Smi::cast(get(EntryToIndex(entry) + kPropertyDetailsOffset)));
69 }
70 
71 inline void OrderedNameDictionary::DetailsAtPut(int entry,
72  PropertyDetails value) {
73  DCHECK_NE(entry, kNotFound);
74  DCHECK_LT(entry, this->UsedCapacity());
75  // TODO(gsathya): Optimize the cast away.
76  this->set(EntryToIndex(entry) + kPropertyDetailsOffset, value.AsSmi());
77 }
78 
79 inline Object* SmallOrderedNameDictionary::ValueAt(int entry) {
80  return this->GetDataEntry(entry, kValueIndex);
81 }
82 
83 // Set the value for entry.
84 inline void SmallOrderedNameDictionary::ValueAtPut(int entry, Object* value) {
85  this->SetDataEntry(entry, kValueIndex, value);
86 }
87 
88 // Returns the property details for the property at entry.
89 inline PropertyDetails SmallOrderedNameDictionary::DetailsAt(int entry) {
90  // TODO(gsathya): Optimize the cast away. And store this in the data table.
91  return PropertyDetails(
92  Smi::cast(this->GetDataEntry(entry, kPropertyDetailsIndex)));
93 }
94 
95 // Set the details for entry.
96 inline void SmallOrderedNameDictionary::DetailsAtPut(int entry,
97  PropertyDetails value) {
98  // TODO(gsathya): Optimize the cast away. And store this in the data table.
99  this->SetDataEntry(entry, kPropertyDetailsIndex, value.AsSmi());
100 }
101 
102 inline bool OrderedHashSet::Is(Handle<HeapObject> table) {
103  return table->IsOrderedHashSet();
104 }
105 
106 inline bool OrderedHashMap::Is(Handle<HeapObject> table) {
107  return table->IsOrderedHashMap();
108 }
109 
110 inline bool SmallOrderedHashSet::Is(Handle<HeapObject> table) {
111  return table->IsSmallOrderedHashSet();
112 }
113 
114 inline bool SmallOrderedHashMap::Is(Handle<HeapObject> table) {
115  return table->IsSmallOrderedHashMap();
116 }
117 } // namespace internal
118 } // namespace v8
119 
120 #include "src/objects/object-macros-undef.h"
121 
122 #endif // V8_OBJECTS_ORDERED_HASH_TABLE_INL_H_
Definition: libplatform.h:13