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/assert-scope.h" | 10 #include "src/assert-scope.h" |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 V(FixedArrayBase) \ | 994 V(FixedArrayBase) \ |
995 V(External) \ | 995 V(External) \ |
996 V(Struct) \ | 996 V(Struct) \ |
997 V(Cell) \ | 997 V(Cell) \ |
998 V(PropertyCell) \ | 998 V(PropertyCell) \ |
999 V(WeakCell) \ | 999 V(WeakCell) \ |
1000 V(ObjectHashTable) \ | 1000 V(ObjectHashTable) \ |
1001 V(WeakHashTable) \ | 1001 V(WeakHashTable) \ |
1002 V(OrderedHashTable) | 1002 V(OrderedHashTable) |
1003 | 1003 |
1004 #define ODDBALL_LIST(V) \ | 1004 #define ODDBALL_LIST(V) \ |
1005 V(Undefined, undefined_value) \ | 1005 V(Undefined) \ |
1006 V(Null, null_value) \ | 1006 V(Null) \ |
1007 V(TheHole, the_hole_value) \ | 1007 V(TheHole) \ |
1008 V(Exception, exception) \ | 1008 V(Exception) \ |
1009 V(Uninitialized, uninitialized_value) \ | 1009 V(Uninitialized) \ |
1010 V(True, true_value) \ | 1010 V(True) \ |
1011 V(False, false_value) \ | 1011 V(False) \ |
1012 V(ArgumentsMarker, arguments_marker) \ | 1012 V(ArgumentsMarker) \ |
1013 V(OptimizedOut, optimized_out) \ | 1013 V(OptimizedOut) \ |
1014 V(StaleRegister, stale_register) | 1014 V(StaleRegister) |
1015 | 1015 |
1016 // The element types selection for CreateListFromArrayLike. | 1016 // The element types selection for CreateListFromArrayLike. |
1017 enum class ElementTypes { kAll, kStringAndSymbol }; | 1017 enum class ElementTypes { kAll, kStringAndSymbol }; |
1018 | 1018 |
1019 // Object is the abstract superclass for all classes in the | 1019 // Object is the abstract superclass for all classes in the |
1020 // object hierarchy. | 1020 // object hierarchy. |
1021 // Object does not use any virtual functions to avoid the | 1021 // Object does not use any virtual functions to avoid the |
1022 // allocation of the C++ vtable. | 1022 // allocation of the C++ vtable. |
1023 // Since both Smi and HeapObject are subclasses of Object no | 1023 // Since both Smi and HeapObject are subclasses of Object no |
1024 // data members can be present in Object. | 1024 // data members can be present in Object. |
1025 class Object { | 1025 class Object { |
1026 public: | 1026 public: |
1027 // Type testing. | 1027 // Type testing. |
1028 bool IsObject() const { return true; } | 1028 bool IsObject() const { return true; } |
1029 | 1029 |
1030 #define IS_TYPE_FUNCTION_DECL(Type) INLINE(bool Is##Type() const); | 1030 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); |
1031 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) | 1031 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) |
1032 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) | 1032 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) |
1033 #undef IS_TYPE_FUNCTION_DECL | |
1034 #define IS_TYPE_FUNCTION_DECL(Type, Value) \ | |
1035 INLINE(bool Is##Type(Isolate* isolate) const); | |
1036 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) | 1033 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) |
1037 #undef IS_TYPE_FUNCTION_DECL | 1034 #undef IS_TYPE_FUNCTION_DECL |
1038 | 1035 |
1039 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas | 1036 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas |
1040 // a keyed store is of the form a[expression] = foo. | 1037 // a keyed store is of the form a[expression] = foo. |
1041 enum StoreFromKeyed { | 1038 enum StoreFromKeyed { |
1042 MAY_BE_STORE_FROM_KEYED, | 1039 MAY_BE_STORE_FROM_KEYED, |
1043 CERTAINLY_NOT_STORE_FROM_KEYED | 1040 CERTAINLY_NOT_STORE_FROM_KEYED |
1044 }; | 1041 }; |
1045 | 1042 |
(...skipping 14 matching lines...) Expand all Loading... |
1060 if ((call).IsNothing()) return value; \ | 1057 if ((call).IsNothing()) return value; \ |
1061 } while (false) | 1058 } while (false) |
1062 | 1059 |
1063 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>()) | 1060 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>()) |
1064 | 1061 |
1065 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ | 1062 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ |
1066 INLINE(bool Is##Name() const); | 1063 INLINE(bool Is##Name() const); |
1067 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 1064 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
1068 #undef DECLARE_STRUCT_PREDICATE | 1065 #undef DECLARE_STRUCT_PREDICATE |
1069 | 1066 |
| 1067 INLINE(bool IsTheHole(Isolate* isolate) const); |
| 1068 INLINE(bool IsUndefined(Isolate* isolate) const); |
| 1069 |
1070 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray. | 1070 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray. |
1071 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object); | 1071 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object); |
1072 | 1072 |
1073 INLINE(bool IsNameDictionary() const); | 1073 INLINE(bool IsNameDictionary() const); |
1074 INLINE(bool IsGlobalDictionary() const); | 1074 INLINE(bool IsGlobalDictionary() const); |
1075 INLINE(bool IsSeededNumberDictionary() const); | 1075 INLINE(bool IsSeededNumberDictionary() const); |
1076 INLINE(bool IsUnseededNumberDictionary() const); | 1076 INLINE(bool IsUnseededNumberDictionary() const); |
1077 INLINE(bool IsOrderedHashSet() const); | 1077 INLINE(bool IsOrderedHashSet() const); |
1078 INLINE(bool IsOrderedHashMap() const); | 1078 INLINE(bool IsOrderedHashMap() const); |
1079 static bool IsPromise(Handle<Object> object); | 1079 static bool IsPromise(Handle<Object> object); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 // necessarily contain a map pointer. | 1542 // necessarily contain a map pointer. |
1543 inline MapWord map_word() const; | 1543 inline MapWord map_word() const; |
1544 inline void set_map_word(MapWord map_word); | 1544 inline void set_map_word(MapWord map_word); |
1545 | 1545 |
1546 // The Heap the object was allocated in. Used also to access Isolate. | 1546 // The Heap the object was allocated in. Used also to access Isolate. |
1547 inline Heap* GetHeap() const; | 1547 inline Heap* GetHeap() const; |
1548 | 1548 |
1549 // Convenience method to get current isolate. | 1549 // Convenience method to get current isolate. |
1550 inline Isolate* GetIsolate() const; | 1550 inline Isolate* GetIsolate() const; |
1551 | 1551 |
1552 #define IS_TYPE_FUNCTION_DECL(Type) INLINE(bool Is##Type() const); | 1552 // TODO(cbruni): clean up once isolate-based versions are in place. |
| 1553 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); |
1553 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) | 1554 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) |
1554 #undef IS_TYPE_FUNCTION_DECL | |
1555 | |
1556 #define IS_TYPE_FUNCTION_DECL(Type, Value) \ | |
1557 INLINE(bool Is##Type(Isolate* isolate) const); | |
1558 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) | 1555 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) |
1559 #undef IS_TYPE_FUNCTION_DECL | 1556 #undef IS_TYPE_FUNCTION_DECL |
1560 | |
1561 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ | 1557 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ |
1562 INLINE(bool Is##Name() const); | 1558 INLINE(bool Is##Name() const); |
1563 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 1559 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
1564 #undef DECLARE_STRUCT_PREDICATE | 1560 #undef DECLARE_STRUCT_PREDICATE |
1565 | 1561 |
| 1562 INLINE(bool IsTheHole(Isolate* isolate) const); |
| 1563 INLINE(bool IsUndefined(Isolate* isolate) const); |
| 1564 |
1566 // Converts an address to a HeapObject pointer. | 1565 // Converts an address to a HeapObject pointer. |
1567 static inline HeapObject* FromAddress(Address address) { | 1566 static inline HeapObject* FromAddress(Address address) { |
1568 DCHECK_TAG_ALIGNED(address); | 1567 DCHECK_TAG_ALIGNED(address); |
1569 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); | 1568 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); |
1570 } | 1569 } |
1571 | 1570 |
1572 // Returns the address of this HeapObject. | 1571 // Returns the address of this HeapObject. |
1573 inline Address address() { | 1572 inline Address address() { |
1574 return reinterpret_cast<Address>(this) - kHeapObjectTag; | 1573 return reinterpret_cast<Address>(this) - kHeapObjectTag; |
1575 } | 1574 } |
(...skipping 9223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10799 } | 10798 } |
10800 return value; | 10799 return value; |
10801 } | 10800 } |
10802 }; | 10801 }; |
10803 | 10802 |
10804 | 10803 |
10805 } // NOLINT, false-positive due to second-order macros. | 10804 } // NOLINT, false-positive due to second-order macros. |
10806 } // NOLINT, false-positive due to second-order macros. | 10805 } // NOLINT, false-positive due to second-order macros. |
10807 | 10806 |
10808 #endif // V8_OBJECTS_H_ | 10807 #endif // V8_OBJECTS_H_ |
OLD | NEW |