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

Side by Side Diff: src/elements.h

Issue 225933002: ElementsAccessor's public interface handlification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // element. This method doesn't iterate up the prototype chain. The caller 72 // element. This method doesn't iterate up the prototype chain. The caller
73 // can optionally pass in the backing store to use for the check, which must 73 // can optionally pass in the backing store to use for the check, which must
74 // be compatible with the ElementsKind of the ElementsAccessor. If 74 // be compatible with the ElementsKind of the ElementsAccessor. If
75 // backing_store is NULL, the holder->elements() is used as the backing store. 75 // backing_store is NULL, the holder->elements() is used as the backing store.
76 MUST_USE_RESULT virtual Handle<Object> Get( 76 MUST_USE_RESULT virtual Handle<Object> Get(
77 Handle<Object> receiver, 77 Handle<Object> receiver,
78 Handle<JSObject> holder, 78 Handle<JSObject> holder,
79 uint32_t key, 79 uint32_t key,
80 Handle<FixedArrayBase> backing_store) = 0; 80 Handle<FixedArrayBase> backing_store) = 0;
81 81
82 MUST_USE_RESULT virtual Handle<Object> Get( 82 MUST_USE_RESULT inline Handle<Object> Get(
83 Handle<Object> receiver, 83 Handle<Object> receiver,
84 Handle<JSObject> holder, 84 Handle<JSObject> holder,
85 uint32_t key) = 0; 85 uint32_t key) {
86 86 return Get(receiver, holder, key, handle(holder->elements()));
87 MUST_USE_RESULT virtual MaybeObject* Get( 87 }
88 Object* receiver,
89 JSObject* holder,
90 uint32_t key,
91 FixedArrayBase* backing_store = NULL) = 0;
92 88
93 // Returns an element's attributes, or ABSENT if there is no such 89 // Returns an element's attributes, or ABSENT if there is no such
94 // element. This method doesn't iterate up the prototype chain. The caller 90 // element. This method doesn't iterate up the prototype chain. The caller
95 // can optionally pass in the backing store to use for the check, which must 91 // can optionally pass in the backing store to use for the check, which must
96 // be compatible with the ElementsKind of the ElementsAccessor. If 92 // be compatible with the ElementsKind of the ElementsAccessor. If
97 // backing_store is NULL, the holder->elements() is used as the backing store. 93 // backing_store is NULL, the holder->elements() is used as the backing store.
98 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( 94 MUST_USE_RESULT virtual PropertyAttributes GetAttributes(
99 Object* receiver, 95 Handle<Object> receiver,
100 JSObject* holder, 96 Handle<JSObject> holder,
101 uint32_t key, 97 uint32_t key,
102 FixedArrayBase* backing_store = NULL) = 0; 98 Handle<FixedArrayBase> backing_store) = 0;
99
100 MUST_USE_RESULT inline PropertyAttributes GetAttributes(
101 Handle<Object> receiver,
102 Handle<JSObject> holder,
103 uint32_t key) {
104 return GetAttributes(receiver, holder, key, handle(holder->elements()));
105 }
103 106
104 // Returns an element's type, or NONEXISTENT if there is no such 107 // Returns an element's type, or NONEXISTENT if there is no such
105 // element. This method doesn't iterate up the prototype chain. The caller 108 // element. This method doesn't iterate up the prototype chain. The caller
106 // can optionally pass in the backing store to use for the check, which must 109 // can optionally pass in the backing store to use for the check, which must
107 // be compatible with the ElementsKind of the ElementsAccessor. If 110 // be compatible with the ElementsKind of the ElementsAccessor. If
108 // backing_store is NULL, the holder->elements() is used as the backing store. 111 // backing_store is NULL, the holder->elements() is used as the backing store.
109 MUST_USE_RESULT virtual PropertyType GetType( 112 MUST_USE_RESULT virtual PropertyType GetType(
110 Object* receiver, 113 Handle<Object> receiver,
111 JSObject* holder, 114 Handle<JSObject> holder,
112 uint32_t key, 115 uint32_t key,
113 FixedArrayBase* backing_store = NULL) = 0; 116 Handle<FixedArrayBase> backing_store) = 0;
117
118 MUST_USE_RESULT inline PropertyType GetType(
119 Handle<Object> receiver,
120 Handle<JSObject> holder,
121 uint32_t key) {
122 return GetType(receiver, holder, key, handle(holder->elements()));
123 }
114 124
115 // Returns an element's accessors, or NULL if the element does not exist or 125 // Returns an element's accessors, or NULL if the element does not exist or
116 // is plain. This method doesn't iterate up the prototype chain. The caller 126 // is plain. This method doesn't iterate up the prototype chain. The caller
117 // can optionally pass in the backing store to use for the check, which must 127 // can optionally pass in the backing store to use for the check, which must
118 // be compatible with the ElementsKind of the ElementsAccessor. If 128 // be compatible with the ElementsKind of the ElementsAccessor. If
119 // backing_store is NULL, the holder->elements() is used as the backing store. 129 // backing_store is NULL, the holder->elements() is used as the backing store.
120 MUST_USE_RESULT virtual AccessorPair* GetAccessorPair( 130 MUST_USE_RESULT virtual AccessorPair* GetAccessorPair(
121 Object* receiver, 131 Object* receiver,
122 JSObject* holder, 132 JSObject* holder,
123 uint32_t key, 133 uint32_t key,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // elements. Indexes refer to elements in terms of their location in the 237 // elements. Indexes refer to elements in terms of their location in the
228 // underlying storage's backing store representation, and are between 0 and 238 // underlying storage's backing store representation, and are between 0 and
229 // GetCapacity. Keys refer to elements in terms of the value that would be 239 // GetCapacity. Keys refer to elements in terms of the value that would be
230 // specified in JavaScript to access the element. In most implementations, 240 // specified in JavaScript to access the element. In most implementations,
231 // keys are equivalent to indexes, and GetKeyForIndex returns the same value 241 // keys are equivalent to indexes, and GetKeyForIndex returns the same value
232 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps 242 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps
233 // the index to a key using the KeyAt method on the NumberDictionary. 243 // the index to a key using the KeyAt method on the NumberDictionary.
234 virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store, 244 virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store,
235 uint32_t index) = 0; 245 uint32_t index) = 0;
236 246
247 // TODO(ishell): Non-handlified versions, used only by accessors'
248 // implementations. To be removed once elements.cc is handlified.
249 MUST_USE_RESULT virtual MaybeObject* Get(
250 Object* receiver,
251 JSObject* holder,
252 uint32_t key,
253 FixedArrayBase* backing_store) = 0;
254
255 MUST_USE_RESULT virtual PropertyAttributes GetAttributes(
256 Object* receiver,
257 JSObject* holder,
258 uint32_t key,
259 FixedArrayBase* backing_store) = 0;
260
261 MUST_USE_RESULT virtual PropertyType GetType(
262 Object* receiver,
263 JSObject* holder,
264 uint32_t key,
265 FixedArrayBase* backing_store) = 0;
266
237 private: 267 private:
238 static ElementsAccessor** elements_accessors_; 268 static ElementsAccessor** elements_accessors_;
239 const char* name_; 269 const char* name_;
240 270
241 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); 271 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor);
242 }; 272 };
243 273
244 void CheckArrayAbuse(JSObject* obj, const char* op, uint32_t key, 274 void CheckArrayAbuse(JSObject* obj, const char* op, uint32_t key,
245 bool allow_appending = false); 275 bool allow_appending = false);
246 276
247 Handle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, 277 Handle<Object> ArrayConstructInitializeElements(Handle<JSArray> array,
248 Arguments* args); 278 Arguments* args);
249 279
250 } } // namespace v8::internal 280 } } // namespace v8::internal
251 281
252 #endif // V8_ELEMENTS_H_ 282 #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