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

Side by Side Diff: src/elements.cc

Issue 8551006: Version 3.7.9. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 1 month 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/codegen.h ('k') | src/extensions/gc-extension.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 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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 case EXTERNAL_PIXEL_ARRAY_TYPE: 794 case EXTERNAL_PIXEL_ARRAY_TYPE:
795 return elements_accessors_[EXTERNAL_PIXEL_ELEMENTS]; 795 return elements_accessors_[EXTERNAL_PIXEL_ELEMENTS];
796 default: 796 default:
797 UNREACHABLE(); 797 UNREACHABLE();
798 return NULL; 798 return NULL;
799 } 799 }
800 } 800 }
801 801
802 802
803 void ElementsAccessor::InitializeOncePerProcess() { 803 void ElementsAccessor::InitializeOncePerProcess() {
804 // First argument in list is the accessor class, the second argument is can
805 // be any arbitrary unique identifier, in this case chosen to be the
806 // corresponding enum. Use the fast element handler for smi-only arrays.
807 // The implementation is currently identical. Note that the order must match
808 // that of the ElementsKind enum for the |accessor_array[]| below to work.
809 #define ELEMENTS_LIST(V) \
810 V(FastObjectElementsAccessor, FAST_SMI_ONLY_ELEMENTS) \
811 V(FastObjectElementsAccessor, FAST_ELEMENTS) \
812 V(FastDoubleElementsAccessor, FAST_DOUBLE_ELEMENTS) \
813 V(DictionaryElementsAccessor, DICTIONARY_ELEMENTS) \
814 V(NonStrictArgumentsElementsAccessor, NON_STRICT_ARGUMENTS_ELEMENTS) \
815 V(ExternalByteElementsAccessor, EXTERNAL_BYTE_ELEMENTS) \
816 V(ExternalUnsignedByteElementsAccessor, EXTERNAL_UNSIGNED_BYTE_ELEMENTS) \
817 V(ExternalShortElementsAccessor, EXTERNAL_SHORT_ELEMENTS) \
818 V(ExternalUnsignedShortElementsAccessor, EXTERNAL_UNSIGNED_SHORT_ELEMENTS) \
819 V(ExternalIntElementsAccessor, EXTERNAL_INT_ELEMENTS) \
820 V(ExternalUnsignedIntElementsAccessor, EXTERNAL_UNSIGNED_INT_ELEMENTS) \
821 V(ExternalFloatElementsAccessor, EXTERNAL_FLOAT_ELEMENTS) \
822 V(ExternalDoubleElementsAccessor, EXTERNAL_DOUBLE_ELEMENTS) \
823 V(PixelElementsAccessor, EXTERNAL_PIXEL_ELEMENTS)
824
804 static struct ConcreteElementsAccessors { 825 static struct ConcreteElementsAccessors {
805 // Use the fast element handler for smi-only arrays. The implementation is 826 #define ACCESSOR_STRUCT(Class, Name) Class* Name##_handler;
806 // currently identical. 827 ELEMENTS_LIST(ACCESSOR_STRUCT)
807 FastObjectElementsAccessor fast_smi_elements_handler; 828 #undef ACCESSOR_STRUCT
808 FastObjectElementsAccessor fast_elements_handler; 829 } element_accessors = {
809 FastDoubleElementsAccessor fast_double_elements_handler; 830 #define ACCESSOR_INIT(Class, Name) new Class(),
810 DictionaryElementsAccessor dictionary_elements_handler; 831 ELEMENTS_LIST(ACCESSOR_INIT)
811 NonStrictArgumentsElementsAccessor non_strict_arguments_elements_handler; 832 #undef ACCESSOR_INIT
812 ExternalByteElementsAccessor byte_elements_handler; 833 };
813 ExternalUnsignedByteElementsAccessor unsigned_byte_elements_handler;
814 ExternalShortElementsAccessor short_elements_handler;
815 ExternalUnsignedShortElementsAccessor unsigned_short_elements_handler;
816 ExternalIntElementsAccessor int_elements_handler;
817 ExternalUnsignedIntElementsAccessor unsigned_int_elements_handler;
818 ExternalFloatElementsAccessor float_elements_handler;
819 ExternalDoubleElementsAccessor double_elements_handler;
820 PixelElementsAccessor pixel_elements_handler;
821 } element_accessors;
822 834
823 static ElementsAccessor* accessor_array[] = { 835 static ElementsAccessor* accessor_array[] = {
824 &element_accessors.fast_smi_elements_handler, 836 #define ACCESSOR_ARRAY(Class, Name) element_accessors.Name##_handler,
825 &element_accessors.fast_elements_handler, 837 ELEMENTS_LIST(ACCESSOR_ARRAY)
826 &element_accessors.fast_double_elements_handler, 838 #undef ACCESSOR_ARRAY
827 &element_accessors.dictionary_elements_handler,
828 &element_accessors.non_strict_arguments_elements_handler,
829 &element_accessors.byte_elements_handler,
830 &element_accessors.unsigned_byte_elements_handler,
831 &element_accessors.short_elements_handler,
832 &element_accessors.unsigned_short_elements_handler,
833 &element_accessors.int_elements_handler,
834 &element_accessors.unsigned_int_elements_handler,
835 &element_accessors.float_elements_handler,
836 &element_accessors.double_elements_handler,
837 &element_accessors.pixel_elements_handler
838 }; 839 };
839 840
841 #undef ELEMENTS_LIST
842
840 STATIC_ASSERT((sizeof(accessor_array) / sizeof(*accessor_array)) == 843 STATIC_ASSERT((sizeof(accessor_array) / sizeof(*accessor_array)) ==
841 kElementsKindCount); 844 kElementsKindCount);
842 845
843 elements_accessors_ = accessor_array; 846 elements_accessors_ = accessor_array;
844 } 847 }
845 848
846 849
847 template <typename ElementsAccessorSubclass, typename BackingStoreClass> 850 template <typename ElementsAccessorSubclass, typename BackingStoreClass>
848 MaybeObject* ElementsAccessorBase<ElementsAccessorSubclass, BackingStoreClass>:: 851 MaybeObject* ElementsAccessorBase<ElementsAccessorSubclass, BackingStoreClass>::
849 SetLength(BackingStoreClass* backing_store, 852 SetLength(BackingStoreClass* backing_store,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 FixedArray* new_backing_store; 899 FixedArray* new_backing_store;
897 MaybeObject* maybe_obj = array->GetHeap()->AllocateFixedArray(1); 900 MaybeObject* maybe_obj = array->GetHeap()->AllocateFixedArray(1);
898 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; 901 if (!maybe_obj->To(&new_backing_store)) return maybe_obj;
899 new_backing_store->set(0, length); 902 new_backing_store->set(0, length);
900 array->SetContent(new_backing_store); 903 array->SetContent(new_backing_store);
901 return array; 904 return array;
902 } 905 }
903 906
904 907
905 } } // namespace v8::internal 908 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/codegen.h ('k') | src/extensions/gc-extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698