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

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: Addressed comments Created 5 years, 6 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
« no previous file with comments | « src/lookup-inl.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter( 1207 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter(
1208 Handle<Object> receiver, 1208 Handle<Object> receiver,
1209 Handle<JSReceiver> setter, 1209 Handle<JSReceiver> setter,
1210 Handle<Object> value); 1210 Handle<Object> value);
1211 1211
1212 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement( 1212 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement(
1213 Isolate* isolate, 1213 Isolate* isolate,
1214 Handle<Object> object, 1214 Handle<Object> object,
1215 uint32_t index); 1215 uint32_t index);
1216 1216
1217 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithReceiver(
1218 Isolate* isolate,
1219 Handle<Object> object,
1220 Handle<Object> receiver,
1221 uint32_t index);
1222
1223 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithReceiver( 1217 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithReceiver(
1224 Isolate* isolate, Handle<Object> object, Handle<Object> receiver, 1218 Isolate* isolate, Handle<Object> object, Handle<Object> receiver,
1225 uint32_t index, Handle<Object> value, LanguageMode language_mode); 1219 uint32_t index, Handle<Object> value, LanguageMode language_mode);
1226 1220
1227 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes( 1221 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes(
1228 Isolate* isolate, Handle<Object> receiver); 1222 Isolate* isolate, Handle<Object> receiver);
1229 1223
1230 // Returns the permanent hash code associated with this object. May return 1224 // Returns the permanent hash code associated with this object. May return
1231 // undefined if not yet created. 1225 // undefined if not yet created.
1232 Object* GetHash(); 1226 Object* GetHash();
(...skipping 12 matching lines...) Expand all
1245 // function is implemented according to ES5, section 9.12 and can be used 1239 // function is implemented according to ES5, section 9.12 and can be used
1246 // to implement the Harmony "egal" function. 1240 // to implement the Harmony "egal" function.
1247 bool SameValue(Object* other); 1241 bool SameValue(Object* other);
1248 1242
1249 // Checks whether this object has the same value as the given one. 1243 // Checks whether this object has the same value as the given one.
1250 // +0 and -0 are treated equal. Everything else is the same as SameValue. 1244 // +0 and -0 are treated equal. Everything else is the same as SameValue.
1251 // This function is implemented according to ES6, section 7.2.4 and is used 1245 // This function is implemented according to ES6, section 7.2.4 and is used
1252 // by ES6 Map and Set. 1246 // by ES6 Map and Set.
1253 bool SameValueZero(Object* other); 1247 bool SameValueZero(Object* other);
1254 1248
1255 // Tries to convert an object to an array index. Returns true and sets 1249 // Tries to convert an object to an array length. Returns true and sets the
1256 // the output parameter if it succeeds. 1250 // output parameter if it succeeds.
1251 inline bool ToArrayLength(uint32_t* index);
1252
1253 // Tries to convert an object to an array index. Returns true and sets the
1254 // output parameter if it succeeds. Equivalent to ToArrayLength, but does not
1255 // allow kMaxUInt32.
1257 inline bool ToArrayIndex(uint32_t* index); 1256 inline bool ToArrayIndex(uint32_t* index);
1258 1257
1259 // Returns true if this is a JSValue containing a string and the index is 1258 // Returns true if this is a JSValue containing a string and the index is
1260 // < the length of the string. Used to implement [] on strings. 1259 // < the length of the string. Used to implement [] on strings.
1261 inline bool IsStringObjectWithCharacterAt(uint32_t index); 1260 inline bool IsStringObjectWithCharacterAt(uint32_t index);
1262 1261
1263 DECLARE_VERIFIER(Object) 1262 DECLARE_VERIFIER(Object)
1264 #ifdef VERIFY_HEAP 1263 #ifdef VERIFY_HEAP
1265 // Verify a pointer is a valid object pointer. 1264 // Verify a pointer is a valid object pointer.
1266 static void VerifyPointer(Object* p); 1265 static void VerifyPointer(Object* p);
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 MUST_USE_RESULT static MaybeHandle<Object> SetOwnElement( 1995 MUST_USE_RESULT static MaybeHandle<Object> SetOwnElement(
1997 Handle<JSObject> object, uint32_t index, Handle<Object> value, 1996 Handle<JSObject> object, uint32_t index, Handle<Object> value,
1998 PropertyAttributes attributes, LanguageMode language_mode); 1997 PropertyAttributes attributes, LanguageMode language_mode);
1999 1998
2000 // Empty handle is returned if the element cannot be set to the given value. 1999 // Empty handle is returned if the element cannot be set to the given value.
2001 MUST_USE_RESULT static MaybeHandle<Object> SetElement( 2000 MUST_USE_RESULT static MaybeHandle<Object> SetElement(
2002 Handle<JSObject> object, uint32_t index, Handle<Object> value, 2001 Handle<JSObject> object, uint32_t index, Handle<Object> value,
2003 PropertyAttributes attributes, LanguageMode language_mode, 2002 PropertyAttributes attributes, LanguageMode language_mode,
2004 bool check_prototype = true, SetPropertyMode set_mode = SET_PROPERTY); 2003 bool check_prototype = true, SetPropertyMode set_mode = SET_PROPERTY);
2005 2004
2006 // Returns the index'th element.
2007 // The undefined object if index is out of bounds.
2008 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithInterceptor(
2009 Handle<JSObject> object, Handle<Object> receiver, uint32_t index,
2010 bool check_prototype);
2011
2012 enum SetFastElementsCapacitySmiMode { 2005 enum SetFastElementsCapacitySmiMode {
2013 kAllowSmiElements, 2006 kAllowSmiElements,
2014 kForceSmiElements, 2007 kForceSmiElements,
2015 kDontAllowSmiElements 2008 kDontAllowSmiElements
2016 }; 2009 };
2017 2010
2018 static Handle<FixedArray> SetFastElementsCapacity( 2011 static Handle<FixedArray> SetFastElementsCapacity(
2019 Handle<JSObject> object, int capacity, 2012 Handle<JSObject> object, int capacity,
2020 SetFastElementsCapacitySmiMode smi_mode); 2013 SetFastElementsCapacitySmiMode smi_mode);
2021 static Handle<FixedArrayBase> SetFastDoubleElementsCapacity( 2014 static Handle<FixedArrayBase> SetFastDoubleElementsCapacity(
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
2299 Handle<Map> new_map, 2292 Handle<Map> new_map,
2300 int expected_additional_properties); 2293 int expected_additional_properties);
2301 2294
2302 static void UpdateAllocationSite(Handle<JSObject> object, 2295 static void UpdateAllocationSite(Handle<JSObject> object,
2303 ElementsKind to_kind); 2296 ElementsKind to_kind);
2304 2297
2305 // Used from Object::GetProperty(). 2298 // Used from Object::GetProperty().
2306 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithFailedAccessCheck( 2299 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithFailedAccessCheck(
2307 LookupIterator* it); 2300 LookupIterator* it);
2308 2301
2309 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithCallback(
2310 Handle<JSObject> object,
2311 Handle<Object> receiver,
2312 Handle<Object> structure,
2313 uint32_t index,
2314 Handle<Object> holder);
2315
2316 MUST_USE_RESULT static Maybe<PropertyAttributes> 2302 MUST_USE_RESULT static Maybe<PropertyAttributes>
2317 GetElementAttributeWithInterceptor(Handle<JSObject> object, 2303 GetElementAttributeWithInterceptor(Handle<JSObject> object,
2318 Handle<JSReceiver> receiver, 2304 Handle<JSReceiver> receiver,
2319 uint32_t index, bool continue_search); 2305 uint32_t index, bool continue_search);
2320 2306
2321 // Queries indexed interceptor on an object for property attributes. 2307 // Queries indexed interceptor on an object for property attributes.
2322 // 2308 //
2323 // We determine property attributes as follows: 2309 // We determine property attributes as follows:
2324 // - if interceptor has a query callback, then the property attributes are 2310 // - if interceptor has a query callback, then the property attributes are
2325 // the result of query callback for index. 2311 // the result of query callback for index.
(...skipping 28 matching lines...) Expand all
2354 static MaybeHandle<Object> SetElementWithCallbackSetterInPrototypes( 2340 static MaybeHandle<Object> SetElementWithCallbackSetterInPrototypes(
2355 Handle<JSObject> object, uint32_t index, Handle<Object> value, 2341 Handle<JSObject> object, uint32_t index, Handle<Object> value,
2356 bool* found, LanguageMode language_mode); 2342 bool* found, LanguageMode language_mode);
2357 MUST_USE_RESULT static MaybeHandle<Object> SetDictionaryElement( 2343 MUST_USE_RESULT static MaybeHandle<Object> SetDictionaryElement(
2358 Handle<JSObject> object, uint32_t index, Handle<Object> value, 2344 Handle<JSObject> object, uint32_t index, Handle<Object> value,
2359 PropertyAttributes attributes, LanguageMode language_mode, 2345 PropertyAttributes attributes, LanguageMode language_mode,
2360 bool check_prototype, SetPropertyMode set_mode = SET_PROPERTY); 2346 bool check_prototype, SetPropertyMode set_mode = SET_PROPERTY);
2361 MUST_USE_RESULT static MaybeHandle<Object> SetFastDoubleElement( 2347 MUST_USE_RESULT static MaybeHandle<Object> SetFastDoubleElement(
2362 Handle<JSObject> object, uint32_t index, Handle<Object> value, 2348 Handle<JSObject> object, uint32_t index, Handle<Object> value,
2363 LanguageMode language_mode, bool check_prototype = true); 2349 LanguageMode language_mode, bool check_prototype = true);
2364 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithFailedAccessCheck(
2365 Isolate* isolate, Handle<JSObject> object, Handle<Object> receiver,
2366 uint32_t index);
2367 MUST_USE_RESULT static Maybe<PropertyAttributes> 2350 MUST_USE_RESULT static Maybe<PropertyAttributes>
2368 GetElementAttributesWithFailedAccessCheck(Isolate* isolate, 2351 GetElementAttributesWithFailedAccessCheck(Isolate* isolate,
2369 Handle<JSObject> object, 2352 Handle<JSObject> object,
2370 Handle<Object> receiver, 2353 Handle<Object> receiver,
2371 uint32_t index); 2354 uint32_t index);
2372 2355
2373 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck( 2356 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck(
2374 LookupIterator* it, Handle<Object> value, LanguageMode language_mode); 2357 LookupIterator* it, Handle<Object> value, LanguageMode language_mode);
2375 2358
2376 // Add a property to a slow-case object. 2359 // Add a property to a slow-case object.
(...skipping 7597 matching lines...) Expand 10 before | Expand all | Expand 10 after
9974 9957
9975 // [hash]: The hash code property (undefined if not initialized yet). 9958 // [hash]: The hash code property (undefined if not initialized yet).
9976 DECL_ACCESSORS(hash, Object) 9959 DECL_ACCESSORS(hash, Object)
9977 9960
9978 DECLARE_CAST(JSProxy) 9961 DECLARE_CAST(JSProxy)
9979 9962
9980 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( 9963 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler(
9981 Handle<JSProxy> proxy, 9964 Handle<JSProxy> proxy,
9982 Handle<Object> receiver, 9965 Handle<Object> receiver,
9983 Handle<Name> name); 9966 Handle<Name> name);
9984 MUST_USE_RESULT static inline MaybeHandle<Object> GetElementWithHandler(
9985 Handle<JSProxy> proxy,
9986 Handle<Object> receiver,
9987 uint32_t index);
9988 9967
9989 // If the handler defines an accessor property with a setter, invoke it. 9968 // If the handler defines an accessor property with a setter, invoke it.
9990 // If it defines an accessor property without a setter, or a data property 9969 // If it defines an accessor property without a setter, or a data property
9991 // that is read-only, throw. In all these cases set '*done' to true, 9970 // that is read-only, throw. In all these cases set '*done' to true,
9992 // otherwise set it to false. 9971 // otherwise set it to false.
9993 MUST_USE_RESULT 9972 MUST_USE_RESULT
9994 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler( 9973 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler(
9995 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, 9974 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
9996 Handle<Object> value, LanguageMode language_mode, bool* done); 9975 Handle<Object> value, LanguageMode language_mode, bool* done);
9997 9976
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
10379 #endif 10358 #endif
10380 10359
10381 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBufferView); 10360 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBufferView);
10382 }; 10361 };
10383 10362
10384 10363
10385 class JSTypedArray: public JSArrayBufferView { 10364 class JSTypedArray: public JSArrayBufferView {
10386 public: 10365 public:
10387 // [length]: length of typed array in elements. 10366 // [length]: length of typed array in elements.
10388 DECL_ACCESSORS(length, Object) 10367 DECL_ACCESSORS(length, Object)
10368 inline uint32_t length_value() const;
10389 10369
10390 DECLARE_CAST(JSTypedArray) 10370 DECLARE_CAST(JSTypedArray)
10391 10371
10392 ExternalArrayType type(); 10372 ExternalArrayType type();
10393 size_t element_size(); 10373 size_t element_size();
10394 10374
10395 Handle<JSArrayBuffer> GetBuffer(); 10375 Handle<JSArrayBuffer> GetBuffer();
10396 10376
10397 // Dispatched behavior. 10377 // Dispatched behavior.
10398 DECLARE_PRINTER(JSTypedArray) 10378 DECLARE_PRINTER(JSTypedArray)
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
11170 } else { 11150 } else {
11171 value &= ~(1 << bit_position); 11151 value &= ~(1 << bit_position);
11172 } 11152 }
11173 return value; 11153 return value;
11174 } 11154 }
11175 }; 11155 };
11176 11156
11177 } } // namespace v8::internal 11157 } } // namespace v8::internal
11178 11158
11179 #endif // V8_OBJECTS_H_ 11159 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/lookup-inl.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698