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

Side by Side Diff: src/elements.h

Issue 228643003: Further ElementsAccessor handlification (GetKeyForIndex(), GetCapacity(), GetType() and GetAttribut… (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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return AddElementsToFixedArray( 219 return AddElementsToFixedArray(
220 receiver, holder, to, handle(holder->elements())); 220 receiver, holder, to, handle(holder->elements()));
221 } 221 }
222 222
223 // Returns a shared ElementsAccessor for the specified ElementsKind. 223 // Returns a shared ElementsAccessor for the specified ElementsKind.
224 static ElementsAccessor* ForKind(ElementsKind elements_kind) { 224 static ElementsAccessor* ForKind(ElementsKind elements_kind) {
225 ASSERT(elements_kind < kElementsKindCount); 225 ASSERT(elements_kind < kElementsKindCount);
226 return elements_accessors_[elements_kind]; 226 return elements_accessors_[elements_kind];
227 } 227 }
228 228
229 // TODO(ishell): Temporary wrapper until handlified. 229 static ElementsAccessor* ForArray(Handle<FixedArrayBase> array);
230 inline static ElementsAccessor* ForArray(Handle<FixedArrayBase> array) {
231 return ForArray(*array);
232 }
233 static ElementsAccessor* ForArray(FixedArrayBase* array);
234 230
235 static void InitializeOncePerProcess(); 231 static void InitializeOncePerProcess();
236 static void TearDown(); 232 static void TearDown();
237 233
238 protected: 234 protected:
239 friend class SloppyArgumentsElementsAccessor; 235 friend class SloppyArgumentsElementsAccessor;
240 236
241 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0; 237 virtual uint32_t GetCapacity(Handle<FixedArrayBase> backing_store) = 0;
242 238
243 // Element handlers distinguish between indexes and keys when they manipulate 239 // Element handlers distinguish between indexes and keys when they manipulate
244 // elements. Indexes refer to elements in terms of their location in the 240 // elements. Indexes refer to elements in terms of their location in the
245 // underlying storage's backing store representation, and are between 0 and 241 // underlying storage's backing store representation, and are between 0 and
246 // GetCapacity. Keys refer to elements in terms of the value that would be 242 // GetCapacity. Keys refer to elements in terms of the value that would be
247 // specified in JavaScript to access the element. In most implementations, 243 // specified in JavaScript to access the element. In most implementations,
248 // keys are equivalent to indexes, and GetKeyForIndex returns the same value 244 // keys are equivalent to indexes, and GetKeyForIndex returns the same value
249 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps 245 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps
250 // the index to a key using the KeyAt method on the NumberDictionary. 246 // the index to a key using the KeyAt method on the NumberDictionary.
251 virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store, 247 virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store,
252 uint32_t index) = 0; 248 uint32_t index) = 0;
253 249
254 // TODO(ishell): Non-handlified versions, used only by accessors'
255 // implementations. To be removed once elements.cc is handlified.
256 MUST_USE_RESULT virtual PropertyAttributes GetAttributes(
257 Object* receiver,
258 JSObject* holder,
259 uint32_t key,
260 FixedArrayBase* backing_store) = 0;
261
262 MUST_USE_RESULT virtual PropertyType GetType(
263 Object* receiver,
264 JSObject* holder,
265 uint32_t key,
266 FixedArrayBase* backing_store) = 0;
267
268 private: 250 private:
269 static ElementsAccessor** elements_accessors_; 251 static ElementsAccessor** elements_accessors_;
270 const char* name_; 252 const char* name_;
271 253
272 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); 254 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor);
273 }; 255 };
274 256
275 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, 257 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key,
276 bool allow_appending = false); 258 bool allow_appending = false);
277 259
278 Handle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, 260 Handle<Object> ArrayConstructInitializeElements(Handle<JSArray> array,
279 Arguments* args); 261 Arguments* args);
280 262
281 } } // namespace v8::internal 263 } } // namespace v8::internal
282 264
283 #endif // V8_ELEMENTS_H_ 265 #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