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

Side by Side Diff: src/objects.h

Issue 101413006: Implement in-heap backing store for typed arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: GC fixes Created 6 years, 11 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/ic.cc ('k') | src/objects.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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 /* Object::IsExternalArray(). */ \ 379 /* Object::IsExternalArray(). */ \
380 V(EXTERNAL_BYTE_ARRAY_TYPE) \ 380 V(EXTERNAL_BYTE_ARRAY_TYPE) \
381 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ 381 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \
382 V(EXTERNAL_SHORT_ARRAY_TYPE) \ 382 V(EXTERNAL_SHORT_ARRAY_TYPE) \
383 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ 383 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \
384 V(EXTERNAL_INT_ARRAY_TYPE) \ 384 V(EXTERNAL_INT_ARRAY_TYPE) \
385 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ 385 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \
386 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ 386 V(EXTERNAL_FLOAT_ARRAY_TYPE) \
387 V(EXTERNAL_DOUBLE_ARRAY_TYPE) \ 387 V(EXTERNAL_DOUBLE_ARRAY_TYPE) \
388 V(EXTERNAL_PIXEL_ARRAY_TYPE) \ 388 V(EXTERNAL_PIXEL_ARRAY_TYPE) \
389 \
390 V(FIXED_INT8_ARRAY_TYPE) \
391 V(FIXED_UINT8_ARRAY_TYPE) \
392 V(FIXED_INT16_ARRAY_TYPE) \
393 V(FIXED_UINT16_ARRAY_TYPE) \
394 V(FIXED_INT32_ARRAY_TYPE) \
395 V(FIXED_UINT32_ARRAY_TYPE) \
396 V(FIXED_FLOAT32_ARRAY_TYPE) \
397 V(FIXED_FLOAT64_ARRAY_TYPE) \
398 V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \
399 \
389 V(FILLER_TYPE) \ 400 V(FILLER_TYPE) \
390 \ 401 \
391 V(DECLARED_ACCESSOR_DESCRIPTOR_TYPE) \ 402 V(DECLARED_ACCESSOR_DESCRIPTOR_TYPE) \
392 V(DECLARED_ACCESSOR_INFO_TYPE) \ 403 V(DECLARED_ACCESSOR_INFO_TYPE) \
393 V(EXECUTABLE_ACCESSOR_INFO_TYPE) \ 404 V(EXECUTABLE_ACCESSOR_INFO_TYPE) \
394 V(ACCESSOR_PAIR_TYPE) \ 405 V(ACCESSOR_PAIR_TYPE) \
395 V(ACCESS_CHECK_INFO_TYPE) \ 406 V(ACCESS_CHECK_INFO_TYPE) \
396 V(INTERCEPTOR_INFO_TYPE) \ 407 V(INTERCEPTOR_INFO_TYPE) \
397 V(CALL_HANDLER_INFO_TYPE) \ 408 V(CALL_HANDLER_INFO_TYPE) \
398 V(FUNCTION_TEMPLATE_INFO_TYPE) \ 409 V(FUNCTION_TEMPLATE_INFO_TYPE) \
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 FREE_SPACE_TYPE, 724 FREE_SPACE_TYPE,
714 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE 725 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE
715 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, 726 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE,
716 EXTERNAL_SHORT_ARRAY_TYPE, 727 EXTERNAL_SHORT_ARRAY_TYPE,
717 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, 728 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE,
718 EXTERNAL_INT_ARRAY_TYPE, 729 EXTERNAL_INT_ARRAY_TYPE,
719 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, 730 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE,
720 EXTERNAL_FLOAT_ARRAY_TYPE, 731 EXTERNAL_FLOAT_ARRAY_TYPE,
721 EXTERNAL_DOUBLE_ARRAY_TYPE, 732 EXTERNAL_DOUBLE_ARRAY_TYPE,
722 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE 733 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE
734
735 FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE
736 FIXED_UINT8_ARRAY_TYPE,
737 FIXED_INT16_ARRAY_TYPE,
738 FIXED_UINT16_ARRAY_TYPE,
739 FIXED_INT32_ARRAY_TYPE,
740 FIXED_UINT32_ARRAY_TYPE,
741 FIXED_FLOAT32_ARRAY_TYPE,
742 FIXED_FLOAT64_ARRAY_TYPE,
743 FIXED_UINT8_CLAMPED_ARRAY_TYPE, // LAST_FIXED_TYPED_ARRAY_TYPE
744
723 FIXED_DOUBLE_ARRAY_TYPE, 745 FIXED_DOUBLE_ARRAY_TYPE,
724 FILLER_TYPE, // LAST_DATA_TYPE 746 FILLER_TYPE, // LAST_DATA_TYPE
725 747
726 // Structs. 748 // Structs.
727 DECLARED_ACCESSOR_DESCRIPTOR_TYPE, 749 DECLARED_ACCESSOR_DESCRIPTOR_TYPE,
728 DECLARED_ACCESSOR_INFO_TYPE, 750 DECLARED_ACCESSOR_INFO_TYPE,
729 EXECUTABLE_ACCESSOR_INFO_TYPE, 751 EXECUTABLE_ACCESSOR_INFO_TYPE,
730 ACCESSOR_PAIR_TYPE, 752 ACCESSOR_PAIR_TYPE,
731 ACCESS_CHECK_INFO_TYPE, 753 ACCESS_CHECK_INFO_TYPE,
732 INTERCEPTOR_INFO_TYPE, 754 INTERCEPTOR_INFO_TYPE,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 FIRST_TYPE = 0x0, 812 FIRST_TYPE = 0x0,
791 LAST_TYPE = JS_FUNCTION_TYPE, 813 LAST_TYPE = JS_FUNCTION_TYPE,
792 FIRST_NAME_TYPE = FIRST_TYPE, 814 FIRST_NAME_TYPE = FIRST_TYPE,
793 LAST_NAME_TYPE = SYMBOL_TYPE, 815 LAST_NAME_TYPE = SYMBOL_TYPE,
794 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE, 816 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE,
795 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE, 817 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE,
796 FIRST_NONSTRING_TYPE = SYMBOL_TYPE, 818 FIRST_NONSTRING_TYPE = SYMBOL_TYPE,
797 // Boundaries for testing for an external array. 819 // Boundaries for testing for an external array.
798 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, 820 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE,
799 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE, 821 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE,
822 // Boundaries for testing for a fixed typed array.
823 FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE,
824 LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE,
800 // Boundary for promotion to old data space/old pointer space. 825 // Boundary for promotion to old data space/old pointer space.
801 LAST_DATA_TYPE = FILLER_TYPE, 826 LAST_DATA_TYPE = FILLER_TYPE,
802 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). 827 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy).
803 // Note that there is no range for JSObject or JSProxy, since their subtypes 828 // Note that there is no range for JSObject or JSProxy, since their subtypes
804 // are not continuous in this enum! The enum ranges instead reflect the 829 // are not continuous in this enum! The enum ranges instead reflect the
805 // external class names, where proxies are treated as either ordinary objects, 830 // external class names, where proxies are treated as either ordinary objects,
806 // or functions. 831 // or functions.
807 FIRST_JS_RECEIVER_TYPE = JS_FUNCTION_PROXY_TYPE, 832 FIRST_JS_RECEIVER_TYPE = JS_FUNCTION_PROXY_TYPE,
808 LAST_JS_RECEIVER_TYPE = LAST_TYPE, 833 LAST_JS_RECEIVER_TYPE = LAST_TYPE,
809 // Boundaries for testing the types represented as JSObject 834 // Boundaries for testing the types represented as JSObject
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 V(ExternalArray) \ 1007 V(ExternalArray) \
983 V(ExternalByteArray) \ 1008 V(ExternalByteArray) \
984 V(ExternalUnsignedByteArray) \ 1009 V(ExternalUnsignedByteArray) \
985 V(ExternalShortArray) \ 1010 V(ExternalShortArray) \
986 V(ExternalUnsignedShortArray) \ 1011 V(ExternalUnsignedShortArray) \
987 V(ExternalIntArray) \ 1012 V(ExternalIntArray) \
988 V(ExternalUnsignedIntArray) \ 1013 V(ExternalUnsignedIntArray) \
989 V(ExternalFloatArray) \ 1014 V(ExternalFloatArray) \
990 V(ExternalDoubleArray) \ 1015 V(ExternalDoubleArray) \
991 V(ExternalPixelArray) \ 1016 V(ExternalPixelArray) \
1017 V(FixedTypedArrayBase) \
1018 V(FixedUint8Array) \
1019 V(FixedInt8Array) \
1020 V(FixedUint16Array) \
1021 V(FixedInt16Array) \
1022 V(FixedUint32Array) \
1023 V(FixedInt32Array) \
1024 V(FixedFloat32Array) \
1025 V(FixedFloat64Array) \
1026 V(FixedUint8ClampedArray) \
992 V(ByteArray) \ 1027 V(ByteArray) \
993 V(FreeSpace) \ 1028 V(FreeSpace) \
994 V(JSReceiver) \ 1029 V(JSReceiver) \
995 V(JSObject) \ 1030 V(JSObject) \
996 V(JSContextExtensionObject) \ 1031 V(JSContextExtensionObject) \
997 V(JSGeneratorObject) \ 1032 V(JSGeneratorObject) \
998 V(JSModule) \ 1033 V(JSModule) \
999 V(Map) \ 1034 V(Map) \
1000 V(DescriptorArray) \ 1035 V(DescriptorArray) \
1001 V(TransitionArray) \ 1036 V(TransitionArray) \
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 // Returns true if an object has any of the fast elements kinds. 2137 // Returns true if an object has any of the fast elements kinds.
2103 inline bool HasFastElements(); 2138 inline bool HasFastElements();
2104 // Returns true if an object has elements of FAST_DOUBLE_ELEMENTS 2139 // Returns true if an object has elements of FAST_DOUBLE_ELEMENTS
2105 // ElementsKind. 2140 // ElementsKind.
2106 inline bool HasFastDoubleElements(); 2141 inline bool HasFastDoubleElements();
2107 // Returns true if an object has elements of FAST_HOLEY_*_ELEMENTS 2142 // Returns true if an object has elements of FAST_HOLEY_*_ELEMENTS
2108 // ElementsKind. 2143 // ElementsKind.
2109 inline bool HasFastHoleyElements(); 2144 inline bool HasFastHoleyElements();
2110 inline bool HasNonStrictArgumentsElements(); 2145 inline bool HasNonStrictArgumentsElements();
2111 inline bool HasDictionaryElements(); 2146 inline bool HasDictionaryElements();
2147
2112 inline bool HasExternalPixelElements(); 2148 inline bool HasExternalPixelElements();
2113 inline bool HasExternalArrayElements(); 2149 inline bool HasExternalArrayElements();
2114 inline bool HasExternalByteElements(); 2150 inline bool HasExternalByteElements();
2115 inline bool HasExternalUnsignedByteElements(); 2151 inline bool HasExternalUnsignedByteElements();
2116 inline bool HasExternalShortElements(); 2152 inline bool HasExternalShortElements();
2117 inline bool HasExternalUnsignedShortElements(); 2153 inline bool HasExternalUnsignedShortElements();
2118 inline bool HasExternalIntElements(); 2154 inline bool HasExternalIntElements();
2119 inline bool HasExternalUnsignedIntElements(); 2155 inline bool HasExternalUnsignedIntElements();
2120 inline bool HasExternalFloatElements(); 2156 inline bool HasExternalFloatElements();
2121 inline bool HasExternalDoubleElements(); 2157 inline bool HasExternalDoubleElements();
2158
2159 inline bool HasFixedTypedArrayElements();
2160
2122 bool HasFastArgumentsElements(); 2161 bool HasFastArgumentsElements();
2123 bool HasDictionaryArgumentsElements(); 2162 bool HasDictionaryArgumentsElements();
2124 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. 2163 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements.
2125 2164
2126 inline void set_map_and_elements( 2165 inline void set_map_and_elements(
2127 Map* map, 2166 Map* map,
2128 FixedArrayBase* value, 2167 FixedArrayBase* value,
2129 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 2168 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
2130 2169
2131 // Requires: HasFastElements(). 2170 // Requires: HasFastElements().
(...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after
4821 4860
4822 // Dispatched behavior. 4861 // Dispatched behavior.
4823 DECLARE_PRINTER(ExternalDoubleArray) 4862 DECLARE_PRINTER(ExternalDoubleArray)
4824 DECLARE_VERIFIER(ExternalDoubleArray) 4863 DECLARE_VERIFIER(ExternalDoubleArray)
4825 4864
4826 private: 4865 private:
4827 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalDoubleArray); 4866 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalDoubleArray);
4828 }; 4867 };
4829 4868
4830 4869
4870 class FixedTypedArrayBase: public FixedArrayBase {
4871 public:
4872 // Casting:
4873 static inline FixedTypedArrayBase* cast(Object* obj);
4874
4875 static const int kDataOffset = kHeaderSize;
4876
4877 inline int size();
4878
4879 private:
4880 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArrayBase);
4881 };
4882
4883
4884 template <class Traits>
4885 class FixedTypedArray: public FixedTypedArrayBase {
4886 public:
4887 typedef typename Traits::ElementType ElementType;
4888 static const InstanceType kInstanceType = Traits::kInstanceType;
4889
4890 // Casting:
4891 static inline FixedTypedArray<Traits>* cast(Object* obj);
4892
4893 static inline int SizeFor(int length) {
4894 return kDataOffset + length * sizeof(ElementType);
4895 }
4896
4897 inline ElementType get_scalar(int index);
4898 MUST_USE_RESULT inline MaybeObject* get(int index);
4899 inline void set(int index, ElementType value);
4900
4901 // This accessor applies the correct conversion from Smi, HeapNumber
4902 // and undefined.
4903 MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value);
4904
4905 static Handle<Object> SetValue(Handle<FixedTypedArray<Traits> > array,
4906 uint32_t index,
4907 Handle<Object> value);
4908
4909 DECLARE_PRINTER(FixedTypedArray)
4910 DECLARE_VERIFIER(FixedTypedArray)
4911
4912 private:
4913 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray);
4914 };
4915
4916 #define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType) \
4917 class Type##ArrayTraits { \
4918 public: \
4919 typedef elementType ElementType; \
4920 static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \
4921 static const char* Designator() { return #type " array"; } \
4922 static inline MaybeObject* ToObject(Heap* heap, elementType scalar); \
4923 static elementType defaultValue() { return 0; } \
4924 }; \
4925 \
4926 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array;
4927
4928 FIXED_TYPED_ARRAY_TRAITS(Uint8, uint8, UINT8, uint8_t)
4929 FIXED_TYPED_ARRAY_TRAITS(Int8, int8, INT8, int8_t)
4930 FIXED_TYPED_ARRAY_TRAITS(Uint16, uint16, UINT16, uint16_t)
4931 FIXED_TYPED_ARRAY_TRAITS(Int16, int16, INT16, int16_t)
4932 FIXED_TYPED_ARRAY_TRAITS(Uint32, uint32, UINT32, uint32_t)
4933 FIXED_TYPED_ARRAY_TRAITS(Int32, int32, INT32, int32_t)
4934 FIXED_TYPED_ARRAY_TRAITS(Float32, float32, FLOAT32, float)
4935 FIXED_TYPED_ARRAY_TRAITS(Float64, float64, FLOAT64, double)
4936 FIXED_TYPED_ARRAY_TRAITS(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t)
4937
4938 #undef FIXED_TYPED_ARRAY_TRAITS
4939
4831 // DeoptimizationInputData is a fixed array used to hold the deoptimization 4940 // DeoptimizationInputData is a fixed array used to hold the deoptimization
4832 // data for code generated by the Hydrogen/Lithium compiler. It also 4941 // data for code generated by the Hydrogen/Lithium compiler. It also
4833 // contains information about functions that were inlined. If N different 4942 // contains information about functions that were inlined. If N different
4834 // functions were inlined then first N elements of the literal array will 4943 // functions were inlined then first N elements of the literal array will
4835 // contain these functions. 4944 // contain these functions.
4836 // 4945 //
4837 // It can be empty. 4946 // It can be empty.
4838 class DeoptimizationInputData: public FixedArray { 4947 class DeoptimizationInputData: public FixedArray {
4839 public: 4948 public:
4840 // Layout description. Indices in the array. 4949 // Layout description. Indices in the array.
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
5830 } 5939 }
5831 5940
5832 inline bool has_non_strict_arguments_elements() { 5941 inline bool has_non_strict_arguments_elements() {
5833 return elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS; 5942 return elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS;
5834 } 5943 }
5835 5944
5836 inline bool has_external_array_elements() { 5945 inline bool has_external_array_elements() {
5837 return IsExternalArrayElementsKind(elements_kind()); 5946 return IsExternalArrayElementsKind(elements_kind());
5838 } 5947 }
5839 5948
5949 inline bool has_fixed_typed_array_elements() {
5950 return IsFixedTypedArrayElementsKind(elements_kind());
5951 }
5952
5840 inline bool has_dictionary_elements() { 5953 inline bool has_dictionary_elements() {
5841 return IsDictionaryElementsKind(elements_kind()); 5954 return IsDictionaryElementsKind(elements_kind());
5842 } 5955 }
5843 5956
5844 inline bool has_slow_elements_kind() { 5957 inline bool has_slow_elements_kind() {
5845 return elements_kind() == DICTIONARY_ELEMENTS 5958 return elements_kind() == DICTIONARY_ELEMENTS
5846 || elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS; 5959 || elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS;
5847 } 5960 }
5848 5961
5849 static bool IsValidElementsTransition(ElementsKind from_kind, 5962 static bool IsValidElementsTransition(ElementsKind from_kind,
(...skipping 4808 matching lines...) Expand 10 before | Expand all | Expand 10 after
10658 } else { 10771 } else {
10659 value &= ~(1 << bit_position); 10772 value &= ~(1 << bit_position);
10660 } 10773 }
10661 return value; 10774 return value;
10662 } 10775 }
10663 }; 10776 };
10664 10777
10665 } } // namespace v8::internal 10778 } } // namespace v8::internal
10666 10779
10667 #endif // V8_OBJECTS_H_ 10780 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698