summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-02-04 01:44:41 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-19 17:38:02 +0000
commit185a027640f9b18c97eda39a49bfa2dcce58fcdb (patch)
treed29b146d37f0f831ec981316da778c91fd77be8a /js
parent99ec088ecf1259643f6124206af024de3ebc49ad (diff)
downloaduxp-185a027640f9b18c97eda39a49bfa2dcce58fcdb.tar.gz
Issue #1877 - Resolve RELEASE_OR_BETA conditionals.
Diffstat (limited to 'js')
-rw-r--r--js/public/Class.h28
-rw-r--r--js/src/builtin/Reflect.cpp10
-rw-r--r--js/src/builtin/TestingFunctions.cpp4
-rw-r--r--js/src/frontend/Parser.cpp4
-rw-r--r--js/src/shell/js.cpp6
5 files changed, 35 insertions, 17 deletions
diff --git a/js/public/Class.h b/js/public/Class.h
index 094e4a7ed7..6f1960a308 100644
--- a/js/public/Class.h
+++ b/js/public/Class.h
@@ -131,16 +131,24 @@ class ObjectOpResult
Uninitialized = uintptr_t(-1)
};
+ static const uintptr_t SoftFailBit = uintptr_t(1) << (sizeof(uintptr_t) * 8 - 1);
+
ObjectOpResult() : code_(Uninitialized) {}
- /* Return true if succeed() was called. */
+ /* Return true if succeed() or failSoft() was called. */
bool ok() const {
MOZ_ASSERT(code_ != Uninitialized);
- return code_ == OkCode;
+ return code_ == OkCode || (code_ & SoftFailBit);
}
explicit operator bool() const { return ok(); }
+ /* Return true if succeed() was called. */
+ bool confirmOk() const {
+ MOZ_ASSERT(code_ != Uninitialized);
+ return code_ == OkCode;
+ }
+
/* Set this ObjectOpResult to true and return true. */
bool succeed() {
code_ = OkCode;
@@ -160,10 +168,26 @@ class ObjectOpResult
*/
bool fail(uint32_t msg) {
MOZ_ASSERT(msg != OkCode);
+ MOZ_ASSERT((msg & SoftFailBit) == 0);
code_ = msg;
return true;
}
+ /*
+ * DEPRECATED: This is a non-standard compatibility hack.
+ *
+ * Set this ObjectOpResult to true, but remembers an error code.
+ * This is used for situations where we really want to fail,
+ * but can't for legacy reasons.
+ *
+ * Always returns true, as a convenience.
+ */
+ bool failSoft(uint32_t msg) {
+ // The msg code is currently never extracted again.
+ code_ = msg | SoftFailBit;
+ return true;
+ }
+
JS_PUBLIC_API(bool) failCantRedefineProp();
JS_PUBLIC_API(bool) failReadOnly();
JS_PUBLIC_API(bool) failGetterOnly();
diff --git a/js/src/builtin/Reflect.cpp b/js/src/builtin/Reflect.cpp
index ab7cca174d..a902c90d8b 100644
--- a/js/src/builtin/Reflect.cpp
+++ b/js/src/builtin/Reflect.cpp
@@ -44,7 +44,7 @@ Reflect_defineProperty(JSContext* cx, unsigned argc, Value* vp)
ObjectOpResult result;
if (!DefineProperty(cx, obj, key, desc, result))
return false;
- args.rval().setBoolean(bool(result));
+ args.rval().setBoolean(result.confirmOk());
return true;
}
@@ -69,7 +69,7 @@ Reflect_deleteProperty(JSContext* cx, unsigned argc, Value* vp)
ObjectOpResult result;
if (!DeleteProperty(cx, target, key, result))
return false;
- args.rval().setBoolean(bool(result));
+ args.rval().setBoolean(result.confirmOk());
return true;
}
@@ -178,7 +178,7 @@ Reflect_preventExtensions(JSContext* cx, unsigned argc, Value* vp)
ObjectOpResult result;
if (!PreventExtensions(cx, target, result))
return false;
- args.rval().setBoolean(bool(result));
+ args.rval().setBoolean(result.confirmOk());
return true;
}
@@ -207,7 +207,7 @@ Reflect_set(JSContext* cx, unsigned argc, Value* vp)
RootedValue value(cx, args.get(2));
if (!SetProperty(cx, target, key, value, receiver, result))
return false;
- args.rval().setBoolean(bool(result));
+ args.rval().setBoolean(result.confirmOk());
return true;
}
@@ -240,7 +240,7 @@ Reflect_setPrototypeOf(JSContext* cx, unsigned argc, Value* vp)
ObjectOpResult result;
if (!SetPrototype(cx, obj, proto, result))
return false;
- args.rval().setBoolean(bool(result));
+ args.rval().setBoolean(result.confirmOk());
return true;
}
diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp
index c9dcadaddf..f91a53eae2 100644
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -123,11 +123,7 @@ GetBuildConfiguration(JSContext* cx, unsigned argc, Value* vp)
if (!JS_SetProperty(cx, info, "debug", value))
return false;
-#ifdef RELEASE_OR_BETA
value = BooleanValue(true);
-#else
- value = BooleanValue(false);
-#endif
if (!JS_SetProperty(cx, info, "release_or_beta", value))
return false;
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index c51545f1b9..38bd77ead3 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -10190,7 +10190,9 @@ Parser<ParseHandler>::exprInParens(InHandling inHandling, YieldHandling yieldHan
bool
ParserBase::warnOnceAboutExprClosure()
{
-#ifndef RELEASE_OR_BETA
+ // We extensively use expression closures.
+ // Disabling spew; see Issue #3061
+#if 0
JSContext* cx = context->maybeJSContext();
if (!cx)
return true;
diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
index 6e155d3ff6..755fb73f1a 100644
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -145,13 +145,9 @@ static const size_t gMaxStackSize = 128 * sizeof(size_t) * 1024;
*/
static const double MAX_TIMEOUT_SECONDS = 1800.0;
-// SharedArrayBuffer and Atomics settings track Firefox. Choose a custom setting
+// SharedArrayBuffer and Atomics settings track browser. Choose a custom setting
// with --shared-memory={on,off}.
-#ifndef RELEASE_OR_BETA
# define SHARED_MEMORY_DEFAULT 1
-#else
-# define SHARED_MEMORY_DEFAULT 0
-#endif
using JobQueue = GCVector<JSObject*, 0, SystemAllocPolicy>;