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

Side by Side Diff: src/elements.h

Issue 1397063002: [runtime] Fancify KeyAccumulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding KeyAccumulator destructor Created 5 years, 2 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') | src/objects.h » ('J')
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 14 matching lines...) Expand all
25 // Checks the elements of an object for consistency, asserting when a problem 25 // Checks the elements of an object for consistency, asserting when a problem
26 // is found. 26 // is found.
27 virtual void Validate(Handle<JSObject> obj) = 0; 27 virtual void Validate(Handle<JSObject> obj) = 0;
28 28
29 // Returns true if a holder contains an element with the specified index 29 // Returns true if a holder contains an element with the specified index
30 // without iterating up the prototype chain. The caller can optionally pass 30 // without iterating up the prototype chain. The caller can optionally pass
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,
36 PropertyAttributes filter = NONE) = 0;
Igor Sheludko 2015/10/15 09:51:43 Please add a comment about filter parameter. How e
36 37
37 inline bool HasElement(Handle<JSObject> holder, uint32_t index) { 38 inline bool HasElement(Handle<JSObject> holder, uint32_t index,
38 return HasElement(holder, index, handle(holder->elements())); 39 PropertyAttributes filter = NONE) {
40 return HasElement(holder, index, handle(holder->elements()), filter);
39 } 41 }
40 42
41 // Returns true if the backing store is compact in the given range 43 // Returns true if the backing store is compact in the given range
42 virtual bool IsPacked(Handle<JSObject> holder, 44 virtual bool IsPacked(Handle<JSObject> holder,
43 Handle<FixedArrayBase> backing_store, uint32_t start, 45 Handle<FixedArrayBase> backing_store, uint32_t start,
44 uint32_t end) = 0; 46 uint32_t end) = 0;
45 47
46 virtual Handle<Object> Get(Handle<FixedArrayBase> backing_store, 48 virtual Handle<Object> Get(Handle<FixedArrayBase> backing_store,
47 uint32_t entry) = 0; 49 uint32_t entry) = 0;
48 50
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 ElementsKind from_kind) { 97 ElementsKind from_kind) {
96 CopyElements( 98 CopyElements(
97 *from_holder, 0, from_kind, to, 0, kCopyToEndAndInitializeToHole); 99 *from_holder, 0, from_kind, to, 0, kCopyToEndAndInitializeToHole);
98 } 100 }
99 101
100 virtual void GrowCapacityAndConvert(Handle<JSObject> object, 102 virtual void GrowCapacityAndConvert(Handle<JSObject> object,
101 uint32_t capacity) = 0; 103 uint32_t capacity) = 0;
102 104
103 virtual void AddElementsToKeyAccumulator(Handle<JSObject> receiver, 105 virtual void AddElementsToKeyAccumulator(Handle<JSObject> receiver,
104 KeyAccumulator* accumulator, 106 KeyAccumulator* accumulator,
105 KeyFilter filter) = 0; 107 AddKeyConversion convert) = 0;
106 108
107 // Returns a shared ElementsAccessor for the specified ElementsKind. 109 // Returns a shared ElementsAccessor for the specified ElementsKind.
108 static ElementsAccessor* ForKind(ElementsKind elements_kind) { 110 static ElementsAccessor* ForKind(ElementsKind elements_kind) {
109 DCHECK(static_cast<int>(elements_kind) < kElementsKindCount); 111 DCHECK(static_cast<int>(elements_kind) < kElementsKindCount);
110 return elements_accessors_[elements_kind]; 112 return elements_accessors_[elements_kind];
111 } 113 }
112 114
113 static ElementsAccessor* ForArray(Handle<FixedArrayBase> array); 115 static ElementsAccessor* ForArray(Handle<FixedArrayBase> array);
114 116
115 static void InitializeOncePerProcess(); 117 static void InitializeOncePerProcess();
(...skipping 30 matching lines...) Expand all
146 Handle<FixedArrayBase> backing_store, 148 Handle<FixedArrayBase> backing_store,
147 uint32_t start, uint32_t delete_count, 149 uint32_t start, uint32_t delete_count,
148 Arguments* args, uint32_t add_count) = 0; 150 Arguments* args, uint32_t add_count) = 0;
149 151
150 virtual Handle<Object> Pop(Handle<JSArray> receiver, 152 virtual Handle<Object> Pop(Handle<JSArray> receiver,
151 Handle<FixedArrayBase> backing_store) = 0; 153 Handle<FixedArrayBase> backing_store) = 0;
152 154
153 virtual Handle<Object> Shift(Handle<JSArray> receiver, 155 virtual Handle<Object> Shift(Handle<JSArray> receiver,
154 Handle<FixedArrayBase> backing_store) = 0; 156 Handle<FixedArrayBase> backing_store) = 0;
155 157
158 virtual uint32_t GetCapacity(JSObject* holder,
159 FixedArrayBase* backing_store) = 0;
160
156 protected: 161 protected:
157 friend class LookupIterator; 162 friend class LookupIterator;
158 163
159 static ElementsAccessor* ForArray(FixedArrayBase* array); 164 static ElementsAccessor* ForArray(FixedArrayBase* array);
160 165
161 virtual uint32_t GetCapacity(JSObject* holder,
162 FixedArrayBase* backing_store) = 0;
163 166
164 // Element handlers distinguish between entries and indices when they 167 // Element handlers distinguish between entries and indices when they
165 // manipulate elements. Entries refer to elements in terms of their location 168 // manipulate elements. Entries refer to elements in terms of their location
166 // in the underlying storage's backing store representation, and are between 0 169 // in the underlying storage's backing store representation, and are between 0
167 // and GetCapacity. Indices refer to elements in terms of the value that would 170 // and GetCapacity. Indices refer to elements in terms of the value that would
168 // be specified in JavaScript to access the element. In most implementations, 171 // be specified in JavaScript to access the element. In most implementations,
169 // indices are equivalent to entries. In the NumberDictionary 172 // indices are equivalent to entries. In the NumberDictionary
170 // ElementsAccessor, entries are mapped to an index using the KeyAt method on 173 // ElementsAccessor, entries are mapped to an index using the KeyAt method on
171 // the NumberDictionary. 174 // the NumberDictionary.
172 virtual uint32_t GetEntryForIndex(JSObject* holder, 175 virtual uint32_t GetEntryForIndex(JSObject* holder,
(...skipping 13 matching lines...) Expand all
186 bool allow_appending = false); 189 bool allow_appending = false);
187 190
188 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( 191 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements(
189 Handle<JSArray> array, 192 Handle<JSArray> array,
190 Arguments* args); 193 Arguments* args);
191 194
192 } // namespace internal 195 } // namespace internal
193 } // namespace v8 196 } // namespace v8
194 197
195 #endif // V8_ELEMENTS_H_ 198 #endif // V8_ELEMENTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/elements.cc » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698