diff --git a/js/public/UbiNode.h b/js/public/UbiNode.h index 775558a5c0f..b45294d0a95 100644 --- a/js/public/UbiNode.h +++ b/js/public/UbiNode.h @@ -187,6 +187,11 @@ class Base { } bool operator!=(const Base& rhs) const { return !(*this == rhs); } + // Returns true if this node is pointing to something on the live heap, as + // opposed to something from a deserialized core dump. Returns false, + // otherwise. + virtual bool isLive() const { return true; }; + // Return a human-readable name for the referent's type. The result should // be statically allocated. (You can use MOZ_UTF16("strings") for this.) // @@ -337,6 +342,8 @@ class Node { return base()->ptr != nullptr; } + bool isLive() const { return base()->isLive(); } + template bool is() const { return base()->typeName() == Concrete::concreteTypeName; @@ -344,12 +351,14 @@ class Node { template T* as() const { + MOZ_ASSERT(isLive()); MOZ_ASSERT(is()); return static_cast(base()->ptr); } template T* asOrNull() const { + MOZ_ASSERT(isLive()); return is() ? static_cast(base()->ptr) : nullptr; }