| 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 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
| 6 * | 6 * |
| 7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
| 8 * | 8 * |
| 9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
| 10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
| (...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 | 1641 |
| 1642 | 1642 |
| 1643 /** | 1643 /** |
| 1644 * A JavaScript string value (ECMA-262, 4.3.17). | 1644 * A JavaScript string value (ECMA-262, 4.3.17). |
| 1645 */ | 1645 */ |
| 1646 class V8_EXPORT String : public Name { | 1646 class V8_EXPORT String : public Name { |
| 1647 public: | 1647 public: |
| 1648 enum Encoding { | 1648 enum Encoding { |
| 1649 UNKNOWN_ENCODING = 0x1, | 1649 UNKNOWN_ENCODING = 0x1, |
| 1650 TWO_BYTE_ENCODING = 0x0, | 1650 TWO_BYTE_ENCODING = 0x0, |
| 1651 ASCII_ENCODING = 0x4, | 1651 ASCII_ENCODING = 0x4, // TODO(yangguo): deprecate this. |
| 1652 ONE_BYTE_ENCODING = 0x4 | 1652 ONE_BYTE_ENCODING = 0x4 |
| 1653 }; | 1653 }; |
| 1654 /** | 1654 /** |
| 1655 * Returns the number of characters in this string. | 1655 * Returns the number of characters in this string. |
| 1656 */ | 1656 */ |
| 1657 int Length() const; | 1657 int Length() const; |
| 1658 | 1658 |
| 1659 /** | 1659 /** |
| 1660 * Returns the number of bytes in the UTF-8 encoded | 1660 * Returns the number of bytes in the UTF-8 encoded |
| 1661 * representation of this string. | 1661 * representation of this string. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 * \param options Various options that might affect performance of this or | 1697 * \param options Various options that might affect performance of this or |
| 1698 * subsequent operations. | 1698 * subsequent operations. |
| 1699 * \return The number of characters copied to the buffer excluding the null | 1699 * \return The number of characters copied to the buffer excluding the null |
| 1700 * terminator. For WriteUtf8: The number of bytes copied to the buffer | 1700 * terminator. For WriteUtf8: The number of bytes copied to the buffer |
| 1701 * including the null terminator (if written). | 1701 * including the null terminator (if written). |
| 1702 */ | 1702 */ |
| 1703 enum WriteOptions { | 1703 enum WriteOptions { |
| 1704 NO_OPTIONS = 0, | 1704 NO_OPTIONS = 0, |
| 1705 HINT_MANY_WRITES_EXPECTED = 1, | 1705 HINT_MANY_WRITES_EXPECTED = 1, |
| 1706 NO_NULL_TERMINATION = 2, | 1706 NO_NULL_TERMINATION = 2, |
| 1707 PRESERVE_ASCII_NULL = 4, | 1707 PRESERVE_ASCII_NULL = 4, // TODO(yangguo): deprecate this. |
| 1708 PRESERVE_ONE_BYTE_NULL = 4, |
| 1708 // Used by WriteUtf8 to replace orphan surrogate code units with the | 1709 // Used by WriteUtf8 to replace orphan surrogate code units with the |
| 1709 // unicode replacement character. Needs to be set to guarantee valid UTF-8 | 1710 // unicode replacement character. Needs to be set to guarantee valid UTF-8 |
| 1710 // output. | 1711 // output. |
| 1711 REPLACE_INVALID_UTF8 = 8 | 1712 REPLACE_INVALID_UTF8 = 8 |
| 1712 }; | 1713 }; |
| 1713 | 1714 |
| 1714 // 16-bit character codes. | 1715 // 16-bit character codes. |
| 1715 int Write(uint16_t* buffer, | 1716 int Write(uint16_t* buffer, |
| 1716 int start = 0, | 1717 int start = 0, |
| 1717 int length = -1, | 1718 int length = -1, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1731 * A zero length string. | 1732 * A zero length string. |
| 1732 */ | 1733 */ |
| 1733 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate); | 1734 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate); |
| 1734 | 1735 |
| 1735 /** | 1736 /** |
| 1736 * Returns true if the string is external | 1737 * Returns true if the string is external |
| 1737 */ | 1738 */ |
| 1738 bool IsExternal() const; | 1739 bool IsExternal() const; |
| 1739 | 1740 |
| 1740 /** | 1741 /** |
| 1741 * Returns true if the string is both external and ASCII | 1742 * Returns true if the string is both external and one-byte. |
| 1742 */ | 1743 */ |
| 1743 bool IsExternalAscii() const; | 1744 bool IsExternalOneByte() const; |
| 1745 |
| 1746 // TODO(yangguo): deprecate this. |
| 1747 bool IsExternalAscii() const { return IsExternalOneByte(); } |
| 1744 | 1748 |
| 1745 class V8_EXPORT ExternalStringResourceBase { // NOLINT | 1749 class V8_EXPORT ExternalStringResourceBase { // NOLINT |
| 1746 public: | 1750 public: |
| 1747 virtual ~ExternalStringResourceBase() {} | 1751 virtual ~ExternalStringResourceBase() {} |
| 1748 | 1752 |
| 1749 protected: | 1753 protected: |
| 1750 ExternalStringResourceBase() {} | 1754 ExternalStringResourceBase() {} |
| 1751 | 1755 |
| 1752 /** | 1756 /** |
| 1753 * Internally V8 will call this Dispose method when the external string | 1757 * Internally V8 will call this Dispose method when the external string |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1788 /** | 1792 /** |
| 1789 * The length of the string. That is, the number of two-byte characters. | 1793 * The length of the string. That is, the number of two-byte characters. |
| 1790 */ | 1794 */ |
| 1791 virtual size_t length() const = 0; | 1795 virtual size_t length() const = 0; |
| 1792 | 1796 |
| 1793 protected: | 1797 protected: |
| 1794 ExternalStringResource() {} | 1798 ExternalStringResource() {} |
| 1795 }; | 1799 }; |
| 1796 | 1800 |
| 1797 /** | 1801 /** |
| 1798 * An ExternalAsciiStringResource is a wrapper around an ASCII | 1802 * An ExternalOneByteStringResource is a wrapper around an one-byte |
| 1799 * string buffer that resides outside V8's heap. Implement an | 1803 * string buffer that resides outside V8's heap. Implement an |
| 1800 * ExternalAsciiStringResource to manage the life cycle of the | 1804 * ExternalOneByteStringResource to manage the life cycle of the |
| 1801 * underlying buffer. Note that the string data must be immutable | 1805 * underlying buffer. Note that the string data must be immutable |
| 1802 * and that the data must be strict (7-bit) ASCII, not Latin-1 or | 1806 * and that the data must be Latin-1 and not UTF-8, which would require |
| 1803 * UTF-8, which would require special treatment internally in the | 1807 * special treatment internally in the engine and do not allow efficient |
| 1804 * engine and, in the case of UTF-8, do not allow efficient indexing. | 1808 * indexing. Use String::New or convert to 16 bit data for non-Latin1. |
| 1805 * Use String::New or convert to 16 bit data for non-ASCII. | |
| 1806 */ | 1809 */ |
| 1807 | 1810 |
| 1808 class V8_EXPORT ExternalAsciiStringResource | 1811 class V8_EXPORT ExternalOneByteStringResource |
| 1809 : public ExternalStringResourceBase { | 1812 : public ExternalStringResourceBase { |
| 1810 public: | 1813 public: |
| 1811 /** | 1814 /** |
| 1812 * Override the destructor to manage the life cycle of the underlying | 1815 * Override the destructor to manage the life cycle of the underlying |
| 1813 * buffer. | 1816 * buffer. |
| 1814 */ | 1817 */ |
| 1815 virtual ~ExternalAsciiStringResource() {} | 1818 virtual ~ExternalOneByteStringResource() {} |
| 1816 /** The string data from the underlying buffer.*/ | 1819 /** The string data from the underlying buffer.*/ |
| 1817 virtual const char* data() const = 0; | 1820 virtual const char* data() const = 0; |
| 1818 /** The number of ASCII characters in the string.*/ | 1821 /** The number of Latin-1 characters in the string.*/ |
| 1819 virtual size_t length() const = 0; | 1822 virtual size_t length() const = 0; |
| 1820 protected: | 1823 protected: |
| 1821 ExternalAsciiStringResource() {} | 1824 ExternalOneByteStringResource() {} |
| 1822 }; | 1825 }; |
| 1823 | 1826 |
| 1824 typedef ExternalAsciiStringResource ExternalOneByteStringResource; | 1827 typedef ExternalOneByteStringResource ExternalAsciiStringResource; |
| 1825 | 1828 |
| 1826 /** | 1829 /** |
| 1827 * If the string is an external string, return the ExternalStringResourceBase | 1830 * If the string is an external string, return the ExternalStringResourceBase |
| 1828 * regardless of the encoding, otherwise return NULL. The encoding of the | 1831 * regardless of the encoding, otherwise return NULL. The encoding of the |
| 1829 * string is returned in encoding_out. | 1832 * string is returned in encoding_out. |
| 1830 */ | 1833 */ |
| 1831 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase( | 1834 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase( |
| 1832 Encoding* encoding_out) const; | 1835 Encoding* encoding_out) const; |
| 1833 | 1836 |
| 1834 /** | 1837 /** |
| 1835 * Get the ExternalStringResource for an external string. Returns | 1838 * Get the ExternalStringResource for an external string. Returns |
| 1836 * NULL if IsExternal() doesn't return true. | 1839 * NULL if IsExternal() doesn't return true. |
| 1837 */ | 1840 */ |
| 1838 V8_INLINE ExternalStringResource* GetExternalStringResource() const; | 1841 V8_INLINE ExternalStringResource* GetExternalStringResource() const; |
| 1839 | 1842 |
| 1840 /** | 1843 /** |
| 1841 * Get the ExternalAsciiStringResource for an external ASCII string. | 1844 * Get the ExternalOneByteStringResource for an external one-byte string. |
| 1842 * Returns NULL if IsExternalAscii() doesn't return true. | 1845 * Returns NULL if IsExternalOneByte() doesn't return true. |
| 1843 */ | 1846 */ |
| 1844 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; | 1847 const ExternalOneByteStringResource* GetExternalOneByteStringResource() const; |
| 1848 |
| 1849 // TODO(yangguo): deprecate this. |
| 1850 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const { |
| 1851 return GetExternalOneByteStringResource(); |
| 1852 } |
| 1845 | 1853 |
| 1846 V8_INLINE static String* Cast(v8::Value* obj); | 1854 V8_INLINE static String* Cast(v8::Value* obj); |
| 1847 | 1855 |
| 1848 enum NewStringType { | 1856 enum NewStringType { |
| 1849 kNormalString, kInternalizedString, kUndetectableString | 1857 kNormalString, kInternalizedString, kUndetectableString |
| 1850 }; | 1858 }; |
| 1851 | 1859 |
| 1852 /** Allocates a new string from UTF-8 data.*/ | 1860 /** Allocates a new string from UTF-8 data.*/ |
| 1853 static Local<String> NewFromUtf8(Isolate* isolate, | 1861 static Local<String> NewFromUtf8(Isolate* isolate, |
| 1854 const char* data, | 1862 const char* data, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 * in place so that existing references to this string in the JavaScript heap | 1899 * in place so that existing references to this string in the JavaScript heap |
| 1892 * will use the external string resource. The external string resource's | 1900 * will use the external string resource. The external string resource's |
| 1893 * character contents need to be equivalent to this string. | 1901 * character contents need to be equivalent to this string. |
| 1894 * Returns true if the string has been changed to be an external string. | 1902 * Returns true if the string has been changed to be an external string. |
| 1895 * The string is not modified if the operation fails. See NewExternal for | 1903 * The string is not modified if the operation fails. See NewExternal for |
| 1896 * information on the lifetime of the resource. | 1904 * information on the lifetime of the resource. |
| 1897 */ | 1905 */ |
| 1898 bool MakeExternal(ExternalStringResource* resource); | 1906 bool MakeExternal(ExternalStringResource* resource); |
| 1899 | 1907 |
| 1900 /** | 1908 /** |
| 1901 * Creates a new external string using the ASCII data defined in the given | 1909 * Creates a new external string using the one-byte data defined in the given |
| 1902 * resource. When the external string is no longer live on V8's heap the | 1910 * resource. When the external string is no longer live on V8's heap the |
| 1903 * resource will be disposed by calling its Dispose method. The caller of | 1911 * resource will be disposed by calling its Dispose method. The caller of |
| 1904 * this function should not otherwise delete or modify the resource. Neither | 1912 * this function should not otherwise delete or modify the resource. Neither |
| 1905 * should the underlying buffer be deallocated or modified except through the | 1913 * should the underlying buffer be deallocated or modified except through the |
| 1906 * destructor of the external string resource. | 1914 * destructor of the external string resource. |
| 1907 */ | 1915 */ |
| 1908 static Local<String> NewExternal(Isolate* isolate, | 1916 static Local<String> NewExternal(Isolate* isolate, |
| 1909 ExternalAsciiStringResource* resource); | 1917 ExternalOneByteStringResource* resource); |
| 1910 | 1918 |
| 1911 /** | 1919 /** |
| 1912 * Associate an external string resource with this string by transforming it | 1920 * Associate an external string resource with this string by transforming it |
| 1913 * in place so that existing references to this string in the JavaScript heap | 1921 * in place so that existing references to this string in the JavaScript heap |
| 1914 * will use the external string resource. The external string resource's | 1922 * will use the external string resource. The external string resource's |
| 1915 * character contents need to be equivalent to this string. | 1923 * character contents need to be equivalent to this string. |
| 1916 * Returns true if the string has been changed to be an external string. | 1924 * Returns true if the string has been changed to be an external string. |
| 1917 * The string is not modified if the operation fails. See NewExternal for | 1925 * The string is not modified if the operation fails. See NewExternal for |
| 1918 * information on the lifetime of the resource. | 1926 * information on the lifetime of the resource. |
| 1919 */ | 1927 */ |
| 1920 bool MakeExternal(ExternalAsciiStringResource* resource); | 1928 bool MakeExternal(ExternalOneByteStringResource* resource); |
| 1921 | 1929 |
| 1922 /** | 1930 /** |
| 1923 * Returns true if this string can be made external. | 1931 * Returns true if this string can be made external. |
| 1924 */ | 1932 */ |
| 1925 bool CanMakeExternal(); | 1933 bool CanMakeExternal(); |
| 1926 | 1934 |
| 1927 /** | 1935 /** |
| 1928 * Converts an object to a UTF-8-encoded character array. Useful if | 1936 * Converts an object to a UTF-8-encoded character array. Useful if |
| 1929 * you want to print the object. If conversion to a string fails | 1937 * you want to print the object. If conversion to a string fails |
| 1930 * (e.g. due to an exception in the toString() method of the object) | 1938 * (e.g. due to an exception in the toString() method of the object) |
| (...skipping 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3867 static Local<TypeSwitch> New(Handle<FunctionTemplate> type); | 3875 static Local<TypeSwitch> New(Handle<FunctionTemplate> type); |
| 3868 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]); | 3876 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]); |
| 3869 int match(Handle<Value> value); | 3877 int match(Handle<Value> value); |
| 3870 private: | 3878 private: |
| 3871 TypeSwitch(); | 3879 TypeSwitch(); |
| 3872 }; | 3880 }; |
| 3873 | 3881 |
| 3874 | 3882 |
| 3875 // --- Extensions --- | 3883 // --- Extensions --- |
| 3876 | 3884 |
| 3877 class V8_EXPORT ExternalAsciiStringResourceImpl | 3885 class V8_EXPORT ExternalOneByteStringResourceImpl |
| 3878 : public String::ExternalAsciiStringResource { | 3886 : public String::ExternalOneByteStringResource { |
| 3879 public: | 3887 public: |
| 3880 ExternalAsciiStringResourceImpl() : data_(0), length_(0) {} | 3888 ExternalOneByteStringResourceImpl() : data_(0), length_(0) {} |
| 3881 ExternalAsciiStringResourceImpl(const char* data, size_t length) | 3889 ExternalOneByteStringResourceImpl(const char* data, size_t length) |
| 3882 : data_(data), length_(length) {} | 3890 : data_(data), length_(length) {} |
| 3883 const char* data() const { return data_; } | 3891 const char* data() const { return data_; } |
| 3884 size_t length() const { return length_; } | 3892 size_t length() const { return length_; } |
| 3885 | 3893 |
| 3886 private: | 3894 private: |
| 3887 const char* data_; | 3895 const char* data_; |
| 3888 size_t length_; | 3896 size_t length_; |
| 3889 }; | 3897 }; |
| 3890 | 3898 |
| 3891 /** | 3899 /** |
| 3892 * Ignore | 3900 * Ignore |
| 3893 */ | 3901 */ |
| 3894 class V8_EXPORT Extension { // NOLINT | 3902 class V8_EXPORT Extension { // NOLINT |
| 3895 public: | 3903 public: |
| 3896 // Note that the strings passed into this constructor must live as long | 3904 // Note that the strings passed into this constructor must live as long |
| 3897 // as the Extension itself. | 3905 // as the Extension itself. |
| 3898 Extension(const char* name, | 3906 Extension(const char* name, |
| 3899 const char* source = 0, | 3907 const char* source = 0, |
| 3900 int dep_count = 0, | 3908 int dep_count = 0, |
| 3901 const char** deps = 0, | 3909 const char** deps = 0, |
| 3902 int source_length = -1); | 3910 int source_length = -1); |
| 3903 virtual ~Extension() { } | 3911 virtual ~Extension() { } |
| 3904 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( | 3912 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 3905 v8::Isolate* isolate, v8::Handle<v8::String> name) { | 3913 v8::Isolate* isolate, v8::Handle<v8::String> name) { |
| 3906 return v8::Handle<v8::FunctionTemplate>(); | 3914 return v8::Handle<v8::FunctionTemplate>(); |
| 3907 } | 3915 } |
| 3908 | 3916 |
| 3909 const char* name() const { return name_; } | 3917 const char* name() const { return name_; } |
| 3910 size_t source_length() const { return source_length_; } | 3918 size_t source_length() const { return source_length_; } |
| 3911 const String::ExternalAsciiStringResource* source() const { | 3919 const String::ExternalOneByteStringResource* source() const { |
| 3912 return &source_; } | 3920 return &source_; } |
| 3913 int dependency_count() { return dep_count_; } | 3921 int dependency_count() { return dep_count_; } |
| 3914 const char** dependencies() { return deps_; } | 3922 const char** dependencies() { return deps_; } |
| 3915 void set_auto_enable(bool value) { auto_enable_ = value; } | 3923 void set_auto_enable(bool value) { auto_enable_ = value; } |
| 3916 bool auto_enable() { return auto_enable_; } | 3924 bool auto_enable() { return auto_enable_; } |
| 3917 | 3925 |
| 3918 private: | 3926 private: |
| 3919 const char* name_; | 3927 const char* name_; |
| 3920 size_t source_length_; // expected to initialize before source_ | 3928 size_t source_length_; // expected to initialize before source_ |
| 3921 ExternalAsciiStringResourceImpl source_; | 3929 ExternalOneByteStringResourceImpl source_; |
| 3922 int dep_count_; | 3930 int dep_count_; |
| 3923 const char** deps_; | 3931 const char** deps_; |
| 3924 bool auto_enable_; | 3932 bool auto_enable_; |
| 3925 | 3933 |
| 3926 // Disallow copying and assigning. | 3934 // Disallow copying and assigning. |
| 3927 Extension(const Extension&); | 3935 Extension(const Extension&); |
| 3928 void operator=(const Extension&); | 3936 void operator=(const Extension&); |
| 3929 }; | 3937 }; |
| 3930 | 3938 |
| 3931 | 3939 |
| (...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5674 | 5682 |
| 5675 static const int kOddballKindOffset = 3 * kApiPointerSize; | 5683 static const int kOddballKindOffset = 3 * kApiPointerSize; |
| 5676 static const int kForeignAddressOffset = kApiPointerSize; | 5684 static const int kForeignAddressOffset = kApiPointerSize; |
| 5677 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | 5685 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; |
| 5678 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | 5686 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; |
| 5679 static const int kContextHeaderSize = 2 * kApiPointerSize; | 5687 static const int kContextHeaderSize = 2 * kApiPointerSize; |
| 5680 static const int kContextEmbedderDataIndex = 95; | 5688 static const int kContextEmbedderDataIndex = 95; |
| 5681 static const int kFullStringRepresentationMask = 0x07; | 5689 static const int kFullStringRepresentationMask = 0x07; |
| 5682 static const int kStringEncodingMask = 0x4; | 5690 static const int kStringEncodingMask = 0x4; |
| 5683 static const int kExternalTwoByteRepresentationTag = 0x02; | 5691 static const int kExternalTwoByteRepresentationTag = 0x02; |
| 5684 static const int kExternalAsciiRepresentationTag = 0x06; | 5692 static const int kExternalOneByteRepresentationTag = 0x06; |
| 5685 | 5693 |
| 5686 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; | 5694 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; |
| 5687 static const int kAmountOfExternalAllocatedMemoryOffset = | 5695 static const int kAmountOfExternalAllocatedMemoryOffset = |
| 5688 4 * kApiPointerSize; | 5696 4 * kApiPointerSize; |
| 5689 static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset = | 5697 static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset = |
| 5690 kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size; | 5698 kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size; |
| 5691 static const int kIsolateRootsOffset = | 5699 static const int kIsolateRootsOffset = |
| 5692 kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset + kApiInt64Size + | 5700 kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset + kApiInt64Size + |
| 5693 kApiPointerSize; | 5701 kApiPointerSize; |
| 5694 static const int kUndefinedValueRootIndex = 5; | 5702 static const int kUndefinedValueRootIndex = 5; |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6345 | 6353 |
| 6346 | 6354 |
| 6347 String::ExternalStringResourceBase* String::GetExternalStringResourceBase( | 6355 String::ExternalStringResourceBase* String::GetExternalStringResourceBase( |
| 6348 String::Encoding* encoding_out) const { | 6356 String::Encoding* encoding_out) const { |
| 6349 typedef internal::Object O; | 6357 typedef internal::Object O; |
| 6350 typedef internal::Internals I; | 6358 typedef internal::Internals I; |
| 6351 O* obj = *reinterpret_cast<O* const*>(this); | 6359 O* obj = *reinterpret_cast<O* const*>(this); |
| 6352 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; | 6360 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; |
| 6353 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask); | 6361 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask); |
| 6354 ExternalStringResourceBase* resource = NULL; | 6362 ExternalStringResourceBase* resource = NULL; |
| 6355 if (type == I::kExternalAsciiRepresentationTag || | 6363 if (type == I::kExternalOneByteRepresentationTag || |
| 6356 type == I::kExternalTwoByteRepresentationTag) { | 6364 type == I::kExternalTwoByteRepresentationTag) { |
| 6357 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | 6365 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); |
| 6358 resource = static_cast<ExternalStringResourceBase*>(value); | 6366 resource = static_cast<ExternalStringResourceBase*>(value); |
| 6359 } | 6367 } |
| 6360 #ifdef V8_ENABLE_CHECKS | 6368 #ifdef V8_ENABLE_CHECKS |
| 6361 VerifyExternalStringResourceBase(resource, *encoding_out); | 6369 VerifyExternalStringResourceBase(resource, *encoding_out); |
| 6362 #endif | 6370 #endif |
| 6363 return resource; | 6371 return resource; |
| 6364 } | 6372 } |
| 6365 | 6373 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6824 */ | 6832 */ |
| 6825 | 6833 |
| 6826 | 6834 |
| 6827 } // namespace v8 | 6835 } // namespace v8 |
| 6828 | 6836 |
| 6829 | 6837 |
| 6830 #undef TYPE_CHECK | 6838 #undef TYPE_CHECK |
| 6831 | 6839 |
| 6832 | 6840 |
| 6833 #endif // V8_H_ | 6841 #endif // V8_H_ |
| OLD | NEW |