Chromium Code Reviews| 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 30 matching lines...) Expand all Loading... | |
| 41 Handle<JSObject> holder, | 41 Handle<JSObject> holder, |
| 42 uint32_t key) { | 42 uint32_t key) { |
| 43 return HasElement(holder, key, handle(holder->elements())); | 43 return HasElement(holder, key, handle(holder->elements())); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Returns the element with the specified key or undefined if there is no such | 46 // Returns the element with the specified key or undefined if there is no such |
| 47 // element. This method doesn't iterate up the prototype chain. The caller | 47 // element. This method doesn't iterate up the prototype chain. The caller |
| 48 // can optionally pass in the backing store to use for the check, which must | 48 // can optionally pass in the backing store to use for the check, which must |
| 49 // be compatible with the ElementsKind of the ElementsAccessor. If | 49 // be compatible with the ElementsKind of the ElementsAccessor. If |
| 50 // backing_store is NULL, the holder->elements() is used as the backing store. | 50 // backing_store is NULL, the holder->elements() is used as the backing store. |
| 51 MUST_USE_RESULT virtual MaybeHandle<Object> Get( | 51 virtual Handle<Object> Get(Handle<Object> receiver, Handle<JSObject> holder, |
| 52 Handle<Object> receiver, | 52 uint32_t key, |
| 53 Handle<JSObject> holder, | 53 Handle<FixedArrayBase> backing_store) = 0; |
| 54 uint32_t key, | |
| 55 Handle<FixedArrayBase> backing_store) = 0; | |
| 56 | 54 |
| 57 MUST_USE_RESULT inline MaybeHandle<Object> Get( | 55 inline Handle<Object> Get(Handle<Object> receiver, Handle<JSObject> holder, |
| 58 Handle<Object> receiver, | 56 uint32_t key) { |
| 59 Handle<JSObject> holder, | |
| 60 uint32_t key) { | |
| 61 return Get(receiver, holder, key, handle(holder->elements())); | 57 return Get(receiver, holder, key, handle(holder->elements())); |
| 62 } | 58 } |
| 63 | 59 |
| 64 // Returns an element's attributes, or ABSENT if there is no such | 60 // Returns an element's attributes, or ABSENT if there is no such |
| 65 // element. This method doesn't iterate up the prototype chain. The caller | 61 // element. This method doesn't iterate up the prototype chain. The caller |
| 66 // can optionally pass in the backing store to use for the check, which must | 62 // can optionally pass in the backing store to use for the check, which must |
| 67 // be compatible with the ElementsKind of the ElementsAccessor. If | 63 // be compatible with the ElementsKind of the ElementsAccessor. If |
| 68 // backing_store is NULL, the holder->elements() is used as the backing store. | 64 // backing_store is NULL, the holder->elements() is used as the backing store. |
| 69 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( | 65 virtual PropertyAttributes GetAttributes(JSObject* holder, uint32_t key, |
| 70 Handle<JSObject> holder, | 66 FixedArrayBase* backing_store) = 0; |
| 71 uint32_t key, | |
| 72 Handle<FixedArrayBase> backing_store) = 0; | |
| 73 | 67 |
| 74 MUST_USE_RESULT inline PropertyAttributes GetAttributes( | 68 inline PropertyAttributes GetAttributes(Handle<JSObject> holder, |
| 75 Handle<JSObject> holder, | 69 uint32_t key) { |
| 76 uint32_t key) { | 70 return GetAttributes(*holder, key, holder->elements()); |
| 77 return GetAttributes(holder, key, handle(holder->elements())); | |
| 78 } | 71 } |
| 79 | 72 |
| 80 // Returns an element's accessors, or NULL if the element does not exist or | 73 // Returns an element's accessors, or NULL if the element does not exist or |
| 81 // is plain. This method doesn't iterate up the prototype chain. The caller | 74 // is plain. This method doesn't iterate up the prototype chain. The caller |
| 82 // can optionally pass in the backing store to use for the check, which must | 75 // can optionally pass in the backing store to use for the check, which must |
| 83 // be compatible with the ElementsKind of the ElementsAccessor. If | 76 // be compatible with the ElementsKind of the ElementsAccessor. If |
| 84 // backing_store is NULL, the holder->elements() is used as the backing store. | 77 // backing_store is NULL, the holder->elements() is used as the backing store. |
| 85 MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair( | 78 virtual MaybeHandle<AccessorPair> GetAccessorPair( |
| 86 Handle<JSObject> holder, | 79 Handle<JSObject> holder, uint32_t key, |
| 87 uint32_t key, | |
| 88 Handle<FixedArrayBase> backing_store) = 0; | 80 Handle<FixedArrayBase> backing_store) = 0; |
| 89 | 81 |
| 90 MUST_USE_RESULT inline MaybeHandle<AccessorPair> GetAccessorPair( | 82 inline MaybeHandle<AccessorPair> GetAccessorPair(Handle<JSObject> holder, |
|
Igor Sheludko
2015/05/26 17:11:56
nit: MUST_USE_RESULT ?
Toon Verwaest
2015/05/27 10:06:24
The MaybeHandle here means that there might not be
| |
| 91 Handle<JSObject> holder, | 83 uint32_t key) { |
| 92 uint32_t key) { | |
| 93 return GetAccessorPair(holder, key, handle(holder->elements())); | 84 return GetAccessorPair(holder, key, handle(holder->elements())); |
| 94 } | 85 } |
| 95 | 86 |
| 96 // Modifies the length data property as specified for JSArrays and resizes the | 87 // Modifies the length data property as specified for JSArrays and resizes the |
| 97 // underlying backing store accordingly. The method honors the semantics of | 88 // underlying backing store accordingly. The method honors the semantics of |
| 98 // changing array sizes as defined in EcmaScript 5.1 15.4.5.2, i.e. array that | 89 // changing array sizes as defined in EcmaScript 5.1 15.4.5.2, i.e. array that |
| 99 // have non-deletable elements can only be shrunk to the size of highest | 90 // have non-deletable elements can only be shrunk to the size of highest |
| 100 // element that is non-deletable. | 91 // element that is non-deletable. |
| 101 MUST_USE_RESULT virtual MaybeHandle<Object> SetLength( | 92 MUST_USE_RESULT virtual MaybeHandle<Object> SetLength( |
| 102 Handle<JSArray> holder, | 93 Handle<JSArray> holder, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 int copy_size) = 0; | 142 int copy_size) = 0; |
| 152 | 143 |
| 153 inline void CopyElements( | 144 inline void CopyElements( |
| 154 Handle<JSObject> from_holder, | 145 Handle<JSObject> from_holder, |
| 155 Handle<FixedArrayBase> to, | 146 Handle<FixedArrayBase> to, |
| 156 ElementsKind from_kind) { | 147 ElementsKind from_kind) { |
| 157 CopyElements( | 148 CopyElements( |
| 158 *from_holder, 0, from_kind, to, 0, kCopyToEndAndInitializeToHole); | 149 *from_holder, 0, from_kind, to, 0, kCopyToEndAndInitializeToHole); |
| 159 } | 150 } |
| 160 | 151 |
| 161 MUST_USE_RESULT virtual MaybeHandle<FixedArray> AddElementsToFixedArray( | 152 virtual Handle<FixedArray> AddElementsToFixedArray( |
| 162 Handle<JSObject> receiver, Handle<FixedArray> to, | 153 Handle<JSObject> receiver, Handle<FixedArray> to, |
| 163 FixedArray::KeyFilter filter) = 0; | 154 FixedArray::KeyFilter filter) = 0; |
| 164 | 155 |
| 165 // Returns a shared ElementsAccessor for the specified ElementsKind. | 156 // Returns a shared ElementsAccessor for the specified ElementsKind. |
| 166 static ElementsAccessor* ForKind(ElementsKind elements_kind) { | 157 static ElementsAccessor* ForKind(ElementsKind elements_kind) { |
| 167 DCHECK(static_cast<int>(elements_kind) < kElementsKindCount); | 158 DCHECK(static_cast<int>(elements_kind) < kElementsKindCount); |
| 168 return elements_accessors_[elements_kind]; | 159 return elements_accessors_[elements_kind]; |
| 169 } | 160 } |
| 170 | 161 |
| 171 static ElementsAccessor* ForArray(Handle<FixedArrayBase> array); | 162 static ElementsAccessor* ForArray(Handle<FixedArrayBase> array); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, | 198 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, |
| 208 bool allow_appending = false); | 199 bool allow_appending = false); |
| 209 | 200 |
| 210 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( | 201 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( |
| 211 Handle<JSArray> array, | 202 Handle<JSArray> array, |
| 212 Arguments* args); | 203 Arguments* args); |
| 213 | 204 |
| 214 } } // namespace v8::internal | 205 } } // namespace v8::internal |
| 215 | 206 |
| 216 #endif // V8_ELEMENTS_H_ | 207 #endif // V8_ELEMENTS_H_ |
| OLD | NEW |