| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // - OrderedHashSet | 85 // - OrderedHashSet |
| 86 // - OrderedHashMap | 86 // - OrderedHashMap |
| 87 // - Context | 87 // - Context |
| 88 // - TypeFeedbackVector | 88 // - TypeFeedbackVector |
| 89 // - JSFunctionResultCache | 89 // - JSFunctionResultCache |
| 90 // - ScopeInfo | 90 // - ScopeInfo |
| 91 // - TransitionArray | 91 // - TransitionArray |
| 92 // - ScriptContextTable | 92 // - ScriptContextTable |
| 93 // - WeakFixedArray | 93 // - WeakFixedArray |
| 94 // - FixedDoubleArray | 94 // - FixedDoubleArray |
| 95 // - ExternalArray | |
| 96 // - ExternalUint8ClampedArray | |
| 97 // - ExternalInt8Array | |
| 98 // - ExternalUint8Array | |
| 99 // - ExternalInt16Array | |
| 100 // - ExternalUint16Array | |
| 101 // - ExternalInt32Array | |
| 102 // - ExternalUint32Array | |
| 103 // - ExternalFloat32Array | |
| 104 // - Name | 95 // - Name |
| 105 // - String | 96 // - String |
| 106 // - SeqString | 97 // - SeqString |
| 107 // - SeqOneByteString | 98 // - SeqOneByteString |
| 108 // - SeqTwoByteString | 99 // - SeqTwoByteString |
| 109 // - SlicedString | 100 // - SlicedString |
| 110 // - ConsString | 101 // - ConsString |
| 111 // - ExternalString | 102 // - ExternalString |
| 112 // - ExternalOneByteString | 103 // - ExternalOneByteString |
| 113 // - ExternalTwoByteString | 104 // - ExternalTwoByteString |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 V(CODE_TYPE) \ | 374 V(CODE_TYPE) \ |
| 384 V(ODDBALL_TYPE) \ | 375 V(ODDBALL_TYPE) \ |
| 385 V(CELL_TYPE) \ | 376 V(CELL_TYPE) \ |
| 386 V(PROPERTY_CELL_TYPE) \ | 377 V(PROPERTY_CELL_TYPE) \ |
| 387 \ | 378 \ |
| 388 V(HEAP_NUMBER_TYPE) \ | 379 V(HEAP_NUMBER_TYPE) \ |
| 389 V(MUTABLE_HEAP_NUMBER_TYPE) \ | 380 V(MUTABLE_HEAP_NUMBER_TYPE) \ |
| 390 V(FOREIGN_TYPE) \ | 381 V(FOREIGN_TYPE) \ |
| 391 V(BYTE_ARRAY_TYPE) \ | 382 V(BYTE_ARRAY_TYPE) \ |
| 392 V(FREE_SPACE_TYPE) \ | 383 V(FREE_SPACE_TYPE) \ |
| 393 /* Note: the order of these external array */ \ | |
| 394 /* types is relied upon in */ \ | |
| 395 /* Object::IsExternalArray(). */ \ | |
| 396 V(EXTERNAL_INT8_ARRAY_TYPE) \ | |
| 397 V(EXTERNAL_UINT8_ARRAY_TYPE) \ | |
| 398 V(EXTERNAL_INT16_ARRAY_TYPE) \ | |
| 399 V(EXTERNAL_UINT16_ARRAY_TYPE) \ | |
| 400 V(EXTERNAL_INT32_ARRAY_TYPE) \ | |
| 401 V(EXTERNAL_UINT32_ARRAY_TYPE) \ | |
| 402 V(EXTERNAL_FLOAT32_ARRAY_TYPE) \ | |
| 403 V(EXTERNAL_FLOAT64_ARRAY_TYPE) \ | |
| 404 V(EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE) \ | |
| 405 \ | 384 \ |
| 406 V(FIXED_INT8_ARRAY_TYPE) \ | 385 V(FIXED_INT8_ARRAY_TYPE) \ |
| 407 V(FIXED_UINT8_ARRAY_TYPE) \ | 386 V(FIXED_UINT8_ARRAY_TYPE) \ |
| 408 V(FIXED_INT16_ARRAY_TYPE) \ | 387 V(FIXED_INT16_ARRAY_TYPE) \ |
| 409 V(FIXED_UINT16_ARRAY_TYPE) \ | 388 V(FIXED_UINT16_ARRAY_TYPE) \ |
| 410 V(FIXED_INT32_ARRAY_TYPE) \ | 389 V(FIXED_INT32_ARRAY_TYPE) \ |
| 411 V(FIXED_UINT32_ARRAY_TYPE) \ | 390 V(FIXED_UINT32_ARRAY_TYPE) \ |
| 412 V(FIXED_FLOAT32_ARRAY_TYPE) \ | 391 V(FIXED_FLOAT32_ARRAY_TYPE) \ |
| 413 V(FIXED_FLOAT64_ARRAY_TYPE) \ | 392 V(FIXED_FLOAT64_ARRAY_TYPE) \ |
| 414 V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \ | 393 V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \ |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 ODDBALL_TYPE, | 658 ODDBALL_TYPE, |
| 680 | 659 |
| 681 // "Data", objects that cannot contain non-map-word pointers to heap | 660 // "Data", objects that cannot contain non-map-word pointers to heap |
| 682 // objects. | 661 // objects. |
| 683 HEAP_NUMBER_TYPE, | 662 HEAP_NUMBER_TYPE, |
| 684 MUTABLE_HEAP_NUMBER_TYPE, | 663 MUTABLE_HEAP_NUMBER_TYPE, |
| 685 FLOAT32X4_TYPE, // FIRST_SIMD_TYPE, LAST_SIMD_TYPE | 664 FLOAT32X4_TYPE, // FIRST_SIMD_TYPE, LAST_SIMD_TYPE |
| 686 FOREIGN_TYPE, | 665 FOREIGN_TYPE, |
| 687 BYTE_ARRAY_TYPE, | 666 BYTE_ARRAY_TYPE, |
| 688 FREE_SPACE_TYPE, | 667 FREE_SPACE_TYPE, |
| 689 EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | |
| 690 EXTERNAL_UINT8_ARRAY_TYPE, | |
| 691 EXTERNAL_INT16_ARRAY_TYPE, | |
| 692 EXTERNAL_UINT16_ARRAY_TYPE, | |
| 693 EXTERNAL_INT32_ARRAY_TYPE, | |
| 694 EXTERNAL_UINT32_ARRAY_TYPE, | |
| 695 EXTERNAL_FLOAT32_ARRAY_TYPE, | |
| 696 EXTERNAL_FLOAT64_ARRAY_TYPE, | |
| 697 EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE | |
| 698 FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE | 668 FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE |
| 699 FIXED_UINT8_ARRAY_TYPE, | 669 FIXED_UINT8_ARRAY_TYPE, |
| 700 FIXED_INT16_ARRAY_TYPE, | 670 FIXED_INT16_ARRAY_TYPE, |
| 701 FIXED_UINT16_ARRAY_TYPE, | 671 FIXED_UINT16_ARRAY_TYPE, |
| 702 FIXED_INT32_ARRAY_TYPE, | 672 FIXED_INT32_ARRAY_TYPE, |
| 703 FIXED_UINT32_ARRAY_TYPE, | 673 FIXED_UINT32_ARRAY_TYPE, |
| 704 FIXED_FLOAT32_ARRAY_TYPE, | 674 FIXED_FLOAT32_ARRAY_TYPE, |
| 705 FIXED_FLOAT64_ARRAY_TYPE, | 675 FIXED_FLOAT64_ARRAY_TYPE, |
| 706 FIXED_UINT8_CLAMPED_ARRAY_TYPE, // LAST_FIXED_TYPED_ARRAY_TYPE | 676 FIXED_UINT8_CLAMPED_ARRAY_TYPE, // LAST_FIXED_TYPED_ARRAY_TYPE |
| 707 FIXED_DOUBLE_ARRAY_TYPE, | 677 FIXED_DOUBLE_ARRAY_TYPE, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 FIRST_TYPE = 0x0, | 740 FIRST_TYPE = 0x0, |
| 771 LAST_TYPE = JS_FUNCTION_TYPE, | 741 LAST_TYPE = JS_FUNCTION_TYPE, |
| 772 FIRST_NAME_TYPE = FIRST_TYPE, | 742 FIRST_NAME_TYPE = FIRST_TYPE, |
| 773 LAST_NAME_TYPE = SYMBOL_TYPE, | 743 LAST_NAME_TYPE = SYMBOL_TYPE, |
| 774 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE, | 744 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE, |
| 775 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE, | 745 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE, |
| 776 FIRST_NONSTRING_TYPE = SYMBOL_TYPE, | 746 FIRST_NONSTRING_TYPE = SYMBOL_TYPE, |
| 777 // Boundaries for testing for a SIMD type. | 747 // Boundaries for testing for a SIMD type. |
| 778 FIRST_SIMD_TYPE = FLOAT32X4_TYPE, | 748 FIRST_SIMD_TYPE = FLOAT32X4_TYPE, |
| 779 LAST_SIMD_TYPE = FLOAT32X4_TYPE, | 749 LAST_SIMD_TYPE = FLOAT32X4_TYPE, |
| 780 // Boundaries for testing for an external array. | |
| 781 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_INT8_ARRAY_TYPE, | |
| 782 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, | |
| 783 // Boundaries for testing for a fixed typed array. | 750 // Boundaries for testing for a fixed typed array. |
| 784 FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE, | 751 FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE, |
| 785 LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE, | 752 LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE, |
| 786 // Boundary for promotion to old space. | 753 // Boundary for promotion to old space. |
| 787 LAST_DATA_TYPE = FILLER_TYPE, | 754 LAST_DATA_TYPE = FILLER_TYPE, |
| 788 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). | 755 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). |
| 789 // Note that there is no range for JSObject or JSProxy, since their subtypes | 756 // Note that there is no range for JSObject or JSProxy, since their subtypes |
| 790 // are not continuous in this enum! The enum ranges instead reflect the | 757 // are not continuous in this enum! The enum ranges instead reflect the |
| 791 // external class names, where proxies are treated as either ordinary objects, | 758 // external class names, where proxies are treated as either ordinary objects, |
| 792 // or functions. | 759 // or functions. |
| 793 FIRST_JS_RECEIVER_TYPE = JS_FUNCTION_PROXY_TYPE, | 760 FIRST_JS_RECEIVER_TYPE = JS_FUNCTION_PROXY_TYPE, |
| 794 LAST_JS_RECEIVER_TYPE = LAST_TYPE, | 761 LAST_JS_RECEIVER_TYPE = LAST_TYPE, |
| 795 // Boundaries for testing the types represented as JSObject | 762 // Boundaries for testing the types represented as JSObject |
| 796 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, | 763 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, |
| 797 LAST_JS_OBJECT_TYPE = LAST_TYPE, | 764 LAST_JS_OBJECT_TYPE = LAST_TYPE, |
| 798 // Boundaries for testing the types represented as JSProxy | 765 // Boundaries for testing the types represented as JSProxy |
| 799 FIRST_JS_PROXY_TYPE = JS_FUNCTION_PROXY_TYPE, | 766 FIRST_JS_PROXY_TYPE = JS_FUNCTION_PROXY_TYPE, |
| 800 LAST_JS_PROXY_TYPE = JS_PROXY_TYPE, | 767 LAST_JS_PROXY_TYPE = JS_PROXY_TYPE, |
| 801 // Boundaries for testing whether the type is a JavaScript object. | 768 // Boundaries for testing whether the type is a JavaScript object. |
| 802 FIRST_SPEC_OBJECT_TYPE = FIRST_JS_RECEIVER_TYPE, | 769 FIRST_SPEC_OBJECT_TYPE = FIRST_JS_RECEIVER_TYPE, |
| 803 LAST_SPEC_OBJECT_TYPE = LAST_JS_RECEIVER_TYPE, | 770 LAST_SPEC_OBJECT_TYPE = LAST_JS_RECEIVER_TYPE, |
| 804 // Boundaries for testing the types for which typeof is "object". | 771 // Boundaries for testing the types for which typeof is "object". |
| 805 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_PROXY_TYPE, | 772 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_PROXY_TYPE, |
| 806 LAST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_REGEXP_TYPE, | 773 LAST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_REGEXP_TYPE, |
| 807 // Note that the types for which typeof is "function" are not continuous. | 774 // Note that the types for which typeof is "function" are not continuous. |
| 808 // Define this so that we can put assertions on discrete checks. | 775 // Define this so that we can put assertions on discrete checks. |
| 809 NUM_OF_CALLABLE_SPEC_OBJECT_TYPES = 2 | 776 NUM_OF_CALLABLE_SPEC_OBJECT_TYPES = 2 |
| 810 }; | 777 }; |
| 811 | 778 |
| 812 const int kExternalArrayTypeCount = | |
| 813 LAST_EXTERNAL_ARRAY_TYPE - FIRST_EXTERNAL_ARRAY_TYPE + 1; | |
| 814 | |
| 815 STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType); | 779 STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType); |
| 816 STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); | 780 STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); |
| 817 STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType); | 781 STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType); |
| 818 STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType); | 782 STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType); |
| 819 | 783 |
| 820 | 784 |
| 821 #define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \ | 785 #define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \ |
| 822 V(FAST_ELEMENTS_SUB_TYPE) \ | 786 V(FAST_ELEMENTS_SUB_TYPE) \ |
| 823 V(DICTIONARY_ELEMENTS_SUB_TYPE) \ | 787 V(DICTIONARY_ELEMENTS_SUB_TYPE) \ |
| 824 V(FAST_PROPERTIES_SUB_TYPE) \ | 788 V(FAST_PROPERTIES_SUB_TYPE) \ |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 V(ExternalString) \ | 887 V(ExternalString) \ |
| 924 V(ConsString) \ | 888 V(ConsString) \ |
| 925 V(SlicedString) \ | 889 V(SlicedString) \ |
| 926 V(ExternalTwoByteString) \ | 890 V(ExternalTwoByteString) \ |
| 927 V(ExternalOneByteString) \ | 891 V(ExternalOneByteString) \ |
| 928 V(SeqTwoByteString) \ | 892 V(SeqTwoByteString) \ |
| 929 V(SeqOneByteString) \ | 893 V(SeqOneByteString) \ |
| 930 V(InternalizedString) \ | 894 V(InternalizedString) \ |
| 931 V(Symbol) \ | 895 V(Symbol) \ |
| 932 \ | 896 \ |
| 933 V(ExternalArray) \ | |
| 934 V(ExternalInt8Array) \ | |
| 935 V(ExternalUint8Array) \ | |
| 936 V(ExternalInt16Array) \ | |
| 937 V(ExternalUint16Array) \ | |
| 938 V(ExternalInt32Array) \ | |
| 939 V(ExternalUint32Array) \ | |
| 940 V(ExternalFloat32Array) \ | |
| 941 V(ExternalFloat64Array) \ | |
| 942 V(ExternalUint8ClampedArray) \ | |
| 943 V(FixedTypedArrayBase) \ | 897 V(FixedTypedArrayBase) \ |
| 944 V(FixedUint8Array) \ | 898 V(FixedUint8Array) \ |
| 945 V(FixedInt8Array) \ | 899 V(FixedInt8Array) \ |
| 946 V(FixedUint16Array) \ | 900 V(FixedUint16Array) \ |
| 947 V(FixedInt16Array) \ | 901 V(FixedInt16Array) \ |
| 948 V(FixedUint32Array) \ | 902 V(FixedUint32Array) \ |
| 949 V(FixedInt32Array) \ | 903 V(FixedInt32Array) \ |
| 950 V(FixedFloat32Array) \ | 904 V(FixedFloat32Array) \ |
| 951 V(FixedFloat64Array) \ | 905 V(FixedFloat64Array) \ |
| 952 V(FixedUint8ClampedArray) \ | 906 V(FixedUint8ClampedArray) \ |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 // | 1715 // |
| 1762 // In the fast mode elements is a FixedArray and so each element can | 1716 // In the fast mode elements is a FixedArray and so each element can |
| 1763 // be quickly accessed. This fact is used in the generated code. The | 1717 // be quickly accessed. This fact is used in the generated code. The |
| 1764 // elements array can have one of three maps in this mode: | 1718 // elements array can have one of three maps in this mode: |
| 1765 // fixed_array_map, sloppy_arguments_elements_map or | 1719 // fixed_array_map, sloppy_arguments_elements_map or |
| 1766 // fixed_cow_array_map (for copy-on-write arrays). In the latter case | 1720 // fixed_cow_array_map (for copy-on-write arrays). In the latter case |
| 1767 // the elements array may be shared by a few objects and so before | 1721 // the elements array may be shared by a few objects and so before |
| 1768 // writing to any element the array must be copied. Use | 1722 // writing to any element the array must be copied. Use |
| 1769 // EnsureWritableFastElements in this case. | 1723 // EnsureWritableFastElements in this case. |
| 1770 // | 1724 // |
| 1771 // In the slow mode the elements is either a NumberDictionary, an | 1725 // In the slow mode the elements is either a NumberDictionary, a |
| 1772 // ExternalArray, or a FixedArray parameter map for a (sloppy) | 1726 // FixedArray parameter map for a (sloppy) arguments object. |
| 1773 // arguments object. | |
| 1774 DECL_ACCESSORS(elements, FixedArrayBase) | 1727 DECL_ACCESSORS(elements, FixedArrayBase) |
| 1775 inline void initialize_elements(); | 1728 inline void initialize_elements(); |
| 1776 static void ResetElements(Handle<JSObject> object); | 1729 static void ResetElements(Handle<JSObject> object); |
| 1777 static inline void SetMapAndElements(Handle<JSObject> object, | 1730 static inline void SetMapAndElements(Handle<JSObject> object, |
| 1778 Handle<Map> map, | 1731 Handle<Map> map, |
| 1779 Handle<FixedArrayBase> elements); | 1732 Handle<FixedArrayBase> elements); |
| 1780 inline ElementsKind GetElementsKind(); | 1733 inline ElementsKind GetElementsKind(); |
| 1781 ElementsAccessor* GetElementsAccessor(); | 1734 ElementsAccessor* GetElementsAccessor(); |
| 1782 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind. | 1735 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind. |
| 1783 inline bool HasFastSmiElements(); | 1736 inline bool HasFastSmiElements(); |
| 1784 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind. | 1737 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind. |
| 1785 inline bool HasFastObjectElements(); | 1738 inline bool HasFastObjectElements(); |
| 1786 // Returns true if an object has elements of FAST_ELEMENTS or | 1739 // Returns true if an object has elements of FAST_ELEMENTS or |
| 1787 // FAST_SMI_ONLY_ELEMENTS. | 1740 // FAST_SMI_ONLY_ELEMENTS. |
| 1788 inline bool HasFastSmiOrObjectElements(); | 1741 inline bool HasFastSmiOrObjectElements(); |
| 1789 // Returns true if an object has any of the fast elements kinds. | 1742 // Returns true if an object has any of the fast elements kinds. |
| 1790 inline bool HasFastElements(); | 1743 inline bool HasFastElements(); |
| 1791 // Returns true if an object has elements of FAST_DOUBLE_ELEMENTS | 1744 // Returns true if an object has elements of FAST_DOUBLE_ELEMENTS |
| 1792 // ElementsKind. | 1745 // ElementsKind. |
| 1793 inline bool HasFastDoubleElements(); | 1746 inline bool HasFastDoubleElements(); |
| 1794 // Returns true if an object has elements of FAST_HOLEY_*_ELEMENTS | 1747 // Returns true if an object has elements of FAST_HOLEY_*_ELEMENTS |
| 1795 // ElementsKind. | 1748 // ElementsKind. |
| 1796 inline bool HasFastHoleyElements(); | 1749 inline bool HasFastHoleyElements(); |
| 1797 inline bool HasSloppyArgumentsElements(); | 1750 inline bool HasSloppyArgumentsElements(); |
| 1798 inline bool HasDictionaryElements(); | 1751 inline bool HasDictionaryElements(); |
| 1799 | 1752 |
| 1800 inline bool HasExternalUint8ClampedElements(); | |
| 1801 inline bool HasExternalArrayElements(); | |
| 1802 inline bool HasExternalInt8Elements(); | |
| 1803 inline bool HasExternalUint8Elements(); | |
| 1804 inline bool HasExternalInt16Elements(); | |
| 1805 inline bool HasExternalUint16Elements(); | |
| 1806 inline bool HasExternalInt32Elements(); | |
| 1807 inline bool HasExternalUint32Elements(); | |
| 1808 inline bool HasExternalFloat32Elements(); | |
| 1809 inline bool HasExternalFloat64Elements(); | |
| 1810 | |
| 1811 inline bool HasFixedTypedArrayElements(); | 1753 inline bool HasFixedTypedArrayElements(); |
| 1812 | 1754 |
| 1813 inline bool HasFixedUint8ClampedElements(); | 1755 inline bool HasFixedUint8ClampedElements(); |
| 1814 inline bool HasFixedArrayElements(); | 1756 inline bool HasFixedArrayElements(); |
| 1815 inline bool HasFixedInt8Elements(); | 1757 inline bool HasFixedInt8Elements(); |
| 1816 inline bool HasFixedUint8Elements(); | 1758 inline bool HasFixedUint8Elements(); |
| 1817 inline bool HasFixedInt16Elements(); | 1759 inline bool HasFixedInt16Elements(); |
| 1818 inline bool HasFixedUint16Elements(); | 1760 inline bool HasFixedUint16Elements(); |
| 1819 inline bool HasFixedInt32Elements(); | 1761 inline bool HasFixedInt32Elements(); |
| 1820 inline bool HasFixedUint32Elements(); | 1762 inline bool HasFixedUint32Elements(); |
| (...skipping 2455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4276 V(Int8, int8, INT8, int8_t, 1) \ | 4218 V(Int8, int8, INT8, int8_t, 1) \ |
| 4277 V(Uint16, uint16, UINT16, uint16_t, 2) \ | 4219 V(Uint16, uint16, UINT16, uint16_t, 2) \ |
| 4278 V(Int16, int16, INT16, int16_t, 2) \ | 4220 V(Int16, int16, INT16, int16_t, 2) \ |
| 4279 V(Uint32, uint32, UINT32, uint32_t, 4) \ | 4221 V(Uint32, uint32, UINT32, uint32_t, 4) \ |
| 4280 V(Int32, int32, INT32, int32_t, 4) \ | 4222 V(Int32, int32, INT32, int32_t, 4) \ |
| 4281 V(Float32, float32, FLOAT32, float, 4) \ | 4223 V(Float32, float32, FLOAT32, float, 4) \ |
| 4282 V(Float64, float64, FLOAT64, double, 8) \ | 4224 V(Float64, float64, FLOAT64, double, 8) \ |
| 4283 V(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t, 1) | 4225 V(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t, 1) |
| 4284 | 4226 |
| 4285 | 4227 |
| 4286 | |
| 4287 // An ExternalArray represents a fixed-size array of primitive values | |
| 4288 // which live outside the JavaScript heap. Its subclasses are used to | |
| 4289 // implement the CanvasArray types being defined in the WebGL | |
| 4290 // specification. As of this writing the first public draft is not yet | |
| 4291 // available, but Khronos members can access the draft at: | |
| 4292 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | |
| 4293 // | |
| 4294 // The semantics of these arrays differ from CanvasPixelArray. | |
| 4295 // Out-of-range values passed to the setter are converted via a C | |
| 4296 // cast, not clamping. Out-of-range indices cause exceptions to be | |
| 4297 // raised rather than being silently ignored. | |
| 4298 class ExternalArray: public FixedArrayBase { | |
| 4299 public: | |
| 4300 inline bool is_the_hole(int index) { return false; } | |
| 4301 | |
| 4302 // [external_pointer]: The pointer to the external memory area backing this | |
| 4303 // external array. | |
| 4304 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. | |
| 4305 | |
| 4306 DECLARE_CAST(ExternalArray) | |
| 4307 | |
| 4308 // Maximal acceptable length for an external array. | |
| 4309 static const int kMaxLength = 0x3fffffff; | |
| 4310 | |
| 4311 // ExternalArray headers are not quadword aligned. | |
| 4312 static const int kExternalPointerOffset = | |
| 4313 POINTER_SIZE_ALIGN(FixedArrayBase::kLengthOffset + kPointerSize); | |
| 4314 static const int kSize = kExternalPointerOffset + kPointerSize; | |
| 4315 | |
| 4316 private: | |
| 4317 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); | |
| 4318 }; | |
| 4319 | |
| 4320 | |
| 4321 // A ExternalUint8ClampedArray represents a fixed-size byte array with special | |
| 4322 // semantics used for implementing the CanvasPixelArray object. Please see the | |
| 4323 // specification at: | |
| 4324 | |
| 4325 // http://www.whatwg.org/specs/web-apps/current-work/ | |
| 4326 // multipage/the-canvas-element.html#canvaspixelarray | |
| 4327 // In particular, write access clamps the value written to 0 or 255 if the | |
| 4328 // value written is outside this range. | |
| 4329 class ExternalUint8ClampedArray: public ExternalArray { | |
| 4330 public: | |
| 4331 inline uint8_t* external_uint8_clamped_pointer(); | |
| 4332 | |
| 4333 // Setter and getter. | |
| 4334 inline uint8_t get_scalar(int index); | |
| 4335 static inline Handle<Object> get(Handle<ExternalUint8ClampedArray> array, | |
| 4336 int index); | |
| 4337 inline void set(int index, uint8_t value); | |
| 4338 | |
| 4339 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4340 // and undefined and clamps the converted value between 0 and 255. | |
| 4341 void SetValue(uint32_t index, Object* value); | |
| 4342 | |
| 4343 DECLARE_CAST(ExternalUint8ClampedArray) | |
| 4344 | |
| 4345 // Dispatched behavior. | |
| 4346 DECLARE_PRINTER(ExternalUint8ClampedArray) | |
| 4347 DECLARE_VERIFIER(ExternalUint8ClampedArray) | |
| 4348 | |
| 4349 private: | |
| 4350 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8ClampedArray); | |
| 4351 }; | |
| 4352 | |
| 4353 | |
| 4354 class ExternalInt8Array: public ExternalArray { | |
| 4355 public: | |
| 4356 // Setter and getter. | |
| 4357 inline int8_t get_scalar(int index); | |
| 4358 static inline Handle<Object> get(Handle<ExternalInt8Array> array, int index); | |
| 4359 inline void set(int index, int8_t value); | |
| 4360 | |
| 4361 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4362 // and undefined. | |
| 4363 void SetValue(uint32_t index, Object* value); | |
| 4364 | |
| 4365 DECLARE_CAST(ExternalInt8Array) | |
| 4366 | |
| 4367 // Dispatched behavior. | |
| 4368 DECLARE_PRINTER(ExternalInt8Array) | |
| 4369 DECLARE_VERIFIER(ExternalInt8Array) | |
| 4370 | |
| 4371 private: | |
| 4372 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt8Array); | |
| 4373 }; | |
| 4374 | |
| 4375 | |
| 4376 class ExternalUint8Array: public ExternalArray { | |
| 4377 public: | |
| 4378 // Setter and getter. | |
| 4379 inline uint8_t get_scalar(int index); | |
| 4380 static inline Handle<Object> get(Handle<ExternalUint8Array> array, int index); | |
| 4381 inline void set(int index, uint8_t value); | |
| 4382 | |
| 4383 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4384 // and undefined. | |
| 4385 void SetValue(uint32_t index, Object* value); | |
| 4386 | |
| 4387 DECLARE_CAST(ExternalUint8Array) | |
| 4388 | |
| 4389 // Dispatched behavior. | |
| 4390 DECLARE_PRINTER(ExternalUint8Array) | |
| 4391 DECLARE_VERIFIER(ExternalUint8Array) | |
| 4392 | |
| 4393 private: | |
| 4394 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8Array); | |
| 4395 }; | |
| 4396 | |
| 4397 | |
| 4398 class ExternalInt16Array: public ExternalArray { | |
| 4399 public: | |
| 4400 // Setter and getter. | |
| 4401 inline int16_t get_scalar(int index); | |
| 4402 static inline Handle<Object> get(Handle<ExternalInt16Array> array, int index); | |
| 4403 inline void set(int index, int16_t value); | |
| 4404 | |
| 4405 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4406 // and undefined. | |
| 4407 void SetValue(uint32_t index, Object* value); | |
| 4408 | |
| 4409 DECLARE_CAST(ExternalInt16Array) | |
| 4410 | |
| 4411 // Dispatched behavior. | |
| 4412 DECLARE_PRINTER(ExternalInt16Array) | |
| 4413 DECLARE_VERIFIER(ExternalInt16Array) | |
| 4414 | |
| 4415 private: | |
| 4416 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt16Array); | |
| 4417 }; | |
| 4418 | |
| 4419 | |
| 4420 class ExternalUint16Array: public ExternalArray { | |
| 4421 public: | |
| 4422 // Setter and getter. | |
| 4423 inline uint16_t get_scalar(int index); | |
| 4424 static inline Handle<Object> get(Handle<ExternalUint16Array> array, | |
| 4425 int index); | |
| 4426 inline void set(int index, uint16_t value); | |
| 4427 | |
| 4428 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4429 // and undefined. | |
| 4430 void SetValue(uint32_t index, Object* value); | |
| 4431 | |
| 4432 DECLARE_CAST(ExternalUint16Array) | |
| 4433 | |
| 4434 // Dispatched behavior. | |
| 4435 DECLARE_PRINTER(ExternalUint16Array) | |
| 4436 DECLARE_VERIFIER(ExternalUint16Array) | |
| 4437 | |
| 4438 private: | |
| 4439 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint16Array); | |
| 4440 }; | |
| 4441 | |
| 4442 | |
| 4443 class ExternalInt32Array: public ExternalArray { | |
| 4444 public: | |
| 4445 // Setter and getter. | |
| 4446 inline int32_t get_scalar(int index); | |
| 4447 static inline Handle<Object> get(Handle<ExternalInt32Array> array, int index); | |
| 4448 inline void set(int index, int32_t value); | |
| 4449 | |
| 4450 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4451 // and undefined. | |
| 4452 void SetValue(uint32_t index, Object* value); | |
| 4453 | |
| 4454 DECLARE_CAST(ExternalInt32Array) | |
| 4455 | |
| 4456 // Dispatched behavior. | |
| 4457 DECLARE_PRINTER(ExternalInt32Array) | |
| 4458 DECLARE_VERIFIER(ExternalInt32Array) | |
| 4459 | |
| 4460 private: | |
| 4461 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt32Array); | |
| 4462 }; | |
| 4463 | |
| 4464 | |
| 4465 class ExternalUint32Array: public ExternalArray { | |
| 4466 public: | |
| 4467 // Setter and getter. | |
| 4468 inline uint32_t get_scalar(int index); | |
| 4469 static inline Handle<Object> get(Handle<ExternalUint32Array> array, | |
| 4470 int index); | |
| 4471 inline void set(int index, uint32_t value); | |
| 4472 | |
| 4473 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4474 // and undefined. | |
| 4475 void SetValue(uint32_t index, Object* value); | |
| 4476 | |
| 4477 DECLARE_CAST(ExternalUint32Array) | |
| 4478 | |
| 4479 // Dispatched behavior. | |
| 4480 DECLARE_PRINTER(ExternalUint32Array) | |
| 4481 DECLARE_VERIFIER(ExternalUint32Array) | |
| 4482 | |
| 4483 private: | |
| 4484 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint32Array); | |
| 4485 }; | |
| 4486 | |
| 4487 | |
| 4488 class ExternalFloat32Array: public ExternalArray { | |
| 4489 public: | |
| 4490 // Setter and getter. | |
| 4491 inline float get_scalar(int index); | |
| 4492 static inline Handle<Object> get(Handle<ExternalFloat32Array> array, | |
| 4493 int index); | |
| 4494 inline void set(int index, float value); | |
| 4495 | |
| 4496 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4497 // and undefined. | |
| 4498 void SetValue(uint32_t index, Object* value); | |
| 4499 | |
| 4500 DECLARE_CAST(ExternalFloat32Array) | |
| 4501 | |
| 4502 // Dispatched behavior. | |
| 4503 DECLARE_PRINTER(ExternalFloat32Array) | |
| 4504 DECLARE_VERIFIER(ExternalFloat32Array) | |
| 4505 | |
| 4506 private: | |
| 4507 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat32Array); | |
| 4508 }; | |
| 4509 | |
| 4510 | |
| 4511 class ExternalFloat64Array: public ExternalArray { | |
| 4512 public: | |
| 4513 // Setter and getter. | |
| 4514 inline double get_scalar(int index); | |
| 4515 static inline Handle<Object> get(Handle<ExternalFloat64Array> array, | |
| 4516 int index); | |
| 4517 inline void set(int index, double value); | |
| 4518 | |
| 4519 // This accessor applies the correct conversion from Smi, HeapNumber | |
| 4520 // and undefined. | |
| 4521 void SetValue(uint32_t index, Object* value); | |
| 4522 | |
| 4523 DECLARE_CAST(ExternalFloat64Array) | |
| 4524 | |
| 4525 // Dispatched behavior. | |
| 4526 DECLARE_PRINTER(ExternalFloat64Array) | |
| 4527 DECLARE_VERIFIER(ExternalFloat64Array) | |
| 4528 | |
| 4529 private: | |
| 4530 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat64Array); | |
| 4531 }; | |
| 4532 | |
| 4533 | |
| 4534 class FixedTypedArrayBase: public FixedArrayBase { | 4228 class FixedTypedArrayBase: public FixedArrayBase { |
| 4535 public: | 4229 public: |
| 4536 // [base_pointer]: For now, points to the FixedTypedArrayBase itself. | 4230 // [base_pointer]: Either points to the FixedTypedArrayBase itself or nullptr. |
| 4537 DECL_ACCESSORS(base_pointer, Object) | 4231 DECL_ACCESSORS(base_pointer, Object) |
| 4538 | 4232 |
| 4539 // [external_pointer]: For now, contains the offset between base_pointer and | 4233 // [external_pointer]: Contains the offset between base_pointer and the start |
| 4540 // the start of the data. | 4234 // of the data. If the base_pointer is a nullptr, the external_pointer |
| 4235 // therefore points to the actual backing store. |
| 4541 DECL_ACCESSORS(external_pointer, void) | 4236 DECL_ACCESSORS(external_pointer, void) |
| 4542 | 4237 |
| 4543 // Dispatched behavior. | 4238 // Dispatched behavior. |
| 4544 inline void FixedTypedArrayBaseIterateBody(ObjectVisitor* v); | 4239 inline void FixedTypedArrayBaseIterateBody(ObjectVisitor* v); |
| 4545 | 4240 |
| 4546 template <typename StaticVisitor> | 4241 template <typename StaticVisitor> |
| 4547 inline void FixedTypedArrayBaseIterateBody(); | 4242 inline void FixedTypedArrayBaseIterateBody(); |
| 4548 | 4243 |
| 4549 DECLARE_CAST(FixedTypedArrayBase) | 4244 DECLARE_CAST(FixedTypedArrayBase) |
| 4550 | 4245 |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5686 } | 5381 } |
| 5687 | 5382 |
| 5688 inline bool has_fast_elements() { | 5383 inline bool has_fast_elements() { |
| 5689 return IsFastElementsKind(elements_kind()); | 5384 return IsFastElementsKind(elements_kind()); |
| 5690 } | 5385 } |
| 5691 | 5386 |
| 5692 inline bool has_sloppy_arguments_elements() { | 5387 inline bool has_sloppy_arguments_elements() { |
| 5693 return IsSloppyArgumentsElements(elements_kind()); | 5388 return IsSloppyArgumentsElements(elements_kind()); |
| 5694 } | 5389 } |
| 5695 | 5390 |
| 5696 inline bool has_external_array_elements() { | |
| 5697 return IsExternalArrayElementsKind(elements_kind()); | |
| 5698 } | |
| 5699 | |
| 5700 inline bool has_fixed_typed_array_elements() { | 5391 inline bool has_fixed_typed_array_elements() { |
| 5701 return IsFixedTypedArrayElementsKind(elements_kind()); | 5392 return IsFixedTypedArrayElementsKind(elements_kind()); |
| 5702 } | 5393 } |
| 5703 | 5394 |
| 5704 inline bool has_dictionary_elements() { | 5395 inline bool has_dictionary_elements() { |
| 5705 return IsDictionaryElementsKind(elements_kind()); | 5396 return IsDictionaryElementsKind(elements_kind()); |
| 5706 } | 5397 } |
| 5707 | 5398 |
| 5708 static bool IsValidElementsTransition(ElementsKind from_kind, | 5399 static bool IsValidElementsTransition(ElementsKind from_kind, |
| 5709 ElementsKind to_kind); | 5400 ElementsKind to_kind); |
| (...skipping 5090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10800 } else { | 10491 } else { |
| 10801 value &= ~(1 << bit_position); | 10492 value &= ~(1 << bit_position); |
| 10802 } | 10493 } |
| 10803 return value; | 10494 return value; |
| 10804 } | 10495 } |
| 10805 }; | 10496 }; |
| 10806 | 10497 |
| 10807 } } // namespace v8::internal | 10498 } } // namespace v8::internal |
| 10808 | 10499 |
| 10809 #endif // V8_OBJECTS_H_ | 10500 #endif // V8_OBJECTS_H_ |
| OLD | NEW |