summaryrefslogtreecommitdiff
path: root/js/src/jscntxt.h
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-07-07 19:41:06 +0200
committerMoonchild <moonchild@palemoon.org>2023-07-07 19:41:06 +0200
commitea9077a8a5fd8b9f7d5397d18e84aa20fb87f406 (patch)
tree64c21104a540df2812482dcc520952869db04ebf /js/src/jscntxt.h
parentb4af6b6265ed489acbc3dc5a2fd9d4ed7f783b13 (diff)
parentaf5dbfc12003e61f21d2a7c71f239d18ae3945cf (diff)
downloaduxp-RC_20230707.tar.gz
Merge branch 'master' into releaseRC_20230707RB_20230711
Diffstat (limited to 'js/src/jscntxt.h')
-rw-r--r--js/src/jscntxt.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h
index 93106d681e..c4ef783d3a 100644
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -12,6 +12,7 @@
#include "js/CharacterEncoding.h"
#include "js/GCVector.h"
+#include "js/Result.h"
#include "js/Utility.h"
#include "js/Vector.h"
#include "vm/Caches.h"
@@ -314,6 +315,30 @@ class ExclusiveContext : public ContextFriendFields,
bool addPendingCompileError(frontend::CompileError** err);
void addPendingOverRecursed();
void addPendingOutOfMemory();
+
+ private:
+ static JS::Error reportedError;
+ static JS::OOM reportedOOM;
+
+ public:
+ inline JS::Result<> boolToResult(bool ok);
+
+ /**
+ * Intentionally awkward signpost method that is stationed on the
+ * boundary between Result-using and non-Result-using code.
+ */
+ template <typename V, typename E>
+ bool resultToBool(JS::Result<V, E> result) {
+ return result.isOk();
+ }
+
+ template <typename V, typename E>
+ V* resultToPtr(JS::Result<V*, E> result) {
+ return result.isOk() ? result.unwrap() : nullptr;
+ }
+
+ mozilla::GenericErrorResult<JS::OOM&> alreadyReportedOOM();
+ mozilla::GenericErrorResult<JS::Error&> alreadyReportedError();
};
void ReportOverRecursed(JSContext* cx, unsigned errorNumber);
@@ -340,6 +365,7 @@ struct JSContext : public js::ExclusiveContext,
using ExclusiveContext::permanentAtoms;
using ExclusiveContext::pod_calloc;
using ExclusiveContext::pod_malloc;
+ using ExclusiveContext::pod_realloc;
using ExclusiveContext::staticStrings;
using ExclusiveContext::updateMallocCounter;
using ExclusiveContext::wellKnownSymbols;
@@ -490,7 +516,7 @@ struct JSContext : public js::ExclusiveContext,
}
public:
- bool isExceptionPending() {
+ bool isExceptionPending() const {
return throwing;
}
@@ -540,6 +566,17 @@ struct JSContext : public js::ExclusiveContext,
namespace js {
+inline JS::Result<>
+ExclusiveContext::boolToResult(bool ok)
+{
+ if (MOZ_LIKELY(ok)) {
+ MOZ_ASSERT_IF(isJSContext(), !asJSContext()->isExceptionPending());
+ MOZ_ASSERT_IF(isJSContext(), !asJSContext()->isPropagatingForcedReturn());
+ return JS::Ok();
+ }
+ return JS::Result<>(reportedError);
+}
+
struct MOZ_RAII AutoResolving {
public:
enum Kind {