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 7628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9558 typedef FixedBodyDescriptor<kValueOffset, kSize, kSize> BodyDescriptor; | 9560 typedef FixedBodyDescriptor<kValueOffset, kSize, kSize> BodyDescriptor; |
9559 | 9561 |
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: |
| 9570 // [handler]: The handler property. |
| 9571 DECL_ACCESSORS(handler, Object) |
9568 // [target]: The target property. | 9572 // [target]: The target property. |
9569 DECL_ACCESSORS(target, Object) | 9573 DECL_ACCESSORS(target, Object) |
9570 | |
9571 // [handler]: The handler property. | |
9572 DECL_ACCESSORS(handler, Object) | |
9573 | |
9574 // [hash]: The hash code property (undefined if not initialized yet). | 9574 // [hash]: The hash code property (undefined if not initialized yet). |
9575 DECL_ACCESSORS(hash, Object) | 9575 DECL_ACCESSORS(hash, Object) |
9576 | 9576 |
| 9577 inline bool has_handler(); |
| 9578 |
9577 DECLARE_CAST(JSProxy) | 9579 DECLARE_CAST(JSProxy) |
9578 | 9580 |
| 9581 static MaybeHandle<Object> GetPrototype(Handle<JSProxy> receiver); |
| 9582 |
9579 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( | 9583 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( |
9580 Handle<JSProxy> proxy, | 9584 Handle<JSProxy> proxy, |
9581 Handle<Object> receiver, | 9585 Handle<Object> receiver, |
9582 Handle<Name> name); | 9586 Handle<Name> name); |
9583 | 9587 |
9584 // If the handler defines an accessor property with a setter, invoke it. | 9588 // If the handler defines an accessor property with a setter, invoke it. |
9585 // If it defines an accessor property without a setter, or a data property | 9589 // If it defines an accessor property without a setter, or a data property |
9586 // that is read-only, fail. In all these cases set '*done' to true. | 9590 // that is read-only, fail. In all these cases set '*done' to true. |
9587 // Otherwise set it to false, in which case the return value is not | 9591 // Otherwise set it to false, in which case the return value is not |
9588 // meaningful. | 9592 // meaningful. |
(...skipping 17 matching lines...) Expand all Loading... |
9606 // Layout description. We add padding so that a proxy has the same | 9610 // Layout description. We add padding so that a proxy has the same |
9607 // size as a virgin JSObject. This is essential for becoming a JSObject | 9611 // size as a virgin JSObject. This is essential for becoming a JSObject |
9608 // upon freeze. | 9612 // upon freeze. |
9609 static const int kTargetOffset = HeapObject::kHeaderSize; | 9613 static const int kTargetOffset = HeapObject::kHeaderSize; |
9610 static const int kHandlerOffset = kTargetOffset + kPointerSize; | 9614 static const int kHandlerOffset = kTargetOffset + kPointerSize; |
9611 static const int kHashOffset = kHandlerOffset + kPointerSize; | 9615 static const int kHashOffset = kHandlerOffset + kPointerSize; |
9612 static const int kSize = kHashOffset + kPointerSize; | 9616 static const int kSize = kHashOffset + kPointerSize; |
9613 | 9617 |
9614 typedef FixedBodyDescriptor<kTargetOffset, kSize, kSize> BodyDescriptor; | 9618 typedef FixedBodyDescriptor<kTargetOffset, kSize, kSize> BodyDescriptor; |
9615 | 9619 |
| 9620 MUST_USE_RESULT Object* GetIdentityHash(); |
| 9621 |
| 9622 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); |
| 9623 |
9616 private: | 9624 private: |
9617 friend class JSReceiver; | 9625 friend class JSReceiver; |
9618 | 9626 |
9619 // Invoke a trap by name. If the trap does not exist on this's handler, | 9627 // Invoke a trap by name. If the trap does not exist on this's handler, |
9620 // but derived_trap is non-NULL, invoke that instead. May cause GC. | 9628 // but derived_trap is non-NULL, invoke that instead. May cause GC. |
9621 MUST_USE_RESULT static MaybeHandle<Object> CallTrap( | 9629 MUST_USE_RESULT static MaybeHandle<Object> CallTrap( |
9622 Handle<JSProxy> proxy, const char* name, Handle<Object> derived_trap, | 9630 Handle<JSProxy> proxy, const char* name, Handle<Object> derived_trap, |
9623 int argc, Handle<Object> args[]); | 9631 int argc, Handle<Object> args[]); |
9624 | 9632 |
9625 MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler( | 9633 MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler( |
9626 Handle<JSProxy> proxy, Handle<Name> name); | 9634 Handle<JSProxy> proxy, Handle<Name> name); |
9627 | 9635 |
9628 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( | 9636 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( |
9629 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); | 9637 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); |
9630 | 9638 |
9631 MUST_USE_RESULT Object* GetIdentityHash(); | |
9632 | |
9633 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); | |
9634 | |
9635 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); | 9639 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); |
9636 }; | 9640 }; |
9637 | 9641 |
9638 | 9642 |
9639 class JSFunctionProxy: public JSProxy { | 9643 class JSFunctionProxy: public JSProxy { |
9640 public: | 9644 public: |
9641 // [call_trap]: The call trap. | 9645 // [call_trap]: The call trap. |
9642 DECL_ACCESSORS(call_trap, JSReceiver) | 9646 DECL_ACCESSORS(call_trap, JSReceiver) |
9643 | 9647 |
9644 // [construct_trap]: The construct trap. | 9648 // [construct_trap]: The construct trap. |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10770 } | 10774 } |
10771 return value; | 10775 return value; |
10772 } | 10776 } |
10773 }; | 10777 }; |
10774 | 10778 |
10775 | 10779 |
10776 } // NOLINT, false-positive due to second-order macros. | 10780 } // NOLINT, false-positive due to second-order macros. |
10777 } // NOLINT, false-positive due to second-order macros. | 10781 } // NOLINT, false-positive due to second-order macros. |
10778 | 10782 |
10779 #endif // V8_OBJECTS_H_ | 10783 #endif // V8_OBJECTS_H_ |
OLD | NEW |