summaryrefslogtreecommitdiff
path: root/js/src/jscntxt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jscntxt.cpp')
-rw-r--r--js/src/jscntxt.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp
index dc14b83fd9..66a548d6e8 100644
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -240,6 +240,13 @@ js::ReportOutOfMemory(ExclusiveContext* cxArg)
cx->setPendingException(oomMessage, nullptr);
}
+mozilla::GenericErrorResult<OOM&>
+js::ReportOutOfMemoryResult(ExclusiveContext* cx)
+{
+ ReportOutOfMemory(cx);
+ return cx->alreadyReportedOOM();
+}
+
void
js::ReportOverRecursed(JSContext* maybecx, unsigned errorNumber)
{
@@ -1004,6 +1011,34 @@ ExclusiveContext::recoverFromOutOfMemory()
task->outOfMemory = false;
}
+JS::Error ExclusiveContext::reportedError;
+JS::OOM ExclusiveContext::reportedOOM;
+
+mozilla::GenericErrorResult<OOM&>
+ExclusiveContext::alreadyReportedOOM()
+{
+#ifdef DEBUG
+ if (JSContext* maybecx = maybeJSContext()) {
+ MOZ_ASSERT(maybecx->isThrowingOutOfMemory());
+ } else {
+ // Keep in sync with addPendingOutOfMemory.
+ if (ParseTask* task = helperThread()->parseTask())
+ MOZ_ASSERT(task->outOfMemory);
+ }
+#endif
+ return mozilla::MakeGenericErrorResult(reportedOOM);
+}
+
+mozilla::GenericErrorResult<JS::Error&>
+ExclusiveContext::alreadyReportedError()
+{
+#ifdef DEBUG
+ if (JSContext* maybecx = maybeJSContext())
+ MOZ_ASSERT(maybecx->isExceptionPending());
+#endif
+ return mozilla::MakeGenericErrorResult(reportedError);
+}
+
JSContext::JSContext(JSRuntime* parentRuntime)
: ExclusiveContext(this, &this->JSRuntime::mainThread, Context_JS, JS::ContextOptions()),
JSRuntime(parentRuntime),