From 634f773a403a6e0d5b04d0d62cee7126dbc9edd3 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 28 May 2015 07:37:43 -0700 Subject: [PATCH] Bug 1024774 - Part 8: Add JS::ubi::Node::isLive; r=jimb --- js/public/UbiNode.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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; }