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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 public: | 1335 public: |
1336 enum DeleteMode { | 1336 enum DeleteMode { |
1337 NORMAL_DELETION, | 1337 NORMAL_DELETION, |
1338 STRICT_DELETION, | 1338 STRICT_DELETION, |
1339 FORCE_DELETION | 1339 FORCE_DELETION |
1340 }; | 1340 }; |
1341 | 1341 |
1342 // Casting. | 1342 // Casting. |
1343 static inline JSReceiver* cast(Object* obj); | 1343 static inline JSReceiver* cast(Object* obj); |
1344 | 1344 |
| 1345 static Handle<Object> SetProperty(Handle<JSReceiver> object, |
| 1346 Handle<String> key, |
| 1347 Handle<Object> value, |
| 1348 PropertyAttributes attributes, |
| 1349 StrictModeFlag strict_mode); |
1345 // Can cause GC. | 1350 // Can cause GC. |
1346 MUST_USE_RESULT MaybeObject* SetProperty(String* key, | 1351 MUST_USE_RESULT MaybeObject* SetProperty(String* key, |
1347 Object* value, | 1352 Object* value, |
1348 PropertyAttributes attributes, | 1353 PropertyAttributes attributes, |
1349 StrictModeFlag strict_mode); | 1354 StrictModeFlag strict_mode); |
1350 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, | 1355 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, |
1351 String* key, | 1356 String* key, |
1352 Object* value, | 1357 Object* value, |
1353 PropertyAttributes attributes, | 1358 PropertyAttributes attributes, |
1354 StrictModeFlag strict_mode); | 1359 StrictModeFlag strict_mode); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( | 1519 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( |
1515 String* name, | 1520 String* name, |
1516 Object* value, | 1521 Object* value, |
1517 PropertyAttributes attributes, | 1522 PropertyAttributes attributes, |
1518 StrictModeFlag strict_mode); | 1523 StrictModeFlag strict_mode); |
1519 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( | 1524 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( |
1520 String* name, | 1525 String* name, |
1521 Object* value, | 1526 Object* value, |
1522 PropertyAttributes attributes, | 1527 PropertyAttributes attributes, |
1523 StrictModeFlag strict_mode); | 1528 StrictModeFlag strict_mode); |
| 1529 |
| 1530 static Handle<Object> SetLocalPropertyIgnoreAttributes( |
| 1531 Handle<JSObject> object, |
| 1532 Handle<String> key, |
| 1533 Handle<Object> value, |
| 1534 PropertyAttributes attributes); |
| 1535 |
| 1536 // Can cause GC. |
1524 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( | 1537 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( |
1525 String* key, | 1538 String* key, |
1526 Object* value, | 1539 Object* value, |
1527 PropertyAttributes attributes); | 1540 PropertyAttributes attributes); |
1528 | 1541 |
1529 // Retrieve a value in a normalized object given a lookup result. | 1542 // Retrieve a value in a normalized object given a lookup result. |
1530 // Handles the special representation of JS global objects. | 1543 // Handles the special representation of JS global objects. |
1531 Object* GetNormalizedProperty(LookupResult* result); | 1544 Object* GetNormalizedProperty(LookupResult* result); |
1532 | 1545 |
1533 // Sets the property value in a normalized object given a lookup result. | 1546 // Sets the property value in a normalized object given a lookup result. |
1534 // Handles the special representation of JS global objects. | 1547 // Handles the special representation of JS global objects. |
1535 Object* SetNormalizedProperty(LookupResult* result, Object* value); | 1548 Object* SetNormalizedProperty(LookupResult* result, Object* value); |
1536 | 1549 |
1537 // Sets the property value in a normalized object given (key, value, details). | 1550 // Sets the property value in a normalized object given (key, value, details). |
1538 // Handles the special representation of JS global objects. | 1551 // Handles the special representation of JS global objects. |
| 1552 static Handle<Object> SetNormalizedProperty(Handle<JSObject> object, |
| 1553 Handle<String> key, |
| 1554 Handle<Object> value, |
| 1555 PropertyDetails details); |
| 1556 |
1539 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, | 1557 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, |
1540 Object* value, | 1558 Object* value, |
1541 PropertyDetails details); | 1559 PropertyDetails details); |
1542 | 1560 |
1543 // Deletes the named property in a normalized object. | 1561 // Deletes the named property in a normalized object. |
1544 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, | 1562 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, |
1545 DeleteMode mode); | 1563 DeleteMode mode); |
1546 | 1564 |
1547 // Retrieve interceptors. | 1565 // Retrieve interceptors. |
1548 InterceptorInfo* GetNamedInterceptor(); | 1566 InterceptorInfo* GetNamedInterceptor(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 // Accessors for hidden properties object. | 1616 // Accessors for hidden properties object. |
1599 // | 1617 // |
1600 // Hidden properties are not local properties of the object itself. | 1618 // Hidden properties are not local properties of the object itself. |
1601 // Instead they are stored in an auxiliary structure kept as a local | 1619 // Instead they are stored in an auxiliary structure kept as a local |
1602 // property with a special name Heap::hidden_symbol(). But if the | 1620 // property with a special name Heap::hidden_symbol(). But if the |
1603 // receiver is a JSGlobalProxy then the auxiliary object is a property | 1621 // receiver is a JSGlobalProxy then the auxiliary object is a property |
1604 // of its prototype, and if it's a detached proxy, then you can't have | 1622 // of its prototype, and if it's a detached proxy, then you can't have |
1605 // hidden properties. | 1623 // hidden properties. |
1606 | 1624 |
1607 // Sets a hidden property on this object. Returns this object if successful, | 1625 // Sets a hidden property on this object. Returns this object if successful, |
1608 // undefined if called on a detached proxy, and a failure if a GC | 1626 // undefined if called on a detached proxy. |
1609 // is required | 1627 static Handle<Object> SetHiddenProperty(Handle<JSObject> obj, |
| 1628 Handle<String> key, |
| 1629 Handle<Object> value); |
| 1630 // Returns a failure if a GC is required. |
1610 MaybeObject* SetHiddenProperty(String* key, Object* value); | 1631 MaybeObject* SetHiddenProperty(String* key, Object* value); |
1611 // Gets the value of a hidden property with the given key. Returns undefined | 1632 // Gets the value of a hidden property with the given key. Returns undefined |
1612 // if the property doesn't exist (or if called on a detached proxy), | 1633 // if the property doesn't exist (or if called on a detached proxy), |
1613 // otherwise returns the value set for the key. | 1634 // otherwise returns the value set for the key. |
1614 Object* GetHiddenProperty(String* key); | 1635 Object* GetHiddenProperty(String* key); |
1615 // Deletes a hidden property. Deleting a non-existing property is | 1636 // Deletes a hidden property. Deleting a non-existing property is |
1616 // considered successful. | 1637 // considered successful. |
1617 void DeleteHiddenProperty(String* key); | 1638 void DeleteHiddenProperty(String* key); |
1618 // Returns true if the object has a property with the hidden symbol as name. | 1639 // Returns true if the object has a property with the hidden symbol as name. |
1619 bool HasHiddenProperties(); | 1640 bool HasHiddenProperties(); |
1620 | 1641 |
| 1642 static int GetIdentityHash(Handle<JSObject> obj); |
1621 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); | 1643 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
1622 MUST_USE_RESULT MaybeObject* SetIdentityHash(Object* hash, CreationFlag flag); | 1644 MUST_USE_RESULT MaybeObject* SetIdentityHash(Object* hash, CreationFlag flag); |
1623 | 1645 |
| 1646 static Handle<Object> DeleteProperty(Handle<JSObject> obj, |
| 1647 Handle<String> name); |
1624 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); | 1648 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); |
| 1649 |
| 1650 static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index); |
1625 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); | 1651 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); |
1626 | 1652 |
1627 inline void ValidateSmiOnlyElements(); | 1653 inline void ValidateSmiOnlyElements(); |
1628 | 1654 |
1629 // Makes sure that this object can contain HeapObject as elements. | 1655 // Makes sure that this object can contain HeapObject as elements. |
1630 inline MaybeObject* EnsureCanContainHeapObjectElements(); | 1656 inline MaybeObject* EnsureCanContainHeapObjectElements(); |
1631 | 1657 |
1632 // Makes sure that this object can contain the specified elements. | 1658 // Makes sure that this object can contain the specified elements. |
1633 inline MaybeObject* EnsureCanContainElements(Object** elements, | 1659 inline MaybeObject* EnsureCanContainElements(Object** elements, |
1634 uint32_t count, | 1660 uint32_t count, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 Object* value, | 1720 Object* value, |
1695 StrictModeFlag strict_mode, | 1721 StrictModeFlag strict_mode, |
1696 bool check_prototype); | 1722 bool check_prototype); |
1697 | 1723 |
1698 MUST_USE_RESULT MaybeObject* SetFastDoubleElement( | 1724 MUST_USE_RESULT MaybeObject* SetFastDoubleElement( |
1699 uint32_t index, | 1725 uint32_t index, |
1700 Object* value, | 1726 Object* value, |
1701 StrictModeFlag strict_mode, | 1727 StrictModeFlag strict_mode, |
1702 bool check_prototype = true); | 1728 bool check_prototype = true); |
1703 | 1729 |
1704 // Set the index'th array element. | 1730 |
| 1731 static Handle<Object> SetOwnElement(Handle<JSObject> object, |
| 1732 uint32_t index, |
| 1733 Handle<Object> value, |
| 1734 StrictModeFlag strict_mode); |
| 1735 |
| 1736 // Empty handle is returned if the element cannot be set to the given value. |
| 1737 static MUST_USE_RESULT Handle<Object> SetElement(Handle<JSObject> object, |
| 1738 uint32_t index, |
| 1739 Handle<Object> value, |
| 1740 StrictModeFlag strict_mode); |
| 1741 |
1705 // A Failure object is returned if GC is needed. | 1742 // A Failure object is returned if GC is needed. |
1706 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, | 1743 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, |
1707 Object* value, | 1744 Object* value, |
1708 StrictModeFlag strict_mode, | 1745 StrictModeFlag strict_mode, |
1709 bool check_prototype); | 1746 bool check_prototype); |
1710 | 1747 |
1711 // Returns the index'th element. | 1748 // Returns the index'th element. |
1712 // The undefined object if index is out of bounds. | 1749 // The undefined object if index is out of bounds. |
1713 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); | 1750 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); |
1714 | 1751 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 Object* value, | 1841 Object* value, |
1805 PropertyAttributes attributes); | 1842 PropertyAttributes attributes); |
1806 | 1843 |
1807 // Returns a new map with all transitions dropped from the object's current | 1844 // Returns a new map with all transitions dropped from the object's current |
1808 // map and the ElementsKind set. | 1845 // map and the ElementsKind set. |
1809 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, | 1846 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, |
1810 ElementsKind to_kind); | 1847 ElementsKind to_kind); |
1811 MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( | 1848 MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( |
1812 ElementsKind elements_kind); | 1849 ElementsKind elements_kind); |
1813 | 1850 |
| 1851 static Handle<Object> TransitionElementsKind(Handle<JSObject> object, |
| 1852 ElementsKind to_kind); |
| 1853 |
1814 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); | 1854 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); |
1815 | 1855 |
1816 // Converts a descriptor of any other type to a real field, | 1856 // Converts a descriptor of any other type to a real field, |
1817 // backed by the properties array. Descriptors of visible | 1857 // backed by the properties array. Descriptors of visible |
1818 // types, such as CONSTANT_FUNCTION, keep their enumeration order. | 1858 // types, such as CONSTANT_FUNCTION, keep their enumeration order. |
1819 // Converts the descriptor on the original object's map to a | 1859 // Converts the descriptor on the original object's map to a |
1820 // map transition, and the the new field is on the object's new map. | 1860 // map transition, and the the new field is on the object's new map. |
1821 MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition( | 1861 MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition( |
1822 String* name, | 1862 String* name, |
1823 Object* new_value, | 1863 Object* new_value, |
(...skipping 20 matching lines...) Expand all Loading... |
1844 // Add a property to an object. | 1884 // Add a property to an object. |
1845 MUST_USE_RESULT MaybeObject* AddProperty(String* name, | 1885 MUST_USE_RESULT MaybeObject* AddProperty(String* name, |
1846 Object* value, | 1886 Object* value, |
1847 PropertyAttributes attributes, | 1887 PropertyAttributes attributes, |
1848 StrictModeFlag strict_mode); | 1888 StrictModeFlag strict_mode); |
1849 | 1889 |
1850 // Convert the object to use the canonical dictionary | 1890 // Convert the object to use the canonical dictionary |
1851 // representation. If the object is expected to have additional properties | 1891 // representation. If the object is expected to have additional properties |
1852 // added this number can be indicated to have the backing store allocated to | 1892 // added this number can be indicated to have the backing store allocated to |
1853 // an initial capacity for holding these properties. | 1893 // an initial capacity for holding these properties. |
| 1894 static void NormalizeProperties(Handle<JSObject> object, |
| 1895 PropertyNormalizationMode mode, |
| 1896 int expected_additional_properties); |
| 1897 |
1854 MUST_USE_RESULT MaybeObject* NormalizeProperties( | 1898 MUST_USE_RESULT MaybeObject* NormalizeProperties( |
1855 PropertyNormalizationMode mode, | 1899 PropertyNormalizationMode mode, |
1856 int expected_additional_properties); | 1900 int expected_additional_properties); |
1857 | 1901 |
1858 // Convert and update the elements backing store to be a NumberDictionary | 1902 // Convert and update the elements backing store to be a NumberDictionary |
1859 // dictionary. Returns the backing after conversion. | 1903 // dictionary. Returns the backing after conversion. |
| 1904 static Handle<NumberDictionary> NormalizeElements(Handle<JSObject> object); |
| 1905 |
1860 MUST_USE_RESULT MaybeObject* NormalizeElements(); | 1906 MUST_USE_RESULT MaybeObject* NormalizeElements(); |
1861 | 1907 |
1862 static void UpdateMapCodeCache(Handle<JSObject> object, | 1908 static void UpdateMapCodeCache(Handle<JSObject> object, |
1863 Handle<String> name, | 1909 Handle<String> name, |
1864 Handle<Code> code); | 1910 Handle<Code> code); |
1865 | 1911 |
1866 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code); | 1912 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code); |
1867 | 1913 |
1868 // Transform slow named properties to fast variants. | 1914 // Transform slow named properties to fast variants. |
1869 // Returns failure if allocation failed. | 1915 // Returns failure if allocation failed. |
| 1916 static void TransformToFastProperties(Handle<JSObject> object, |
| 1917 int unused_property_fields); |
| 1918 |
1870 MUST_USE_RESULT MaybeObject* TransformToFastProperties( | 1919 MUST_USE_RESULT MaybeObject* TransformToFastProperties( |
1871 int unused_property_fields); | 1920 int unused_property_fields); |
1872 | 1921 |
1873 // Access fast-case object properties at index. | 1922 // Access fast-case object properties at index. |
1874 inline Object* FastPropertyAt(int index); | 1923 inline Object* FastPropertyAt(int index); |
1875 inline Object* FastPropertyAtPut(int index, Object* value); | 1924 inline Object* FastPropertyAtPut(int index, Object* value); |
1876 | 1925 |
1877 // Access to in object properties. | 1926 // Access to in object properties. |
1878 inline int GetInObjectPropertyOffset(int index); | 1927 inline int GetInObjectPropertyOffset(int index); |
1879 inline Object* InObjectPropertyAt(int index); | 1928 inline Object* InObjectPropertyAt(int index); |
(...skipping 11 matching lines...) Expand all Loading... |
1891 Object* pre_allocated_value, | 1940 Object* pre_allocated_value, |
1892 Object* filler_value); | 1941 Object* filler_value); |
1893 | 1942 |
1894 // Check whether this object references another object | 1943 // Check whether this object references another object |
1895 bool ReferencesObject(Object* obj); | 1944 bool ReferencesObject(Object* obj); |
1896 | 1945 |
1897 // Casting. | 1946 // Casting. |
1898 static inline JSObject* cast(Object* obj); | 1947 static inline JSObject* cast(Object* obj); |
1899 | 1948 |
1900 // Disalow further properties to be added to the object. | 1949 // Disalow further properties to be added to the object. |
| 1950 static Handle<Object> PreventExtensions(Handle<JSObject> object); |
1901 MUST_USE_RESULT MaybeObject* PreventExtensions(); | 1951 MUST_USE_RESULT MaybeObject* PreventExtensions(); |
1902 | 1952 |
1903 | 1953 |
1904 // Dispatched behavior. | 1954 // Dispatched behavior. |
1905 void JSObjectShortPrint(StringStream* accumulator); | 1955 void JSObjectShortPrint(StringStream* accumulator); |
1906 #ifdef OBJECT_PRINT | 1956 #ifdef OBJECT_PRINT |
1907 inline void JSObjectPrint() { | 1957 inline void JSObjectPrint() { |
1908 JSObjectPrint(stdout); | 1958 JSObjectPrint(stdout); |
1909 } | 1959 } |
1910 void JSObjectPrint(FILE* out); | 1960 void JSObjectPrint(FILE* out); |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2966 return reinterpret_cast<NumberDictionary*>(obj); | 3016 return reinterpret_cast<NumberDictionary*>(obj); |
2967 } | 3017 } |
2968 | 3018 |
2969 // Type specific at put (default NONE attributes is used when adding). | 3019 // Type specific at put (default NONE attributes is used when adding). |
2970 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value); | 3020 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value); |
2971 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, | 3021 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, |
2972 Object* value, | 3022 Object* value, |
2973 PropertyDetails details); | 3023 PropertyDetails details); |
2974 | 3024 |
2975 // Set an existing entry or add a new one if needed. | 3025 // Set an existing entry or add a new one if needed. |
| 3026 // Return the updated dictionary. |
| 3027 MUST_USE_RESULT static Handle<NumberDictionary> Set( |
| 3028 Handle<NumberDictionary> dictionary, |
| 3029 uint32_t index, |
| 3030 Handle<Object> value, |
| 3031 PropertyDetails details); |
| 3032 |
2976 MUST_USE_RESULT MaybeObject* Set(uint32_t key, | 3033 MUST_USE_RESULT MaybeObject* Set(uint32_t key, |
2977 Object* value, | 3034 Object* value, |
2978 PropertyDetails details); | 3035 PropertyDetails details); |
2979 | 3036 |
2980 void UpdateMaxNumberKey(uint32_t key); | 3037 void UpdateMaxNumberKey(uint32_t key); |
2981 | 3038 |
2982 // If slow elements are required we will never go back to fast-case | 3039 // If slow elements are required we will never go back to fast-case |
2983 // for the elements kept in this dictionary. We require slow | 3040 // for the elements kept in this dictionary. We require slow |
2984 // elements if an element has been added at an index larger than | 3041 // elements if an element has been added at an index larger than |
2985 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called | 3042 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called |
(...skipping 5022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8008 } else { | 8065 } else { |
8009 value &= ~(1 << bit_position); | 8066 value &= ~(1 << bit_position); |
8010 } | 8067 } |
8011 return value; | 8068 return value; |
8012 } | 8069 } |
8013 }; | 8070 }; |
8014 | 8071 |
8015 } } // namespace v8::internal | 8072 } } // namespace v8::internal |
8016 | 8073 |
8017 #endif // V8_OBJECTS_H_ | 8074 #endif // V8_OBJECTS_H_ |
OLD | NEW |