77
88#include " src/objects/dictionary.h"
99
10+ #include " src/execution/isolate-utils-inl.h"
1011#include " src/numbers/hash-seed-inl.h"
1112#include " src/objects/hash-table-inl.h"
13+ #include " src/objects/objects-inl.h"
1214#include " src/objects/oddball.h"
1315#include " src/objects/property-cell-inl.h"
1416
@@ -27,10 +29,62 @@ template <typename Derived, typename Shape>
2729Dictionary<Derived, Shape>::Dictionary(Address ptr)
2830 : HashTable<Derived, Shape>(ptr) {}
2931
32+ template <typename Derived, typename Shape>
33+ Object Dictionary<Derived, Shape>::ValueAt(int entry) {
34+ Isolate* isolate = GetIsolateForPtrCompr (*this );
35+ return ValueAt (isolate, entry);
36+ }
37+
38+ template <typename Derived, typename Shape>
39+ Object Dictionary<Derived, Shape>::ValueAt(Isolate* isolate, int entry) {
40+ return this ->get (isolate, DerivedHashTable::EntryToIndex (entry) + 1 );
41+ }
42+
43+ template <typename Derived, typename Shape>
44+ void Dictionary<Derived, Shape>::ValueAtPut(int entry, Object value) {
45+ this ->set (DerivedHashTable::EntryToIndex (entry) + 1 , value);
46+ }
47+
48+ template <typename Derived, typename Shape>
49+ PropertyDetails Dictionary<Derived, Shape>::DetailsAt(int entry) {
50+ return Shape::DetailsAt (Derived::cast (*this ), entry);
51+ }
52+
53+ template <typename Derived, typename Shape>
54+ void Dictionary<Derived, Shape>::DetailsAtPut(Isolate* isolate, int entry,
55+ PropertyDetails value) {
56+ Shape::DetailsAtPut (isolate, Derived::cast (*this ), entry, value);
57+ }
58+
3059template <typename Derived, typename Shape>
3160BaseNameDictionary<Derived, Shape>::BaseNameDictionary(Address ptr)
3261 : Dictionary<Derived, Shape>(ptr) {}
3362
63+ template <typename Derived, typename Shape>
64+ void BaseNameDictionary<Derived, Shape>::SetNextEnumerationIndex(int index) {
65+ DCHECK_NE (0 , index);
66+ this ->set (kNextEnumerationIndexIndex , Smi::FromInt (index));
67+ }
68+
69+ template <typename Derived, typename Shape>
70+ int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex() {
71+ return Smi::ToInt (this ->get (kNextEnumerationIndexIndex ));
72+ }
73+
74+ template <typename Derived, typename Shape>
75+ void BaseNameDictionary<Derived, Shape>::SetHash(int hash) {
76+ DCHECK (PropertyArray::HashField::is_valid (hash));
77+ this ->set (kObjectHashIndex , Smi::FromInt (hash));
78+ }
79+
80+ template <typename Derived, typename Shape>
81+ int BaseNameDictionary<Derived, Shape>::Hash() const {
82+ Object hash_obj = this ->get (kObjectHashIndex );
83+ int hash = Smi::ToInt (hash_obj);
84+ DCHECK (PropertyArray::HashField::is_valid (hash));
85+ return hash;
86+ }
87+
3488GlobalDictionary::GlobalDictionary (Address ptr)
3589 : BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>(ptr) {
3690 SLOW_DCHECK (IsGlobalDictionary ());
@@ -90,6 +144,25 @@ void Dictionary<Derived, Shape>::SetEntry(Isolate* isolate, int entry,
90144 if (Shape::kHasDetails ) DetailsAtPut (isolate, entry, details);
91145}
92146
147+ template <typename Key>
148+ template <typename Dictionary>
149+ PropertyDetails BaseDictionaryShape<Key>::DetailsAt(Dictionary dict,
150+ int entry) {
151+ STATIC_ASSERT (Dictionary::kEntrySize == 3 );
152+ DCHECK_GE (entry, 0 ); // Not found is -1, which is not caught by get().
153+ return PropertyDetails (Smi::cast (dict.get (Dictionary::EntryToIndex (entry) +
154+ Dictionary::kEntryDetailsIndex )));
155+ }
156+
157+ template <typename Key>
158+ template <typename Dictionary>
159+ void BaseDictionaryShape<Key>::DetailsAtPut(Isolate* isolate, Dictionary dict,
160+ int entry, PropertyDetails value) {
161+ STATIC_ASSERT (Dictionary::kEntrySize == 3 );
162+ dict.set (Dictionary::EntryToIndex (entry) + Dictionary::kEntryDetailsIndex ,
163+ value.AsSmi ());
164+ }
165+
93166Object GlobalDictionaryShape::Unwrap (Object object) {
94167 return PropertyCell::cast (object).name ();
95168}
0 commit comments