| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // - OrderedHashSet | 86 // - OrderedHashSet |
| 87 // - OrderedHashMap | 87 // - OrderedHashMap |
| 88 // - Context | 88 // - Context |
| 89 // - TypeFeedbackVector | 89 // - TypeFeedbackVector |
| 90 // - JSFunctionResultCache | 90 // - JSFunctionResultCache |
| 91 // - ScopeInfo | 91 // - ScopeInfo |
| 92 // - TransitionArray | 92 // - TransitionArray |
| 93 // - ScriptContextTable | 93 // - ScriptContextTable |
| 94 // - WeakFixedArray | 94 // - WeakFixedArray |
| 95 // - FixedDoubleArray | 95 // - FixedDoubleArray |
| 96 // - ExternalArray | |
| 97 // - ExternalUint8ClampedArray | |
| 98 // - ExternalInt8Array | |
| 99 // - ExternalUint8Array | |
| 100 // - ExternalInt16Array | |
| 101 // - ExternalUint16Array | |
| 102 // - ExternalInt32Array | |
| 103 // - ExternalUint32Array | |
| 104 // - ExternalFloat32Array | |
| 105 // - Name | 96 // - Name |
| 106 // - String | 97 // - String |
| 107 // - SeqString | 98 // - SeqString |
| 108 // - SeqOneByteString | 99 // - SeqOneByteString |
| 109 // - SeqTwoByteString | 100 // - SeqTwoByteString |
| 110 // - SlicedString | 101 // - SlicedString |
| 111 // - ConsString | 102 // - ConsString |
| 112 // - ExternalString | 103 // - ExternalString |
| 113 // - ExternalOneByteString | 104 // - ExternalOneByteString |
| 114 // - ExternalTwoByteString | 105 // - ExternalTwoByteString |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 V(ODDBALL_TYPE) \ | 376 V(ODDBALL_TYPE) \ |
| 386 V(CELL_TYPE) \ | 377 V(CELL_TYPE) \ |
| 387 V(PROPERTY_CELL_TYPE) \ | 378 V(PROPERTY_CELL_TYPE) \ |
| 388 \ | 379 \ |
| 389 V(HEAP_NUMBER_TYPE) \ | 380 V(HEAP_NUMBER_TYPE) \ |
| 390 V(MUTABLE_HEAP_NUMBER_TYPE) \ | 381 V(MUTABLE_HEAP_NUMBER_TYPE) \ |
| 391 V(FOREIGN_TYPE) \ | 382 V(FOREIGN_TYPE) \ |
| 392 V(BYTE_ARRAY_TYPE) \ | 383 V(BYTE_ARRAY_TYPE) \ |
| 393 V(BYTECODE_ARRAY_TYPE) \ | 384 V(BYTECODE_ARRAY_TYPE) \ |
| 394 V(FREE_SPACE_TYPE) \ | 385 V(FREE_SPACE_TYPE) \ |
| 395 /* Note: the order of these external array */ \ | |
| 396 /* types is relied upon in */ \ | |
| 397 /* Object::IsExternalArray(). */ \ | |
| 398 V(EXTERNAL_INT8_ARRAY_TYPE) \ | |
| 399 V(EXTERNAL_UINT8_ARRAY_TYPE) \ | |
| 400 V(EXTERNAL_INT16_ARRAY_TYPE) \ | |
| 401 V(EXTERNAL_UINT16_ARRAY_TYPE) \ | |
| 402 V(EXTERNAL_INT32_ARRAY_TYPE) \ | |
| 403 V(EXTERNAL_UINT32_ARRAY_TYPE) \ | |
| 404 V(EXTERNAL_FLOAT32_ARRAY_TYPE) \ | |
| 405 V(EXTERNAL_FLOAT64_ARRAY_TYPE) \ | |
| 406 V(EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE) \ | |
| 407 \ | 386 \ |
| 408 V(FIXED_INT8_ARRAY_TYPE) \ | 387 V(FIXED_INT8_ARRAY_TYPE) \ |
| 409 V(FIXED_UINT8_ARRAY_TYPE) \ | 388 V(FIXED_UINT8_ARRAY_TYPE) \ |
| 410 V(FIXED_INT16_ARRAY_TYPE) \ | 389 V(FIXED_INT16_ARRAY_TYPE) \ |
| 411 V(FIXED_UINT16_ARRAY_TYPE) \ | 390 V(FIXED_UINT16_ARRAY_TYPE) \ |
| 412 V(FIXED_INT32_ARRAY_TYPE) \ | 391 V(FIXED_INT32_ARRAY_TYPE) \ |
| 413 V(FIXED_UINT32_ARRAY_TYPE) \ | 392 V(FIXED_UINT32_ARRAY_TYPE) \ |
| 414 V(FIXED_FLOAT32_ARRAY_TYPE) \ | 393 V(FIXED_FLOAT32_ARRAY_TYPE) \ |
| 415 V(FIXED_FLOAT64_ARRAY_TYPE) \ | 394 V(FIXED_FLOAT64_ARRAY_TYPE) \ |
| 416 V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \ | 395 V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \ |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 | 661 |
| 683 // "Data", objects that cannot contain non-map-word pointers to heap | 662 // "Data", objects that cannot contain non-map-word pointers to heap |
| 684 // objects. | 663 // objects. |
| 685 HEAP_NUMBER_TYPE, | 664 HEAP_NUMBER_TYPE, |
| 686 MUTABLE_HEAP_NUMBER_TYPE, | 665 MUTABLE_HEAP_NUMBER_TYPE, |
| 687 FLOAT32X4_TYPE, // FIRST_SIMD_TYPE, LAST_SIMD_TYPE | 666 FLOAT32X4_TYPE, // FIRST_SIMD_TYPE, LAST_SIMD_TYPE |
| 688 FOREIGN_TYPE, | 667 FOREIGN_TYPE, |
| 689 BYTE_ARRAY_TYPE, | 668 BYTE_ARRAY_TYPE, |
| 690 BYTECODE_ARRAY_TYPE, | 669 BYTECODE_ARRAY_TYPE, |
| 691 FREE_SPACE_TYPE, | 670 FREE_SPACE_TYPE, |
| 692 EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | |
| 693 EXTERNAL_UINT8_ARRAY_TYPE, | |
| 694 EXTERNAL_INT16_ARRAY_TYPE, | |
| 695 EXTERNAL_UINT16_ARRAY_TYPE, | |
| 696 EXTERNAL_INT32_ARRAY_TYPE, | |
| 697 EXTERNAL_UINT32_ARRAY_TYPE, | |
| 698 EXTERNAL_FLOAT32_ARRAY_TYPE, | |
| 699 EXTERNAL_FLOAT64_ARRAY_TYPE, | |
| 700 EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE | |
| 701 FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE | 671 FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE |
| 702 FIXED_UINT8_ARRAY_TYPE, | 672 FIXED_UINT8_ARRAY_TYPE, |
| 703 FIXED_INT16_ARRAY_TYPE, | 673 FIXED_INT16_ARRAY_TYPE, |
| 704 FIXED_UINT16_ARRAY_TYPE, | 674 FIXED_UINT16_ARRAY_TYPE, |
| 705 FIXED_INT32_ARRAY_TYPE, | 675 FIXED_INT32_ARRAY_TYPE, |
| 706 FIXED_UINT32_ARRAY_TYPE, | 676 FIXED_UINT32_ARRAY_TYPE, |
| 707 FIXED_FLOAT32_ARRAY_TYPE, | 677 FIXED_FLOAT32_ARRAY_TYPE, |
| 708 FIXED_FLOAT64_ARRAY_TYPE, | 678 FIXED_FLOAT64_ARRAY_TYPE, |
| 709 FIXED_UINT8_CLAMPED_ARRAY_TYPE, // LAST_FIXED_TYPED_ARRAY_TYPE | 679 FIXED_UINT8_CLAMPED_ARRAY_TYPE, // LAST_FIXED_TYPED_ARRAY_TYPE |
| 710 FIXED_DOUBLE_ARRAY_TYPE, | 680 FIXED_DOUBLE_ARRAY_TYPE, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 FIRST_TYPE = 0x0, | 743 FIRST_TYPE = 0x0, |
| 774 LAST_TYPE = JS_FUNCTION_TYPE, | 744 LAST_TYPE = JS_FUNCTION_TYPE, |
| 775 FIRST_NAME_TYPE = FIRST_TYPE, | 745 FIRST_NAME_TYPE = FIRST_TYPE, |
| 776 LAST_NAME_TYPE = SYMBOL_TYPE, | 746 LAST_NAME_TYPE = SYMBOL_TYPE, |
| 777 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE, | 747 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE, |
| 778 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE, | 748 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE, |
| 779 FIRST_NONSTRING_TYPE = SYMBOL_TYPE, | 749 FIRST_NONSTRING_TYPE = SYMBOL_TYPE, |
| 780 // Boundaries for testing for a SIMD type. | 750 // Boundaries for testing for a SIMD type. |
| 781 FIRST_SIMD_TYPE = FLOAT32X4_TYPE, | 751 FIRST_SIMD_TYPE = FLOAT32X4_TYPE, |
| 782 LAST_SIMD_TYPE = FLOAT32X4_TYPE, | 752 LAST_SIMD_TYPE = FLOAT32X4_TYPE, |
| 783 // Boundaries for testing for an external array. | |
| 784 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_INT8_ARRAY_TYPE, | |
| 785 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, | |
| 786 // Boundaries for testing for a fixed typed array. | 753 // Boundaries for testing for a fixed typed array. |
| 787 FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE, | 754 FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE, |
| 788 LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE, | 755 LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE, |
| 789 // Boundary for promotion to old space. | 756 // Boundary for promotion to old space. |
| 790 LAST_DATA_TYPE = FILLER_TYPE, | 757 LAST_DATA_TYPE = FILLER_TYPE, |
| 791 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). | 758 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). |
| 792 // Note that there is no range for JSObject or JSProxy, since their subtypes | 759 // Note that there is no range for JSObject or JSProxy, since their subtypes |
| 793 // are not continuous in this enum! The enum ranges instead reflect the | 760 // are not continuous in this enum! The enum ranges instead reflect the |
| 794 // external class names, where proxies are treated as either ordinary objects, | 761 // external class names, where proxies are treated as either ordinary objects, |
| 795 // or functions. | 762 // or functions. |
| 796 FIRST_JS_RECEIVER_TYPE = JS_FUNCTION_PROXY_TYPE, | 763 FIRST_JS_RECEIVER_TYPE = JS_FUNCTION_PROXY_TYPE, |
| 797 LAST_JS_RECEIVER_TYPE = LAST_TYPE, | 764 LAST_JS_RECEIVER_TYPE = LAST_TYPE, |
| 798 // Boundaries for testing the types represented as JSObject | 765 // Boundaries for testing the types represented as JSObject |
| 799 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, | 766 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, |
| 800 LAST_JS_OBJECT_TYPE = LAST_TYPE, | 767 LAST_JS_OBJECT_TYPE = LAST_TYPE, |
| 801 // Boundaries for testing the types represented as JSProxy | 768 // Boundaries for testing the types represented as JSProxy |
| 802 FIRST_JS_PROXY_TYPE = JS_FUNCTION_PROXY_TYPE, | 769 FIRST_JS_PROXY_TYPE = JS_FUNCTION_PROXY_TYPE, |
| 803 LAST_JS_PROXY_TYPE = JS_PROXY_TYPE, | 770 LAST_JS_PROXY_TYPE = JS_PROXY_TYPE, |
| 804 // Boundaries for testing whether the type is a JavaScript object. | 771 // Boundaries for testing whether the type is a JavaScript object. |
| 805 FIRST_SPEC_OBJECT_TYPE = FIRST_JS_RECEIVER_TYPE, | 772 FIRST_SPEC_OBJECT_TYPE = FIRST_JS_RECEIVER_TYPE, |
| 806 LAST_SPEC_OBJECT_TYPE = LAST_JS_RECEIVER_TYPE, | 773 LAST_SPEC_OBJECT_TYPE = LAST_JS_RECEIVER_TYPE, |
| 807 // Boundaries for testing the types for which typeof is "object". | 774 // Boundaries for testing the types for which typeof is "object". |
| 808 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_PROXY_TYPE, | 775 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_PROXY_TYPE, |
| 809 LAST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_REGEXP_TYPE, | 776 LAST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_REGEXP_TYPE, |
| 810 // Note that the types for which typeof is "function" are not continuous. | 777 // Note that the types for which typeof is "function" are not continuous. |
| 811 // Define this so that we can put assertions on discrete checks. | 778 // Define this so that we can put assertions on discrete checks. |
| 812 NUM_OF_CALLABLE_SPEC_OBJECT_TYPES = 2 | 779 NUM_OF_CALLABLE_SPEC_OBJECT_TYPES = 2 |
| 813 }; | 780 }; |
| 814 | 781 |
| 815 const int kExternalArrayTypeCount = | |
| 816 LAST_EXTERNAL_ARRAY_TYPE - FIRST_EXTERNAL_ARRAY_TYPE + 1; | |
| 817 | |
| 818 STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType); | 782 STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType); |
| 819 STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); | 783 STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); |
| 820 STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType); | 784 STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType); |
| 821 STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType); | 785 STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType); |
| 822 | 786 |
| 823 | 787 |
| 824 #define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \ | 788 #define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \ |
| 825 V(FAST_ELEMENTS_SUB_TYPE) \ | 789 V(FAST_ELEMENTS_SUB_TYPE) \ |
| 826 V(DICTIONARY_ELEMENTS_SUB_TYPE) \ | 790 V(DICTIONARY_ELEMENTS_SUB_TYPE) \ |
| 827 V(FAST_PROPERTIES_SUB_TYPE) \ | 791 V(FAST_PROPERTIES_SUB_TYPE) \ |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 V(ExternalString) \ | 890 V(ExternalString) \ |
| 927 V(ConsString) \ | 891 V(ConsString) \ |
| 928 V(SlicedString) \ | 892 V(SlicedString) \ |
| 929 V(ExternalTwoByteString) \ | 893 V(ExternalTwoByteString) \ |
| 930 V(ExternalOneByteString) \ | 894 V(ExternalOneByteString) \ |
| 931 V(SeqTwoByteString) \ | 895 V(SeqTwoByteString) \ |
| 932 V(SeqOneByteString) \ | 896 V(SeqOneByteString) \ |
| 933 V(InternalizedString) \ | 897 V(InternalizedString) \ |
| 934 V(Symbol) \ | 898 V(Symbol) \ |
| 935 \ | 899 \ |
| 936 V(ExternalArray) \ | |
| 937 V(ExternalInt8Array) \ | |
| 938 V(ExternalUint8Array) \ | |
| 939 V(ExternalInt16Array) \ | |
| 940 V(ExternalUint16Array) \ | |
| 941 V(ExternalInt32Array) \ | |
| 942 V(ExternalUint32Array) \ | |
| 943 V(ExternalFloat32Array) \ | |
| 944 V(ExternalFloat64Array) \ | |
| 945 V(ExternalUint8ClampedArray) \ | |
| 946 V(FixedTypedArrayBase) \ | 900 V(FixedTypedArrayBase) \ |
| 947 V(FixedUint8Array) \ | 901 V(FixedUint8Array) \ |
| 948 V(FixedInt8Array) \ | 902 V(FixedInt8Array) \ |
| 949 V(FixedUint16Array) \ | 903 V(FixedUint16Array) \ |
| 950 V(FixedInt16Array) \ | 904 V(FixedInt16Array) \ |
| 951 V(FixedUint32Array) \ | 905 V(FixedUint32Array) \ |
| 952 V(FixedInt32Array) \ | 906 V(FixedInt32Array) \ |
| 953 V(FixedFloat32Array) \ | 907 V(FixedFloat32Array) \ |
| 954 V(FixedFloat64Array) \ | 908 V(FixedFloat64Array) \ |
| 955 V(FixedUint8ClampedArray) \ | 909 V(FixedUint8ClampedArray) \ |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 // | 1719 // |
| 1766 // In the fast mode elements is a FixedArray and so each element can | 1720 // In the fast mode elements is a FixedArray and so each element can |
| 1767 // be quickly accessed. This fact is used in the generated code. The | 1721 // be quickly accessed. This fact is used in the generated code. The |
| 1768 // elements array can have one of three maps in this mode: | 1722 // elements array can have one of three maps in this mode: |
| 1769 // fixed_array_map, sloppy_arguments_elements_map or | 1723 // fixed_array_map, sloppy_arguments_elements_map or |
| 1770 // fixed_cow_array_map (for copy-on-write arrays). In the latter case | 1724 // fixed_cow_array_map (for copy-on-write arrays). In the latter case |
| 1771 // the elements array may be shared by a few objects and so before | 1725 // the elements array may be shared by a few objects and so before |
| 1772 // writing to any element the array must be copied. Use | 1726 // writing to any element the array must be copied. Use |
| 1773 // EnsureWritableFastElements in this case. | 1727 // EnsureWritableFastElements in this case. |
| 1774 // | 1728 // |
| 1775 // In the slow mode the elements is either a NumberDictionary, an | 1729 // In the slow mode the elements is either a NumberDictionary, a |
| 1776 // ExternalArray, or a FixedArray parameter map for a (sloppy) | 1730 // FixedArray parameter map for a (sloppy) arguments object. |
| 1777 // arguments object. | |
| 1778 DECL_ACCESSORS(elements, FixedArrayBase) | 1731 DECL_ACCESSORS(elements, FixedArrayBase) |
| 1779 inline void initialize_elements(); | 1732 inline void initialize_elements(); |
| 1780 static void ResetElements(Handle<JSObject> object); | 1733 static void ResetElements(Handle<JSObject> object); |
| 1781 static inline void SetMapAndElements(Handle<JSObject> object, | 1734 static inline void SetMapAndElements(Handle<JSObject> object, |
| 1782 Handle<Map> map, | 1735 Handle<Map> map, |
| 1783 Handle<FixedArrayBase> elements); | 1736 Handle<FixedArrayBase> elements); |
| 1784 inline ElementsKind GetElementsKind(); | 1737 inline ElementsKind GetElementsKind(); |
| 1785 ElementsAccessor* GetElementsAccessor(); | 1738 ElementsAccessor* GetElementsAccessor(); |
| 1786 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind. | 1739 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind. |
| 1787 inline bool HasFastSmiElements(); | 1740 inline bool HasFastSmiElements(); |
| 1788 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind. | 1741 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind. |
| 1789 inline bool HasFastObjectElements(); | 1742 inline bool HasFastObjectElements(); |
| 1790 // Returns true if an object has elements of FAST_ELEMENTS or | 1743 // Returns true if an object has elements of FAST_ELEMENTS or |
| 1791 // FAST_SMI_ONLY_ELEMENTS. | 1744 // FAST_SMI_ONLY_ELEMENTS. |
| 1792 inline bool HasFastSmiOrObjectElements(); | 1745 inline bool HasFastSmiOrObjectElements(); |
| 1793 // Returns true if an object has any of the fast elements kinds. | 1746 // Returns true if an object has any of the fast elements kinds. |
| 1794 inline bool HasFastElements(); | 1747 inline bool HasFastElements(); |
| 1795 // Returns true if an object has elements of FAST_DOUBLE_ELEMENTS | 1748 // Returns true if an object has elements of FAST_DOUBLE_ELEMENTS |
| 1796 // ElementsKind. | 1749 // ElementsKind. |
| 1797 inline bool HasFastDoubleElements(); | 1750 inline bool HasFastDoubleElements(); |
| 1798 // Returns true if an object has elements of FAST_HOLEY_*_ELEMENTS | 1751 // Returns true if an object has elements of FAST_HOLEY_*_ELEMENTS |
| 1799 // ElementsKind. | 1752 // ElementsKind. |
| 1800 inline bool HasFastHoleyElements(); | 1753 inline bool HasFastHoleyElements(); |
| 1801 inline bool HasSloppyArgumentsElements(); | 1754 inline bool HasSloppyArgumentsElements(); |
| 1802 inline bool HasDictionaryElements(); | 1755 inline bool HasDictionaryElements(); |
| 1803 | 1756 |
| 1804 inline bool HasExternalUint8ClampedElements(); | |
| 1805 inline bool HasExternalArrayElements(); | |
| 1806 inline bool HasExternalInt8Elements(); | |
| 1807 inline bool HasExternalUint8Elements(); | |
| 1808 inline bool HasExternalInt16Elements(); | |
| 1809 inline bool HasExternalUint16Elements(); | |
| 1810 inline bool HasExternalInt32Elements(); | |
| 1811 inline bool HasExternalUint32Elements(); | |
| 1812 inline bool HasExternalFloat32Elements(); | |
| 1813 inline bool HasExternalFloat64Elements(); | |
| 1814 | |
| 1815 inline bool HasFixedTypedArrayElements(); | 1757 inline bool HasFixedTypedArrayElements(); |
| 1816 | 1758 |
| 1817 inline bool HasFixedUint8ClampedElements(); | 1759 inline bool HasFixedUint8ClampedElements(); |
| 1818 inline bool HasFixedArrayElements(); | 1760 inline bool HasFixedArrayElements(); |
| 1819 inline bool HasFixedInt8Elements(); | 1761 inline bool HasFixedInt8Elements(); |
| 1820 inline bool HasFixedUint8Elements(); | 1762 inline bool HasFixedUint8Elements(); |
| 1821 inline bool HasFixedInt16Elements(); | 1763 inline bool HasFixedInt16Elements(); |
| 1822 inline bool HasFixedUint16Elements(); | 1764 inline bool HasFixedUint16Elements(); |
| 1823 inline bool HasFixedInt32Elements(); | 1765 inline bool HasFixedInt32Elements(); |
| 1824 inline bool HasFixedUint32Elements(); | 1766 inline bool HasFixedUint32Elements(); |
| (...skipping 2499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4324 V(Int8, int8, INT8, int8_t, 1) \ | 4266 V(Int8, int8, INT8, int8_t, 1) \ |
| 4325 V(Uint16, uint16, UINT16, uint16_t, 2) \ | 4267 V(Uint16, uint16, UINT16, uint16_t, 2) \ |
| 4326 V(Int16, int16, INT16, int16_t, 2) \ | 4268 V(Int16, int16, INT16, int16_t, 2) \ |
| 4327 V(Uint32, uint32, UINT32, uint32_t, 4) \ | 4269 V(Uint32, uint32, UINT32, uint32_t, 4) \ |
| 4328 V(Int32, int32, INT32, int32_t, 4) \ | 4270 V(Int32, int32, INT32, int32_t, 4) \ |
| 4329 V(Float32, float32, FLOAT32, float, 4) \ | 4271 V(Float32, float32, FLOAT32, float, 4) \ |
| 4330 V(Float64, float64, FLOAT64, double, 8) \ | 4272 V(Float64, float64, FLOAT64, double, 8) \ |
| 4331 V(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t, 1) | 4273 V(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t, 1) |
| 4332 | 4274 |
| 4333 | 4275 |
| 4334 | |
| 4335 // An ExternalArray represents a fixed-size array of primitive values | |
| 4336 // which live outside the JavaScript heap. Its subclasses are used to | |
| 4337 // implement the CanvasArray types being defined in the WebGL | |
| 4338 // specification. As of this writing the first public draft is not yet | |
| 4339 // available, but Khronos members can access the draft at: | |
| 4340 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | |
| 4341 // | |
| 4342 // The semantics of these arrays differ from CanvasPixelArray. | |
| 4343 // Out-of-range values passed to the setter are converted via a C | |
| 4344 // cast, not clamping. Out-of-range indices cause exceptions to be | |
| 4345 // raised rather than being silently ignored. | |
| 4346 class ExternalArray: public FixedArrayBase { | |
| 4347 public: | |
| 4348 inline bool is_the_hole(int index) { return false; } | |
| 4349 | |
| 4350 // [external_pointer]: The pointer to the external memory area backing this | |
| 4351 // external array. | |
| 4352 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. | |
| 4353 | |
| 4354 DECLARE_CAST(ExternalArray) | |
| 4355 | |
| 4356 // Maximal acceptable length for an external array. | |
| 4357 static const int kMaxLength = 0x3fffffff; | |
| 4358 | |
| 4359 // ExternalArray headers are not quadword aligned. | |
| 4360 static const int kExternalPointerOffset = | |
| 4361 POINTER_SIZE_ALIGN(FixedArrayBase::kLengthOffset + kPointerSize); | |
| 4362 static const int kSize = kExternalPointerOffset + kPointerSize; | |
| 4363 | |
| 4364 private: | |
| 4365 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); | |
| 4366 }; | |
| 4367 | |
| 4368 | |
| 4369 // A ExternalUint8ClampedArray represents a fixed-size byte array with special | |
| 4370 // semantics used for implementing the CanvasPixelArray object. Please see the | |
| 4371 // specification at: | |
| 4372 | |
| 4373 // http://www.whatwg.org/specs/web-apps/current-work/ | |
| 4374 // multipage/the-canvas-element.html#canvaspixelarray | |
| 4375 // In particular, write access clamps the value written to 0 or 255 if the | |
| 4376 // value written is outside this range. | |
| 4377 class ExternalUint8ClampedArray: public ExternalArray { | |
| 4378 public: | |
| 4379 inline uint8_t* external_uint8_clamped_pointer(); | |
| 4380 | |
| 4381 // Setter and getter. | |
| 4382 inline uint8_t get_scalar(int index); | |
| 4383 static inline Handle<Object> get(Handle<ExternalUint8ClampedArray> array, | |
| 4384 int index); | |
| 4385 inline void set(int index, uint8_t value); | |
| 4386 | |
| 4387 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4388 // and undefined and clamps the converted value between 0 and 255. | |
| 4389 void SetValue(uint32_t index, Object* value); | |
| 4390 | |
| 4391 DECLARE_CAST(ExternalUint8ClampedArray) | |
| 4392 | |
| 4393 // Dispatched behavior. | |
| 4394 DECLARE_PRINTER(ExternalUint8ClampedArray) | |
| 4395 DECLARE_VERIFIER(ExternalUint8ClampedArray) | |
| 4396 | |
| 4397 private: | |
| 4398 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8ClampedArray); | |
| 4399 }; | |
| 4400 | |
| 4401 | |
| 4402 class ExternalInt8Array: public ExternalArray { | |
| 4403 public: | |
| 4404 // Setter and getter. | |
| 4405 inline int8_t get_scalar(int index); | |
| 4406 static inline Handle<Object> get(Handle<ExternalInt8Array> array, int index); | |
| 4407 inline void set(int index, int8_t value); | |
| 4408 | |
| 4409 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4410 // and undefined. | |
| 4411 void SetValue(uint32_t index, Object* value); | |
| 4412 | |
| 4413 DECLARE_CAST(ExternalInt8Array) | |
| 4414 | |
| 4415 // Dispatched behavior. | |
| 4416 DECLARE_PRINTER(ExternalInt8Array) | |
| 4417 DECLARE_VERIFIER(ExternalInt8Array) | |
| 4418 | |
| 4419 private: | |
| 4420 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt8Array); | |
| 4421 }; | |
| 4422 | |
| 4423 | |
| 4424 class ExternalUint8Array: public ExternalArray { | |
| 4425 public: | |
| 4426 // Setter and getter. | |
| 4427 inline uint8_t get_scalar(int index); | |
| 4428 static inline Handle<Object> get(Handle<ExternalUint8Array> array, int index); | |
| 4429 inline void set(int index, uint8_t value); | |
| 4430 | |
| 4431 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4432 // and undefined. | |
| 4433 void SetValue(uint32_t index, Object* value); | |
| 4434 | |
| 4435 DECLARE_CAST(ExternalUint8Array) | |
| 4436 | |
| 4437 // Dispatched behavior. | |
| 4438 DECLARE_PRINTER(ExternalUint8Array) | |
| 4439 DECLARE_VERIFIER(ExternalUint8Array) | |
| 4440 | |
| 4441 private: | |
| 4442 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8Array); | |
| 4443 }; | |
| 4444 | |
| 4445 | |
| 4446 class ExternalInt16Array: public ExternalArray { | |
| 4447 public: | |
| 4448 // Setter and getter. | |
| 4449 inline int16_t get_scalar(int index); | |
| 4450 static inline Handle<Object> get(Handle<ExternalInt16Array> array, int index); | |
| 4451 inline void set(int index, int16_t value); | |
| 4452 | |
| 4453 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4454 // and undefined. | |
| 4455 void SetValue(uint32_t index, Object* value); | |
| 4456 | |
| 4457 DECLARE_CAST(ExternalInt16Array) | |
| 4458 | |
| 4459 // Dispatched behavior. | |
| 4460 DECLARE_PRINTER(ExternalInt16Array) | |
| 4461 DECLARE_VERIFIER(ExternalInt16Array) | |
| 4462 | |
| 4463 private: | |
| 4464 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt16Array); | |
| 4465 }; | |
| 4466 | |
| 4467 | |
| 4468 class ExternalUint16Array: public ExternalArray { | |
| 4469 public: | |
| 4470 // Setter and getter. | |
| 4471 inline uint16_t get_scalar(int index); | |
| 4472 static inline Handle<Object> get(Handle<ExternalUint16Array> array, | |
| 4473 int index); | |
| 4474 inline void set(int index, uint16_t value); | |
| 4475 | |
| 4476 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4477 // and undefined. | |
| 4478 void SetValue(uint32_t index, Object* value); | |
| 4479 | |
| 4480 DECLARE_CAST(ExternalUint16Array) | |
| 4481 | |
| 4482 // Dispatched behavior. | |
| 4483 DECLARE_PRINTER(ExternalUint16Array) | |
| 4484 DECLARE_VERIFIER(ExternalUint16Array) | |
| 4485 | |
| 4486 private: | |
| 4487 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint16Array); | |
| 4488 }; | |
| 4489 | |
| 4490 | |
| 4491 class ExternalInt32Array: public ExternalArray { | |
| 4492 public: | |
| 4493 // Setter and getter. | |
| 4494 inline int32_t get_scalar(int index); | |
| 4495 static inline Handle<Object> get(Handle<ExternalInt32Array> array, int index); | |
| 4496 inline void set(int index, int32_t value); | |
| 4497 | |
| 4498 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4499 // and undefined. | |
| 4500 void SetValue(uint32_t index, Object* value); | |
| 4501 | |
| 4502 DECLARE_CAST(ExternalInt32Array) | |
| 4503 | |
| 4504 // Dispatched behavior. | |
| 4505 DECLARE_PRINTER(ExternalInt32Array) | |
| 4506 DECLARE_VERIFIER(ExternalInt32Array) | |
| 4507 | |
| 4508 private: | |
| 4509 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt32Array); | |
| 4510 }; | |
| 4511 | |
| 4512 | |
| 4513 class ExternalUint32Array: public ExternalArray { | |
| 4514 public: | |
| 4515 // Setter and getter. | |
| 4516 inline uint32_t get_scalar(int index); | |
| 4517 static inline Handle<Object> get(Handle<ExternalUint32Array> array, | |
| 4518 int index); | |
| 4519 inline void set(int index, uint32_t value); | |
| 4520 | |
| 4521 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4522 // and undefined. | |
| 4523 void SetValue(uint32_t index, Object* value); | |
| 4524 | |
| 4525 DECLARE_CAST(ExternalUint32Array) | |
| 4526 | |
| 4527 // Dispatched behavior. | |
| 4528 DECLARE_PRINTER(ExternalUint32Array) | |
| 4529 DECLARE_VERIFIER(ExternalUint32Array) | |
| 4530 | |
| 4531 private: | |
| 4532 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint32Array); | |
| 4533 }; | |
| 4534 | |
| 4535 | |
| 4536 class ExternalFloat32Array: public ExternalArray { | |
| 4537 public: | |
| 4538 // Setter and getter. | |
| 4539 inline float get_scalar(int index); | |
| 4540 static inline Handle<Object> get(Handle<ExternalFloat32Array> array, | |
| 4541 int index); | |
| 4542 inline void set(int index, float value); | |
| 4543 | |
| 4544 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4545 // and undefined. | |
| 4546 void SetValue(uint32_t index, Object* value); | |
| 4547 | |
| 4548 DECLARE_CAST(ExternalFloat32Array) | |
| 4549 | |
| 4550 // Dispatched behavior. | |
| 4551 DECLARE_PRINTER(ExternalFloat32Array) | |
| 4552 DECLARE_VERIFIER(ExternalFloat32Array) | |
| 4553 | |
| 4554 private: | |
| 4555 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat32Array); | |
| 4556 }; | |
| 4557 | |
| 4558 | |
| 4559 class ExternalFloat64Array: public ExternalArray { | |
| 4560 public: | |
| 4561 // Setter and getter. | |
| 4562 inline double get_scalar(int index); | |
| 4563 static inline Handle<Object> get(Handle<ExternalFloat64Array> array, | |
| 4564 int index); | |
| 4565 inline void set(int index, double value); | |
| 4566 | |
| 4567 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4568 // and undefined. | |
| 4569 void SetValue(uint32_t index, Object* value); | |
| 4570 | |
| 4571 DECLARE_CAST(ExternalFloat64Array) | |
| 4572 | |
| 4573 // Dispatched behavior. | |
| 4574 DECLARE_PRINTER(ExternalFloat64Array) | |
| 4575 DECLARE_VERIFIER(ExternalFloat64Array) | |
| 4576 | |
| 4577 private: | |
| 4578 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat64Array); | |
| 4579 }; | |
| 4580 | |
| 4581 | |
| 4582 class FixedTypedArrayBase: public FixedArrayBase { | 4276 class FixedTypedArrayBase: public FixedArrayBase { |
| 4583 public: | 4277 public: |
| 4584 // [base_pointer]: For now, points to the FixedTypedArrayBase itself. | 4278 // [base_pointer]: Either points to the FixedTypedArrayBase itself or nullptr. |
| 4585 DECL_ACCESSORS(base_pointer, Object) | 4279 DECL_ACCESSORS(base_pointer, Object) |
| 4586 | 4280 |
| 4587 // [external_pointer]: For now, contains the offset between base_pointer and | 4281 // [external_pointer]: Contains the offset between base_pointer and the start |
| 4588 // the start of the data. | 4282 // of the data. If the base_pointer is a nullptr, the external_pointer |
| 4283 // therefore points to the actual backing store. |
| 4589 DECL_ACCESSORS(external_pointer, void) | 4284 DECL_ACCESSORS(external_pointer, void) |
| 4590 | 4285 |
| 4591 // Dispatched behavior. | 4286 // Dispatched behavior. |
| 4592 inline void FixedTypedArrayBaseIterateBody(ObjectVisitor* v); | 4287 inline void FixedTypedArrayBaseIterateBody(ObjectVisitor* v); |
| 4593 | 4288 |
| 4594 template <typename StaticVisitor> | 4289 template <typename StaticVisitor> |
| 4595 inline void FixedTypedArrayBaseIterateBody(); | 4290 inline void FixedTypedArrayBaseIterateBody(); |
| 4596 | 4291 |
| 4597 DECLARE_CAST(FixedTypedArrayBase) | 4292 DECLARE_CAST(FixedTypedArrayBase) |
| 4598 | 4293 |
| (...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5729 } | 5424 } |
| 5730 | 5425 |
| 5731 inline bool has_fast_elements() { | 5426 inline bool has_fast_elements() { |
| 5732 return IsFastElementsKind(elements_kind()); | 5427 return IsFastElementsKind(elements_kind()); |
| 5733 } | 5428 } |
| 5734 | 5429 |
| 5735 inline bool has_sloppy_arguments_elements() { | 5430 inline bool has_sloppy_arguments_elements() { |
| 5736 return IsSloppyArgumentsElements(elements_kind()); | 5431 return IsSloppyArgumentsElements(elements_kind()); |
| 5737 } | 5432 } |
| 5738 | 5433 |
| 5739 inline bool has_external_array_elements() { | |
| 5740 return IsExternalArrayElementsKind(elements_kind()); | |
| 5741 } | |
| 5742 | |
| 5743 inline bool has_fixed_typed_array_elements() { | 5434 inline bool has_fixed_typed_array_elements() { |
| 5744 return IsFixedTypedArrayElementsKind(elements_kind()); | 5435 return IsFixedTypedArrayElementsKind(elements_kind()); |
| 5745 } | 5436 } |
| 5746 | 5437 |
| 5747 inline bool has_dictionary_elements() { | 5438 inline bool has_dictionary_elements() { |
| 5748 return IsDictionaryElementsKind(elements_kind()); | 5439 return IsDictionaryElementsKind(elements_kind()); |
| 5749 } | 5440 } |
| 5750 | 5441 |
| 5751 static bool IsValidElementsTransition(ElementsKind from_kind, | 5442 static bool IsValidElementsTransition(ElementsKind from_kind, |
| 5752 ElementsKind to_kind); | 5443 ElementsKind to_kind); |
| (...skipping 5094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10847 } else { | 10538 } else { |
| 10848 value &= ~(1 << bit_position); | 10539 value &= ~(1 << bit_position); |
| 10849 } | 10540 } |
| 10850 return value; | 10541 return value; |
| 10851 } | 10542 } |
| 10852 }; | 10543 }; |
| 10853 | 10544 |
| 10854 } } // namespace v8::internal | 10545 } } // namespace v8::internal |
| 10855 | 10546 |
| 10856 #endif // V8_OBJECTS_H_ | 10547 #endif // V8_OBJECTS_H_ |
| OLD | NEW |