diff options
Diffstat (limited to 'deps/v8/src/objects/maybe-object.h')
-rw-r--r-- | deps/v8/src/objects/maybe-object.h | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/deps/v8/src/objects/maybe-object.h b/deps/v8/src/objects/maybe-object.h index 84c8538224..0d55ff859c 100644 --- a/deps/v8/src/objects/maybe-object.h +++ b/deps/v8/src/objects/maybe-object.h @@ -5,6 +5,7 @@ #ifndef V8_OBJECTS_MAYBE_OBJECT_H_ #define V8_OBJECTS_MAYBE_OBJECT_H_ +#include "include/v8-internal.h" #include "include/v8.h" #include "src/globals.h" #include "src/objects.h" @@ -23,30 +24,53 @@ class MaybeObject { public: bool IsSmi() const { return HAS_SMI_TAG(this); } inline bool ToSmi(Smi** value); - inline Smi* ToSmi(); - bool IsClearedWeakHeapObject() const { + bool IsCleared() const { return ::v8::internal::IsClearedWeakHeapObject(this); } - inline bool IsStrongOrWeakHeapObject() const; - inline bool ToStrongOrWeakHeapObject(HeapObject** result); - inline bool ToStrongOrWeakHeapObject(HeapObject** result, - HeapObjectReferenceType* reference_type); - inline bool IsStrongHeapObject() const; - inline bool ToStrongHeapObject(HeapObject** result); - inline HeapObject* ToStrongHeapObject(); - inline bool IsWeakHeapObject() const; - inline bool IsWeakOrClearedHeapObject() const; - inline bool ToWeakHeapObject(HeapObject** result); - inline HeapObject* ToWeakHeapObject(); - - // Returns the HeapObject pointed to (either strongly or weakly). + inline bool IsStrongOrWeak() const; + inline bool IsStrong() const; + + // If this MaybeObject is a strong pointer to a HeapObject, returns true and + // sets *result. Otherwise returns false. + inline bool GetHeapObjectIfStrong(HeapObject** result); + + // DCHECKs that this MaybeObject is a strong pointer to a HeapObject and + // returns the HeapObject. + inline HeapObject* GetHeapObjectAssumeStrong(); + + inline bool IsWeak() const; + inline bool IsWeakOrCleared() const; + + // If this MaybeObject is a weak pointer to a HeapObject, returns true and + // sets *result. Otherwise returns false. + inline bool GetHeapObjectIfWeak(HeapObject** result); + + // DCHECKs that this MaybeObject is a weak pointer to a HeapObject and + // returns the HeapObject. + inline HeapObject* GetHeapObjectAssumeWeak(); + + // If this MaybeObject is a strong or weak pointer to a HeapObject, returns + // true and sets *result. Otherwise returns false. + inline bool GetHeapObject(HeapObject** result); + inline bool GetHeapObject(HeapObject** result, + HeapObjectReferenceType* reference_type); + + // DCHECKs that this MaybeObject is a strong or a weak pointer to a HeapObject + // and returns the HeapObject. inline HeapObject* GetHeapObject(); + + // DCHECKs that this MaybeObject is a strong or a weak pointer to a HeapObject + // or a SMI and returns the HeapObject or SMI. inline Object* GetHeapObjectOrSmi(); inline bool IsObject() const; - inline Object* ToObject(); + template <typename T> + T* cast() { + DCHECK(!HasWeakHeapObjectTag(this)); + return T::cast(reinterpret_cast<Object*>(this)); + } static MaybeObject* FromSmi(Smi* smi) { DCHECK(HAS_SMI_TAG(smi)); |