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

Side by Side Diff: src/elements.cc

Issue 7901016: Basic support for tracking smi-only arrays on ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ready to land 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
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 private: 220 private:
221 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase); 221 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase);
222 }; 222 };
223 223
224 224
225 class FastElementsAccessor 225 class FastElementsAccessor
226 : public ElementsAccessorBase<FastElementsAccessor, FixedArray> { 226 : public ElementsAccessorBase<FastElementsAccessor, FixedArray> {
227 public: 227 public:
228 static MaybeObject* DeleteCommon(JSObject* obj, 228 static MaybeObject* DeleteCommon(JSObject* obj,
229 uint32_t key) { 229 uint32_t key) {
230 ASSERT(obj->HasFastElements() || obj->HasFastArgumentsElements()); 230 ASSERT(obj->HasFastElements() ||
231 obj->HasFastSmiOnlyElements() ||
232 obj->HasFastArgumentsElements());
231 Heap* heap = obj->GetHeap(); 233 Heap* heap = obj->GetHeap();
232 FixedArray* backing_store = FixedArray::cast(obj->elements()); 234 FixedArray* backing_store = FixedArray::cast(obj->elements());
233 if (backing_store->map() == heap->non_strict_arguments_elements_map()) { 235 if (backing_store->map() == heap->non_strict_arguments_elements_map()) {
234 backing_store = FixedArray::cast(backing_store->get(1)); 236 backing_store = FixedArray::cast(backing_store->get(1));
235 } else { 237 } else {
236 Object* writable; 238 Object* writable;
237 MaybeObject* maybe = obj->EnsureWritableFastElements(); 239 MaybeObject* maybe = obj->EnsureWritableFastElements();
238 if (!maybe->ToObject(&writable)) return maybe; 240 if (!maybe->ToObject(&writable)) return maybe;
239 backing_store = FixedArray::cast(writable); 241 backing_store = FixedArray::cast(writable);
240 } 242 }
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 return elements_accessors_[EXTERNAL_PIXEL_ELEMENTS]; 591 return elements_accessors_[EXTERNAL_PIXEL_ELEMENTS];
590 default: 592 default:
591 UNREACHABLE(); 593 UNREACHABLE();
592 return NULL; 594 return NULL;
593 } 595 }
594 } 596 }
595 597
596 598
597 void ElementsAccessor::InitializeOncePerProcess() { 599 void ElementsAccessor::InitializeOncePerProcess() {
598 static struct ConcreteElementsAccessors { 600 static struct ConcreteElementsAccessors {
601 // Use the fast element handler for smi-only arrays. The implementation is
602 // currently identical.
603 FastElementsAccessor fast_smi_elements_handler;
599 FastElementsAccessor fast_elements_handler; 604 FastElementsAccessor fast_elements_handler;
600 FastDoubleElementsAccessor fast_double_elements_handler; 605 FastDoubleElementsAccessor fast_double_elements_handler;
601 DictionaryElementsAccessor dictionary_elements_handler; 606 DictionaryElementsAccessor dictionary_elements_handler;
602 NonStrictArgumentsElementsAccessor non_strict_arguments_elements_handler; 607 NonStrictArgumentsElementsAccessor non_strict_arguments_elements_handler;
603 ExternalByteElementsAccessor byte_elements_handler; 608 ExternalByteElementsAccessor byte_elements_handler;
604 ExternalUnsignedByteElementsAccessor unsigned_byte_elements_handler; 609 ExternalUnsignedByteElementsAccessor unsigned_byte_elements_handler;
605 ExternalShortElementsAccessor short_elements_handler; 610 ExternalShortElementsAccessor short_elements_handler;
606 ExternalUnsignedShortElementsAccessor unsigned_short_elements_handler; 611 ExternalUnsignedShortElementsAccessor unsigned_short_elements_handler;
607 ExternalIntElementsAccessor int_elements_handler; 612 ExternalIntElementsAccessor int_elements_handler;
608 ExternalUnsignedIntElementsAccessor unsigned_int_elements_handler; 613 ExternalUnsignedIntElementsAccessor unsigned_int_elements_handler;
609 ExternalFloatElementsAccessor float_elements_handler; 614 ExternalFloatElementsAccessor float_elements_handler;
610 ExternalDoubleElementsAccessor double_elements_handler; 615 ExternalDoubleElementsAccessor double_elements_handler;
611 PixelElementsAccessor pixel_elements_handler; 616 PixelElementsAccessor pixel_elements_handler;
612 } element_accessors; 617 } element_accessors;
613 618
614 static ElementsAccessor* accessor_array[] = { 619 static ElementsAccessor* accessor_array[] = {
620 &element_accessors.fast_smi_elements_handler,
615 &element_accessors.fast_elements_handler, 621 &element_accessors.fast_elements_handler,
616 &element_accessors.fast_double_elements_handler, 622 &element_accessors.fast_double_elements_handler,
617 &element_accessors.dictionary_elements_handler, 623 &element_accessors.dictionary_elements_handler,
618 &element_accessors.non_strict_arguments_elements_handler, 624 &element_accessors.non_strict_arguments_elements_handler,
619 &element_accessors.byte_elements_handler, 625 &element_accessors.byte_elements_handler,
620 &element_accessors.unsigned_byte_elements_handler, 626 &element_accessors.unsigned_byte_elements_handler,
621 &element_accessors.short_elements_handler, 627 &element_accessors.short_elements_handler,
622 &element_accessors.unsigned_short_elements_handler, 628 &element_accessors.unsigned_short_elements_handler,
623 &element_accessors.int_elements_handler, 629 &element_accessors.int_elements_handler,
624 &element_accessors.unsigned_int_elements_handler, 630 &element_accessors.unsigned_int_elements_handler,
625 &element_accessors.float_elements_handler, 631 &element_accessors.float_elements_handler,
626 &element_accessors.double_elements_handler, 632 &element_accessors.double_elements_handler,
627 &element_accessors.pixel_elements_handler 633 &element_accessors.pixel_elements_handler
628 }; 634 };
629 635
636 STATIC_ASSERT((sizeof(accessor_array) / sizeof(*accessor_array)) ==
637 kElementsKindCount);
638
630 elements_accessors_ = accessor_array; 639 elements_accessors_ = accessor_array;
631 } 640 }
632 641
633 642
634 } } // namespace v8::internal 643 } } // namespace v8::internal
OLDNEW
« src/bootstrapper.cc ('K') | « src/code-stubs.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698