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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // can optionally pass in the backing store to use for the check, which must | 53 // can optionally pass in the backing store to use for the check, which must |
54 // be compatible with the ElementsKind of the ElementsAccessor. If | 54 // be compatible with the ElementsKind of the ElementsAccessor. If |
55 // backing_store is NULL, the holder->elements() is used as the backing store. | 55 // backing_store is NULL, the holder->elements() is used as the backing store. |
56 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key, | 56 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key, |
57 Handle<FixedArrayBase> backing_store) = 0; | 57 Handle<FixedArrayBase> backing_store) = 0; |
58 | 58 |
59 inline Handle<Object> Get(Handle<JSObject> holder, uint32_t key) { | 59 inline Handle<Object> Get(Handle<JSObject> holder, uint32_t key) { |
60 return Get(holder, key, handle(holder->elements())); | 60 return Get(holder, key, handle(holder->elements())); |
61 } | 61 } |
62 | 62 |
| 63 // Returns an element's attributes, or ABSENT if there is no such |
| 64 // element. This method doesn't iterate up the prototype chain. The caller |
| 65 // can optionally pass in the backing store to use for the check, which must |
| 66 // be compatible with the ElementsKind of the ElementsAccessor. If |
| 67 // backing_store is NULL, the holder->elements() is used as the backing store. |
| 68 virtual PropertyAttributes GetAttributes(JSObject* holder, uint32_t key, |
| 69 FixedArrayBase* backing_store) = 0; |
| 70 |
| 71 inline PropertyAttributes GetAttributes(Handle<JSObject> holder, |
| 72 uint32_t key) { |
| 73 return GetAttributes(*holder, key, holder->elements()); |
| 74 } |
| 75 |
63 // Returns an element's accessors, or NULL if the element does not exist or | 76 // Returns an element's accessors, or NULL if the element does not exist or |
64 // is plain. This method doesn't iterate up the prototype chain. The caller | 77 // is plain. This method doesn't iterate up the prototype chain. The caller |
65 // can optionally pass in the backing store to use for the check, which must | 78 // can optionally pass in the backing store to use for the check, which must |
66 // be compatible with the ElementsKind of the ElementsAccessor. If | 79 // be compatible with the ElementsKind of the ElementsAccessor. If |
67 // backing_store is NULL, the holder->elements() is used as the backing store. | 80 // backing_store is NULL, the holder->elements() is used as the backing store. |
68 virtual MaybeHandle<AccessorPair> GetAccessorPair( | 81 virtual MaybeHandle<AccessorPair> GetAccessorPair( |
69 Handle<JSObject> holder, uint32_t key, | 82 Handle<JSObject> holder, uint32_t key, |
70 Handle<FixedArrayBase> backing_store) = 0; | 83 Handle<FixedArrayBase> backing_store) = 0; |
71 | 84 |
72 inline MaybeHandle<AccessorPair> GetAccessorPair(Handle<JSObject> holder, | 85 inline MaybeHandle<AccessorPair> GetAccessorPair(Handle<JSObject> holder, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Element handlers distinguish between indexes and keys when they manipulate | 179 // Element handlers distinguish between indexes and keys when they manipulate |
167 // elements. Indexes refer to elements in terms of their location in the | 180 // elements. Indexes refer to elements in terms of their location in the |
168 // underlying storage's backing store representation, and are between 0 and | 181 // underlying storage's backing store representation, and are between 0 and |
169 // GetCapacity. Keys refer to elements in terms of the value that would be | 182 // GetCapacity. Keys refer to elements in terms of the value that would be |
170 // specified in JavaScript to access the element. In most implementations, | 183 // specified in JavaScript to access the element. In most implementations, |
171 // keys are equivalent to indexes, and GetKeyForIndex returns the same value | 184 // keys are equivalent to indexes, and GetKeyForIndex returns the same value |
172 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps | 185 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps |
173 // the index to a key using the KeyAt method on the NumberDictionary. | 186 // the index to a key using the KeyAt method on the NumberDictionary. |
174 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, | 187 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
175 uint32_t index) = 0; | 188 uint32_t index) = 0; |
176 virtual uint32_t GetIndexForKey(JSObject* holder, | 189 virtual uint32_t GetIndexForKey(FixedArrayBase* backing_store, |
177 FixedArrayBase* backing_store, | |
178 uint32_t key) = 0; | 190 uint32_t key) = 0; |
179 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, | 191 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, |
180 uint32_t index) = 0; | 192 uint32_t index) = 0; |
181 virtual bool HasIndex(FixedArrayBase* backing_store, uint32_t key) = 0; | 193 virtual bool HasIndex(FixedArrayBase* backing_store, uint32_t key) = 0; |
182 | 194 |
183 virtual Handle<Object> Set(Handle<JSObject> holder, uint32_t key, | 195 virtual Handle<Object> Set(Handle<JSObject> holder, uint32_t key, |
184 Handle<FixedArrayBase> backing_store, | 196 Handle<FixedArrayBase> backing_store, |
185 Handle<Object> value) = 0; | 197 Handle<Object> value) = 0; |
186 | 198 |
187 private: | 199 private: |
188 static ElementsAccessor** elements_accessors_; | 200 static ElementsAccessor** elements_accessors_; |
189 const char* name_; | 201 const char* name_; |
190 | 202 |
191 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); | 203 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); |
192 }; | 204 }; |
193 | 205 |
194 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, | 206 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, |
195 bool allow_appending = false); | 207 bool allow_appending = false); |
196 | 208 |
197 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( | 209 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( |
198 Handle<JSArray> array, | 210 Handle<JSArray> array, |
199 Arguments* args); | 211 Arguments* args); |
200 | 212 |
201 } } // namespace v8::internal | 213 } } // namespace v8::internal |
202 | 214 |
203 #endif // V8_ELEMENTS_H_ | 215 #endif // V8_ELEMENTS_H_ |
OLD | NEW |