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

Side by Side Diff: src/objects.h

Issue 1394983005: Restructure Object::SetProperty and related functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Redo again, now using ShouldThrow argument. Created 5 years, 2 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 | « no previous file | src/objects.cc » ('j') | src/objects.cc » ('J')
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 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 class Object { 1018 class Object {
1019 public: 1019 public:
1020 // Type testing. 1020 // Type testing.
1021 bool IsObject() const { return true; } 1021 bool IsObject() const { return true; }
1022 1022
1023 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); 1023 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const);
1024 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 1024 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
1025 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 1025 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
1026 #undef IS_TYPE_FUNCTION_DECL 1026 #undef IS_TYPE_FUNCTION_DECL
1027 1027
1028 enum ShouldThrow { THROW_ON_ERROR, DONT_THROW };
1029
1028 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas 1030 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas
1029 // a keyed store is of the form a[expression] = foo. 1031 // a keyed store is of the form a[expression] = foo.
1030 enum StoreFromKeyed { 1032 enum StoreFromKeyed {
1031 MAY_BE_STORE_FROM_KEYED, 1033 MAY_BE_STORE_FROM_KEYED,
1032 CERTAINLY_NOT_STORE_FROM_KEYED 1034 CERTAINLY_NOT_STORE_FROM_KEYED
1033 }; 1035 };
1034 1036
1035 INLINE(bool IsFixedArrayBase() const); 1037 INLINE(bool IsFixedArrayBase() const);
1036 INLINE(bool IsExternal() const); 1038 INLINE(bool IsExternal() const);
1037 INLINE(bool IsAccessorInfo() const); 1039 INLINE(bool IsAccessorInfo() const);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 MUST_USE_RESULT static MaybeHandle<Object> BitwiseOr( 1211 MUST_USE_RESULT static MaybeHandle<Object> BitwiseOr(
1210 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, 1212 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs,
1211 Strength strength = Strength::WEAK); 1213 Strength strength = Strength::WEAK);
1212 MUST_USE_RESULT static MaybeHandle<Object> BitwiseXor( 1214 MUST_USE_RESULT static MaybeHandle<Object> BitwiseXor(
1213 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, 1215 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs,
1214 Strength strength = Strength::WEAK); 1216 Strength strength = Strength::WEAK);
1215 1217
1216 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( 1218 MUST_USE_RESULT static MaybeHandle<Object> GetProperty(
1217 LookupIterator* it, LanguageMode language_mode = SLOPPY); 1219 LookupIterator* it, LanguageMode language_mode = SLOPPY);
1218 1220
1219 // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5. 1221
1222 // ES6 [[Set]] (when passed DONT_THROW)
1223 // Invariants for this and related functions (unless stated otherwise):
1224 // 1) When the result is Nothing, an exception is pending.
1225 // 2) When passed THROW_ON_ERROR, the result is never Just(false).
1226 // In some cases, an exception is thrown regardless of the ShouldThrow
1227 // argument. These cases are either in accordance with the spec or not
1228 // covered by it (eg., concerning API callbacks).
1229 MUST_USE_RESULT static Maybe<bool> SetProperty(LookupIterator* it,
1230 Handle<Object> value,
1231 LanguageMode language_mode,
1232 ShouldThrow should_throw,
1233 StoreFromKeyed store_mode);
1220 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( 1234 MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
1221 Handle<Object> object, Handle<Name> name, Handle<Object> value, 1235 Handle<Object> object, Handle<Name> name, Handle<Object> value,
1222 LanguageMode language_mode, 1236 LanguageMode language_mode,
1223 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); 1237 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
1224
1225 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( 1238 MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
1226 LookupIterator* it, Handle<Object> value, LanguageMode language_mode, 1239 LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
1227 StoreFromKeyed store_mode); 1240 StoreFromKeyed store_mode);
1228 1241
1229 MUST_USE_RESULT static MaybeHandle<Object> SetSuperProperty( 1242 MUST_USE_RESULT static MaybeHandle<Object> SetSuperProperty(
1230 LookupIterator* it, Handle<Object> value, LanguageMode language_mode, 1243 LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
1231 StoreFromKeyed store_mode); 1244 StoreFromKeyed store_mode);
1232 1245
1233 MUST_USE_RESULT static MaybeHandle<Object> ReadAbsentProperty( 1246 MUST_USE_RESULT static MaybeHandle<Object> ReadAbsentProperty(
1234 LookupIterator* it, LanguageMode language_mode); 1247 LookupIterator* it, LanguageMode language_mode);
1235 MUST_USE_RESULT static MaybeHandle<Object> ReadAbsentProperty( 1248 MUST_USE_RESULT static MaybeHandle<Object> ReadAbsentProperty(
1236 Isolate* isolate, Handle<Object> receiver, Handle<Object> name, 1249 Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
1237 LanguageMode language_mode); 1250 LanguageMode language_mode);
1238 MUST_USE_RESULT static MaybeHandle<Object> CannotCreateProperty( 1251 MUST_USE_RESULT static Maybe<bool> CannotCreateProperty(
1239 LookupIterator* it, Handle<Object> value, LanguageMode language_mode);
1240 MUST_USE_RESULT static MaybeHandle<Object> CannotCreateProperty(
1241 Isolate* isolate, Handle<Object> receiver, Handle<Object> name, 1252 Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
1242 Handle<Object> value, LanguageMode language_mode); 1253 Handle<Object> value, LanguageMode language_mode,
1243 MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyProperty( 1254 ShouldThrow should_throw);
1244 LookupIterator* it, Handle<Object> value, LanguageMode language_mode); 1255 MUST_USE_RESULT static Maybe<bool> WriteToReadOnlyProperty(
1245 MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyProperty( 1256 LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
1257 ShouldThrow should_throw);
1258 MUST_USE_RESULT static Maybe<bool> WriteToReadOnlyProperty(
1246 Isolate* isolate, Handle<Object> receiver, Handle<Object> name, 1259 Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
1247 Handle<Object> value, LanguageMode language_mode); 1260 Handle<Object> value, LanguageMode language_mode,
1261 ShouldThrow should_throw);
1248 MUST_USE_RESULT static MaybeHandle<Object> RedefineNonconfigurableProperty( 1262 MUST_USE_RESULT static MaybeHandle<Object> RedefineNonconfigurableProperty(
1249 Isolate* isolate, Handle<Object> name, Handle<Object> value, 1263 Isolate* isolate, Handle<Object> name, Handle<Object> value,
1250 LanguageMode language_mode); 1264 LanguageMode language_mode);
1251 MUST_USE_RESULT static MaybeHandle<Object> SetDataProperty( 1265 MUST_USE_RESULT static Maybe<bool> SetDataProperty(LookupIterator* it,
1252 LookupIterator* it, Handle<Object> value); 1266 Handle<Object> value,
1267 ShouldThrow should_throw);
1253 MUST_USE_RESULT static MaybeHandle<Object> AddDataProperty( 1268 MUST_USE_RESULT static MaybeHandle<Object> AddDataProperty(
1254 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes, 1269 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
1255 LanguageMode language_mode, StoreFromKeyed store_mode); 1270 LanguageMode language_mode, StoreFromKeyed store_mode);
1271 MUST_USE_RESULT static Maybe<bool> AddDataProperty(
1272 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
1273 LanguageMode language_mode, ShouldThrow should_throw,
1274 StoreFromKeyed store_mode);
1256 MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement( 1275 MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
1257 Handle<Object> object, Handle<Name> name, 1276 Handle<Object> object, Handle<Name> name,
1258 LanguageMode language_mode = SLOPPY); 1277 LanguageMode language_mode = SLOPPY);
1259 MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement( 1278 MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
1260 Handle<JSReceiver> holder, Handle<Name> name, Handle<Object> receiver, 1279 Handle<JSReceiver> holder, Handle<Name> name, Handle<Object> receiver,
1261 LanguageMode language_mode = SLOPPY); 1280 LanguageMode language_mode = SLOPPY);
1262 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( 1281 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
1263 Isolate* isolate, Handle<Object> object, const char* key, 1282 Isolate* isolate, Handle<Object> object, const char* key,
1264 LanguageMode language_mode = SLOPPY); 1283 LanguageMode language_mode = SLOPPY);
1265 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( 1284 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
1266 Handle<Object> object, Handle<Name> name, 1285 Handle<Object> object, Handle<Name> name,
1267 LanguageMode language_mode = SLOPPY); 1286 LanguageMode language_mode = SLOPPY);
1268 1287
1269 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithAccessor( 1288 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithAccessor(
1270 LookupIterator* it, LanguageMode language_mode); 1289 LookupIterator* it, LanguageMode language_mode);
1271 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithAccessor( 1290 MUST_USE_RESULT static Maybe<bool> SetPropertyWithAccessor(
1272 LookupIterator* it, Handle<Object> value, LanguageMode language_mode); 1291 LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
1292 ShouldThrow should_throw);
1273 1293
1274 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter( 1294 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter(
1275 Handle<Object> receiver, 1295 Handle<Object> receiver,
1276 Handle<JSReceiver> getter); 1296 Handle<JSReceiver> getter);
1277 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter( 1297 MUST_USE_RESULT static Maybe<bool> SetPropertyWithDefinedSetter(
1278 Handle<Object> receiver, 1298 Handle<Object> receiver, Handle<JSReceiver> setter, Handle<Object> value,
1279 Handle<JSReceiver> setter, 1299 ShouldThrow should_throw);
1280 Handle<Object> value);
1281 1300
1282 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement( 1301 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement(
1283 Isolate* isolate, Handle<Object> object, uint32_t index, 1302 Isolate* isolate, Handle<Object> object, uint32_t index,
1284 LanguageMode language_mode = SLOPPY); 1303 LanguageMode language_mode = SLOPPY);
1285 1304
1286 MUST_USE_RESULT static inline MaybeHandle<Object> SetElement( 1305 MUST_USE_RESULT static inline MaybeHandle<Object> SetElement(
1287 Isolate* isolate, Handle<Object> object, uint32_t index, 1306 Isolate* isolate, Handle<Object> object, uint32_t index,
1288 Handle<Object> value, LanguageMode language_mode); 1307 Handle<Object> value, LanguageMode language_mode);
1289 1308
1290 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes( 1309 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 #endif 1382 #endif
1364 1383
1365 private: 1384 private:
1366 friend class LookupIterator; 1385 friend class LookupIterator;
1367 friend class PrototypeIterator; 1386 friend class PrototypeIterator;
1368 1387
1369 // Return the map of the root of object's prototype chain. 1388 // Return the map of the root of object's prototype chain.
1370 Map* GetRootMap(Isolate* isolate); 1389 Map* GetRootMap(Isolate* isolate);
1371 1390
1372 // Helper for SetProperty and SetSuperProperty. 1391 // Helper for SetProperty and SetSuperProperty.
1373 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyInternal( 1392 // Return value is only meaningful if [found] is set to true on return.
1393 MUST_USE_RESULT static Maybe<bool> SetPropertyInternal(
1374 LookupIterator* it, Handle<Object> value, LanguageMode language_mode, 1394 LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
1375 StoreFromKeyed store_mode, bool* found); 1395 ShouldThrow should_throw, StoreFromKeyed store_mode, bool* found);
1376 1396
1377 DISALLOW_IMPLICIT_CONSTRUCTORS(Object); 1397 DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
1378 }; 1398 };
1379 1399
1380 1400
1381 // In objects.h to be usable without objects-inl.h inclusion. 1401 // In objects.h to be usable without objects-inl.h inclusion.
1382 bool Object::IsSmi() const { return HAS_SMI_TAG(this); } 1402 bool Object::IsSmi() const { return HAS_SMI_TAG(this); }
1383 bool Object::IsHeapObject() const { return Internals::HasHeapObjectTag(this); } 1403 bool Object::IsHeapObject() const { return Internals::HasHeapObjectTag(this); }
1384 1404
1385 1405
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 // Indicator for one component of an AccessorPair. 1804 // Indicator for one component of an AccessorPair.
1785 enum AccessorComponent { 1805 enum AccessorComponent {
1786 ACCESSOR_GETTER, 1806 ACCESSOR_GETTER,
1787 ACCESSOR_SETTER 1807 ACCESSOR_SETTER
1788 }; 1808 };
1789 1809
1790 1810
1791 enum KeyFilter { SKIP_SYMBOLS, INCLUDE_SYMBOLS }; 1811 enum KeyFilter { SKIP_SYMBOLS, INCLUDE_SYMBOLS };
1792 1812
1793 1813
1794 enum ShouldThrow { THROW_ON_ERROR, DONT_THROW };
1795
1796
1797 // JSReceiver includes types on which properties can be defined, i.e., 1814 // JSReceiver includes types on which properties can be defined, i.e.,
1798 // JSObject and JSProxy. 1815 // JSObject and JSProxy.
1799 class JSReceiver: public HeapObject { 1816 class JSReceiver: public HeapObject {
1800 public: 1817 public:
1801 DECLARE_CAST(JSReceiver) 1818 DECLARE_CAST(JSReceiver)
1802 1819
1803 // ES6 section 7.1.1 ToPrimitive 1820 // ES6 section 7.1.1 ToPrimitive
1804 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive( 1821 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive(
1805 Handle<JSReceiver> receiver, 1822 Handle<JSReceiver> receiver,
1806 ToPrimitiveHint hint = ToPrimitiveHint::kDefault); 1823 ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 // Undefined values are placed after non-undefined values. 2012 // Undefined values are placed after non-undefined values.
1996 // Returns the number of non-undefined values. 2013 // Returns the number of non-undefined values.
1997 static Handle<Object> PrepareElementsForSort(Handle<JSObject> object, 2014 static Handle<Object> PrepareElementsForSort(Handle<JSObject> object,
1998 uint32_t limit); 2015 uint32_t limit);
1999 // As PrepareElementsForSort, but only on objects where elements is 2016 // As PrepareElementsForSort, but only on objects where elements is
2000 // a dictionary, and it will stay a dictionary. Collates undefined and 2017 // a dictionary, and it will stay a dictionary. Collates undefined and
2001 // unexisting elements below limit from position zero of the elements. 2018 // unexisting elements below limit from position zero of the elements.
2002 static Handle<Object> PrepareSlowElementsForSort(Handle<JSObject> object, 2019 static Handle<Object> PrepareSlowElementsForSort(Handle<JSObject> object,
2003 uint32_t limit); 2020 uint32_t limit);
2004 2021
2005 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithInterceptor( 2022 // Beware: This may return Nothing even if there is no pending exception.
rossberg 2015/10/14 15:59:06 In what cases?
neis 2015/10/21 14:42:25 I actually changed the code now such that it behav
2006 LookupIterator* it, Handle<Object> value); 2023 MUST_USE_RESULT static Maybe<bool> SetPropertyWithInterceptor(
2024 LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
2007 2025
2008 // SetLocalPropertyIgnoreAttributes converts callbacks to fields. We need to 2026 // SetLocalPropertyIgnoreAttributes converts callbacks to fields. We need to
2009 // grant an exemption to ExecutableAccessor callbacks in some cases. 2027 // grant an exemption to ExecutableAccessor callbacks in some cases.
2010 enum ExecutableAccessorInfoHandling { DEFAULT_HANDLING, DONT_FORCE_FIELD }; 2028 enum ExecutableAccessorInfoHandling { DEFAULT_HANDLING, DONT_FORCE_FIELD };
2011 2029
2012 MUST_USE_RESULT static MaybeHandle<Object> DefineOwnPropertyIgnoreAttributes( 2030 MUST_USE_RESULT static MaybeHandle<Object> DefineOwnPropertyIgnoreAttributes(
2013 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes, 2031 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
2014 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); 2032 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
2015 2033
2016 MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes( 2034 MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes(
(...skipping 15 matching lines...) Expand all
2032 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); 2050 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
2033 2051
2034 // Adds or reconfigures a property to attributes NONE. It will fail when it 2052 // Adds or reconfigures a property to attributes NONE. It will fail when it
2035 // cannot. 2053 // cannot.
2036 MUST_USE_RESULT static Maybe<bool> CreateDataProperty(LookupIterator* it, 2054 MUST_USE_RESULT static Maybe<bool> CreateDataProperty(LookupIterator* it,
2037 Handle<Object> value); 2055 Handle<Object> value);
2038 2056
2039 static void AddProperty(Handle<JSObject> object, Handle<Name> name, 2057 static void AddProperty(Handle<JSObject> object, Handle<Name> name,
2040 Handle<Object> value, PropertyAttributes attributes); 2058 Handle<Object> value, PropertyAttributes attributes);
2041 2059
2060 MUST_USE_RESULT static Maybe<bool> AddDataElement(
2061 Handle<JSObject> receiver, uint32_t index, Handle<Object> value,
2062 PropertyAttributes attributes, ShouldThrow should_throw);
2042 MUST_USE_RESULT static MaybeHandle<Object> AddDataElement( 2063 MUST_USE_RESULT static MaybeHandle<Object> AddDataElement(
2043 Handle<JSObject> receiver, uint32_t index, Handle<Object> value, 2064 Handle<JSObject> receiver, uint32_t index, Handle<Object> value,
2044 PropertyAttributes attributes); 2065 PropertyAttributes attributes);
2045 2066
2046 // Extend the receiver with a single fast property appeared first in the 2067 // Extend the receiver with a single fast property appeared first in the
2047 // passed map. This also extends the property backing store if necessary. 2068 // passed map. This also extends the property backing store if necessary.
2048 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); 2069 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map);
2049 2070
2050 // Migrates the given object to a map whose field representations are the 2071 // Migrates the given object to a map whose field representations are the
2051 // lowest upper bound of all known representations for that field. 2072 // lowest upper bound of all known representations for that field.
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 // Note: this call does not update write barrier, the caller is responsible 2329 // Note: this call does not update write barrier, the caller is responsible
2309 // to ensure that |filler_value| can be collected without WB here. 2330 // to ensure that |filler_value| can be collected without WB here.
2310 inline void InitializeBody(Map* map, 2331 inline void InitializeBody(Map* map,
2311 Object* pre_allocated_value, 2332 Object* pre_allocated_value,
2312 Object* filler_value); 2333 Object* filler_value);
2313 2334
2314 // Check whether this object references another object 2335 // Check whether this object references another object
2315 bool ReferencesObject(Object* obj); 2336 bool ReferencesObject(Object* obj);
2316 2337
2317 // Disallow further properties to be added to the oject. 2338 // Disallow further properties to be added to the oject.
2339 // TODO(neis): Use ShouldThrow to be consistent with SetProperty et al.
2318 MUST_USE_RESULT static Maybe<bool> PreventExtensionsInternal( 2340 MUST_USE_RESULT static Maybe<bool> PreventExtensionsInternal(
2319 Handle<JSObject> object); // ES [[PreventExtensions]] 2341 Handle<JSObject> object); // ES [[PreventExtensions]]
2320 MUST_USE_RESULT static MaybeHandle<Object> PreventExtensions( 2342 MUST_USE_RESULT static MaybeHandle<Object> PreventExtensions(
2321 Handle<JSObject> object); // ES Object.preventExtensions 2343 Handle<JSObject> object); // ES Object.preventExtensions
2322 2344
2323 static bool IsExtensible(Handle<JSObject> object); 2345 static bool IsExtensible(Handle<JSObject> object);
2324 2346
2325 // ES5 Object.seal 2347 // ES5 Object.seal
2326 MUST_USE_RESULT static MaybeHandle<Object> Seal(Handle<JSObject> object); 2348 MUST_USE_RESULT static MaybeHandle<Object> Seal(Handle<JSObject> object);
2327 2349
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 2480
2459 static void MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map); 2481 static void MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map);
2460 static void MigrateFastToSlow(Handle<JSObject> object, 2482 static void MigrateFastToSlow(Handle<JSObject> object,
2461 Handle<Map> new_map, 2483 Handle<Map> new_map,
2462 int expected_additional_properties); 2484 int expected_additional_properties);
2463 2485
2464 // Used from Object::GetProperty(). 2486 // Used from Object::GetProperty().
2465 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithFailedAccessCheck( 2487 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithFailedAccessCheck(
2466 LookupIterator* it); 2488 LookupIterator* it);
2467 2489
2468 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck( 2490 MUST_USE_RESULT static Maybe<bool> SetPropertyWithFailedAccessCheck(
2469 LookupIterator* it, Handle<Object> value); 2491 LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
2470 2492
2471 // Add a property to a slow-case object. 2493 // Add a property to a slow-case object.
2472 static void AddSlowProperty(Handle<JSObject> object, 2494 static void AddSlowProperty(Handle<JSObject> object,
2473 Handle<Name> name, 2495 Handle<Name> name,
2474 Handle<Object> value, 2496 Handle<Object> value,
2475 PropertyAttributes attributes); 2497 PropertyAttributes attributes);
2476 2498
2477 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithInterceptor( 2499 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithInterceptor(
2478 LookupIterator* it); 2500 LookupIterator* it);
2479 2501
(...skipping 7014 matching lines...) Expand 10 before | Expand all | Expand 10 after
9494 9516
9495 DECLARE_CAST(JSProxy) 9517 DECLARE_CAST(JSProxy)
9496 9518
9497 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( 9519 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler(
9498 Handle<JSProxy> proxy, 9520 Handle<JSProxy> proxy,
9499 Handle<Object> receiver, 9521 Handle<Object> receiver,
9500 Handle<Name> name); 9522 Handle<Name> name);
9501 9523
9502 // If the handler defines an accessor property with a setter, invoke it. 9524 // If the handler defines an accessor property with a setter, invoke it.
9503 // If it defines an accessor property without a setter, or a data property 9525 // If it defines an accessor property without a setter, or a data property
9504 // that is read-only, throw. In all these cases set '*done' to true, 9526 // that is read-only, fail. In all these cases set '*done' to true.
9505 // otherwise set it to false. 9527 // Otherwise set it to false, in which case the return value is not
9528 // meaningful.
9506 MUST_USE_RESULT 9529 MUST_USE_RESULT
9507 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler( 9530 static Maybe<bool> SetPropertyViaPrototypesWithHandler(
9508 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, 9531 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
9509 Handle<Object> value, LanguageMode language_mode, bool* done); 9532 Handle<Object> value, LanguageMode language_mode,
9533 ShouldThrow should_throw, bool* done);
9510 9534
9511 MUST_USE_RESULT static Maybe<PropertyAttributes> 9535 MUST_USE_RESULT static Maybe<PropertyAttributes>
9512 GetPropertyAttributesWithHandler(Handle<JSProxy> proxy, 9536 GetPropertyAttributesWithHandler(Handle<JSProxy> proxy,
9513 Handle<Object> receiver, 9537 Handle<Object> receiver,
9514 Handle<Name> name); 9538 Handle<Name> name);
9515 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithHandler( 9539 MUST_USE_RESULT static Maybe<bool> SetPropertyWithHandler(
9516 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, 9540 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
9517 Handle<Object> value, LanguageMode language_mode); 9541 Handle<Object> value, LanguageMode language_mode,
9542 ShouldThrow should_throw);
9518 9543
9519 // Turn the proxy into an (empty) JSObject. 9544 // Turn the proxy into an (empty) JSObject.
9520 static void Fix(Handle<JSProxy> proxy); 9545 static void Fix(Handle<JSProxy> proxy);
9521 9546
9522 // Initializes the body after the handler slot. 9547 // Initializes the body after the handler slot.
9523 inline void InitializeBody(int object_size, Object* value); 9548 inline void InitializeBody(int object_size, Object* value);
9524 9549
9525 // Invoke a trap by name. If the trap does not exist on this's handler, 9550 // Invoke a trap by name. If the trap does not exist on this's handler,
9526 // but derived_trap is non-NULL, invoke that instead. May cause GC. 9551 // but derived_trap is non-NULL, invoke that instead. May cause GC.
9527 MUST_USE_RESULT static MaybeHandle<Object> CallTrap( 9552 MUST_USE_RESULT static MaybeHandle<Object> CallTrap(
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
10041 public: 10066 public:
10042 // [length]: The length property. 10067 // [length]: The length property.
10043 DECL_ACCESSORS(length, Object) 10068 DECL_ACCESSORS(length, Object)
10044 10069
10045 // Overload the length setter to skip write barrier when the length 10070 // Overload the length setter to skip write barrier when the length
10046 // is set to a smi. This matches the set function on FixedArray. 10071 // is set to a smi. This matches the set function on FixedArray.
10047 inline void set_length(Smi* length); 10072 inline void set_length(Smi* length);
10048 10073
10049 static bool HasReadOnlyLength(Handle<JSArray> array); 10074 static bool HasReadOnlyLength(Handle<JSArray> array);
10050 static bool WouldChangeReadOnlyLength(Handle<JSArray> array, uint32_t index); 10075 static bool WouldChangeReadOnlyLength(Handle<JSArray> array, uint32_t index);
10051 static MaybeHandle<Object> ReadOnlyLengthError(Handle<JSArray> array);
10052 10076
10053 // Initialize the array with the given capacity. The function may 10077 // Initialize the array with the given capacity. The function may
10054 // fail due to out-of-memory situations, but only if the requested 10078 // fail due to out-of-memory situations, but only if the requested
10055 // capacity is non-zero. 10079 // capacity is non-zero.
10056 static void Initialize(Handle<JSArray> array, int capacity, int length = 0); 10080 static void Initialize(Handle<JSArray> array, int capacity, int length = 0);
10057 10081
10058 // If the JSArray has fast elements, and new_length would result in 10082 // If the JSArray has fast elements, and new_length would result in
10059 // normalization, returns true. 10083 // normalization, returns true.
10060 bool SetLengthWouldNormalize(uint32_t new_length); 10084 bool SetLengthWouldNormalize(uint32_t new_length);
10061 static inline bool SetLengthWouldNormalize(Heap* heap, uint32_t new_length); 10085 static inline bool SetLengthWouldNormalize(Heap* heap, uint32_t new_length);
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
10725 Handle<FixedArray> keys_; 10749 Handle<FixedArray> keys_;
10726 Handle<OrderedHashSet> set_; 10750 Handle<OrderedHashSet> set_;
10727 int length_; 10751 int length_;
10728 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); 10752 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator);
10729 }; 10753 };
10730 10754
10731 } // NOLINT, false-positive due to second-order macros. 10755 } // NOLINT, false-positive due to second-order macros.
10732 } // NOLINT, false-positive due to second-order macros. 10756 } // NOLINT, false-positive due to second-order macros.
10733 10757
10734 #endif // V8_OBJECTS_H_ 10758 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698