OLD | NEW |
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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 BYTE_ARRAY_TYPE, | 526 BYTE_ARRAY_TYPE, |
527 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | 527 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE |
528 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, | 528 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, |
529 EXTERNAL_SHORT_ARRAY_TYPE, | 529 EXTERNAL_SHORT_ARRAY_TYPE, |
530 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, | 530 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, |
531 EXTERNAL_INT_ARRAY_TYPE, | 531 EXTERNAL_INT_ARRAY_TYPE, |
532 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, | 532 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, |
533 EXTERNAL_FLOAT_ARRAY_TYPE, | 533 EXTERNAL_FLOAT_ARRAY_TYPE, |
534 EXTERNAL_DOUBLE_ARRAY_TYPE, | 534 EXTERNAL_DOUBLE_ARRAY_TYPE, |
535 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE | 535 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE |
| 536 FIXED_DOUBLE_ARRAY_TYPE, |
536 FILLER_TYPE, // LAST_DATA_TYPE | 537 FILLER_TYPE, // LAST_DATA_TYPE |
537 | 538 |
538 // Structs. | 539 // Structs. |
539 ACCESSOR_INFO_TYPE, | 540 ACCESSOR_INFO_TYPE, |
540 ACCESS_CHECK_INFO_TYPE, | 541 ACCESS_CHECK_INFO_TYPE, |
541 INTERCEPTOR_INFO_TYPE, | 542 INTERCEPTOR_INFO_TYPE, |
542 CALL_HANDLER_INFO_TYPE, | 543 CALL_HANDLER_INFO_TYPE, |
543 FUNCTION_TEMPLATE_INFO_TYPE, | 544 FUNCTION_TEMPLATE_INFO_TYPE, |
544 OBJECT_TEMPLATE_INFO_TYPE, | 545 OBJECT_TEMPLATE_INFO_TYPE, |
545 SIGNATURE_INFO_TYPE, | 546 SIGNATURE_INFO_TYPE, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 V(ExternalPixelArray) \ | 726 V(ExternalPixelArray) \ |
726 V(ByteArray) \ | 727 V(ByteArray) \ |
727 V(JSReceiver) \ | 728 V(JSReceiver) \ |
728 V(JSObject) \ | 729 V(JSObject) \ |
729 V(JSContextExtensionObject) \ | 730 V(JSContextExtensionObject) \ |
730 V(Map) \ | 731 V(Map) \ |
731 V(DescriptorArray) \ | 732 V(DescriptorArray) \ |
732 V(DeoptimizationInputData) \ | 733 V(DeoptimizationInputData) \ |
733 V(DeoptimizationOutputData) \ | 734 V(DeoptimizationOutputData) \ |
734 V(FixedArray) \ | 735 V(FixedArray) \ |
| 736 V(FixedDoubleArray) \ |
735 V(Context) \ | 737 V(Context) \ |
736 V(CatchContext) \ | 738 V(CatchContext) \ |
737 V(GlobalContext) \ | 739 V(GlobalContext) \ |
738 V(JSFunction) \ | 740 V(JSFunction) \ |
739 V(Code) \ | 741 V(Code) \ |
740 V(Oddball) \ | 742 V(Oddball) \ |
741 V(SharedFunctionInfo) \ | 743 V(SharedFunctionInfo) \ |
742 V(JSValue) \ | 744 V(JSValue) \ |
743 V(JSMessageObject) \ | 745 V(JSMessageObject) \ |
744 V(StringWrapper) \ | 746 V(StringWrapper) \ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 INLINE(bool IsUndefined()); | 795 INLINE(bool IsUndefined()); |
794 INLINE(bool IsNull()); | 796 INLINE(bool IsNull()); |
795 INLINE(bool IsTheHole()); // Shadows MaybeObject's implementation. | 797 INLINE(bool IsTheHole()); // Shadows MaybeObject's implementation. |
796 INLINE(bool IsTrue()); | 798 INLINE(bool IsTrue()); |
797 INLINE(bool IsFalse()); | 799 INLINE(bool IsFalse()); |
798 inline bool IsArgumentsMarker(); | 800 inline bool IsArgumentsMarker(); |
799 | 801 |
800 // Extract the number. | 802 // Extract the number. |
801 inline double Number(); | 803 inline double Number(); |
802 | 804 |
| 805 // Returns true if the object is of the correct type to be used as a |
| 806 // implementation of a JSObject's elements. |
| 807 inline bool HasValidElements(); |
| 808 |
803 inline bool HasSpecificClassOf(String* name); | 809 inline bool HasSpecificClassOf(String* name); |
804 | 810 |
805 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. | 811 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. |
806 Object* ToBoolean(); // ECMA-262 9.2. | 812 Object* ToBoolean(); // ECMA-262 9.2. |
807 | 813 |
808 // Convert to a JSObject if needed. | 814 // Convert to a JSObject if needed. |
809 // global_context is used when creating wrapper object. | 815 // global_context is used when creating wrapper object. |
810 MUST_USE_RESULT MaybeObject* ToObject(Context* global_context); | 816 MUST_USE_RESULT MaybeObject* ToObject(Context* global_context); |
811 | 817 |
812 // Converts this to a Smi if possible. | 818 // Converts this to a Smi if possible. |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 enum DeleteMode { | 1426 enum DeleteMode { |
1421 NORMAL_DELETION, | 1427 NORMAL_DELETION, |
1422 STRICT_DELETION, | 1428 STRICT_DELETION, |
1423 FORCE_DELETION | 1429 FORCE_DELETION |
1424 }; | 1430 }; |
1425 | 1431 |
1426 enum ElementsKind { | 1432 enum ElementsKind { |
1427 // The "fast" kind for tagged values. Must be first to make it possible | 1433 // The "fast" kind for tagged values. Must be first to make it possible |
1428 // to efficiently check maps if they have fast elements. | 1434 // to efficiently check maps if they have fast elements. |
1429 FAST_ELEMENTS, | 1435 FAST_ELEMENTS, |
| 1436 |
| 1437 // The "fast" kind for unwrapped, non-tagged double values. |
| 1438 FAST_DOUBLE_ELEMENTS, |
| 1439 |
1430 // The "slow" kind. | 1440 // The "slow" kind. |
1431 DICTIONARY_ELEMENTS, | 1441 DICTIONARY_ELEMENTS, |
1432 // The "fast" kind for external arrays | 1442 // The "fast" kind for external arrays |
1433 EXTERNAL_BYTE_ELEMENTS, | 1443 EXTERNAL_BYTE_ELEMENTS, |
1434 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, | 1444 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, |
1435 EXTERNAL_SHORT_ELEMENTS, | 1445 EXTERNAL_SHORT_ELEMENTS, |
1436 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, | 1446 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, |
1437 EXTERNAL_INT_ELEMENTS, | 1447 EXTERNAL_INT_ELEMENTS, |
1438 EXTERNAL_UNSIGNED_INT_ELEMENTS, | 1448 EXTERNAL_UNSIGNED_INT_ELEMENTS, |
1439 EXTERNAL_FLOAT_ELEMENTS, | 1449 EXTERNAL_FLOAT_ELEMENTS, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 // arrays). In the latter case the elements array may be shared by a | 1481 // arrays). In the latter case the elements array may be shared by a |
1472 // few objects and so before writing to any element the array must | 1482 // few objects and so before writing to any element the array must |
1473 // be copied. Use EnsureWritableFastElements in this case. | 1483 // be copied. Use EnsureWritableFastElements in this case. |
1474 // | 1484 // |
1475 // In the slow mode elements is either a NumberDictionary or an ExternalArray. | 1485 // In the slow mode elements is either a NumberDictionary or an ExternalArray. |
1476 DECL_ACCESSORS(elements, HeapObject) | 1486 DECL_ACCESSORS(elements, HeapObject) |
1477 inline void initialize_elements(); | 1487 inline void initialize_elements(); |
1478 MUST_USE_RESULT inline MaybeObject* ResetElements(); | 1488 MUST_USE_RESULT inline MaybeObject* ResetElements(); |
1479 inline ElementsKind GetElementsKind(); | 1489 inline ElementsKind GetElementsKind(); |
1480 inline bool HasFastElements(); | 1490 inline bool HasFastElements(); |
| 1491 inline bool HasFastDoubleElements(); |
1481 inline bool HasDictionaryElements(); | 1492 inline bool HasDictionaryElements(); |
1482 inline bool HasExternalPixelElements(); | 1493 inline bool HasExternalPixelElements(); |
1483 inline bool HasExternalArrayElements(); | 1494 inline bool HasExternalArrayElements(); |
1484 inline bool HasExternalByteElements(); | 1495 inline bool HasExternalByteElements(); |
1485 inline bool HasExternalUnsignedByteElements(); | 1496 inline bool HasExternalUnsignedByteElements(); |
1486 inline bool HasExternalShortElements(); | 1497 inline bool HasExternalShortElements(); |
1487 inline bool HasExternalUnsignedShortElements(); | 1498 inline bool HasExternalUnsignedShortElements(); |
1488 inline bool HasExternalIntElements(); | 1499 inline bool HasExternalIntElements(); |
1489 inline bool HasExternalUnsignedIntElements(); | 1500 inline bool HasExternalUnsignedIntElements(); |
1490 inline bool HasExternalFloatElements(); | 1501 inline bool HasExternalFloatElements(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 bool IsSimpleEnum(); | 1641 bool IsSimpleEnum(); |
1631 | 1642 |
1632 // Do we want to keep the elements in fast case when increasing the | 1643 // Do we want to keep the elements in fast case when increasing the |
1633 // capacity? | 1644 // capacity? |
1634 bool ShouldConvertToSlowElements(int new_capacity); | 1645 bool ShouldConvertToSlowElements(int new_capacity); |
1635 // Returns true if the backing storage for the slow-case elements of | 1646 // Returns true if the backing storage for the slow-case elements of |
1636 // this object takes up nearly as much space as a fast-case backing | 1647 // this object takes up nearly as much space as a fast-case backing |
1637 // storage would. In that case the JSObject should have fast | 1648 // storage would. In that case the JSObject should have fast |
1638 // elements. | 1649 // elements. |
1639 bool ShouldConvertToFastElements(); | 1650 bool ShouldConvertToFastElements(); |
| 1651 // Returns true if the elements of JSObject contains only values that can be |
| 1652 // represented in a FixedDoubleArray. |
| 1653 bool ShouldConvertToFastDoubleElements(); |
1640 | 1654 |
1641 // Tells whether the index'th element is present. | 1655 // Tells whether the index'th element is present. |
1642 inline bool HasElement(uint32_t index); | 1656 inline bool HasElement(uint32_t index); |
1643 bool HasElementWithReceiver(JSReceiver* receiver, uint32_t index); | 1657 bool HasElementWithReceiver(JSReceiver* receiver, uint32_t index); |
1644 | 1658 |
1645 // Computes the new capacity when expanding the elements of a JSObject. | 1659 // Computes the new capacity when expanding the elements of a JSObject. |
1646 static int NewElementsCapacity(int old_capacity) { | 1660 static int NewElementsCapacity(int old_capacity) { |
1647 // (old_capacity + 50%) + 16 | 1661 // (old_capacity + 50%) + 16 |
1648 return old_capacity + (old_capacity >> 1) + 16; | 1662 return old_capacity + (old_capacity >> 1) + 16; |
1649 } | 1663 } |
(...skipping 19 matching lines...) Expand all Loading... |
1669 LocalElementType HasLocalElement(uint32_t index); | 1683 LocalElementType HasLocalElement(uint32_t index); |
1670 | 1684 |
1671 bool HasElementWithInterceptor(JSReceiver* receiver, uint32_t index); | 1685 bool HasElementWithInterceptor(JSReceiver* receiver, uint32_t index); |
1672 bool HasElementPostInterceptor(JSReceiver* receiver, uint32_t index); | 1686 bool HasElementPostInterceptor(JSReceiver* receiver, uint32_t index); |
1673 | 1687 |
1674 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, | 1688 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, |
1675 Object* value, | 1689 Object* value, |
1676 StrictModeFlag strict_mode, | 1690 StrictModeFlag strict_mode, |
1677 bool check_prototype = true); | 1691 bool check_prototype = true); |
1678 | 1692 |
| 1693 MUST_USE_RESULT MaybeObject* SetFastDoubleElement( |
| 1694 uint32_t index, |
| 1695 Object* value, |
| 1696 StrictModeFlag strict_mode, |
| 1697 bool check_prototype = true); |
| 1698 |
1679 // Set the index'th array element. | 1699 // Set the index'th array element. |
1680 // A Failure object is returned if GC is needed. | 1700 // A Failure object is returned if GC is needed. |
1681 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, | 1701 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, |
1682 Object* value, | 1702 Object* value, |
1683 StrictModeFlag strict_mode, | 1703 StrictModeFlag strict_mode, |
1684 bool check_prototype = true); | 1704 bool check_prototype = true); |
1685 | 1705 |
1686 // Returns the index'th element. | 1706 // Returns the index'th element. |
1687 // The undefined object if index is out of bounds. | 1707 // The undefined object if index is out of bounds. |
1688 MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index); | 1708 MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index); |
1689 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); | 1709 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); |
1690 | 1710 |
1691 // Get external element value at index if there is one and undefined | 1711 // Get external element value at index if there is one and undefined |
1692 // otherwise. Can return a failure if allocation of a heap number | 1712 // otherwise. Can return a failure if allocation of a heap number |
1693 // failed. | 1713 // failed. |
1694 MaybeObject* GetExternalElement(uint32_t index); | 1714 MaybeObject* GetExternalElement(uint32_t index); |
1695 | 1715 |
1696 MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength(int capacity, | 1716 MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength(int capacity, |
1697 int length); | 1717 int length); |
| 1718 MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( |
| 1719 int capacity, |
| 1720 int length); |
1698 MUST_USE_RESULT MaybeObject* SetSlowElements(Object* length); | 1721 MUST_USE_RESULT MaybeObject* SetSlowElements(Object* length); |
1699 | 1722 |
1700 // Lookup interceptors are used for handling properties controlled by host | 1723 // Lookup interceptors are used for handling properties controlled by host |
1701 // objects. | 1724 // objects. |
1702 inline bool HasNamedInterceptor(); | 1725 inline bool HasNamedInterceptor(); |
1703 inline bool HasIndexedInterceptor(); | 1726 inline bool HasIndexedInterceptor(); |
1704 | 1727 |
1705 // Support functions for v8 api (needed for correct interceptor behavior). | 1728 // Support functions for v8 api (needed for correct interceptor behavior). |
1706 bool HasRealNamedProperty(String* key); | 1729 bool HasRealNamedProperty(String* key); |
1707 bool HasRealElementProperty(uint32_t index); | 1730 bool HasRealElementProperty(uint32_t index); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 MUST_USE_RESULT MaybeObject* DefineGetterSetter( | 2002 MUST_USE_RESULT MaybeObject* DefineGetterSetter( |
1980 String* name, | 2003 String* name, |
1981 PropertyAttributes attributes); | 2004 PropertyAttributes attributes); |
1982 | 2005 |
1983 void LookupInDescriptor(String* name, LookupResult* result); | 2006 void LookupInDescriptor(String* name, LookupResult* result); |
1984 | 2007 |
1985 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); | 2008 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); |
1986 }; | 2009 }; |
1987 | 2010 |
1988 | 2011 |
1989 // FixedArray describes fixed-sized arrays with element type Object*. | 2012 // Common superclass for FixedArrays that allow implementations to share |
1990 class FixedArray: public HeapObject { | 2013 // common accessors and some code paths. |
| 2014 class FixedArrayBase: public HeapObject { |
1991 public: | 2015 public: |
1992 // [length]: length of the array. | 2016 // [length]: length of the array. |
1993 inline int length(); | 2017 inline int length(); |
1994 inline void set_length(int value); | 2018 inline void set_length(int value); |
1995 | 2019 |
| 2020 inline static FixedArrayBase* cast(Object* object); |
| 2021 |
| 2022 // Layout description. |
| 2023 // Length is smi tagged when it is stored. |
| 2024 static const int kLengthOffset = HeapObject::kHeaderSize; |
| 2025 static const int kHeaderSize = kLengthOffset + kPointerSize; |
| 2026 }; |
| 2027 |
| 2028 |
| 2029 // FixedArray describes fixed-sized arrays with element type Object*. |
| 2030 class FixedArray: public FixedArrayBase { |
| 2031 public: |
1996 // Setter and getter for elements. | 2032 // Setter and getter for elements. |
1997 inline Object* get(int index); | 2033 inline Object* get(int index); |
1998 // Setter that uses write barrier. | 2034 // Setter that uses write barrier. |
1999 inline void set(int index, Object* value); | 2035 inline void set(int index, Object* value); |
2000 | 2036 |
2001 // Setter that doesn't need write barrier). | 2037 // Setter that doesn't need write barrier). |
2002 inline void set(int index, Smi* value); | 2038 inline void set(int index, Smi* value); |
2003 // Setter with explicit barrier mode. | 2039 // Setter with explicit barrier mode. |
2004 inline void set(int index, Object* value, WriteBarrierMode mode); | 2040 inline void set(int index, Object* value, WriteBarrierMode mode); |
2005 | 2041 |
(...skipping 30 matching lines...) Expand all Loading... |
2036 | 2072 |
2037 // Garbage collection support. | 2073 // Garbage collection support. |
2038 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } | 2074 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } |
2039 | 2075 |
2040 // Code Generation support. | 2076 // Code Generation support. |
2041 static int OffsetOfElementAt(int index) { return SizeFor(index); } | 2077 static int OffsetOfElementAt(int index) { return SizeFor(index); } |
2042 | 2078 |
2043 // Casting. | 2079 // Casting. |
2044 static inline FixedArray* cast(Object* obj); | 2080 static inline FixedArray* cast(Object* obj); |
2045 | 2081 |
2046 // Layout description. | |
2047 // Length is smi tagged when it is stored. | |
2048 static const int kLengthOffset = HeapObject::kHeaderSize; | |
2049 static const int kHeaderSize = kLengthOffset + kPointerSize; | |
2050 | |
2051 // Maximal allowed size, in bytes, of a single FixedArray. | 2082 // Maximal allowed size, in bytes, of a single FixedArray. |
2052 // Prevents overflowing size computations, as well as extreme memory | 2083 // Prevents overflowing size computations, as well as extreme memory |
2053 // consumption. | 2084 // consumption. |
2054 static const int kMaxSize = 512 * MB; | 2085 static const int kMaxSize = 512 * MB; |
2055 // Maximally allowed length of a FixedArray. | 2086 // Maximally allowed length of a FixedArray. |
2056 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; | 2087 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; |
2057 | 2088 |
2058 // Dispatched behavior. | 2089 // Dispatched behavior. |
2059 #ifdef OBJECT_PRINT | 2090 #ifdef OBJECT_PRINT |
2060 inline void FixedArrayPrint() { | 2091 inline void FixedArrayPrint() { |
(...skipping 27 matching lines...) Expand all Loading... |
2088 protected: | 2119 protected: |
2089 // Set operation on FixedArray without using write barriers. Can | 2120 // Set operation on FixedArray without using write barriers. Can |
2090 // only be used for storing old space objects or smis. | 2121 // only be used for storing old space objects or smis. |
2091 static inline void fast_set(FixedArray* array, int index, Object* value); | 2122 static inline void fast_set(FixedArray* array, int index, Object* value); |
2092 | 2123 |
2093 private: | 2124 private: |
2094 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray); | 2125 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray); |
2095 }; | 2126 }; |
2096 | 2127 |
2097 | 2128 |
| 2129 // FixedDoubleArray describes fixed-sized arrays with element type double. |
| 2130 class FixedDoubleArray: public FixedArrayBase { |
| 2131 public: |
| 2132 inline void Initialize(FixedArray* from); |
| 2133 inline void Initialize(FixedDoubleArray* from); |
| 2134 inline void Initialize(NumberDictionary* from); |
| 2135 |
| 2136 // Setter and getter for elements. |
| 2137 inline double get(int index); |
| 2138 inline void set(int index, double value); |
| 2139 inline void set_the_hole(int index); |
| 2140 |
| 2141 // Checking for the hole. |
| 2142 inline bool is_the_hole(int index); |
| 2143 |
| 2144 // Garbage collection support. |
| 2145 inline static int SizeFor(int length) { |
| 2146 return kHeaderSize + length * kDoubleSize; |
| 2147 } |
| 2148 |
| 2149 // The following can't be declared inline as const static |
| 2150 // because they're 64-bit. |
| 2151 static uint64_t kCanonicalNonHoleNanLower32; |
| 2152 static uint64_t kCanonicalNonHoleNanInt64; |
| 2153 static uint64_t kHoleNanInt64; |
| 2154 |
| 2155 inline static bool is_the_hole_nan(double value) { |
| 2156 return BitCast<uint64_t, double>(value) == kHoleNanInt64; |
| 2157 } |
| 2158 |
| 2159 inline static double hole_nan_as_double() { |
| 2160 return BitCast<double, uint64_t>(kHoleNanInt64); |
| 2161 } |
| 2162 |
| 2163 inline static double canonical_not_the_hole_nan_as_double() { |
| 2164 return BitCast<double, uint64_t>(kCanonicalNonHoleNanInt64); |
| 2165 } |
| 2166 |
| 2167 // Casting. |
| 2168 static inline FixedDoubleArray* cast(Object* obj); |
| 2169 |
| 2170 // Maximal allowed size, in bytes, of a single FixedDoubleArray. |
| 2171 // Prevents overflowing size computations, as well as extreme memory |
| 2172 // consumption. |
| 2173 static const int kMaxSize = 512 * MB; |
| 2174 // Maximally allowed length of a FixedArray. |
| 2175 static const int kMaxLength = (kMaxSize - kHeaderSize) / kDoubleSize; |
| 2176 |
| 2177 // Dispatched behavior. |
| 2178 #ifdef OBJECT_PRINT |
| 2179 inline void FixedDoubleArrayPrint() { |
| 2180 FixedDoubleArrayPrint(stdout); |
| 2181 } |
| 2182 void FixedDoubleArrayPrint(FILE* out); |
| 2183 #endif |
| 2184 |
| 2185 #ifdef DEBUG |
| 2186 void FixedDoubleArrayVerify(); |
| 2187 #endif |
| 2188 |
| 2189 private: |
| 2190 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); |
| 2191 }; |
| 2192 |
| 2193 |
2098 // DescriptorArrays are fixed arrays used to hold instance descriptors. | 2194 // DescriptorArrays are fixed arrays used to hold instance descriptors. |
2099 // The format of the these objects is: | 2195 // The format of the these objects is: |
2100 // TODO(1399): It should be possible to make room for bit_field3 in the map | 2196 // TODO(1399): It should be possible to make room for bit_field3 in the map |
2101 // without overloading the instance descriptors field in the map | 2197 // without overloading the instance descriptors field in the map |
2102 // (and storing it in the DescriptorArray when the map has one). | 2198 // (and storing it in the DescriptorArray when the map has one). |
2103 // [0]: storage for bit_field3 for Map owning this object (Smi) | 2199 // [0]: storage for bit_field3 for Map owning this object (Smi) |
2104 // [1]: point to a fixed array with (value, detail) pairs. | 2200 // [1]: point to a fixed array with (value, detail) pairs. |
2105 // [2]: next enumeration index (Smi), or pointer to small fixed array: | 2201 // [2]: next enumeration index (Smi), or pointer to small fixed array: |
2106 // [0]: next enumeration index (Smi) | 2202 // [0]: next enumeration index (Smi) |
2107 // [1]: pointer to fixed array with enum cache | 2203 // [1]: pointer to fixed array with enum cache |
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3802 | 3898 |
3803 inline JSObject::ElementsKind elements_kind() { | 3899 inline JSObject::ElementsKind elements_kind() { |
3804 return static_cast<JSObject::ElementsKind>( | 3900 return static_cast<JSObject::ElementsKind>( |
3805 (bit_field2() & kElementsKindMask) >> kElementsKindShift); | 3901 (bit_field2() & kElementsKindMask) >> kElementsKindShift); |
3806 } | 3902 } |
3807 | 3903 |
3808 inline bool has_fast_elements() { | 3904 inline bool has_fast_elements() { |
3809 return elements_kind() == JSObject::FAST_ELEMENTS; | 3905 return elements_kind() == JSObject::FAST_ELEMENTS; |
3810 } | 3906 } |
3811 | 3907 |
| 3908 inline bool has_fast_double_elements() { |
| 3909 return elements_kind() == JSObject::FAST_DOUBLE_ELEMENTS; |
| 3910 } |
| 3911 |
3812 inline bool has_external_array_elements() { | 3912 inline bool has_external_array_elements() { |
3813 JSObject::ElementsKind kind(elements_kind()); | 3913 JSObject::ElementsKind kind(elements_kind()); |
3814 return kind >= JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && | 3914 return kind >= JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && |
3815 kind <= JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND; | 3915 kind <= JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND; |
3816 } | 3916 } |
3817 | 3917 |
3818 // Tells whether the map is attached to SharedFunctionInfo | 3918 // Tells whether the map is attached to SharedFunctionInfo |
3819 // (for inobject slack tracking). | 3919 // (for inobject slack tracking). |
3820 inline void set_attached_to_shared_function_info(bool value); | 3920 inline void set_attached_to_shared_function_info(bool value); |
3821 | 3921 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3894 | 3994 |
3895 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); | 3995 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); |
3896 | 3996 |
3897 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, | 3997 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, |
3898 NormalizedMapSharingMode sharing); | 3998 NormalizedMapSharingMode sharing); |
3899 | 3999 |
3900 // Returns a copy of the map, with all transitions dropped from the | 4000 // Returns a copy of the map, with all transitions dropped from the |
3901 // instance descriptors. | 4001 // instance descriptors. |
3902 MUST_USE_RESULT MaybeObject* CopyDropTransitions(); | 4002 MUST_USE_RESULT MaybeObject* CopyDropTransitions(); |
3903 | 4003 |
3904 // Returns this map if it has the fast elements bit set, otherwise | 4004 // Returns this map if it already has elements that are fast, otherwise |
3905 // returns a copy of the map, with all transitions dropped from the | 4005 // returns a copy of the map, with all transitions dropped from the |
3906 // descriptors and the fast elements bit set. | 4006 // descriptors and the ElementsKind set to FAST_ELEMENTS. |
3907 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); | 4007 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); |
3908 | 4008 |
3909 // Returns this map if it has the fast elements bit cleared, | 4009 // Returns this map if it already has fast elements that are doubles, |
3910 // otherwise returns a copy of the map, with all transitions dropped | 4010 // otherwise returns a copy of the map, with all transitions dropped from the |
3911 // from the descriptors and the fast elements bit cleared. | 4011 // descriptors and the ElementsKind set to FAST_DOUBLE_ELEMENTS. |
| 4012 MUST_USE_RESULT inline MaybeObject* GetFastDoubleElementsMap(); |
| 4013 |
| 4014 // Returns this map if already has dictionary elements, otherwise returns a |
| 4015 // copy of the map, with all transitions dropped from the descriptors and the |
| 4016 // ElementsKind set to DICTIONARY_ELEMENTS. |
3912 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); | 4017 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); |
3913 | 4018 |
3914 // Returns a new map with all transitions dropped from the descriptors and the | 4019 // Returns a new map with all transitions dropped from the descriptors and the |
3915 // external array elements bit set. | 4020 // ElementsKind set to one of the value corresponding to array_type. |
3916 MUST_USE_RESULT MaybeObject* GetExternalArrayElementsMap( | 4021 MUST_USE_RESULT MaybeObject* GetExternalArrayElementsMap( |
3917 ExternalArrayType array_type, | 4022 ExternalArrayType array_type, |
3918 bool safe_to_add_transition); | 4023 bool safe_to_add_transition); |
3919 | 4024 |
3920 // Returns the property index for name (only valid for FAST MODE). | 4025 // Returns the property index for name (only valid for FAST MODE). |
3921 int PropertyIndexFor(String* name); | 4026 int PropertyIndexFor(String* name); |
3922 | 4027 |
3923 // Returns the next free property index (only valid for FAST MODE). | 4028 // Returns the next free property index (only valid for FAST MODE). |
3924 int NextFreePropertyIndex(); | 4029 int NextFreePropertyIndex(); |
3925 | 4030 |
(...skipping 3055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6981 } else { | 7086 } else { |
6982 value &= ~(1 << bit_position); | 7087 value &= ~(1 << bit_position); |
6983 } | 7088 } |
6984 return value; | 7089 return value; |
6985 } | 7090 } |
6986 }; | 7091 }; |
6987 | 7092 |
6988 } } // namespace v8::internal | 7093 } } // namespace v8::internal |
6989 | 7094 |
6990 #endif // V8_OBJECTS_H_ | 7095 #endif // V8_OBJECTS_H_ |
OLD | NEW |