| 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) \ | 1005 V(Undefined, undefined_value) \ |
| 1006 V(Null) \ | 1006 V(Null, null_value) \ |
| 1007 V(TheHole) \ | 1007 V(TheHole, the_hole_value) \ |
| 1008 V(Exception) \ | 1008 V(Exception, exception) \ |
| 1009 V(Uninitialized) \ | 1009 V(Uninitialized, uninitialized_value) \ |
| 1010 V(True) \ | 1010 V(True, true_value) \ |
| 1011 V(False) \ | 1011 V(False, false_value) \ |
| 1012 V(ArgumentsMarker) \ | 1012 V(ArgumentsMarker, arguments_marker) \ |
| 1013 V(OptimizedOut) \ | 1013 V(OptimizedOut, optimized_out) \ |
| 1014 V(StaleRegister) | 1014 V(StaleRegister, stale_register) |
| 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); |
| 1033 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) | 1036 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) |
| 1034 #undef IS_TYPE_FUNCTION_DECL | 1037 #undef IS_TYPE_FUNCTION_DECL |
| 1035 | 1038 |
| 1036 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas | 1039 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas |
| 1037 // a keyed store is of the form a[expression] = foo. | 1040 // a keyed store is of the form a[expression] = foo. |
| 1038 enum StoreFromKeyed { | 1041 enum StoreFromKeyed { |
| 1039 MAY_BE_STORE_FROM_KEYED, | 1042 MAY_BE_STORE_FROM_KEYED, |
| 1040 CERTAINLY_NOT_STORE_FROM_KEYED | 1043 CERTAINLY_NOT_STORE_FROM_KEYED |
| 1041 }; | 1044 }; |
| 1042 | 1045 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1057 if ((call).IsNothing()) return value; \ | 1060 if ((call).IsNothing()) return value; \ |
| 1058 } while (false) | 1061 } while (false) |
| 1059 | 1062 |
| 1060 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>()) | 1063 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>()) |
| 1061 | 1064 |
| 1062 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ | 1065 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ |
| 1063 INLINE(bool Is##Name() const); | 1066 INLINE(bool Is##Name() const); |
| 1064 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 1067 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
| 1065 #undef DECLARE_STRUCT_PREDICATE | 1068 #undef DECLARE_STRUCT_PREDICATE |
| 1066 | 1069 |
| 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 // TODO(cbruni): clean up once isolate-based versions are in place. | 1552 #define IS_TYPE_FUNCTION_DECL(Type) INLINE(bool Is##Type() const); |
| 1553 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); | |
| 1554 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) | 1553 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); |
| 1555 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) | 1558 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) |
| 1556 #undef IS_TYPE_FUNCTION_DECL | 1559 #undef IS_TYPE_FUNCTION_DECL |
| 1560 |
| 1557 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ | 1561 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ |
| 1558 INLINE(bool Is##Name() const); | 1562 INLINE(bool Is##Name() const); |
| 1559 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 1563 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
| 1560 #undef DECLARE_STRUCT_PREDICATE | 1564 #undef DECLARE_STRUCT_PREDICATE |
| 1561 | 1565 |
| 1562 INLINE(bool IsTheHole(Isolate* isolate) const); | |
| 1563 INLINE(bool IsUndefined(Isolate* isolate) const); | |
| 1564 | |
| 1565 // Converts an address to a HeapObject pointer. | 1566 // Converts an address to a HeapObject pointer. |
| 1566 static inline HeapObject* FromAddress(Address address) { | 1567 static inline HeapObject* FromAddress(Address address) { |
| 1567 DCHECK_TAG_ALIGNED(address); | 1568 DCHECK_TAG_ALIGNED(address); |
| 1568 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); | 1569 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); |
| 1569 } | 1570 } |
| 1570 | 1571 |
| 1571 // Returns the address of this HeapObject. | 1572 // Returns the address of this HeapObject. |
| 1572 inline Address address() { | 1573 inline Address address() { |
| 1573 return reinterpret_cast<Address>(this) - kHeapObjectTag; | 1574 return reinterpret_cast<Address>(this) - kHeapObjectTag; |
| 1574 } | 1575 } |
| (...skipping 9223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10798 } | 10799 } |
| 10799 return value; | 10800 return value; |
| 10800 } | 10801 } |
| 10801 }; | 10802 }; |
| 10802 | 10803 |
| 10803 | 10804 |
| 10804 } // NOLINT, false-positive due to second-order macros. | 10805 } // NOLINT, false-positive due to second-order macros. |
| 10805 } // NOLINT, false-positive due to second-order macros. | 10806 } // NOLINT, false-positive due to second-order macros. |
| 10806 | 10807 |
| 10807 #endif // V8_OBJECTS_H_ | 10808 #endif // V8_OBJECTS_H_ |
| OLD | NEW |