OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_ELEMENTS_H_ | 5 #ifndef V8_ELEMENTS_H_ |
6 #define V8_ELEMENTS_H_ | 6 #define V8_ELEMENTS_H_ |
7 | 7 |
8 #include "src/elements-kind.h" | 8 #include "src/elements-kind.h" |
9 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return elements_accessors_[elements_kind]; | 175 return elements_accessors_[elements_kind]; |
176 } | 176 } |
177 | 177 |
178 static ElementsAccessor* ForArray(Handle<FixedArrayBase> array); | 178 static ElementsAccessor* ForArray(Handle<FixedArrayBase> array); |
179 | 179 |
180 static void InitializeOncePerProcess(); | 180 static void InitializeOncePerProcess(); |
181 static void TearDown(); | 181 static void TearDown(); |
182 | 182 |
183 protected: | 183 protected: |
184 friend class SloppyArgumentsElementsAccessor; | 184 friend class SloppyArgumentsElementsAccessor; |
| 185 friend class LookupIterator; |
185 | 186 |
186 virtual uint32_t GetCapacity(Handle<JSObject> holder, | 187 static ElementsAccessor* ForArray(FixedArrayBase* array); |
187 Handle<FixedArrayBase> backing_store) = 0; | 188 |
| 189 virtual uint32_t GetCapacity(JSObject* holder, |
| 190 FixedArrayBase* backing_store) = 0; |
188 | 191 |
189 // Element handlers distinguish between indexes and keys when they manipulate | 192 // Element handlers distinguish between indexes and keys when they manipulate |
190 // elements. Indexes refer to elements in terms of their location in the | 193 // elements. Indexes refer to elements in terms of their location in the |
191 // underlying storage's backing store representation, and are between 0 and | 194 // underlying storage's backing store representation, and are between 0 and |
192 // GetCapacity. Keys refer to elements in terms of the value that would be | 195 // GetCapacity. Keys refer to elements in terms of the value that would be |
193 // specified in JavaScript to access the element. In most implementations, | 196 // specified in JavaScript to access the element. In most implementations, |
194 // keys are equivalent to indexes, and GetKeyForIndex returns the same value | 197 // keys are equivalent to indexes, and GetKeyForIndex returns the same value |
195 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps | 198 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps |
196 // the index to a key using the KeyAt method on the NumberDictionary. | 199 // the index to a key using the KeyAt method on the NumberDictionary. |
197 virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store, | 200 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
198 uint32_t index) = 0; | 201 uint32_t index) = 0; |
| 202 virtual uint32_t GetIndexForKey(FixedArrayBase* backing_store, |
| 203 uint32_t key) = 0; |
| 204 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, |
| 205 uint32_t index) = 0; |
199 | 206 |
200 private: | 207 private: |
201 static ElementsAccessor** elements_accessors_; | 208 static ElementsAccessor** elements_accessors_; |
202 const char* name_; | 209 const char* name_; |
203 | 210 |
204 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); | 211 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); |
205 }; | 212 }; |
206 | 213 |
207 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, | 214 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, |
208 bool allow_appending = false); | 215 bool allow_appending = false); |
209 | 216 |
210 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( | 217 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( |
211 Handle<JSArray> array, | 218 Handle<JSArray> array, |
212 Arguments* args); | 219 Arguments* args); |
213 | 220 |
214 } } // namespace v8::internal | 221 } } // namespace v8::internal |
215 | 222 |
216 #endif // V8_ELEMENTS_H_ | 223 #endif // V8_ELEMENTS_H_ |
OLD | NEW |