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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 inline bool HasElement(Handle<JSObject> holder, uint32_t index, | 50 inline bool HasElement(Handle<JSObject> holder, uint32_t index, |
51 PropertyFilter filter = ALL_PROPERTIES) { | 51 PropertyFilter filter = ALL_PROPERTIES) { |
52 return HasElement(holder, index, handle(holder->elements()), filter); | 52 return HasElement(holder, index, handle(holder->elements()), filter); |
53 } | 53 } |
54 | 54 |
55 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t entry) = 0; | 55 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t entry) = 0; |
56 | 56 |
57 virtual PropertyDetails GetDetails(JSObject* holder, uint32_t entry) = 0; | 57 virtual PropertyDetails GetDetails(JSObject* holder, uint32_t entry) = 0; |
58 virtual bool HasAccessors(JSObject* holder) = 0; | 58 virtual bool HasAccessors(JSObject* holder) = 0; |
| 59 virtual uint32_t NumberOfElements(JSObject* holder) = 0; |
59 | 60 |
60 // Modifies the length data property as specified for JSArrays and resizes the | 61 // Modifies the length data property as specified for JSArrays and resizes the |
61 // underlying backing store accordingly. The method honors the semantics of | 62 // underlying backing store accordingly. The method honors the semantics of |
62 // changing array sizes as defined in EcmaScript 5.1 15.4.5.2, i.e. array that | 63 // changing array sizes as defined in EcmaScript 5.1 15.4.5.2, i.e. array that |
63 // have non-deletable elements can only be shrunk to the size of highest | 64 // have non-deletable elements can only be shrunk to the size of highest |
64 // element that is non-deletable. | 65 // element that is non-deletable. |
65 virtual void SetLength(Handle<JSArray> holder, uint32_t new_length) = 0; | 66 virtual void SetLength(Handle<JSArray> holder, uint32_t new_length) = 0; |
66 | 67 |
67 // Deletes an element in an object. | 68 // Deletes an element in an object. |
68 virtual void Delete(Handle<JSObject> holder, uint32_t entry) = 0; | 69 virtual void Delete(Handle<JSObject> holder, uint32_t entry) = 0; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 friend class LookupIterator; | 157 friend class LookupIterator; |
157 | 158 |
158 // Element handlers distinguish between entries and indices when they | 159 // Element handlers distinguish between entries and indices when they |
159 // manipulate elements. Entries refer to elements in terms of their location | 160 // manipulate elements. Entries refer to elements in terms of their location |
160 // in the underlying storage's backing store representation, and are between 0 | 161 // in the underlying storage's backing store representation, and are between 0 |
161 // and GetCapacity. Indices refer to elements in terms of the value that would | 162 // and GetCapacity. Indices refer to elements in terms of the value that would |
162 // be specified in JavaScript to access the element. In most implementations, | 163 // be specified in JavaScript to access the element. In most implementations, |
163 // indices are equivalent to entries. In the NumberDictionary | 164 // indices are equivalent to entries. In the NumberDictionary |
164 // ElementsAccessor, entries are mapped to an index using the KeyAt method on | 165 // ElementsAccessor, entries are mapped to an index using the KeyAt method on |
165 // the NumberDictionary. | 166 // the NumberDictionary. |
166 virtual uint32_t GetEntryForIndex(JSObject* holder, | 167 virtual uint32_t GetEntryForIndex(Isolate* isolate, JSObject* holder, |
167 FixedArrayBase* backing_store, | 168 FixedArrayBase* backing_store, |
168 uint32_t index) = 0; | 169 uint32_t index) = 0; |
169 | 170 |
170 // NOTE: this method violates the handlified function signature convention: | 171 // NOTE: this method violates the handlified function signature convention: |
171 // raw pointer parameter |source_holder| in the function that allocates. | 172 // raw pointer parameter |source_holder| in the function that allocates. |
172 // This is done intentionally to avoid ArrayConcat() builtin performance | 173 // This is done intentionally to avoid ArrayConcat() builtin performance |
173 // degradation. | 174 // degradation. |
174 virtual void CopyElements(JSObject* source_holder, uint32_t source_start, | 175 virtual void CopyElements(JSObject* source_holder, uint32_t source_start, |
175 ElementsKind source_kind, | 176 ElementsKind source_kind, |
176 Handle<FixedArrayBase> destination, | 177 Handle<FixedArrayBase> destination, |
(...skipping 10 matching lines...) Expand all Loading... |
187 bool allow_appending = false); | 188 bool allow_appending = false); |
188 | 189 |
189 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( | 190 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( |
190 Handle<JSArray> array, | 191 Handle<JSArray> array, |
191 Arguments* args); | 192 Arguments* args); |
192 | 193 |
193 } // namespace internal | 194 } // namespace internal |
194 } // namespace v8 | 195 } // namespace v8 |
195 | 196 |
196 #endif // V8_ELEMENTS_H_ | 197 #endif // V8_ELEMENTS_H_ |
OLD | NEW |