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