summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-11-08 23:08:26 +0000
committerMoonchild <moonchild@palemoon.org>2020-11-08 23:08:26 +0000
commit699fe778b43798cee77e8c3504348576becebfdf (patch)
treea916b86c87a638c80a4ad2444dab885fc2a1d291
parent9346d2b55ecb29f36bd0378caf48d1ddea869668 (diff)
downloaduxp-699fe778b43798cee77e8c3504348576becebfdf.tar.gz
Bug 1328948 - add is(), as() to Cell.
-rw-r--r--js/src/gc/Heap.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/src/gc/Heap.h b/js/src/gc/Heap.h
index 60e7ef729c..2089415326 100644
--- a/js/src/gc/Heap.h
+++ b/js/src/gc/Heap.h
@@ -28,6 +28,7 @@
#include "js/HeapAPI.h"
#include "js/RootingAPI.h"
#include "js/TracingAPI.h"
+#include "js/TraceKind.h"
struct JSRuntime;
@@ -272,6 +273,23 @@ struct Cell
static MOZ_ALWAYS_INLINE bool needWriteBarrierPre(JS::Zone* zone);
+ template <class T>
+ inline bool is() const {
+ return getTraceKind() == JS::MapTypeToTraceKind<T>::kind;
+ }
+
+ template<class T>
+ inline T* as() {
+ MOZ_ASSERT(is<T>());
+ return static_cast<T*>(this);
+ }
+
+ template <class T>
+ inline const T* as() const {
+ MOZ_ASSERT(is<T>());
+ return static_cast<const T*>(this);
+ }
+
#ifdef DEBUG
inline bool isAligned() const;
void dump(FILE* fp) const;