Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: src/elements.h

Issue 1767113004: [esnext] handle elements in FastObjectValuesOrEntries() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make ElementsAccessor::GetCapacity() public, and use it Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/elements.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 inline void CollectElementIndices(Handle<JSObject> object, 89 inline void CollectElementIndices(Handle<JSObject> object,
90 KeyAccumulator* keys, 90 KeyAccumulator* keys,
91 uint32_t range = kMaxUInt32, 91 uint32_t range = kMaxUInt32,
92 PropertyFilter filter = ALL_PROPERTIES, 92 PropertyFilter filter = ALL_PROPERTIES,
93 uint32_t offset = 0) { 93 uint32_t offset = 0) {
94 CollectElementIndices(object, handle(object->elements()), keys, range, 94 CollectElementIndices(object, handle(object->elements()), keys, range,
95 filter, offset); 95 filter, offset);
96 } 96 }
97 97
98 virtual Maybe<bool> CollectValuesOrEntries(
99 Isolate* isolate, Handle<JSObject> object,
100 Handle<FixedArray> values_or_entries, bool get_entries, int* nof_items,
101 PropertyFilter filter = ALL_PROPERTIES) = 0;
102
98 // 103 //
99 virtual Handle<FixedArray> PrependElementIndices( 104 virtual Handle<FixedArray> PrependElementIndices(
100 Handle<JSObject> object, Handle<FixedArrayBase> backing_store, 105 Handle<JSObject> object, Handle<FixedArrayBase> backing_store,
101 Handle<FixedArray> keys, GetKeysConversion convert, 106 Handle<FixedArray> keys, GetKeysConversion convert,
102 PropertyFilter filter = ALL_PROPERTIES) = 0; 107 PropertyFilter filter = ALL_PROPERTIES) = 0;
103 108
104 inline Handle<FixedArray> PrependElementIndices( 109 inline Handle<FixedArray> PrependElementIndices(
105 Handle<JSObject> object, Handle<FixedArray> keys, 110 Handle<JSObject> object, Handle<FixedArray> keys,
106 GetKeysConversion convert, PropertyFilter filter = ALL_PROPERTIES) { 111 GetKeysConversion convert, PropertyFilter filter = ALL_PROPERTIES) {
107 return PrependElementIndices(object, handle(object->elements()), keys, 112 return PrependElementIndices(object, handle(object->elements()), keys,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 virtual Handle<JSArray> Splice(Handle<JSArray> receiver, 149 virtual Handle<JSArray> Splice(Handle<JSArray> receiver,
145 uint32_t start, uint32_t delete_count, 150 uint32_t start, uint32_t delete_count,
146 Arguments* args, uint32_t add_count) = 0; 151 Arguments* args, uint32_t add_count) = 0;
147 152
148 virtual Handle<Object> Pop(Handle<JSArray> receiver) = 0; 153 virtual Handle<Object> Pop(Handle<JSArray> receiver) = 0;
149 154
150 virtual Handle<Object> Shift(Handle<JSArray> receiver) = 0; 155 virtual Handle<Object> Shift(Handle<JSArray> receiver) = 0;
151 156
152 virtual Handle<SeededNumberDictionary> Normalize(Handle<JSObject> object) = 0; 157 virtual Handle<SeededNumberDictionary> Normalize(Handle<JSObject> object) = 0;
153 158
159 virtual uint32_t GetCapacity(JSObject* holder,
160 FixedArrayBase* backing_store) = 0;
161
154 protected: 162 protected:
155 friend class LookupIterator; 163 friend class LookupIterator;
156 164
157 // Element handlers distinguish between entries and indices when they 165 // Element handlers distinguish between entries and indices when they
158 // manipulate elements. Entries refer to elements in terms of their location 166 // manipulate elements. Entries refer to elements in terms of their location
159 // in the underlying storage's backing store representation, and are between 0 167 // in the underlying storage's backing store representation, and are between 0
160 // and GetCapacity. Indices refer to elements in terms of the value that would 168 // and GetCapacity. Indices refer to elements in terms of the value that would
161 // be specified in JavaScript to access the element. In most implementations, 169 // be specified in JavaScript to access the element. In most implementations,
162 // indices are equivalent to entries. In the NumberDictionary 170 // indices are equivalent to entries. In the NumberDictionary
163 // ElementsAccessor, entries are mapped to an index using the KeyAt method on 171 // ElementsAccessor, entries are mapped to an index using the KeyAt method on
164 // the NumberDictionary. 172 // the NumberDictionary.
165 virtual uint32_t GetEntryForIndex(JSObject* holder, 173 virtual uint32_t GetEntryForIndex(JSObject* holder,
166 FixedArrayBase* backing_store, 174 FixedArrayBase* backing_store,
167 uint32_t index) = 0; 175 uint32_t index) = 0;
168 176
169 // NOTE: this method violates the handlified function signature convention: 177 // NOTE: this method violates the handlified function signature convention:
170 // raw pointer parameter |source_holder| in the function that allocates. 178 // raw pointer parameter |source_holder| in the function that allocates.
171 // This is done intentionally to avoid ArrayConcat() builtin performance 179 // This is done intentionally to avoid ArrayConcat() builtin performance
172 // degradation. 180 // degradation.
173 virtual void CopyElements(JSObject* source_holder, uint32_t source_start, 181 virtual void CopyElements(JSObject* source_holder, uint32_t source_start,
174 ElementsKind source_kind, 182 ElementsKind source_kind,
175 Handle<FixedArrayBase> destination, 183 Handle<FixedArrayBase> destination,
176 uint32_t destination_start, int copy_size) = 0; 184 uint32_t destination_start, int copy_size) = 0;
177 185
178 private: 186 private:
179 virtual uint32_t GetCapacity(JSObject* holder,
180 FixedArrayBase* backing_store) = 0;
181 static ElementsAccessor** elements_accessors_; 187 static ElementsAccessor** elements_accessors_;
182 const char* name_; 188 const char* name_;
183 189
184 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); 190 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor);
185 }; 191 };
186 192
187 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t index, 193 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t index,
188 bool allow_appending = false); 194 bool allow_appending = false);
189 195
190 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( 196 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements(
191 Handle<JSArray> array, 197 Handle<JSArray> array,
192 Arguments* args); 198 Arguments* args);
193 199
194 } // namespace internal 200 } // namespace internal
195 } // namespace v8 201 } // namespace v8
196 202
197 #endif // V8_ELEMENTS_H_ 203 #endif // V8_ELEMENTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/elements.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698