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 20 matching lines...) Expand all Loading... |
31 // in the backing store to use for the check, which must be compatible with | 31 // in the backing store to use for the check, which must be compatible with |
32 // the ElementsKind of the ElementsAccessor. If backing_store is NULL, the | 32 // the ElementsKind of the ElementsAccessor. If backing_store is NULL, the |
33 // holder->elements() is used as the backing store. | 33 // holder->elements() is used as the backing store. |
34 virtual bool HasElement(Handle<JSObject> holder, uint32_t index, | 34 virtual bool HasElement(Handle<JSObject> holder, uint32_t index, |
35 Handle<FixedArrayBase> backing_store) = 0; | 35 Handle<FixedArrayBase> backing_store) = 0; |
36 | 36 |
37 inline bool HasElement(Handle<JSObject> holder, uint32_t index) { | 37 inline bool HasElement(Handle<JSObject> holder, uint32_t index) { |
38 return HasElement(holder, index, handle(holder->elements())); | 38 return HasElement(holder, index, handle(holder->elements())); |
39 } | 39 } |
40 | 40 |
| 41 // Returns true if the backing store is compact in the given range |
| 42 virtual bool IsPacked(Handle<JSObject> holder, |
| 43 Handle<FixedArrayBase> backing_store, uint32_t start, |
| 44 uint32_t end) = 0; |
| 45 |
41 virtual Handle<Object> Get(Handle<FixedArrayBase> backing_store, | 46 virtual Handle<Object> Get(Handle<FixedArrayBase> backing_store, |
42 uint32_t entry) = 0; | 47 uint32_t entry) = 0; |
43 | 48 |
44 // Modifies the length data property as specified for JSArrays and resizes the | 49 // Modifies the length data property as specified for JSArrays and resizes the |
45 // underlying backing store accordingly. The method honors the semantics of | 50 // underlying backing store accordingly. The method honors the semantics of |
46 // changing array sizes as defined in EcmaScript 5.1 15.4.5.2, i.e. array that | 51 // changing array sizes as defined in EcmaScript 5.1 15.4.5.2, i.e. array that |
47 // have non-deletable elements can only be shrunk to the size of highest | 52 // have non-deletable elements can only be shrunk to the size of highest |
48 // element that is non-deletable. | 53 // element that is non-deletable. |
49 virtual void SetLength(Handle<JSArray> holder, uint32_t new_length) = 0; | 54 virtual void SetLength(Handle<JSArray> holder, uint32_t new_length) = 0; |
50 | 55 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 virtual void Add(Handle<JSObject> object, uint32_t index, | 129 virtual void Add(Handle<JSObject> object, uint32_t index, |
125 Handle<Object> value, PropertyAttributes attributes, | 130 Handle<Object> value, PropertyAttributes attributes, |
126 uint32_t new_capacity) = 0; | 131 uint32_t new_capacity) = 0; |
127 | 132 |
128 // TODO(cbruni): Consider passing Arguments* instead of Object** depending on | 133 // TODO(cbruni): Consider passing Arguments* instead of Object** depending on |
129 // the requirements of future callers. | 134 // the requirements of future callers. |
130 virtual uint32_t Push(Handle<JSArray> receiver, | 135 virtual uint32_t Push(Handle<JSArray> receiver, |
131 Handle<FixedArrayBase> backing_store, Object** objects, | 136 Handle<FixedArrayBase> backing_store, Object** objects, |
132 uint32_t start, int direction) = 0; | 137 uint32_t start, int direction) = 0; |
133 | 138 |
| 139 virtual Handle<JSArray> Slice(Handle<JSObject> receiver, |
| 140 Handle<FixedArrayBase> backing_store, |
| 141 uint32_t start, uint32_t end) = 0; |
| 142 |
134 virtual Handle<JSArray> Splice(Handle<JSArray> receiver, | 143 virtual Handle<JSArray> Splice(Handle<JSArray> receiver, |
135 Handle<FixedArrayBase> backing_store, | 144 Handle<FixedArrayBase> backing_store, |
136 uint32_t start, uint32_t delete_count, | 145 uint32_t start, uint32_t delete_count, |
137 Arguments args, uint32_t add_count) = 0; | 146 Arguments args, uint32_t add_count) = 0; |
138 | 147 |
139 protected: | 148 protected: |
140 friend class LookupIterator; | 149 friend class LookupIterator; |
141 | 150 |
142 static ElementsAccessor* ForArray(FixedArrayBase* array); | 151 static ElementsAccessor* ForArray(FixedArrayBase* array); |
143 | 152 |
(...skipping 24 matching lines...) Expand all Loading... |
168 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t index, | 177 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t index, |
169 bool allow_appending = false); | 178 bool allow_appending = false); |
170 | 179 |
171 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( | 180 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( |
172 Handle<JSArray> array, | 181 Handle<JSArray> array, |
173 Arguments* args); | 182 Arguments* args); |
174 | 183 |
175 } } // namespace v8::internal | 184 } } // namespace v8::internal |
176 | 185 |
177 #endif // V8_ELEMENTS_H_ | 186 #endif // V8_ELEMENTS_H_ |
OLD | NEW |