| 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 "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
| 10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
| (...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 DECLARE_CAST(JSReceiver) | 1953 DECLARE_CAST(JSReceiver) |
| 1954 | 1954 |
| 1955 MUST_USE_RESULT static MaybeHandle<Object> SetElement( | 1955 MUST_USE_RESULT static MaybeHandle<Object> SetElement( |
| 1956 Handle<JSReceiver> object, | 1956 Handle<JSReceiver> object, |
| 1957 uint32_t index, | 1957 uint32_t index, |
| 1958 Handle<Object> value, | 1958 Handle<Object> value, |
| 1959 PropertyAttributes attributes, | 1959 PropertyAttributes attributes, |
| 1960 StrictMode strict_mode); | 1960 StrictMode strict_mode); |
| 1961 | 1961 |
| 1962 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. | 1962 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. |
| 1963 static inline bool HasProperty(Handle<JSReceiver> object, Handle<Name> name); | 1963 MUST_USE_RESULT static inline Maybe<bool> HasProperty( |
| 1964 static inline bool HasOwnProperty(Handle<JSReceiver>, Handle<Name> name); | 1964 Handle<JSReceiver> object, Handle<Name> name); |
| 1965 static inline bool HasElement(Handle<JSReceiver> object, uint32_t index); | 1965 MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(Handle<JSReceiver>, |
| 1966 static inline bool HasOwnElement(Handle<JSReceiver> object, uint32_t index); | 1966 Handle<Name> name); |
| 1967 MUST_USE_RESULT static inline Maybe<bool> HasElement( |
| 1968 Handle<JSReceiver> object, uint32_t index); |
| 1969 MUST_USE_RESULT static inline Maybe<bool> HasOwnElement( |
| 1970 Handle<JSReceiver> object, uint32_t index); |
| 1967 | 1971 |
| 1968 // Implementation of [[Delete]], ECMA-262 5th edition, section 8.12.7. | 1972 // Implementation of [[Delete]], ECMA-262 5th edition, section 8.12.7. |
| 1969 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( | 1973 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( |
| 1970 Handle<JSReceiver> object, | 1974 Handle<JSReceiver> object, |
| 1971 Handle<Name> name, | 1975 Handle<Name> name, |
| 1972 DeleteMode mode = NORMAL_DELETION); | 1976 DeleteMode mode = NORMAL_DELETION); |
| 1973 MUST_USE_RESULT static MaybeHandle<Object> DeleteElement( | 1977 MUST_USE_RESULT static MaybeHandle<Object> DeleteElement( |
| 1974 Handle<JSReceiver> object, | 1978 Handle<JSReceiver> object, |
| 1975 uint32_t index, | 1979 uint32_t index, |
| 1976 DeleteMode mode = NORMAL_DELETION); | 1980 DeleteMode mode = NORMAL_DELETION); |
| 1977 | 1981 |
| 1978 // Tests for the fast common case for property enumeration. | 1982 // Tests for the fast common case for property enumeration. |
| 1979 bool IsSimpleEnum(); | 1983 bool IsSimpleEnum(); |
| 1980 | 1984 |
| 1981 // Returns the class name ([[Class]] property in the specification). | 1985 // Returns the class name ([[Class]] property in the specification). |
| 1982 String* class_name(); | 1986 String* class_name(); |
| 1983 | 1987 |
| 1984 // Returns the constructor name (the name (possibly, inferred name) of the | 1988 // Returns the constructor name (the name (possibly, inferred name) of the |
| 1985 // function that was used to instantiate the object). | 1989 // function that was used to instantiate the object). |
| 1986 String* constructor_name(); | 1990 String* constructor_name(); |
| 1987 | 1991 |
| 1988 static inline PropertyAttributes GetPropertyAttributes( | 1992 MUST_USE_RESULT static inline Maybe<PropertyAttributes> GetPropertyAttributes( |
| 1989 Handle<JSReceiver> object, | 1993 Handle<JSReceiver> object, Handle<Name> name); |
| 1990 Handle<Name> name); | 1994 MUST_USE_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes( |
| 1991 static PropertyAttributes GetPropertyAttributes(LookupIterator* it); | 1995 LookupIterator* it); |
| 1992 static PropertyAttributes GetOwnPropertyAttributes( | 1996 MUST_USE_RESULT static Maybe<PropertyAttributes> GetOwnPropertyAttributes( |
| 1993 Handle<JSReceiver> object, | 1997 Handle<JSReceiver> object, Handle<Name> name); |
| 1994 Handle<Name> name); | |
| 1995 | 1998 |
| 1996 static inline PropertyAttributes GetElementAttribute( | 1999 MUST_USE_RESULT static inline Maybe<PropertyAttributes> GetElementAttribute( |
| 1997 Handle<JSReceiver> object, | 2000 Handle<JSReceiver> object, uint32_t index); |
| 1998 uint32_t index); | 2001 MUST_USE_RESULT static inline Maybe<PropertyAttributes> |
| 1999 static inline PropertyAttributes GetOwnElementAttribute( | 2002 GetOwnElementAttribute(Handle<JSReceiver> object, uint32_t index); |
| 2000 Handle<JSReceiver> object, | |
| 2001 uint32_t index); | |
| 2002 | 2003 |
| 2003 // Return the constructor function (may be Heap::null_value()). | 2004 // Return the constructor function (may be Heap::null_value()). |
| 2004 inline Object* GetConstructor(); | 2005 inline Object* GetConstructor(); |
| 2005 | 2006 |
| 2006 // Retrieves a permanent object identity hash code. The undefined value might | 2007 // Retrieves a permanent object identity hash code. The undefined value might |
| 2007 // be returned in case no hash was created yet. | 2008 // be returned in case no hash was created yet. |
| 2008 inline Object* GetIdentityHash(); | 2009 inline Object* GetIdentityHash(); |
| 2009 | 2010 |
| 2010 // Retrieves a permanent object identity hash code. May create and store a | 2011 // Retrieves a permanent object identity hash code. May create and store a |
| 2011 // hash code if needed and none exists. | 2012 // hash code if needed and none exists. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 Handle<Object> value, | 2192 Handle<Object> value, |
| 2192 PropertyDetails details); | 2193 PropertyDetails details); |
| 2193 | 2194 |
| 2194 static void OptimizeAsPrototype(Handle<JSObject> object); | 2195 static void OptimizeAsPrototype(Handle<JSObject> object); |
| 2195 | 2196 |
| 2196 // Retrieve interceptors. | 2197 // Retrieve interceptors. |
| 2197 InterceptorInfo* GetNamedInterceptor(); | 2198 InterceptorInfo* GetNamedInterceptor(); |
| 2198 InterceptorInfo* GetIndexedInterceptor(); | 2199 InterceptorInfo* GetIndexedInterceptor(); |
| 2199 | 2200 |
| 2200 // Used from JSReceiver. | 2201 // Used from JSReceiver. |
| 2201 static Maybe<PropertyAttributes> GetPropertyAttributesWithInterceptor( | 2202 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 2202 Handle<JSObject> holder, | 2203 GetPropertyAttributesWithInterceptor(Handle<JSObject> holder, |
| 2203 Handle<Object> receiver, | 2204 Handle<Object> receiver, |
| 2204 Handle<Name> name); | 2205 Handle<Name> name); |
| 2205 static PropertyAttributes GetPropertyAttributesWithFailedAccessCheck( | 2206 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 2206 LookupIterator* it); | 2207 GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it); |
| 2207 static PropertyAttributes GetElementAttributeWithReceiver( | 2208 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 2208 Handle<JSObject> object, | 2209 GetElementAttributeWithReceiver(Handle<JSObject> object, |
| 2209 Handle<JSReceiver> receiver, | 2210 Handle<JSReceiver> receiver, |
| 2210 uint32_t index, | 2211 uint32_t index, bool check_prototype); |
| 2211 bool check_prototype); | |
| 2212 | 2212 |
| 2213 // Retrieves an AccessorPair property from the given object. Might return | 2213 // Retrieves an AccessorPair property from the given object. Might return |
| 2214 // undefined if the property doesn't exist or is of a different kind. | 2214 // undefined if the property doesn't exist or is of a different kind. |
| 2215 MUST_USE_RESULT static MaybeHandle<Object> GetAccessor( | 2215 MUST_USE_RESULT static MaybeHandle<Object> GetAccessor( |
| 2216 Handle<JSObject> object, | 2216 Handle<JSObject> object, |
| 2217 Handle<Name> name, | 2217 Handle<Name> name, |
| 2218 AccessorComponent component); | 2218 AccessorComponent component); |
| 2219 | 2219 |
| 2220 // Defines an AccessorPair property on the given object. | 2220 // Defines an AccessorPair property on the given object. |
| 2221 // TODO(mstarzinger): Rename to SetAccessor() and return empty handle on | 2221 // TODO(mstarzinger): Rename to SetAccessor(). |
| 2222 // exception instead of letting callers check for scheduled exception. | 2222 static MaybeHandle<Object> DefineAccessor(Handle<JSObject> object, |
| 2223 static void DefineAccessor(Handle<JSObject> object, | 2223 Handle<Name> name, |
| 2224 Handle<Name> name, | 2224 Handle<Object> getter, |
| 2225 Handle<Object> getter, | 2225 Handle<Object> setter, |
| 2226 Handle<Object> setter, | 2226 PropertyAttributes attributes); |
| 2227 PropertyAttributes attributes); | |
| 2228 | 2227 |
| 2229 // Defines an AccessorInfo property on the given object. | 2228 // Defines an AccessorInfo property on the given object. |
| 2230 MUST_USE_RESULT static MaybeHandle<Object> SetAccessor( | 2229 MUST_USE_RESULT static MaybeHandle<Object> SetAccessor( |
| 2231 Handle<JSObject> object, | 2230 Handle<JSObject> object, |
| 2232 Handle<AccessorInfo> info); | 2231 Handle<AccessorInfo> info); |
| 2233 | 2232 |
| 2234 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithInterceptor( | 2233 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithInterceptor( |
| 2235 Handle<JSObject> object, | 2234 Handle<JSObject> object, |
| 2236 Handle<Object> receiver, | 2235 Handle<Object> receiver, |
| 2237 Handle<Name> name); | 2236 Handle<Name> name); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2374 // Computes the enumerable keys from interceptors. Used for debug mirrors and | 2373 // Computes the enumerable keys from interceptors. Used for debug mirrors and |
| 2375 // by JSReceiver::GetKeys. | 2374 // by JSReceiver::GetKeys. |
| 2376 MUST_USE_RESULT static MaybeHandle<JSObject> GetKeysForNamedInterceptor( | 2375 MUST_USE_RESULT static MaybeHandle<JSObject> GetKeysForNamedInterceptor( |
| 2377 Handle<JSObject> object, | 2376 Handle<JSObject> object, |
| 2378 Handle<JSReceiver> receiver); | 2377 Handle<JSReceiver> receiver); |
| 2379 MUST_USE_RESULT static MaybeHandle<JSObject> GetKeysForIndexedInterceptor( | 2378 MUST_USE_RESULT static MaybeHandle<JSObject> GetKeysForIndexedInterceptor( |
| 2380 Handle<JSObject> object, | 2379 Handle<JSObject> object, |
| 2381 Handle<JSReceiver> receiver); | 2380 Handle<JSReceiver> receiver); |
| 2382 | 2381 |
| 2383 // Support functions for v8 api (needed for correct interceptor behavior). | 2382 // Support functions for v8 api (needed for correct interceptor behavior). |
| 2384 static bool HasRealNamedProperty(Handle<JSObject> object, | 2383 MUST_USE_RESULT static Maybe<bool> HasRealNamedProperty( |
| 2385 Handle<Name> key); | 2384 Handle<JSObject> object, Handle<Name> key); |
| 2386 static bool HasRealElementProperty(Handle<JSObject> object, uint32_t index); | 2385 MUST_USE_RESULT static Maybe<bool> HasRealElementProperty( |
| 2387 static bool HasRealNamedCallbackProperty(Handle<JSObject> object, | 2386 Handle<JSObject> object, uint32_t index); |
| 2388 Handle<Name> key); | 2387 MUST_USE_RESULT static Maybe<bool> HasRealNamedCallbackProperty( |
| 2388 Handle<JSObject> object, Handle<Name> key); |
| 2389 | 2389 |
| 2390 // Get the header size for a JSObject. Used to compute the index of | 2390 // Get the header size for a JSObject. Used to compute the index of |
| 2391 // internal fields as well as the number of internal fields. | 2391 // internal fields as well as the number of internal fields. |
| 2392 inline int GetHeaderSize(); | 2392 inline int GetHeaderSize(); |
| 2393 | 2393 |
| 2394 inline int GetInternalFieldCount(); | 2394 inline int GetInternalFieldCount(); |
| 2395 inline int GetInternalFieldOffset(int index); | 2395 inline int GetInternalFieldOffset(int index); |
| 2396 inline Object* GetInternalField(int index); | 2396 inline Object* GetInternalField(int index); |
| 2397 inline void SetInternalField(int index, Object* value); | 2397 inline void SetInternalField(int index, Object* value); |
| 2398 inline void SetInternalField(int index, Smi* value); | 2398 inline void SetInternalField(int index, Smi* value); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2651 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithFailedAccessCheck( | 2651 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithFailedAccessCheck( |
| 2652 LookupIterator* it); | 2652 LookupIterator* it); |
| 2653 | 2653 |
| 2654 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithCallback( | 2654 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithCallback( |
| 2655 Handle<JSObject> object, | 2655 Handle<JSObject> object, |
| 2656 Handle<Object> receiver, | 2656 Handle<Object> receiver, |
| 2657 Handle<Object> structure, | 2657 Handle<Object> structure, |
| 2658 uint32_t index, | 2658 uint32_t index, |
| 2659 Handle<Object> holder); | 2659 Handle<Object> holder); |
| 2660 | 2660 |
| 2661 static PropertyAttributes GetElementAttributeWithInterceptor( | 2661 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 2662 Handle<JSObject> object, | 2662 GetElementAttributeWithInterceptor(Handle<JSObject> object, |
| 2663 Handle<JSReceiver> receiver, | 2663 Handle<JSReceiver> receiver, |
| 2664 uint32_t index, | 2664 uint32_t index, bool continue_search); |
| 2665 bool continue_search); | 2665 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 2666 static PropertyAttributes GetElementAttributeWithoutInterceptor( | 2666 GetElementAttributeWithoutInterceptor(Handle<JSObject> object, |
| 2667 Handle<JSObject> object, | 2667 Handle<JSReceiver> receiver, |
| 2668 Handle<JSReceiver> receiver, | 2668 uint32_t index, |
| 2669 uint32_t index, | 2669 bool continue_search); |
| 2670 bool continue_search); | |
| 2671 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithCallback( | 2670 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithCallback( |
| 2672 Handle<JSObject> object, | 2671 Handle<JSObject> object, |
| 2673 Handle<Object> structure, | 2672 Handle<Object> structure, |
| 2674 uint32_t index, | 2673 uint32_t index, |
| 2675 Handle<Object> value, | 2674 Handle<Object> value, |
| 2676 Handle<JSObject> holder, | 2675 Handle<JSObject> holder, |
| 2677 StrictMode strict_mode); | 2676 StrictMode strict_mode); |
| 2678 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithInterceptor( | 2677 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithInterceptor( |
| 2679 Handle<JSObject> object, | 2678 Handle<JSObject> object, |
| 2680 uint32_t index, | 2679 uint32_t index, |
| (...skipping 7259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9940 | 9939 |
| 9941 // If the handler defines an accessor property with a setter, invoke it. | 9940 // If the handler defines an accessor property with a setter, invoke it. |
| 9942 // If it defines an accessor property without a setter, or a data property | 9941 // If it defines an accessor property without a setter, or a data property |
| 9943 // that is read-only, throw. In all these cases set '*done' to true, | 9942 // that is read-only, throw. In all these cases set '*done' to true, |
| 9944 // otherwise set it to false. | 9943 // otherwise set it to false. |
| 9945 MUST_USE_RESULT | 9944 MUST_USE_RESULT |
| 9946 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler( | 9945 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler( |
| 9947 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, | 9946 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, |
| 9948 Handle<Object> value, StrictMode strict_mode, bool* done); | 9947 Handle<Object> value, StrictMode strict_mode, bool* done); |
| 9949 | 9948 |
| 9950 static PropertyAttributes GetPropertyAttributesWithHandler( | 9949 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 9951 Handle<JSProxy> proxy, | 9950 GetPropertyAttributesWithHandler(Handle<JSProxy> proxy, |
| 9952 Handle<Object> receiver, | 9951 Handle<Object> receiver, |
| 9953 Handle<Name> name); | 9952 Handle<Name> name); |
| 9954 static PropertyAttributes GetElementAttributeWithHandler( | 9953 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 9955 Handle<JSProxy> proxy, | 9954 GetElementAttributeWithHandler(Handle<JSProxy> proxy, |
| 9956 Handle<JSReceiver> receiver, | 9955 Handle<JSReceiver> receiver, |
| 9957 uint32_t index); | 9956 uint32_t index); |
| 9958 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithHandler( | 9957 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithHandler( |
| 9959 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, | 9958 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, |
| 9960 Handle<Object> value, StrictMode strict_mode); | 9959 Handle<Object> value, StrictMode strict_mode); |
| 9961 | 9960 |
| 9962 // Turn the proxy into an (empty) JSObject. | 9961 // Turn the proxy into an (empty) JSObject. |
| 9963 static void Fix(Handle<JSProxy> proxy); | 9962 static void Fix(Handle<JSProxy> proxy); |
| 9964 | 9963 |
| 9965 // Initializes the body after the handler slot. | 9964 // Initializes the body after the handler slot. |
| 9966 inline void InitializeBody(int object_size, Object* value); | 9965 inline void InitializeBody(int object_size, Object* value); |
| 9967 | 9966 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 9997 private: | 9996 private: |
| 9998 friend class JSReceiver; | 9997 friend class JSReceiver; |
| 9999 | 9998 |
| 10000 MUST_USE_RESULT static inline MaybeHandle<Object> SetElementWithHandler( | 9999 MUST_USE_RESULT static inline MaybeHandle<Object> SetElementWithHandler( |
| 10001 Handle<JSProxy> proxy, | 10000 Handle<JSProxy> proxy, |
| 10002 Handle<JSReceiver> receiver, | 10001 Handle<JSReceiver> receiver, |
| 10003 uint32_t index, | 10002 uint32_t index, |
| 10004 Handle<Object> value, | 10003 Handle<Object> value, |
| 10005 StrictMode strict_mode); | 10004 StrictMode strict_mode); |
| 10006 | 10005 |
| 10007 static bool HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name); | 10006 MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler( |
| 10008 static inline bool HasElementWithHandler(Handle<JSProxy> proxy, | 10007 Handle<JSProxy> proxy, Handle<Name> name); |
| 10009 uint32_t index); | 10008 MUST_USE_RESULT static inline Maybe<bool> HasElementWithHandler( |
| 10009 Handle<JSProxy> proxy, uint32_t index); |
| 10010 | 10010 |
| 10011 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( | 10011 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( |
| 10012 Handle<JSProxy> proxy, | 10012 Handle<JSProxy> proxy, |
| 10013 Handle<Name> name, | 10013 Handle<Name> name, |
| 10014 DeleteMode mode); | 10014 DeleteMode mode); |
| 10015 MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithHandler( | 10015 MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithHandler( |
| 10016 Handle<JSProxy> proxy, | 10016 Handle<JSProxy> proxy, |
| 10017 uint32_t index, | 10017 uint32_t index, |
| 10018 DeleteMode mode); | 10018 DeleteMode mode); |
| 10019 | 10019 |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11209 } else { | 11209 } else { |
| 11210 value &= ~(1 << bit_position); | 11210 value &= ~(1 << bit_position); |
| 11211 } | 11211 } |
| 11212 return value; | 11212 return value; |
| 11213 } | 11213 } |
| 11214 }; | 11214 }; |
| 11215 | 11215 |
| 11216 } } // namespace v8::internal | 11216 } } // namespace v8::internal |
| 11217 | 11217 |
| 11218 #endif // V8_OBJECTS_H_ | 11218 #endif // V8_OBJECTS_H_ |
| OLD | NEW |