5 #ifndef V8_OBJECTS_MAYBE_OBJECT_H_ 6 #define V8_OBJECTS_MAYBE_OBJECT_H_ 8 #include "include/v8-internal.h" 9 #include "include/v8.h" 10 #include "src/globals.h" 11 #include "src/objects.h" 12 #include "src/objects/slots.h" 13 #include "src/objects/smi.h" 30 bool operator==(
const MaybeObject& other)
const {
return ptr_ == other.ptr_; }
31 bool operator!=(
const MaybeObject& other)
const {
return ptr_ != other.ptr_; }
33 Address ptr()
const {
return ptr_; }
37 const MaybeObject* operator->()
const {
return this; }
39 bool IsSmi()
const {
return HAS_SMI_TAG(ptr_); }
40 inline bool ToSmi(
Smi* value);
41 inline Smi ToSmi()
const;
43 bool IsCleared()
const {
44 return static_cast<uint32_t>(ptr_) == kClearedWeakHeapObjectLower32;
47 inline bool IsStrongOrWeak()
const;
48 inline bool IsStrong()
const;
52 inline bool GetHeapObjectIfStrong(
HeapObject** result)
const;
56 inline HeapObject* GetHeapObjectAssumeStrong()
const;
58 inline bool IsWeak()
const;
59 inline bool IsWeakOrCleared()
const;
63 inline bool GetHeapObjectIfWeak(
HeapObject** result)
const;
67 inline HeapObject* GetHeapObjectAssumeWeak()
const;
71 inline bool GetHeapObject(
HeapObject** result)
const;
73 HeapObjectReferenceType* reference_type)
const;
81 inline Object* GetHeapObjectOrSmi()
const;
83 inline bool IsObject()
const;
84 template <
typename T,
typename =
typename std::enable_if<
85 std::is_base_of<Object, T>::value>
::type>
87 DCHECK(!HasWeakHeapObjectTag(ptr_));
88 return T::cast(reinterpret_cast<Object*>(ptr_));
92 template <
typename T,
typename =
typename std::enable_if<
93 std::is_base_of<ObjectPtr, T>::value>
::type>
95 DCHECK(!HasWeakHeapObjectTag(ptr_));
100 DCHECK(HAS_SMI_TAG(smi->ptr()));
105 DCHECK(!HasWeakHeapObjectTag(
object));
110 DCHECK(!HasWeakHeapObjectTag(
object.ptr()));
121 void ShortPrint(FILE* out = stdout);
126 void ShortPrint(std::ostream& os);
130 void Print(std::ostream& os);
132 void Print() { ShortPrint(); }
133 void Print(std::ostream& os) { ShortPrint(os); }
148 DCHECK(!object->IsSmi());
149 DCHECK(!HasWeakHeapObjectTag(
object));
154 DCHECK(!object->IsSmi());
155 DCHECK(!HasWeakHeapObjectTag(
object));
167 #endif // V8_OBJECTS_MAYBE_OBJECT_H_