| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 | 1463 |
| 1464 // Returns the constructor name (the name (possibly, inferred name) of the | 1464 // Returns the constructor name (the name (possibly, inferred name) of the |
| 1465 // function that was used to instantiate the object). | 1465 // function that was used to instantiate the object). |
| 1466 String* constructor_name(); | 1466 String* constructor_name(); |
| 1467 | 1467 |
| 1468 inline PropertyAttributes GetPropertyAttribute(String* name); | 1468 inline PropertyAttributes GetPropertyAttribute(String* name); |
| 1469 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver, | 1469 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver, |
| 1470 String* name); | 1470 String* name); |
| 1471 PropertyAttributes GetLocalPropertyAttribute(String* name); | 1471 PropertyAttributes GetLocalPropertyAttribute(String* name); |
| 1472 | 1472 |
| 1473 inline PropertyAttributes GetElementAttribute(uint32_t index); |
| 1474 inline PropertyAttributes GetElementAttributeWithReceiver( |
| 1475 JSReceiver* receiver, |
| 1476 uint32_t index, |
| 1477 bool continue_search); |
| 1478 inline PropertyAttributes GetLocalElementAttribute(uint32_t index); |
| 1479 |
| 1473 // Can cause a GC. | 1480 // Can cause a GC. |
| 1474 inline bool HasProperty(String* name); | 1481 inline bool HasProperty(String* name); |
| 1475 inline bool HasLocalProperty(String* name); | 1482 inline bool HasLocalProperty(String* name); |
| 1476 inline bool HasElement(uint32_t index); | 1483 inline bool HasElement(uint32_t index); |
| 1484 inline bool HasLocalElement(uint32_t index); |
| 1477 | 1485 |
| 1478 // Return the object's prototype (might be Heap::null_value()). | 1486 // Return the object's prototype (might be Heap::null_value()). |
| 1479 inline Object* GetPrototype(); | 1487 inline Object* GetPrototype(); |
| 1480 | 1488 |
| 1481 // Return the constructor function (may be Heap::null_value()). | 1489 // Return the constructor function (may be Heap::null_value()). |
| 1482 inline Object* GetConstructor(); | 1490 inline Object* GetConstructor(); |
| 1483 | 1491 |
| 1484 // Set the object's prototype (only JSReceiver and null are allowed). | 1492 // Set the object's prototype (only JSReceiver and null are allowed). |
| 1485 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, | 1493 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, |
| 1486 bool skip_hidden_prototypes); | 1494 bool skip_hidden_prototypes); |
| 1487 | 1495 |
| 1488 // Retrieves a permanent object identity hash code. The undefined value might | 1496 // Retrieves a permanent object identity hash code. The undefined value might |
| 1489 // be returned in case no hash was created yet and OMIT_CREATION was used. | 1497 // be returned in case no hash was created yet and OMIT_CREATION was used. |
| 1490 inline MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); | 1498 inline MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
| 1491 | 1499 |
| 1492 // Lookup a property. If found, the result is valid and has | 1500 // Lookup a property. If found, the result is valid and has |
| 1493 // detailed information. | 1501 // detailed information. |
| 1494 void LocalLookup(String* name, LookupResult* result); | 1502 void LocalLookup(String* name, LookupResult* result); |
| 1495 void Lookup(String* name, LookupResult* result); | 1503 void Lookup(String* name, LookupResult* result); |
| 1496 | 1504 |
| 1497 protected: | 1505 protected: |
| 1498 Smi* GenerateIdentityHash(); | 1506 Smi* GenerateIdentityHash(); |
| 1499 | 1507 |
| 1500 private: | 1508 private: |
| 1501 PropertyAttributes GetPropertyAttribute(JSReceiver* receiver, | 1509 PropertyAttributes GetPropertyAttributeForResult(JSReceiver* receiver, |
| 1502 LookupResult* result, | 1510 LookupResult* result, |
| 1503 String* name, | 1511 String* name, |
| 1504 bool continue_search); | 1512 bool continue_search); |
| 1505 | 1513 |
| 1506 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); | 1514 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); |
| 1507 }; | 1515 }; |
| 1508 | 1516 |
| 1509 // The JSObject describes real heap allocated JavaScript objects with | 1517 // The JSObject describes real heap allocated JavaScript objects with |
| 1510 // properties. | 1518 // properties. |
| 1511 // Note that the map of JSObject changes during execution to enable inline | 1519 // Note that the map of JSObject changes during execution to enable inline |
| 1512 // caching. | 1520 // caching. |
| 1513 class JSObject: public JSReceiver { | 1521 class JSObject: public JSReceiver { |
| 1514 public: | 1522 public: |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 String* name, | 1689 String* name, |
| 1682 bool continue_search); | 1690 bool continue_search); |
| 1683 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, | 1691 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, |
| 1684 String* name, | 1692 String* name, |
| 1685 bool continue_search); | 1693 bool continue_search); |
| 1686 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck( | 1694 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck( |
| 1687 Object* receiver, | 1695 Object* receiver, |
| 1688 LookupResult* result, | 1696 LookupResult* result, |
| 1689 String* name, | 1697 String* name, |
| 1690 bool continue_search); | 1698 bool continue_search); |
| 1699 PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver, |
| 1700 uint32_t index, |
| 1701 bool continue_search); |
| 1691 | 1702 |
| 1692 static void DefineAccessor(Handle<JSObject> object, | 1703 static void DefineAccessor(Handle<JSObject> object, |
| 1693 Handle<String> name, | 1704 Handle<String> name, |
| 1694 Handle<Object> getter, | 1705 Handle<Object> getter, |
| 1695 Handle<Object> setter, | 1706 Handle<Object> setter, |
| 1696 PropertyAttributes attributes); | 1707 PropertyAttributes attributes); |
| 1697 // Can cause GC. | 1708 // Can cause GC. |
| 1698 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, | 1709 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, |
| 1699 Object* getter, | 1710 Object* getter, |
| 1700 Object* setter, | 1711 Object* setter, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 // Returns true if the backing storage for the slow-case elements of | 1813 // Returns true if the backing storage for the slow-case elements of |
| 1803 // this object takes up nearly as much space as a fast-case backing | 1814 // this object takes up nearly as much space as a fast-case backing |
| 1804 // storage would. In that case the JSObject should have fast | 1815 // storage would. In that case the JSObject should have fast |
| 1805 // elements. | 1816 // elements. |
| 1806 bool ShouldConvertToFastElements(); | 1817 bool ShouldConvertToFastElements(); |
| 1807 // Returns true if the elements of JSObject contains only values that can be | 1818 // Returns true if the elements of JSObject contains only values that can be |
| 1808 // represented in a FixedDoubleArray and has at least one value that can only | 1819 // represented in a FixedDoubleArray and has at least one value that can only |
| 1809 // be represented as a double and not a Smi. | 1820 // be represented as a double and not a Smi. |
| 1810 bool ShouldConvertToFastDoubleElements(bool* has_smi_only_elements); | 1821 bool ShouldConvertToFastDoubleElements(bool* has_smi_only_elements); |
| 1811 | 1822 |
| 1812 // Tells whether the index'th element is present. | |
| 1813 bool HasElementWithReceiver(JSReceiver* receiver, uint32_t index); | |
| 1814 | |
| 1815 // Computes the new capacity when expanding the elements of a JSObject. | 1823 // Computes the new capacity when expanding the elements of a JSObject. |
| 1816 static int NewElementsCapacity(int old_capacity) { | 1824 static int NewElementsCapacity(int old_capacity) { |
| 1817 // (old_capacity + 50%) + 16 | 1825 // (old_capacity + 50%) + 16 |
| 1818 return old_capacity + (old_capacity >> 1) + 16; | 1826 return old_capacity + (old_capacity >> 1) + 16; |
| 1819 } | 1827 } |
| 1820 | 1828 |
| 1821 // Tells whether the index'th element is present and how it is stored. | 1829 // Tells whether the index'th element is present and how it is stored. |
| 1822 enum LocalElementType { | 1830 enum LocalElementType { |
| 1823 // There is no element with given index. | 1831 // There is no element with given index. |
| 1824 UNDEFINED_ELEMENT, | 1832 UNDEFINED_ELEMENT, |
| 1825 | 1833 |
| 1826 // Element with given index is handled by interceptor. | 1834 // Element with given index is handled by interceptor. |
| 1827 INTERCEPTED_ELEMENT, | 1835 INTERCEPTED_ELEMENT, |
| 1828 | 1836 |
| 1829 // Element with given index is character in string. | 1837 // Element with given index is character in string. |
| 1830 STRING_CHARACTER_ELEMENT, | 1838 STRING_CHARACTER_ELEMENT, |
| 1831 | 1839 |
| 1832 // Element with given index is stored in fast backing store. | 1840 // Element with given index is stored in fast backing store. |
| 1833 FAST_ELEMENT, | 1841 FAST_ELEMENT, |
| 1834 | 1842 |
| 1835 // Element with given index is stored in slow backing store. | 1843 // Element with given index is stored in slow backing store. |
| 1836 DICTIONARY_ELEMENT | 1844 DICTIONARY_ELEMENT |
| 1837 }; | 1845 }; |
| 1838 | 1846 |
| 1839 LocalElementType HasLocalElement(uint32_t index); | 1847 LocalElementType GetLocalElementType(uint32_t index); |
| 1840 | |
| 1841 bool HasElementWithInterceptor(JSReceiver* receiver, uint32_t index); | |
| 1842 | 1848 |
| 1843 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, | 1849 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, |
| 1844 Object* value, | 1850 Object* value, |
| 1845 StrictModeFlag strict_mode, | 1851 StrictModeFlag strict_mode, |
| 1846 bool check_prototype); | 1852 bool check_prototype); |
| 1847 | 1853 |
| 1848 MUST_USE_RESULT MaybeObject* SetDictionaryElement( | 1854 MUST_USE_RESULT MaybeObject* SetDictionaryElement( |
| 1849 uint32_t index, | 1855 uint32_t index, |
| 1850 Object* value, | 1856 Object* value, |
| 1851 PropertyAttributes attributes, | 1857 PropertyAttributes attributes, |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2189 static inline int SizeOf(Map* map, HeapObject* object); | 2195 static inline int SizeOf(Map* map, HeapObject* object); |
| 2190 }; | 2196 }; |
| 2191 | 2197 |
| 2192 private: | 2198 private: |
| 2193 friend class DictionaryElementsAccessor; | 2199 friend class DictionaryElementsAccessor; |
| 2194 | 2200 |
| 2195 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, | 2201 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, |
| 2196 Object* structure, | 2202 Object* structure, |
| 2197 uint32_t index, | 2203 uint32_t index, |
| 2198 Object* holder); | 2204 Object* holder); |
| 2205 MUST_USE_RESULT PropertyAttributes GetElementAttributeWithInterceptor( |
| 2206 JSReceiver* receiver, |
| 2207 uint32_t index, |
| 2208 bool continue_search); |
| 2209 MUST_USE_RESULT PropertyAttributes GetElementAttributeWithoutInterceptor( |
| 2210 JSReceiver* receiver, |
| 2211 uint32_t index, |
| 2212 bool continue_search); |
| 2199 MUST_USE_RESULT MaybeObject* SetElementWithCallback( | 2213 MUST_USE_RESULT MaybeObject* SetElementWithCallback( |
| 2200 Object* structure, | 2214 Object* structure, |
| 2201 uint32_t index, | 2215 uint32_t index, |
| 2202 Object* value, | 2216 Object* value, |
| 2203 JSObject* holder, | 2217 JSObject* holder, |
| 2204 StrictModeFlag strict_mode); | 2218 StrictModeFlag strict_mode); |
| 2205 MUST_USE_RESULT MaybeObject* SetElementWithInterceptor( | 2219 MUST_USE_RESULT MaybeObject* SetElementWithInterceptor( |
| 2206 uint32_t index, | 2220 uint32_t index, |
| 2207 Object* value, | 2221 Object* value, |
| 2208 PropertyAttributes attributes, | 2222 PropertyAttributes attributes, |
| (...skipping 6766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8975 } else { | 8989 } else { |
| 8976 value &= ~(1 << bit_position); | 8990 value &= ~(1 << bit_position); |
| 8977 } | 8991 } |
| 8978 return value; | 8992 return value; |
| 8979 } | 8993 } |
| 8980 }; | 8994 }; |
| 8981 | 8995 |
| 8982 } } // namespace v8::internal | 8996 } } // namespace v8::internal |
| 8983 | 8997 |
| 8984 #endif // V8_OBJECTS_H_ | 8998 #endif // V8_OBJECTS_H_ |
| OLD | NEW |