summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-11-09 21:10:53 -0500
committerMoonchild <moonchild@palemoon.org>2020-11-18 10:54:04 +0000
commitd7df9b336ae34ff4c4b64f7aa4e0be2579c95ece (patch)
tree5b4bc568f53620acdbdd7c45824f91f36d57a99c /js
parent6c1b1bd18f2830a2f71027f9b3060200acfd4061 (diff)
downloadUXP-d7df9b336ae34ff4c4b64f7aa4e0be2579c95ece.tar
UXP-d7df9b336ae34ff4c4b64f7aa4e0be2579c95ece.tar.gz
UXP-d7df9b336ae34ff4c4b64f7aa4e0be2579c95ece.tar.lz
UXP-d7df9b336ae34ff4c4b64f7aa4e0be2579c95ece.tar.xz
UXP-d7df9b336ae34ff4c4b64f7aa4e0be2579c95ece.zip
Bug 1328948 - Add is(), as() to Cell.
Tag #1679
Diffstat (limited to 'js')
-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 697803380..7f2c5fb4f 100644
--- a/js/src/gc/Heap.h
+++ b/js/src/gc/Heap.h
@@ -29,6 +29,7 @@
#include "js/HeapAPI.h"
#include "js/RootingAPI.h"
#include "js/TracingAPI.h"
+#include "js/TraceKind.h"
struct JSRuntime;
@@ -273,6 +274,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;