OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 ShouldThrow should_throw); | 1295 ShouldThrow should_throw); |
1296 | 1296 |
1297 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement( | 1297 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement( |
1298 Isolate* isolate, Handle<Object> object, uint32_t index, | 1298 Isolate* isolate, Handle<Object> object, uint32_t index, |
1299 LanguageMode language_mode = SLOPPY); | 1299 LanguageMode language_mode = SLOPPY); |
1300 | 1300 |
1301 MUST_USE_RESULT static inline MaybeHandle<Object> SetElement( | 1301 MUST_USE_RESULT static inline MaybeHandle<Object> SetElement( |
1302 Isolate* isolate, Handle<Object> object, uint32_t index, | 1302 Isolate* isolate, Handle<Object> object, uint32_t index, |
1303 Handle<Object> value, LanguageMode language_mode); | 1303 Handle<Object> value, LanguageMode language_mode); |
1304 | 1304 |
1305 // Get the first non-hidden prototype. | |
1306 static inline MaybeHandle<Object> GetPrototype(Isolate* isolate, | |
1307 Handle<Object> receiver); | |
1308 | |
1309 MUST_USE_RESULT static Maybe<bool> HasInPrototypeChain(Isolate* isolate, | |
1310 Handle<Object> object, | |
1311 Handle<Object> proto); | |
1312 | |
1313 // Returns the permanent hash code associated with this object. May return | 1305 // Returns the permanent hash code associated with this object. May return |
1314 // undefined if not yet created. | 1306 // undefined if not yet created. |
1315 Object* GetHash(); | 1307 Object* GetHash(); |
1316 | 1308 |
1317 // Returns undefined for JSObjects, but returns the hash code for simple | 1309 // Returns undefined for JSObjects, but returns the hash code for simple |
1318 // objects. This avoids a double lookup in the cases where we know we will | 1310 // objects. This avoids a double lookup in the cases where we know we will |
1319 // add the hash to the JSObject if it does not already exist. | 1311 // add the hash to the JSObject if it does not already exist. |
1320 Object* GetSimpleHash(); | 1312 Object* GetSimpleHash(); |
1321 | 1313 |
1322 // Returns the permanent hash code associated with this object depending on | 1314 // Returns the permanent hash code associated with this object depending on |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 | 1371 |
1380 // Prints this object with details. | 1372 // Prints this object with details. |
1381 void Print(std::ostream& os); // NOLINT | 1373 void Print(std::ostream& os); // NOLINT |
1382 #else | 1374 #else |
1383 void Print() { ShortPrint(); } | 1375 void Print() { ShortPrint(); } |
1384 void Print(std::ostream& os) { ShortPrint(os); } // NOLINT | 1376 void Print(std::ostream& os) { ShortPrint(os); } // NOLINT |
1385 #endif | 1377 #endif |
1386 | 1378 |
1387 private: | 1379 private: |
1388 friend class LookupIterator; | 1380 friend class LookupIterator; |
1389 friend class PrototypeIterator; | 1381 friend class StringStream; |
1390 | 1382 |
1391 // Return the map of the root of object's prototype chain. | 1383 // Return the map of the root of object's prototype chain. |
1392 Map* GetRootMap(Isolate* isolate); | 1384 Map* GetRootMap(Isolate* isolate); |
1393 | 1385 |
1394 // Helper for SetProperty and SetSuperProperty. | 1386 // Helper for SetProperty and SetSuperProperty. |
1395 // Return value is only meaningful if [found] is set to true on return. | 1387 // Return value is only meaningful if [found] is set to true on return. |
1396 MUST_USE_RESULT static Maybe<bool> SetPropertyInternal( | 1388 MUST_USE_RESULT static Maybe<bool> SetPropertyInternal( |
1397 LookupIterator* it, Handle<Object> value, LanguageMode language_mode, | 1389 LookupIterator* it, Handle<Object> value, LanguageMode language_mode, |
1398 StoreFromKeyed store_mode, bool* found); | 1390 StoreFromKeyed store_mode, bool* found); |
1399 | 1391 |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 | 1797 |
1806 // ES6 section 7.1.1 ToPrimitive | 1798 // ES6 section 7.1.1 ToPrimitive |
1807 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive( | 1799 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive( |
1808 Handle<JSReceiver> receiver, | 1800 Handle<JSReceiver> receiver, |
1809 ToPrimitiveHint hint = ToPrimitiveHint::kDefault); | 1801 ToPrimitiveHint hint = ToPrimitiveHint::kDefault); |
1810 MUST_USE_RESULT static MaybeHandle<Object> OrdinaryToPrimitive( | 1802 MUST_USE_RESULT static MaybeHandle<Object> OrdinaryToPrimitive( |
1811 Handle<JSReceiver> receiver, OrdinaryToPrimitiveHint hint); | 1803 Handle<JSReceiver> receiver, OrdinaryToPrimitiveHint hint); |
1812 | 1804 |
1813 static MaybeHandle<Context> GetFunctionRealm(Handle<JSReceiver> receiver); | 1805 static MaybeHandle<Context> GetFunctionRealm(Handle<JSReceiver> receiver); |
1814 | 1806 |
| 1807 // Get the first non-hidden prototype. |
| 1808 static inline MaybeHandle<Object> GetPrototype(Isolate* isolate, |
| 1809 Handle<JSReceiver> receiver); |
| 1810 |
| 1811 MUST_USE_RESULT static Maybe<bool> HasInPrototypeChain( |
| 1812 Isolate* isolate, Handle<JSReceiver> object, Handle<Object> proto); |
| 1813 |
1815 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. | 1814 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. |
1816 MUST_USE_RESULT static Maybe<bool> HasProperty(LookupIterator* it); | 1815 MUST_USE_RESULT static Maybe<bool> HasProperty(LookupIterator* it); |
1817 MUST_USE_RESULT static inline Maybe<bool> HasProperty( | 1816 MUST_USE_RESULT static inline Maybe<bool> HasProperty( |
1818 Handle<JSReceiver> object, Handle<Name> name); | 1817 Handle<JSReceiver> object, Handle<Name> name); |
1819 MUST_USE_RESULT static inline Maybe<bool> HasElement( | 1818 MUST_USE_RESULT static inline Maybe<bool> HasElement( |
1820 Handle<JSReceiver> object, uint32_t index); | 1819 Handle<JSReceiver> object, uint32_t index); |
1821 | 1820 |
1822 MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty( | 1821 MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty( |
1823 Handle<JSReceiver> object, Handle<Name> name); | 1822 Handle<JSReceiver> object, Handle<Name> name); |
1824 | 1823 |
(...skipping 3730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5555 inline uint32_t bit_field3() const; | 5554 inline uint32_t bit_field3() const; |
5556 inline void set_bit_field3(uint32_t bits); | 5555 inline void set_bit_field3(uint32_t bits); |
5557 | 5556 |
5558 class EnumLengthBits: public BitField<int, | 5557 class EnumLengthBits: public BitField<int, |
5559 0, kDescriptorIndexBitCount> {}; // NOLINT | 5558 0, kDescriptorIndexBitCount> {}; // NOLINT |
5560 class NumberOfOwnDescriptorsBits: public BitField<int, | 5559 class NumberOfOwnDescriptorsBits: public BitField<int, |
5561 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT | 5560 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT |
5562 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); | 5561 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); |
5563 class DictionaryMap : public BitField<bool, 20, 1> {}; | 5562 class DictionaryMap : public BitField<bool, 20, 1> {}; |
5564 class OwnsDescriptors : public BitField<bool, 21, 1> {}; | 5563 class OwnsDescriptors : public BitField<bool, 21, 1> {}; |
5565 class IsHiddenPrototype : public BitField<bool, 22, 1> {}; | 5564 class HasHiddenPrototype : public BitField<bool, 22, 1> {}; |
5566 class Deprecated : public BitField<bool, 23, 1> {}; | 5565 class Deprecated : public BitField<bool, 23, 1> {}; |
5567 class IsUnstable : public BitField<bool, 24, 1> {}; | 5566 class IsUnstable : public BitField<bool, 24, 1> {}; |
5568 class IsMigrationTarget : public BitField<bool, 25, 1> {}; | 5567 class IsMigrationTarget : public BitField<bool, 25, 1> {}; |
5569 class IsStrong : public BitField<bool, 26, 1> {}; | 5568 class IsStrong : public BitField<bool, 26, 1> {}; |
5570 class NewTargetIsBase : public BitField<bool, 27, 1> {}; | 5569 class NewTargetIsBase : public BitField<bool, 27, 1> {}; |
5571 // Bit 28 is free. | 5570 // Bit 28 is free. |
5572 | 5571 |
5573 // Keep this bit field at the very end for better code in | 5572 // Keep this bit field at the very end for better code in |
5574 // Builtins::kJSConstructStubGeneric stub. | 5573 // Builtins::kJSConstructStubGeneric stub. |
5575 // This counter is used for in-object slack tracking. | 5574 // This counter is used for in-object slack tracking. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5634 // property will not be used to create instances of the function. | 5633 // property will not be used to create instances of the function. |
5635 // See ECMA-262, 13.2.2. | 5634 // See ECMA-262, 13.2.2. |
5636 inline void set_non_instance_prototype(bool value); | 5635 inline void set_non_instance_prototype(bool value); |
5637 inline bool has_non_instance_prototype(); | 5636 inline bool has_non_instance_prototype(); |
5638 | 5637 |
5639 // Tells whether the instance has a [[Construct]] internal method. | 5638 // Tells whether the instance has a [[Construct]] internal method. |
5640 // This property is implemented according to ES6, section 7.2.4. | 5639 // This property is implemented according to ES6, section 7.2.4. |
5641 inline void set_is_constructor(bool value); | 5640 inline void set_is_constructor(bool value); |
5642 inline bool is_constructor() const; | 5641 inline bool is_constructor() const; |
5643 | 5642 |
5644 // Tells whether the instance with this map should be ignored by the | 5643 // Tells whether the instance with this map has a hidden prototype. |
5645 // Object.getPrototypeOf() function and the __proto__ accessor. | 5644 inline void set_has_hidden_prototype(bool value); |
5646 inline void set_is_hidden_prototype(); | 5645 inline bool has_hidden_prototype() const; |
5647 inline bool is_hidden_prototype() const; | |
5648 | 5646 |
5649 // Records and queries whether the instance has a named interceptor. | 5647 // Records and queries whether the instance has a named interceptor. |
5650 inline void set_has_named_interceptor(); | 5648 inline void set_has_named_interceptor(); |
5651 inline bool has_named_interceptor(); | 5649 inline bool has_named_interceptor(); |
5652 | 5650 |
5653 // Records and queries whether the instance has an indexed interceptor. | 5651 // Records and queries whether the instance has an indexed interceptor. |
5654 inline void set_has_indexed_interceptor(); | 5652 inline void set_has_indexed_interceptor(); |
5655 inline bool has_indexed_interceptor(); | 5653 inline bool has_indexed_interceptor(); |
5656 | 5654 |
5657 // Tells whether the instance is undetectable. | 5655 // Tells whether the instance is undetectable. |
(...skipping 5136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10794 } | 10792 } |
10795 return value; | 10793 return value; |
10796 } | 10794 } |
10797 }; | 10795 }; |
10798 | 10796 |
10799 | 10797 |
10800 } // NOLINT, false-positive due to second-order macros. | 10798 } // NOLINT, false-positive due to second-order macros. |
10801 } // NOLINT, false-positive due to second-order macros. | 10799 } // NOLINT, false-positive due to second-order macros. |
10802 | 10800 |
10803 #endif // V8_OBJECTS_H_ | 10801 #endif // V8_OBJECTS_H_ |
OLD | NEW |