| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return elements_accessors_[elements_kind]; | 168 return elements_accessors_[elements_kind]; |
| 169 } | 169 } |
| 170 | 170 |
| 171 static ElementsAccessor* ForArray(Handle<FixedArrayBase> array); | 171 static ElementsAccessor* ForArray(Handle<FixedArrayBase> array); |
| 172 | 172 |
| 173 static void InitializeOncePerProcess(); | 173 static void InitializeOncePerProcess(); |
| 174 static void TearDown(); | 174 static void TearDown(); |
| 175 | 175 |
| 176 protected: | 176 protected: |
| 177 friend class SloppyArgumentsElementsAccessor; | 177 friend class SloppyArgumentsElementsAccessor; |
| 178 friend class LookupIterator; |
| 178 | 179 |
| 179 virtual uint32_t GetCapacity(Handle<JSObject> holder, | 180 static ElementsAccessor* ForArray(FixedArrayBase* array); |
| 180 Handle<FixedArrayBase> backing_store) = 0; | 181 |
| 182 virtual uint32_t GetCapacity(JSObject* holder, |
| 183 FixedArrayBase* backing_store) = 0; |
| 181 | 184 |
| 182 // Element handlers distinguish between indexes and keys when they manipulate | 185 // Element handlers distinguish between indexes and keys when they manipulate |
| 183 // elements. Indexes refer to elements in terms of their location in the | 186 // elements. Indexes refer to elements in terms of their location in the |
| 184 // underlying storage's backing store representation, and are between 0 and | 187 // underlying storage's backing store representation, and are between 0 and |
| 185 // GetCapacity. Keys refer to elements in terms of the value that would be | 188 // GetCapacity. Keys refer to elements in terms of the value that would be |
| 186 // specified in JavaScript to access the element. In most implementations, | 189 // specified in JavaScript to access the element. In most implementations, |
| 187 // keys are equivalent to indexes, and GetKeyForIndex returns the same value | 190 // keys are equivalent to indexes, and GetKeyForIndex returns the same value |
| 188 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps | 191 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps |
| 189 // the index to a key using the KeyAt method on the NumberDictionary. | 192 // the index to a key using the KeyAt method on the NumberDictionary. |
| 190 virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store, | 193 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
| 191 uint32_t index) = 0; | 194 uint32_t index) = 0; |
| 195 virtual uint32_t GetIndexForKey(FixedArrayBase* backing_store, |
| 196 uint32_t key) = 0; |
| 197 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, |
| 198 uint32_t index) = 0; |
| 192 | 199 |
| 193 private: | 200 private: |
| 194 static ElementsAccessor** elements_accessors_; | 201 static ElementsAccessor** elements_accessors_; |
| 195 const char* name_; | 202 const char* name_; |
| 196 | 203 |
| 197 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); | 204 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); |
| 198 }; | 205 }; |
| 199 | 206 |
| 200 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, | 207 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, |
| 201 bool allow_appending = false); | 208 bool allow_appending = false); |
| 202 | 209 |
| 203 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( | 210 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( |
| 204 Handle<JSArray> array, | 211 Handle<JSArray> array, |
| 205 Arguments* args); | 212 Arguments* args); |
| 206 | 213 |
| 207 } } // namespace v8::internal | 214 } } // namespace v8::internal |
| 208 | 215 |
| 209 #endif // V8_ELEMENTS_H_ | 216 #endif // V8_ELEMENTS_H_ |
| OLD | NEW |