| 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 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 static inline JSReceiver* cast(Object* obj); | 2044 static inline JSReceiver* cast(Object* obj); |
| 2045 | 2045 |
| 2046 // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5. | 2046 // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5. |
| 2047 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( | 2047 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( |
| 2048 Handle<JSReceiver> object, | 2048 Handle<JSReceiver> object, |
| 2049 Handle<Name> key, | 2049 Handle<Name> key, |
| 2050 Handle<Object> value, | 2050 Handle<Object> value, |
| 2051 PropertyAttributes attributes, | 2051 PropertyAttributes attributes, |
| 2052 StrictMode strict_mode, | 2052 StrictMode strict_mode, |
| 2053 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); | 2053 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); |
| 2054 static Handle<Object> SetElement(Handle<JSReceiver> object, | 2054 MUST_USE_RESULT static MaybeHandle<Object> SetElement( |
| 2055 uint32_t index, | 2055 Handle<JSReceiver> object, |
| 2056 Handle<Object> value, | 2056 uint32_t index, |
| 2057 PropertyAttributes attributes, | 2057 Handle<Object> value, |
| 2058 StrictMode strict_mode); | 2058 PropertyAttributes attributes, |
| 2059 StrictMode strict_mode); |
| 2059 | 2060 |
| 2060 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. | 2061 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. |
| 2061 static inline bool HasProperty(Handle<JSReceiver> object, Handle<Name> name); | 2062 static inline bool HasProperty(Handle<JSReceiver> object, Handle<Name> name); |
| 2062 static inline bool HasLocalProperty(Handle<JSReceiver>, Handle<Name> name); | 2063 static inline bool HasLocalProperty(Handle<JSReceiver>, Handle<Name> name); |
| 2063 static inline bool HasElement(Handle<JSReceiver> object, uint32_t index); | 2064 static inline bool HasElement(Handle<JSReceiver> object, uint32_t index); |
| 2064 static inline bool HasLocalElement(Handle<JSReceiver> object, uint32_t index); | 2065 static inline bool HasLocalElement(Handle<JSReceiver> object, uint32_t index); |
| 2065 | 2066 |
| 2066 // Implementation of [[Delete]], ECMA-262 5th edition, section 8.12.7. | 2067 // Implementation of [[Delete]], ECMA-262 5th edition, section 8.12.7. |
| 2067 static Handle<Object> DeleteProperty(Handle<JSReceiver> object, | 2068 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( |
| 2068 Handle<Name> name, | 2069 Handle<JSReceiver> object, |
| 2069 DeleteMode mode = NORMAL_DELETION); | 2070 Handle<Name> name, |
| 2070 static Handle<Object> DeleteElement(Handle<JSReceiver> object, | 2071 DeleteMode mode = NORMAL_DELETION); |
| 2071 uint32_t index, | 2072 MUST_USE_RESULT static MaybeHandle<Object> DeleteElement( |
| 2072 DeleteMode mode = NORMAL_DELETION); | 2073 Handle<JSReceiver> object, |
| 2074 uint32_t index, |
| 2075 DeleteMode mode = NORMAL_DELETION); |
| 2073 | 2076 |
| 2074 // Tests for the fast common case for property enumeration. | 2077 // Tests for the fast common case for property enumeration. |
| 2075 bool IsSimpleEnum(); | 2078 bool IsSimpleEnum(); |
| 2076 | 2079 |
| 2077 // Returns the class name ([[Class]] property in the specification). | 2080 // Returns the class name ([[Class]] property in the specification). |
| 2078 String* class_name(); | 2081 String* class_name(); |
| 2079 | 2082 |
| 2080 // Returns the constructor name (the name (possibly, inferred name) of the | 2083 // Returns the constructor name (the name (possibly, inferred name) of the |
| 2081 // function that was used to instantiate the object). | 2084 // function that was used to instantiate the object). |
| 2082 String* constructor_name(); | 2085 String* constructor_name(); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2469 } | 2472 } |
| 2470 | 2473 |
| 2471 // These methods do not perform access checks! | 2474 // These methods do not perform access checks! |
| 2472 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetLocalPropertyAccessorPair( | 2475 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetLocalPropertyAccessorPair( |
| 2473 Handle<JSObject> object, | 2476 Handle<JSObject> object, |
| 2474 Handle<Name> name); | 2477 Handle<Name> name); |
| 2475 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetLocalElementAccessorPair( | 2478 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetLocalElementAccessorPair( |
| 2476 Handle<JSObject> object, | 2479 Handle<JSObject> object, |
| 2477 uint32_t index); | 2480 uint32_t index); |
| 2478 | 2481 |
| 2479 static Handle<Object> SetFastElement(Handle<JSObject> object, uint32_t index, | 2482 MUST_USE_RESULT static MaybeHandle<Object> SetFastElement( |
| 2480 Handle<Object> value, | |
| 2481 StrictMode strict_mode, | |
| 2482 bool check_prototype); | |
| 2483 | |
| 2484 static Handle<Object> SetOwnElement(Handle<JSObject> object, | |
| 2485 uint32_t index, | |
| 2486 Handle<Object> value, | |
| 2487 StrictMode strict_mode); | |
| 2488 | |
| 2489 // Empty handle is returned if the element cannot be set to the given value. | |
| 2490 static Handle<Object> SetElement( | |
| 2491 Handle<JSObject> object, | 2483 Handle<JSObject> object, |
| 2492 uint32_t index, | 2484 uint32_t index, |
| 2493 Handle<Object> value, | 2485 Handle<Object> value, |
| 2486 StrictMode strict_mode, |
| 2487 bool check_prototype); |
| 2488 |
| 2489 MUST_USE_RESULT static MaybeHandle<Object> SetOwnElement( |
| 2490 Handle<JSObject> object, |
| 2491 uint32_t index, |
| 2492 Handle<Object> value, |
| 2493 StrictMode strict_mode); |
| 2494 |
| 2495 // Empty handle is returned if the element cannot be set to the given value. |
| 2496 MUST_USE_RESULT static MaybeHandle<Object> SetElement( |
| 2497 Handle<JSObject> object, |
| 2498 uint32_t index, |
| 2499 Handle<Object> value, |
| 2494 PropertyAttributes attributes, | 2500 PropertyAttributes attributes, |
| 2495 StrictMode strict_mode, | 2501 StrictMode strict_mode, |
| 2496 bool check_prototype = true, | 2502 bool check_prototype = true, |
| 2497 SetPropertyMode set_mode = SET_PROPERTY); | 2503 SetPropertyMode set_mode = SET_PROPERTY); |
| 2498 | 2504 |
| 2499 // Returns the index'th element. | 2505 // Returns the index'th element. |
| 2500 // The undefined object if index is out of bounds. | 2506 // The undefined object if index is out of bounds. |
| 2501 static Handle<Object> GetElementWithInterceptor(Handle<JSObject> object, | 2507 static Handle<Object> GetElementWithInterceptor(Handle<JSObject> object, |
| 2502 Handle<Object> receiver, | 2508 Handle<Object> receiver, |
| 2503 uint32_t index); | 2509 uint32_t index); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2805 Handle<JSReceiver> receiver, | 2811 Handle<JSReceiver> receiver, |
| 2806 uint32_t index, | 2812 uint32_t index, |
| 2807 bool continue_search); | 2813 bool continue_search); |
| 2808 static Handle<Object> SetElementWithCallback( | 2814 static Handle<Object> SetElementWithCallback( |
| 2809 Handle<JSObject> object, | 2815 Handle<JSObject> object, |
| 2810 Handle<Object> structure, | 2816 Handle<Object> structure, |
| 2811 uint32_t index, | 2817 uint32_t index, |
| 2812 Handle<Object> value, | 2818 Handle<Object> value, |
| 2813 Handle<JSObject> holder, | 2819 Handle<JSObject> holder, |
| 2814 StrictMode strict_mode); | 2820 StrictMode strict_mode); |
| 2815 static Handle<Object> SetElementWithInterceptor( | 2821 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithInterceptor( |
| 2816 Handle<JSObject> object, | 2822 Handle<JSObject> object, |
| 2817 uint32_t index, | 2823 uint32_t index, |
| 2818 Handle<Object> value, | 2824 Handle<Object> value, |
| 2819 PropertyAttributes attributes, | 2825 PropertyAttributes attributes, |
| 2820 StrictMode strict_mode, | 2826 StrictMode strict_mode, |
| 2821 bool check_prototype, | 2827 bool check_prototype, |
| 2822 SetPropertyMode set_mode); | 2828 SetPropertyMode set_mode); |
| 2823 static Handle<Object> SetElementWithoutInterceptor( | 2829 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithoutInterceptor( |
| 2824 Handle<JSObject> object, | 2830 Handle<JSObject> object, |
| 2825 uint32_t index, | 2831 uint32_t index, |
| 2826 Handle<Object> value, | 2832 Handle<Object> value, |
| 2827 PropertyAttributes attributes, | 2833 PropertyAttributes attributes, |
| 2828 StrictMode strict_mode, | 2834 StrictMode strict_mode, |
| 2829 bool check_prototype, | 2835 bool check_prototype, |
| 2830 SetPropertyMode set_mode); | 2836 SetPropertyMode set_mode); |
| 2831 static Handle<Object> SetElementWithCallbackSetterInPrototypes( | 2837 MUST_USE_RESULT |
| 2838 static MaybeHandle<Object> SetElementWithCallbackSetterInPrototypes( |
| 2832 Handle<JSObject> object, | 2839 Handle<JSObject> object, |
| 2833 uint32_t index, | 2840 uint32_t index, |
| 2834 Handle<Object> value, | 2841 Handle<Object> value, |
| 2835 bool* found, | 2842 bool* found, |
| 2836 StrictMode strict_mode); | 2843 StrictMode strict_mode); |
| 2837 static Handle<Object> SetDictionaryElement( | 2844 MUST_USE_RESULT static MaybeHandle<Object> SetDictionaryElement( |
| 2838 Handle<JSObject> object, | 2845 Handle<JSObject> object, |
| 2839 uint32_t index, | 2846 uint32_t index, |
| 2840 Handle<Object> value, | 2847 Handle<Object> value, |
| 2841 PropertyAttributes attributes, | 2848 PropertyAttributes attributes, |
| 2842 StrictMode strict_mode, | 2849 StrictMode strict_mode, |
| 2843 bool check_prototype, | 2850 bool check_prototype, |
| 2844 SetPropertyMode set_mode = SET_PROPERTY); | 2851 SetPropertyMode set_mode = SET_PROPERTY); |
| 2845 static Handle<Object> SetFastDoubleElement( | 2852 MUST_USE_RESULT static MaybeHandle<Object> SetFastDoubleElement( |
| 2846 Handle<JSObject> object, | 2853 Handle<JSObject> object, |
| 2847 uint32_t index, | 2854 uint32_t index, |
| 2848 Handle<Object> value, | 2855 Handle<Object> value, |
| 2849 StrictMode strict_mode, | 2856 StrictMode strict_mode, |
| 2850 bool check_prototype = true); | 2857 bool check_prototype = true); |
| 2851 | 2858 |
| 2852 // Searches the prototype chain for property 'name'. If it is found and | 2859 // Searches the prototype chain for property 'name'. If it is found and |
| 2853 // has a setter, invoke it and set '*done' to true. If it is found and is | 2860 // has a setter, invoke it and set '*done' to true. If it is found and is |
| 2854 // read-only, reject and set '*done' to true. Otherwise, set '*done' to | 2861 // read-only, reject and set '*done' to true. Otherwise, set '*done' to |
| 2855 // false. Can throw and return an empty handle with '*done==true'. | 2862 // false. Can throw and return an empty handle with '*done==true'. |
| (...skipping 6943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9799 Object* receiver, | 9806 Object* receiver, |
| 9800 Name* name); | 9807 Name* name); |
| 9801 MUST_USE_RESULT MaybeObject* GetElementWithHandler( | 9808 MUST_USE_RESULT MaybeObject* GetElementWithHandler( |
| 9802 Object* receiver, | 9809 Object* receiver, |
| 9803 uint32_t index); | 9810 uint32_t index); |
| 9804 | 9811 |
| 9805 // If the handler defines an accessor property with a setter, invoke it. | 9812 // If the handler defines an accessor property with a setter, invoke it. |
| 9806 // If it defines an accessor property without a setter, or a data property | 9813 // If it defines an accessor property without a setter, or a data property |
| 9807 // that is read-only, throw. In all these cases set '*done' to true, | 9814 // that is read-only, throw. In all these cases set '*done' to true, |
| 9808 // otherwise set it to false. | 9815 // otherwise set it to false. |
| 9809 static Handle<Object> SetPropertyViaPrototypesWithHandler( | 9816 MUST_USE_RESULT |
| 9817 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler( |
| 9810 Handle<JSProxy> proxy, | 9818 Handle<JSProxy> proxy, |
| 9811 Handle<JSReceiver> receiver, | 9819 Handle<JSReceiver> receiver, |
| 9812 Handle<Name> name, | 9820 Handle<Name> name, |
| 9813 Handle<Object> value, | 9821 Handle<Object> value, |
| 9814 PropertyAttributes attributes, | 9822 PropertyAttributes attributes, |
| 9815 StrictMode strict_mode, | 9823 StrictMode strict_mode, |
| 9816 bool* done); | 9824 bool* done); |
| 9817 | 9825 |
| 9818 static PropertyAttributes GetPropertyAttributeWithHandler( | 9826 static PropertyAttributes GetPropertyAttributeWithHandler( |
| 9819 Handle<JSProxy> proxy, | 9827 Handle<JSProxy> proxy, |
| 9820 Handle<JSReceiver> receiver, | 9828 Handle<JSReceiver> receiver, |
| 9821 Handle<Name> name); | 9829 Handle<Name> name); |
| 9822 static PropertyAttributes GetElementAttributeWithHandler( | 9830 static PropertyAttributes GetElementAttributeWithHandler( |
| 9823 Handle<JSProxy> proxy, | 9831 Handle<JSProxy> proxy, |
| 9824 Handle<JSReceiver> receiver, | 9832 Handle<JSReceiver> receiver, |
| 9825 uint32_t index); | 9833 uint32_t index); |
| 9826 | 9834 |
| 9827 // Turn the proxy into an (empty) JSObject. | 9835 // Turn the proxy into an (empty) JSObject. |
| 9828 static void Fix(Handle<JSProxy> proxy); | 9836 static void Fix(Handle<JSProxy> proxy); |
| 9829 | 9837 |
| 9830 // Initializes the body after the handler slot. | 9838 // Initializes the body after the handler slot. |
| 9831 inline void InitializeBody(int object_size, Object* value); | 9839 inline void InitializeBody(int object_size, Object* value); |
| 9832 | 9840 |
| 9833 // Invoke a trap by name. If the trap does not exist on this's handler, | 9841 // Invoke a trap by name. If the trap does not exist on this's handler, |
| 9834 // but derived_trap is non-NULL, invoke that instead. May cause GC. | 9842 // but derived_trap is non-NULL, invoke that instead. May cause GC. |
| 9835 Handle<Object> CallTrap(const char* name, | 9843 MUST_USE_RESULT static MaybeHandle<Object> CallTrap( |
| 9836 Handle<Object> derived_trap, | 9844 Handle<JSProxy> proxy, |
| 9837 int argc, | 9845 const char* name, |
| 9838 Handle<Object> args[]); | 9846 Handle<Object> derived_trap, |
| 9847 int argc, |
| 9848 Handle<Object> args[]); |
| 9839 | 9849 |
| 9840 // Dispatched behavior. | 9850 // Dispatched behavior. |
| 9841 DECLARE_PRINTER(JSProxy) | 9851 DECLARE_PRINTER(JSProxy) |
| 9842 DECLARE_VERIFIER(JSProxy) | 9852 DECLARE_VERIFIER(JSProxy) |
| 9843 | 9853 |
| 9844 // Layout description. We add padding so that a proxy has the same | 9854 // Layout description. We add padding so that a proxy has the same |
| 9845 // size as a virgin JSObject. This is essential for becoming a JSObject | 9855 // size as a virgin JSObject. This is essential for becoming a JSObject |
| 9846 // upon freeze. | 9856 // upon freeze. |
| 9847 static const int kHandlerOffset = HeapObject::kHeaderSize; | 9857 static const int kHandlerOffset = HeapObject::kHeaderSize; |
| 9848 static const int kHashOffset = kHandlerOffset + kPointerSize; | 9858 static const int kHashOffset = kHandlerOffset + kPointerSize; |
| 9849 static const int kPaddingOffset = kHashOffset + kPointerSize; | 9859 static const int kPaddingOffset = kHashOffset + kPointerSize; |
| 9850 static const int kSize = JSObject::kHeaderSize; | 9860 static const int kSize = JSObject::kHeaderSize; |
| 9851 static const int kHeaderSize = kPaddingOffset; | 9861 static const int kHeaderSize = kPaddingOffset; |
| 9852 static const int kPaddingSize = kSize - kPaddingOffset; | 9862 static const int kPaddingSize = kSize - kPaddingOffset; |
| 9853 | 9863 |
| 9854 STATIC_CHECK(kPaddingSize >= 0); | 9864 STATIC_CHECK(kPaddingSize >= 0); |
| 9855 | 9865 |
| 9856 typedef FixedBodyDescriptor<kHandlerOffset, | 9866 typedef FixedBodyDescriptor<kHandlerOffset, |
| 9857 kPaddingOffset, | 9867 kPaddingOffset, |
| 9858 kSize> BodyDescriptor; | 9868 kSize> BodyDescriptor; |
| 9859 | 9869 |
| 9860 private: | 9870 private: |
| 9861 friend class JSReceiver; | 9871 friend class JSReceiver; |
| 9862 | 9872 |
| 9863 static Handle<Object> SetPropertyWithHandler(Handle<JSProxy> proxy, | 9873 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithHandler( |
| 9864 Handle<JSReceiver> receiver, | 9874 Handle<JSProxy> proxy, |
| 9865 Handle<Name> name, | 9875 Handle<JSReceiver> receiver, |
| 9866 Handle<Object> value, | 9876 Handle<Name> name, |
| 9867 PropertyAttributes attributes, | 9877 Handle<Object> value, |
| 9868 StrictMode strict_mode); | 9878 PropertyAttributes attributes, |
| 9869 static Handle<Object> SetElementWithHandler(Handle<JSProxy> proxy, | 9879 StrictMode strict_mode); |
| 9870 Handle<JSReceiver> receiver, | 9880 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithHandler( |
| 9871 uint32_t index, | 9881 Handle<JSProxy> proxy, |
| 9872 Handle<Object> value, | 9882 Handle<JSReceiver> receiver, |
| 9873 StrictMode strict_mode); | 9883 uint32_t index, |
| 9884 Handle<Object> value, |
| 9885 StrictMode strict_mode); |
| 9874 | 9886 |
| 9875 static bool HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name); | 9887 static bool HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name); |
| 9876 static bool HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index); | 9888 static bool HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index); |
| 9877 | 9889 |
| 9878 static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> proxy, | 9890 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( |
| 9879 Handle<Name> name, | 9891 Handle<JSProxy> proxy, |
| 9880 DeleteMode mode); | 9892 Handle<Name> name, |
| 9881 static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> proxy, | 9893 DeleteMode mode); |
| 9882 uint32_t index, | 9894 MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithHandler( |
| 9883 DeleteMode mode); | 9895 Handle<JSProxy> proxy, |
| 9896 uint32_t index, |
| 9897 DeleteMode mode); |
| 9884 | 9898 |
| 9885 MUST_USE_RESULT Object* GetIdentityHash(); | 9899 MUST_USE_RESULT Object* GetIdentityHash(); |
| 9886 | 9900 |
| 9887 static Handle<Object> GetOrCreateIdentityHash(Handle<JSProxy> proxy); | 9901 static Handle<Object> GetOrCreateIdentityHash(Handle<JSProxy> proxy); |
| 9888 | 9902 |
| 9889 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); | 9903 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); |
| 9890 }; | 9904 }; |
| 9891 | 9905 |
| 9892 | 9906 |
| 9893 class JSFunctionProxy: public JSProxy { | 9907 class JSFunctionProxy: public JSProxy { |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10990 } else { | 11004 } else { |
| 10991 value &= ~(1 << bit_position); | 11005 value &= ~(1 << bit_position); |
| 10992 } | 11006 } |
| 10993 return value; | 11007 return value; |
| 10994 } | 11008 } |
| 10995 }; | 11009 }; |
| 10996 | 11010 |
| 10997 } } // namespace v8::internal | 11011 } } // namespace v8::internal |
| 10998 | 11012 |
| 10999 #endif // V8_OBJECTS_H_ | 11013 #endif // V8_OBJECTS_H_ |
| OLD | NEW |