summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/src/gc/Heap.h18
-rw-r--r--js/src/jsapi.cpp4
2 files changed, 21 insertions, 1 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;
diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
index c0f0e61cc..cd370e42c 100644
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -7040,7 +7040,9 @@ JS::CaptureCurrentStack(JSContext* cx, JS::MutableHandleObject stackp,
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
- MOZ_RELEASE_ASSERT(cx->compartment());
+ if (!cx->compartment()) {
+ return false;
+ }
JSCompartment* compartment = cx->compartment();
Rooted<SavedFrame*> frame(cx);