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,66 @@ 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(InternalIndex 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,
40+ InternalIndex entry) {
41+ return this ->get (isolate, DerivedHashTable::EntryToIndex (entry) +
42+ Derived::kEntryValueIndex );
43+ }
44+
45+ template <typename Derived, typename Shape>
46+ void Dictionary<Derived, Shape>::ValueAtPut(InternalIndex entry, Object value) {
47+ this ->set (DerivedHashTable::EntryToIndex (entry) + Derived::kEntryValueIndex ,
48+ value);
49+ }
50+
51+ template <typename Derived, typename Shape>
52+ PropertyDetails Dictionary<Derived, Shape>::DetailsAt(InternalIndex entry) {
53+ return Shape::DetailsAt (Derived::cast (*this ), entry);
54+ }
55+
56+ template <typename Derived, typename Shape>
57+ void Dictionary<Derived, Shape>::DetailsAtPut(Isolate* isolate,
58+ InternalIndex entry,
59+ PropertyDetails value) {
60+ Shape::DetailsAtPut (isolate, Derived::cast (*this ), entry, value);
61+ }
62+
3063template <typename Derived, typename Shape>
3164BaseNameDictionary<Derived, Shape>::BaseNameDictionary(Address ptr)
3265 : Dictionary<Derived, Shape>(ptr) {}
3366
67+ template <typename Derived, typename Shape>
68+ void BaseNameDictionary<Derived, Shape>::SetNextEnumerationIndex(int index) {
69+ DCHECK_NE (0 , index);
70+ this ->set (kNextEnumerationIndexIndex , Smi::FromInt (index));
71+ }
72+
73+ template <typename Derived, typename Shape>
74+ int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex() {
75+ return Smi::ToInt (this ->get (kNextEnumerationIndexIndex ));
76+ }
77+
78+ template <typename Derived, typename Shape>
79+ void BaseNameDictionary<Derived, Shape>::SetHash(int hash) {
80+ DCHECK (PropertyArray::HashField::is_valid (hash));
81+ this ->set (kObjectHashIndex , Smi::FromInt (hash));
82+ }
83+
84+ template <typename Derived, typename Shape>
85+ int BaseNameDictionary<Derived, Shape>::Hash() const {
86+ Object hash_obj = this ->get (kObjectHashIndex );
87+ int hash = Smi::ToInt (hash_obj);
88+ DCHECK (PropertyArray::HashField::is_valid (hash));
89+ return hash;
90+ }
91+
3492GlobalDictionary::GlobalDictionary (Address ptr)
3593 : BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>(ptr) {
3694 SLOW_DCHECK (IsGlobalDictionary ());
@@ -91,6 +149,26 @@ void Dictionary<Derived, Shape>::SetEntry(Isolate* isolate, InternalIndex entry,
91149 if (Shape::kHasDetails ) DetailsAtPut (isolate, entry, details);
92150}
93151
152+ template <typename Key>
153+ template <typename Dictionary>
154+ PropertyDetails BaseDictionaryShape<Key>::DetailsAt(Dictionary dict,
155+ InternalIndex entry) {
156+ STATIC_ASSERT (Dictionary::kEntrySize == 3 );
157+ DCHECK (entry.is_found ());
158+ return PropertyDetails (Smi::cast (dict.get (Dictionary::EntryToIndex (entry) +
159+ Dictionary::kEntryDetailsIndex )));
160+ }
161+
162+ template <typename Key>
163+ template <typename Dictionary>
164+ void BaseDictionaryShape<Key>::DetailsAtPut(Isolate* isolate, Dictionary dict,
165+ InternalIndex entry,
166+ PropertyDetails value) {
167+ STATIC_ASSERT (Dictionary::kEntrySize == 3 );
168+ dict.set (Dictionary::EntryToIndex (entry) + Dictionary::kEntryDetailsIndex ,
169+ value.AsSmi ());
170+ }
171+
94172Object GlobalDictionaryShape::Unwrap (Object object) {
95173 return PropertyCell::cast (object).name ();
96174}
0 commit comments