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

Side by Side Diff: src/elements.cc

Issue 7904016: Refactoring: move HasElementAtKey to ElementsAccessor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 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 | « src/elements.h ('k') | src/objects.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return ElementsAccessorSubclass::GetCapacity( 184 return ElementsAccessorSubclass::GetCapacity(
185 BackingStoreClass::cast(backing_store)); 185 BackingStoreClass::cast(backing_store));
186 } 186 }
187 187
188 static bool HasElementAtIndex(BackingStoreClass* backing_store, 188 static bool HasElementAtIndex(BackingStoreClass* backing_store,
189 uint32_t index, 189 uint32_t index,
190 JSObject* holder, 190 JSObject* holder,
191 Object* receiver) { 191 Object* receiver) {
192 uint32_t key = 192 uint32_t key =
193 ElementsAccessorSubclass::GetKeyForIndex(backing_store, index); 193 ElementsAccessorSubclass::GetKeyForIndex(backing_store, index);
194 MaybeObject* element = ElementsAccessorSubclass::Get(backing_store, 194 return ElementsAccessorSubclass::HasElementAtKey(
195 key, 195 backing_store, key, holder, receiver);
196 holder,
197 receiver);
198 return !element->IsTheHole();
199 } 196 }
200 197
201 virtual bool HasElementAtIndex(FixedArrayBase* backing_store, 198 virtual bool HasElementAtIndex(FixedArrayBase* backing_store,
202 uint32_t index, 199 uint32_t index,
203 JSObject* holder, 200 JSObject* holder,
204 Object* receiver) { 201 Object* receiver) {
205 return ElementsAccessorSubclass::HasElementAtIndex( 202 return ElementsAccessorSubclass::HasElementAtIndex(
206 BackingStoreClass::cast(backing_store), index, holder, receiver); 203 BackingStoreClass::cast(backing_store), index, holder, receiver);
207 } 204 }
208 205
206 static bool HasElementAtKey(BackingStoreClass* backing_store,
207 uint32_t key,
208 JSObject* holder,
209 Object* receiver) {
210 MaybeObject* element = ElementsAccessorSubclass::Get(
211 backing_store, key, holder, receiver);
212 return !element->IsTheHole();
213 }
214
215 virtual bool HasElementAtKey(FixedArrayBase* backing_store,
216 uint32_t key,
217 JSObject* holder,
218 Object* receiver) {
219 return ElementsAccessorSubclass::HasElementAtKey(
220 BackingStoreClass::cast(backing_store), key, holder, receiver);
221 }
222
209 static uint32_t GetKeyForIndex(BackingStoreClass* backing_store, 223 static uint32_t GetKeyForIndex(BackingStoreClass* backing_store,
210 uint32_t index) { 224 uint32_t index) {
211 return index; 225 return index;
212 } 226 }
213 227
214 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, 228 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store,
215 uint32_t index) { 229 uint32_t index) {
216 return ElementsAccessorSubclass::GetKeyForIndex( 230 return ElementsAccessorSubclass::GetKeyForIndex(
217 BackingStoreClass::cast(backing_store), index); 231 BackingStoreClass::cast(backing_store), index);
218 } 232 }
219 233
220 private: 234 private:
221 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase); 235 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase);
222 }; 236 };
223 237
224 238
225 class FastElementsAccessor 239 class FastElementsAccessor
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 return backing_store->GetHeap()->undefined_value(); 340 return backing_store->GetHeap()->undefined_value();
327 } 341 }
328 } 342 }
329 343
330 virtual MaybeObject* Delete(JSObject* obj, 344 virtual MaybeObject* Delete(JSObject* obj,
331 uint32_t key, 345 uint32_t key,
332 JSReceiver::DeleteMode mode) { 346 JSReceiver::DeleteMode mode) {
333 // External arrays always ignore deletes. 347 // External arrays always ignore deletes.
334 return obj->GetHeap()->true_value(); 348 return obj->GetHeap()->true_value();
335 } 349 }
350
351 static bool HasElementAtKey(ExternalArray* backing_store,
352 uint32_t key,
353 JSObject* holder,
354 Object* receiver) {
355 return key < ExternalElementsAccessorSubclass::GetCapacity(backing_store);
356 }
336 }; 357 };
337 358
338 359
339 class ExternalByteElementsAccessor 360 class ExternalByteElementsAccessor
340 : public ExternalElementsAccessor<ExternalByteElementsAccessor, 361 : public ExternalElementsAccessor<ExternalByteElementsAccessor,
341 ExternalByteArray> { 362 ExternalByteArray> {
342 }; 363 };
343 364
344 365
345 class ExternalUnsignedByteElementsAccessor 366 class ExternalUnsignedByteElementsAccessor
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 &element_accessors.float_elements_handler, 646 &element_accessors.float_elements_handler,
626 &element_accessors.double_elements_handler, 647 &element_accessors.double_elements_handler,
627 &element_accessors.pixel_elements_handler 648 &element_accessors.pixel_elements_handler
628 }; 649 };
629 650
630 elements_accessors_ = accessor_array; 651 elements_accessors_ = accessor_array;
631 } 652 }
632 653
633 654
634 } } // namespace v8::internal 655 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698