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