Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: src/objects.h

Issue 1159433003: Use GetProperty for getting elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter( 1199 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter(
1200 Handle<Object> receiver, 1200 Handle<Object> receiver,
1201 Handle<JSReceiver> setter, 1201 Handle<JSReceiver> setter,
1202 Handle<Object> value); 1202 Handle<Object> value);
1203 1203
1204 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement( 1204 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement(
1205 Isolate* isolate, 1205 Isolate* isolate,
1206 Handle<Object> object, 1206 Handle<Object> object,
1207 uint32_t index); 1207 uint32_t index);
1208 1208
1209 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithReceiver(
1210 Isolate* isolate,
1211 Handle<Object> object,
1212 Handle<Object> receiver,
1213 uint32_t index);
1214
1215 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithReceiver( 1209 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithReceiver(
1216 Isolate* isolate, Handle<Object> object, Handle<Object> receiver, 1210 Isolate* isolate, Handle<Object> object, Handle<Object> receiver,
1217 uint32_t index, Handle<Object> value, LanguageMode language_mode); 1211 uint32_t index, Handle<Object> value, LanguageMode language_mode);
1218 1212
1219 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes( 1213 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes(
1220 Isolate* isolate, Handle<Object> receiver); 1214 Isolate* isolate, Handle<Object> receiver);
1221 1215
1222 // Returns the permanent hash code associated with this object. May return 1216 // Returns the permanent hash code associated with this object. May return
1223 // undefined if not yet created. 1217 // undefined if not yet created.
1224 Object* GetHash(); 1218 Object* GetHash();
1225 1219
1226 // Returns the permanent hash code associated with this object depending on 1220 // Returns the permanent hash code associated with this object depending on
1227 // the actual object type. May create and store a hash code if needed and none 1221 // the actual object type. May create and store a hash code if needed and none
1228 // exists. 1222 // exists.
1229 static Handle<Smi> GetOrCreateHash(Isolate* isolate, Handle<Object> object); 1223 static Handle<Smi> GetOrCreateHash(Isolate* isolate, Handle<Object> object);
1230 1224
1231 // Checks whether this object has the same value as the given one. This 1225 // Checks whether this object has the same value as the given one. This
1232 // function is implemented according to ES5, section 9.12 and can be used 1226 // function is implemented according to ES5, section 9.12 and can be used
1233 // to implement the Harmony "egal" function. 1227 // to implement the Harmony "egal" function.
1234 bool SameValue(Object* other); 1228 bool SameValue(Object* other);
1235 1229
1236 // Checks whether this object has the same value as the given one. 1230 // Checks whether this object has the same value as the given one.
1237 // +0 and -0 are treated equal. Everything else is the same as SameValue. 1231 // +0 and -0 are treated equal. Everything else is the same as SameValue.
1238 // This function is implemented according to ES6, section 7.2.4 and is used 1232 // This function is implemented according to ES6, section 7.2.4 and is used
1239 // by ES6 Map and Set. 1233 // by ES6 Map and Set.
1240 bool SameValueZero(Object* other); 1234 bool SameValueZero(Object* other);
1241 1235
1242 // Tries to convert an object to an array index. Returns true and sets 1236 // Tries to convert an object to an array length. Returns true and sets the
1243 // the output parameter if it succeeds. 1237 // output parameter if it succeeds.
1238 inline bool ToArrayLength(uint32_t* index);
1239
1240 // Tries to convert an object to an array index. Returns true and sets the
1241 // output parameter if it succeeds. Equivalent to ToArrayLength, but does not
1242 // allow kMaxUInt32.
1244 inline bool ToArrayIndex(uint32_t* index); 1243 inline bool ToArrayIndex(uint32_t* index);
1245 1244
1246 // Returns true if this is a JSValue containing a string and the index is 1245 // Returns true if this is a JSValue containing a string and the index is
1247 // < the length of the string. Used to implement [] on strings. 1246 // < the length of the string. Used to implement [] on strings.
1248 inline bool IsStringObjectWithCharacterAt(uint32_t index); 1247 inline bool IsStringObjectWithCharacterAt(uint32_t index);
1249 1248
1250 DECLARE_VERIFIER(Object) 1249 DECLARE_VERIFIER(Object)
1251 #ifdef VERIFY_HEAP 1250 #ifdef VERIFY_HEAP
1252 // Verify a pointer is a valid object pointer. 1251 // Verify a pointer is a valid object pointer.
1253 static void VerifyPointer(Object* p); 1252 static void VerifyPointer(Object* p);
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 MUST_USE_RESULT static MaybeHandle<Object> SetOwnElement( 1979 MUST_USE_RESULT static MaybeHandle<Object> SetOwnElement(
1981 Handle<JSObject> object, uint32_t index, Handle<Object> value, 1980 Handle<JSObject> object, uint32_t index, Handle<Object> value,
1982 PropertyAttributes attributes, LanguageMode language_mode); 1981 PropertyAttributes attributes, LanguageMode language_mode);
1983 1982
1984 // Empty handle is returned if the element cannot be set to the given value. 1983 // Empty handle is returned if the element cannot be set to the given value.
1985 MUST_USE_RESULT static MaybeHandle<Object> SetElement( 1984 MUST_USE_RESULT static MaybeHandle<Object> SetElement(
1986 Handle<JSObject> object, uint32_t index, Handle<Object> value, 1985 Handle<JSObject> object, uint32_t index, Handle<Object> value,
1987 PropertyAttributes attributes, LanguageMode language_mode, 1986 PropertyAttributes attributes, LanguageMode language_mode,
1988 bool check_prototype = true, SetPropertyMode set_mode = SET_PROPERTY); 1987 bool check_prototype = true, SetPropertyMode set_mode = SET_PROPERTY);
1989 1988
1990 // Returns the index'th element.
1991 // The undefined object if index is out of bounds.
1992 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithInterceptor(
1993 Handle<JSObject> object, Handle<Object> receiver, uint32_t index,
1994 bool check_prototype);
1995
1996 enum SetFastElementsCapacitySmiMode { 1989 enum SetFastElementsCapacitySmiMode {
1997 kAllowSmiElements, 1990 kAllowSmiElements,
1998 kForceSmiElements, 1991 kForceSmiElements,
1999 kDontAllowSmiElements 1992 kDontAllowSmiElements
2000 }; 1993 };
2001 1994
2002 static Handle<FixedArray> SetFastElementsCapacity( 1995 static Handle<FixedArray> SetFastElementsCapacity(
2003 Handle<JSObject> object, int capacity, 1996 Handle<JSObject> object, int capacity,
2004 SetFastElementsCapacitySmiMode smi_mode); 1997 SetFastElementsCapacitySmiMode smi_mode);
2005 static Handle<FixedArrayBase> SetFastDoubleElementsCapacity( 1998 static Handle<FixedArrayBase> SetFastDoubleElementsCapacity(
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 Handle<Map> new_map, 2274 Handle<Map> new_map,
2282 int expected_additional_properties); 2275 int expected_additional_properties);
2283 2276
2284 static void UpdateAllocationSite(Handle<JSObject> object, 2277 static void UpdateAllocationSite(Handle<JSObject> object,
2285 ElementsKind to_kind); 2278 ElementsKind to_kind);
2286 2279
2287 // Used from Object::GetProperty(). 2280 // Used from Object::GetProperty().
2288 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithFailedAccessCheck( 2281 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithFailedAccessCheck(
2289 LookupIterator* it); 2282 LookupIterator* it);
2290 2283
2291 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithCallback(
2292 Handle<JSObject> object,
2293 Handle<Object> receiver,
2294 Handle<Object> structure,
2295 uint32_t index,
2296 Handle<Object> holder);
2297
2298 MUST_USE_RESULT static Maybe<PropertyAttributes> 2284 MUST_USE_RESULT static Maybe<PropertyAttributes>
2299 GetElementAttributeWithInterceptor(Handle<JSObject> object, 2285 GetElementAttributeWithInterceptor(Handle<JSObject> object,
2300 Handle<JSReceiver> receiver, 2286 Handle<JSReceiver> receiver,
2301 uint32_t index, bool continue_search); 2287 uint32_t index, bool continue_search);
2302 2288
2303 // Queries indexed interceptor on an object for property attributes. 2289 // Queries indexed interceptor on an object for property attributes.
2304 // 2290 //
2305 // We determine property attributes as follows: 2291 // We determine property attributes as follows:
2306 // - if interceptor has a query callback, then the property attributes are 2292 // - if interceptor has a query callback, then the property attributes are
2307 // the result of query callback for index. 2293 // the result of query callback for index.
(...skipping 28 matching lines...) Expand all
2336 static MaybeHandle<Object> SetElementWithCallbackSetterInPrototypes( 2322 static MaybeHandle<Object> SetElementWithCallbackSetterInPrototypes(
2337 Handle<JSObject> object, uint32_t index, Handle<Object> value, 2323 Handle<JSObject> object, uint32_t index, Handle<Object> value,
2338 bool* found, LanguageMode language_mode); 2324 bool* found, LanguageMode language_mode);
2339 MUST_USE_RESULT static MaybeHandle<Object> SetDictionaryElement( 2325 MUST_USE_RESULT static MaybeHandle<Object> SetDictionaryElement(
2340 Handle<JSObject> object, uint32_t index, Handle<Object> value, 2326 Handle<JSObject> object, uint32_t index, Handle<Object> value,
2341 PropertyAttributes attributes, LanguageMode language_mode, 2327 PropertyAttributes attributes, LanguageMode language_mode,
2342 bool check_prototype, SetPropertyMode set_mode = SET_PROPERTY); 2328 bool check_prototype, SetPropertyMode set_mode = SET_PROPERTY);
2343 MUST_USE_RESULT static MaybeHandle<Object> SetFastDoubleElement( 2329 MUST_USE_RESULT static MaybeHandle<Object> SetFastDoubleElement(
2344 Handle<JSObject> object, uint32_t index, Handle<Object> value, 2330 Handle<JSObject> object, uint32_t index, Handle<Object> value,
2345 LanguageMode language_mode, bool check_prototype = true); 2331 LanguageMode language_mode, bool check_prototype = true);
2346 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithFailedAccessCheck(
2347 Isolate* isolate, Handle<JSObject> object, Handle<Object> receiver,
2348 uint32_t index);
2349 MUST_USE_RESULT static Maybe<PropertyAttributes> 2332 MUST_USE_RESULT static Maybe<PropertyAttributes>
2350 GetElementAttributesWithFailedAccessCheck(Isolate* isolate, 2333 GetElementAttributesWithFailedAccessCheck(Isolate* isolate,
2351 Handle<JSObject> object, 2334 Handle<JSObject> object,
2352 Handle<Object> receiver, 2335 Handle<Object> receiver,
2353 uint32_t index); 2336 uint32_t index);
2354 2337
2355 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck( 2338 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck(
2356 LookupIterator* it, Handle<Object> value, LanguageMode language_mode); 2339 LookupIterator* it, Handle<Object> value, LanguageMode language_mode);
2357 2340
2358 // Add a property to a slow-case object. 2341 // Add a property to a slow-case object.
(...skipping 7599 matching lines...) Expand 10 before | Expand all | Expand 10 after
9958 9941
9959 // [hash]: The hash code property (undefined if not initialized yet). 9942 // [hash]: The hash code property (undefined if not initialized yet).
9960 DECL_ACCESSORS(hash, Object) 9943 DECL_ACCESSORS(hash, Object)
9961 9944
9962 DECLARE_CAST(JSProxy) 9945 DECLARE_CAST(JSProxy)
9963 9946
9964 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( 9947 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler(
9965 Handle<JSProxy> proxy, 9948 Handle<JSProxy> proxy,
9966 Handle<Object> receiver, 9949 Handle<Object> receiver,
9967 Handle<Name> name); 9950 Handle<Name> name);
9968 MUST_USE_RESULT static inline MaybeHandle<Object> GetElementWithHandler(
9969 Handle<JSProxy> proxy,
9970 Handle<Object> receiver,
9971 uint32_t index);
9972 9951
9973 // If the handler defines an accessor property with a setter, invoke it. 9952 // If the handler defines an accessor property with a setter, invoke it.
9974 // If it defines an accessor property without a setter, or a data property 9953 // If it defines an accessor property without a setter, or a data property
9975 // that is read-only, throw. In all these cases set '*done' to true, 9954 // that is read-only, throw. In all these cases set '*done' to true,
9976 // otherwise set it to false. 9955 // otherwise set it to false.
9977 MUST_USE_RESULT 9956 MUST_USE_RESULT
9978 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler( 9957 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler(
9979 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, 9958 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
9980 Handle<Object> value, LanguageMode language_mode, bool* done); 9959 Handle<Object> value, LanguageMode language_mode, bool* done);
9981 9960
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
10355 #endif 10334 #endif
10356 10335
10357 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBufferView); 10336 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBufferView);
10358 }; 10337 };
10359 10338
10360 10339
10361 class JSTypedArray: public JSArrayBufferView { 10340 class JSTypedArray: public JSArrayBufferView {
10362 public: 10341 public:
10363 // [length]: length of typed array in elements. 10342 // [length]: length of typed array in elements.
10364 DECL_ACCESSORS(length, Object) 10343 DECL_ACCESSORS(length, Object)
10344 inline uint32_t length_value() const;
10365 10345
10366 DECLARE_CAST(JSTypedArray) 10346 DECLARE_CAST(JSTypedArray)
10367 10347
10368 ExternalArrayType type(); 10348 ExternalArrayType type();
10369 size_t element_size(); 10349 size_t element_size();
10370 10350
10371 Handle<JSArrayBuffer> GetBuffer(); 10351 Handle<JSArrayBuffer> GetBuffer();
10372 10352
10373 // Dispatched behavior. 10353 // Dispatched behavior.
10374 DECLARE_PRINTER(JSTypedArray) 10354 DECLARE_PRINTER(JSTypedArray)
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
11146 } else { 11126 } else {
11147 value &= ~(1 << bit_position); 11127 value &= ~(1 << bit_position);
11148 } 11128 }
11149 return value; 11129 return value;
11150 } 11130 }
11151 }; 11131 };
11152 11132
11153 } } // namespace v8::internal 11133 } } // namespace v8::internal
11154 11134
11155 #endif // V8_OBJECTS_H_ 11135 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698