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

Side by Side Diff: src/elements.h

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