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 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 | 1299 |
1300 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement( | 1300 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement( |
1301 Isolate* isolate, Handle<Object> object, uint32_t index, | 1301 Isolate* isolate, Handle<Object> object, uint32_t index, |
1302 LanguageMode language_mode = SLOPPY); | 1302 LanguageMode language_mode = SLOPPY); |
1303 | 1303 |
1304 MUST_USE_RESULT static inline MaybeHandle<Object> SetElement( | 1304 MUST_USE_RESULT static inline MaybeHandle<Object> SetElement( |
1305 Isolate* isolate, Handle<Object> object, uint32_t index, | 1305 Isolate* isolate, Handle<Object> object, uint32_t index, |
1306 Handle<Object> value, LanguageMode language_mode); | 1306 Handle<Object> value, LanguageMode language_mode); |
1307 | 1307 |
1308 // Get the first non-hidden prototype. | 1308 // Get the first non-hidden prototype. |
1309 static inline Handle<Object> GetPrototype(Isolate* isolate, | 1309 static inline MaybeHandle<Object> GetPrototype(Isolate* isolate, |
1310 Handle<Object> receiver); | 1310 Handle<Object> receiver); |
1311 | 1311 |
1312 bool HasInPrototypeChain(Isolate* isolate, Object* object); | 1312 bool HasInPrototypeChain(Isolate* isolate, Object* object); |
1313 | 1313 |
1314 // Returns the permanent hash code associated with this object. May return | 1314 // Returns the permanent hash code associated with this object. May return |
1315 // undefined if not yet created. | 1315 // undefined if not yet created. |
1316 Object* GetHash(); | 1316 Object* GetHash(); |
1317 | 1317 |
1318 // Returns undefined for JSObjects, but returns the hash code for simple | 1318 // Returns undefined for JSObjects, but returns the hash code for simple |
1319 // objects. This avoids a double lookup in the cases where we know we will | 1319 // objects. This avoids a double lookup in the cases where we know we will |
1320 // add the hash to the JSObject if it does not already exist. | 1320 // add the hash to the JSObject if it does not already exist. |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 Handle<Object> key, | 1910 Handle<Object> key, |
1911 PropertyDescriptor* desc); | 1911 PropertyDescriptor* desc); |
1912 static bool GetOwnPropertyDescriptor(LookupIterator* it, | 1912 static bool GetOwnPropertyDescriptor(LookupIterator* it, |
1913 PropertyDescriptor* desc); | 1913 PropertyDescriptor* desc); |
1914 | 1914 |
1915 // Disallow further properties to be added to the object. This is | 1915 // Disallow further properties to be added to the object. This is |
1916 // ES6's [[PreventExtensions]] when passed DONT_THROW. | 1916 // ES6's [[PreventExtensions]] when passed DONT_THROW. |
1917 MUST_USE_RESULT static Maybe<bool> PreventExtensions( | 1917 MUST_USE_RESULT static Maybe<bool> PreventExtensions( |
1918 Handle<JSReceiver> object, ShouldThrow should_throw); | 1918 Handle<JSReceiver> object, ShouldThrow should_throw); |
1919 | 1919 |
| 1920 MUST_USE_RESULT static Maybe<bool> IsExtensible(Handle<JSReceiver> object); |
| 1921 |
1920 // Tests for the fast common case for property enumeration. | 1922 // Tests for the fast common case for property enumeration. |
1921 bool IsSimpleEnum(); | 1923 bool IsSimpleEnum(); |
1922 | 1924 |
1923 // Returns the class name ([[Class]] property in the specification). | 1925 // Returns the class name ([[Class]] property in the specification). |
1924 String* class_name(); | 1926 String* class_name(); |
1925 | 1927 |
1926 // Returns the constructor name (the name (possibly, inferred name) of the | 1928 // Returns the constructor name (the name (possibly, inferred name) of the |
1927 // function that was used to instantiate the object). | 1929 // function that was used to instantiate the object). |
1928 String* constructor_name(); | 1930 String* constructor_name(); |
1929 | 1931 |
(...skipping 7630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9560 private: | 9562 private: |
9561 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakCell); | 9563 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakCell); |
9562 }; | 9564 }; |
9563 | 9565 |
9564 | 9566 |
9565 // The JSProxy describes EcmaScript Harmony proxies | 9567 // The JSProxy describes EcmaScript Harmony proxies |
9566 class JSProxy: public JSReceiver { | 9568 class JSProxy: public JSReceiver { |
9567 public: | 9569 public: |
9568 // [handler]: The handler property. | 9570 // [handler]: The handler property. |
9569 DECL_ACCESSORS(handler, Object) | 9571 DECL_ACCESSORS(handler, Object) |
9570 | 9572 // [target]: The target property. |
| 9573 DECL_ACCESSORS(target, Object) |
9571 // [hash]: The hash code property (undefined if not initialized yet). | 9574 // [hash]: The hash code property (undefined if not initialized yet). |
9572 DECL_ACCESSORS(hash, Object) | 9575 DECL_ACCESSORS(hash, Object) |
9573 | 9576 |
9574 DECLARE_CAST(JSProxy) | 9577 DECLARE_CAST(JSProxy) |
9575 | 9578 |
| 9579 |
| 9580 static MaybeHandle<Object> GetPrototype(Handle<JSProxy> receiver); |
| 9581 |
9576 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( | 9582 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( |
9577 Handle<JSProxy> proxy, | 9583 Handle<JSProxy> proxy, |
9578 Handle<Object> receiver, | 9584 Handle<Object> receiver, |
9579 Handle<Name> name); | 9585 Handle<Name> name); |
9580 | 9586 |
9581 // If the handler defines an accessor property with a setter, invoke it. | 9587 // If the handler defines an accessor property with a setter, invoke it. |
9582 // If it defines an accessor property without a setter, or a data property | 9588 // If it defines an accessor property without a setter, or a data property |
9583 // that is read-only, fail. In all these cases set '*done' to true. | 9589 // that is read-only, fail. In all these cases set '*done' to true. |
9584 // Otherwise set it to false, in which case the return value is not | 9590 // Otherwise set it to false, in which case the return value is not |
9585 // meaningful. | 9591 // meaningful. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9624 static const int kSize = JSObject::kHeaderSize; | 9630 static const int kSize = JSObject::kHeaderSize; |
9625 static const int kHeaderSize = kPaddingOffset; | 9631 static const int kHeaderSize = kPaddingOffset; |
9626 static const int kPaddingSize = kSize - kPaddingOffset; | 9632 static const int kPaddingSize = kSize - kPaddingOffset; |
9627 | 9633 |
9628 STATIC_ASSERT(kPaddingSize >= 0); | 9634 STATIC_ASSERT(kPaddingSize >= 0); |
9629 | 9635 |
9630 typedef FixedBodyDescriptor<kHandlerOffset, | 9636 typedef FixedBodyDescriptor<kHandlerOffset, |
9631 kPaddingOffset, | 9637 kPaddingOffset, |
9632 kSize> BodyDescriptor; | 9638 kSize> BodyDescriptor; |
9633 | 9639 |
| 9640 MUST_USE_RESULT Object* GetIdentityHash(); |
| 9641 |
| 9642 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); |
| 9643 |
9634 private: | 9644 private: |
9635 friend class JSReceiver; | 9645 friend class JSReceiver; |
9636 | 9646 |
9637 MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler( | 9647 MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler( |
9638 Handle<JSProxy> proxy, Handle<Name> name); | 9648 Handle<JSProxy> proxy, Handle<Name> name); |
9639 | 9649 |
9640 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( | 9650 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( |
9641 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); | 9651 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); |
9642 | 9652 |
9643 MUST_USE_RESULT Object* GetIdentityHash(); | |
9644 | |
9645 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); | |
9646 | |
9647 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); | 9653 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); |
9648 }; | 9654 }; |
9649 | 9655 |
9650 | 9656 |
9651 class JSFunctionProxy: public JSProxy { | 9657 class JSFunctionProxy: public JSProxy { |
9652 public: | 9658 public: |
9653 // [call_trap]: The call trap. | 9659 // [call_trap]: The call trap. |
9654 DECL_ACCESSORS(call_trap, JSReceiver) | 9660 DECL_ACCESSORS(call_trap, JSReceiver) |
9655 | 9661 |
9656 // [construct_trap]: The construct trap. | 9662 // [construct_trap]: The construct trap. |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10788 } | 10794 } |
10789 return value; | 10795 return value; |
10790 } | 10796 } |
10791 }; | 10797 }; |
10792 | 10798 |
10793 | 10799 |
10794 } // NOLINT, false-positive due to second-order macros. | 10800 } // NOLINT, false-positive due to second-order macros. |
10795 } // NOLINT, false-positive due to second-order macros. | 10801 } // NOLINT, false-positive due to second-order macros. |
10796 | 10802 |
10797 #endif // V8_OBJECTS_H_ | 10803 #endif // V8_OBJECTS_H_ |
OLD | NEW |