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 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 | 1794 |
1795 enum KeyFilter { SKIP_SYMBOLS, INCLUDE_SYMBOLS }; | 1795 enum KeyFilter { SKIP_SYMBOLS, INCLUDE_SYMBOLS }; |
1796 | 1796 |
1797 | 1797 |
1798 enum GetKeysConversion { KEEP_NUMBERS, CONVERT_TO_STRING }; | 1798 enum GetKeysConversion { KEEP_NUMBERS, CONVERT_TO_STRING }; |
1799 | 1799 |
1800 | 1800 |
1801 enum ShouldThrow { THROW_ON_ERROR, DONT_THROW }; | 1801 enum ShouldThrow { THROW_ON_ERROR, DONT_THROW }; |
1802 | 1802 |
1803 | 1803 |
| 1804 #define RETURN_FAILURE(isolate, should_throw, call) \ |
| 1805 do { \ |
| 1806 if ((should_throw) == DONT_THROW) { \ |
| 1807 return Just(false); \ |
| 1808 } else { \ |
| 1809 isolate->Throw(*isolate->factory()->call); \ |
| 1810 return Nothing<bool>(); \ |
| 1811 } \ |
| 1812 } while (false) |
| 1813 |
| 1814 |
| 1815 #define MAYBE_RETURN(call, value) \ |
| 1816 do { \ |
| 1817 if ((call).IsNothing()) return value; \ |
| 1818 } while (false) |
| 1819 |
| 1820 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>()) |
| 1821 |
| 1822 |
1804 // JSReceiver includes types on which properties can be defined, i.e., | 1823 // JSReceiver includes types on which properties can be defined, i.e., |
1805 // JSObject and JSProxy. | 1824 // JSObject and JSProxy. |
1806 class JSReceiver: public HeapObject { | 1825 class JSReceiver: public HeapObject { |
1807 public: | 1826 public: |
1808 DECLARE_CAST(JSReceiver) | 1827 DECLARE_CAST(JSReceiver) |
1809 | 1828 |
1810 // ES6 section 7.1.1 ToPrimitive | 1829 // ES6 section 7.1.1 ToPrimitive |
1811 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive( | 1830 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive( |
1812 Handle<JSReceiver> receiver, | 1831 Handle<JSReceiver> receiver, |
1813 ToPrimitiveHint hint = ToPrimitiveHint::kDefault); | 1832 ToPrimitiveHint hint = ToPrimitiveHint::kDefault); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 GetOwnPropertyAttributes(Handle<JSReceiver> object, Handle<Name> name); | 1906 GetOwnPropertyAttributes(Handle<JSReceiver> object, Handle<Name> name); |
1888 | 1907 |
1889 MUST_USE_RESULT static inline Maybe<PropertyAttributes> GetElementAttributes( | 1908 MUST_USE_RESULT static inline Maybe<PropertyAttributes> GetElementAttributes( |
1890 Handle<JSReceiver> object, uint32_t index); | 1909 Handle<JSReceiver> object, uint32_t index); |
1891 MUST_USE_RESULT static inline Maybe<PropertyAttributes> | 1910 MUST_USE_RESULT static inline Maybe<PropertyAttributes> |
1892 GetOwnElementAttributes(Handle<JSReceiver> object, uint32_t index); | 1911 GetOwnElementAttributes(Handle<JSReceiver> object, uint32_t index); |
1893 | 1912 |
1894 MUST_USE_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes( | 1913 MUST_USE_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes( |
1895 LookupIterator* it); | 1914 LookupIterator* it); |
1896 | 1915 |
| 1916 // Set the object's prototype (only JSReceiver and null are allowed values). |
| 1917 MUST_USE_RESULT static Maybe<bool> SetPrototype(Handle<JSReceiver> object, |
| 1918 Handle<Object> value, |
| 1919 bool from_javascript, |
| 1920 ShouldThrow should_throw); |
| 1921 |
1897 | 1922 |
1898 static Handle<Object> GetDataProperty(Handle<JSReceiver> object, | 1923 static Handle<Object> GetDataProperty(Handle<JSReceiver> object, |
1899 Handle<Name> name); | 1924 Handle<Name> name); |
1900 static Handle<Object> GetDataProperty(LookupIterator* it); | 1925 static Handle<Object> GetDataProperty(LookupIterator* it); |
1901 | 1926 |
1902 | 1927 |
1903 // Retrieves a permanent object identity hash code. The undefined value might | 1928 // Retrieves a permanent object identity hash code. The undefined value might |
1904 // be returned in case no hash was created yet. | 1929 // be returned in case no hash was created yet. |
1905 inline Object* GetIdentityHash(); | 1930 inline Object* GetIdentityHash(); |
1906 | 1931 |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2308 | 2333 |
2309 // Access to in object properties. | 2334 // Access to in object properties. |
2310 inline int GetInObjectPropertyOffset(int index); | 2335 inline int GetInObjectPropertyOffset(int index); |
2311 inline Object* InObjectPropertyAt(int index); | 2336 inline Object* InObjectPropertyAt(int index); |
2312 inline Object* InObjectPropertyAtPut(int index, | 2337 inline Object* InObjectPropertyAtPut(int index, |
2313 Object* value, | 2338 Object* value, |
2314 WriteBarrierMode mode | 2339 WriteBarrierMode mode |
2315 = UPDATE_WRITE_BARRIER); | 2340 = UPDATE_WRITE_BARRIER); |
2316 | 2341 |
2317 // Set the object's prototype (only JSReceiver and null are allowed values). | 2342 // Set the object's prototype (only JSReceiver and null are allowed values). |
2318 MUST_USE_RESULT static MaybeHandle<Object> SetPrototype( | 2343 MUST_USE_RESULT static Maybe<bool> SetPrototype(Handle<JSObject> object, |
2319 Handle<JSObject> object, Handle<Object> value, bool from_javascript); | 2344 Handle<Object> value, |
| 2345 bool from_javascript, |
| 2346 ShouldThrow should_throw); |
2320 | 2347 |
2321 // Initializes the body after properties slot, properties slot is | 2348 // Initializes the body after properties slot, properties slot is |
2322 // initialized by set_properties. Fill the pre-allocated fields with | 2349 // initialized by set_properties. Fill the pre-allocated fields with |
2323 // pre_allocated_value and the rest with filler_value. | 2350 // pre_allocated_value and the rest with filler_value. |
2324 // Note: this call does not update write barrier, the caller is responsible | 2351 // Note: this call does not update write barrier, the caller is responsible |
2325 // to ensure that |filler_value| can be collected without WB here. | 2352 // to ensure that |filler_value| can be collected without WB here. |
2326 inline void InitializeBody(Map* map, | 2353 inline void InitializeBody(Map* map, |
2327 Object* pre_allocated_value, | 2354 Object* pre_allocated_value, |
2328 Object* filler_value); | 2355 Object* filler_value); |
2329 | 2356 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 | 2542 |
2516 static Handle<SeededNumberDictionary> GetNormalizedElementDictionary( | 2543 static Handle<SeededNumberDictionary> GetNormalizedElementDictionary( |
2517 Handle<JSObject> object, Handle<FixedArrayBase> elements); | 2544 Handle<JSObject> object, Handle<FixedArrayBase> elements); |
2518 | 2545 |
2519 // Helper for fast versions of preventExtensions, seal, and freeze. | 2546 // Helper for fast versions of preventExtensions, seal, and freeze. |
2520 // attrs is one of NONE, SEALED, or FROZEN (depending on the operation). | 2547 // attrs is one of NONE, SEALED, or FROZEN (depending on the operation). |
2521 template <PropertyAttributes attrs> | 2548 template <PropertyAttributes attrs> |
2522 MUST_USE_RESULT static Maybe<bool> PreventExtensionsWithTransition( | 2549 MUST_USE_RESULT static Maybe<bool> PreventExtensionsWithTransition( |
2523 Handle<JSObject> object, ShouldThrow should_throw); | 2550 Handle<JSObject> object, ShouldThrow should_throw); |
2524 | 2551 |
2525 MUST_USE_RESULT static MaybeHandle<Object> SetPrototypeUnobserved( | 2552 MUST_USE_RESULT static Maybe<bool> SetPrototypeUnobserved( |
2526 Handle<JSObject> object, Handle<Object> value, bool from_javascript); | 2553 Handle<JSObject> object, Handle<Object> value, bool from_javascript, |
| 2554 ShouldThrow should_throw); |
2527 | 2555 |
2528 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); | 2556 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); |
2529 }; | 2557 }; |
2530 | 2558 |
2531 | 2559 |
2532 // Common superclass for FixedArrays that allow implementations to share | 2560 // Common superclass for FixedArrays that allow implementations to share |
2533 // common accessors and some code paths. | 2561 // common accessors and some code paths. |
2534 class FixedArrayBase: public HeapObject { | 2562 class FixedArrayBase: public HeapObject { |
2535 public: | 2563 public: |
2536 // [length]: length of the array. | 2564 // [length]: length of the array. |
(...skipping 8251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10788 // (elements + properties) in the current level. | 10816 // (elements + properties) in the current level. |
10789 int levelLength_; | 10817 int levelLength_; |
10790 | 10818 |
10791 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); | 10819 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
10792 }; | 10820 }; |
10793 | 10821 |
10794 } // NOLINT, false-positive due to second-order macros. | 10822 } // NOLINT, false-positive due to second-order macros. |
10795 } // NOLINT, false-positive due to second-order macros. | 10823 } // NOLINT, false-positive due to second-order macros. |
10796 | 10824 |
10797 #endif // V8_OBJECTS_H_ | 10825 #endif // V8_OBJECTS_H_ |
OLD | NEW |