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