summaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
Diffstat (limited to 'js/src')
-rw-r--r--js/src/builtin/TestingFunctions.cpp53
-rw-r--r--js/src/jsapi-tests/moz.build6
-rw-r--r--js/src/jsprototypes.h8
-rw-r--r--js/src/moz.build4
-rw-r--r--js/src/shell/js.cpp22
-rw-r--r--js/src/vm/Debugger.cpp12
-rw-r--r--js/src/vm/Debugger.h14
-rw-r--r--js/src/vm/GlobalObject.cpp2
-rw-r--r--js/src/wasm/WasmJS.cpp4
9 files changed, 3 insertions, 122 deletions
diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp
index b521e2bb34..a9a307da71 100644
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -1328,7 +1328,6 @@ OOMTest(JSContext* cx, unsigned argc, Value* vp)
}
#endif
-#ifdef SPIDERMONKEY_PROMISE
static bool
SettlePromiseNow(JSContext* cx, unsigned argc, Value* vp)
{
@@ -1437,43 +1436,6 @@ RejectPromise(JSContext* cx, unsigned argc, Value* vp)
return result;
}
-#else
-
-static const js::Class FakePromiseClass = {
- "Promise", JSCLASS_IS_ANONYMOUS
-};
-
-static bool
-MakeFakePromise(JSContext* cx, unsigned argc, Value* vp)
-{
- CallArgs args = CallArgsFromVp(argc, vp);
-
- RootedObject obj(cx, NewObjectWithGivenProto(cx, &FakePromiseClass, nullptr));
- if (!obj)
- return false;
-
- JS::dbg::onNewPromise(cx, obj);
- args.rval().setObject(*obj);
- return true;
-}
-
-static bool
-SettleFakePromise(JSContext* cx, unsigned argc, Value* vp)
-{
- CallArgs args = CallArgsFromVp(argc, vp);
- if (!args.requireAtLeast(cx, "settleFakePromise", 1))
- return false;
- if (!args[0].isObject() || args[0].toObject().getClass() != &FakePromiseClass) {
- JS_ReportErrorASCII(cx, "first argument must be a (fake) Promise object");
- return false;
- }
-
- RootedObject promise(cx, &args[0].toObject());
- JS::dbg::onPromiseSettled(cx, promise);
- return true;
-}
-#endif // SPIDERMONKEY_PROMISE
-
static unsigned finalizeCount = 0;
static void
@@ -4190,7 +4152,6 @@ static const JSFunctionSpecWithHelp TestingFunctions[] = {
" This is also disabled when --fuzzing-safe is specified."),
#endif
-#ifdef SPIDERMONKEY_PROMISE
JS_FN_HELP("settlePromiseNow", SettlePromiseNow, 1, 0,
"settlePromiseNow(promise)",
" 'Settle' a 'promise' immediately. This just marks the promise as resolved\n"
@@ -4207,20 +4168,6 @@ JS_FN_HELP("resolvePromise", ResolvePromise, 2, 0,
JS_FN_HELP("rejectPromise", RejectPromise, 2, 0,
"rejectPromise(promise, reason)",
" Reject a Promise by calling the JSAPI function JS::RejectPromise."),
-#else
- JS_FN_HELP("makeFakePromise", MakeFakePromise, 0, 0,
-"makeFakePromise()",
-" Create an object whose [[Class]] name is 'Promise' and call\n"
-" JS::dbg::onNewPromise on it before returning it. It doesn't actually have\n"
-" any of the other behavior associated with promises."),
-
- JS_FN_HELP("settleFakePromise", SettleFakePromise, 1, 0,
-"settleFakePromise(promise)",
-" 'Settle' a 'promise' created by makeFakePromise(). This doesn't have any\n"
-" observable effects outside of firing any onPromiseSettled hooks set on\n"
-" Debugger instances that are observing the given promise's global as a\n"
-" debuggee."),
-#endif // SPIDERMONKEY_PROMISE
JS_FN_HELP("makeFinalizeObserver", MakeFinalizeObserver, 0, 0,
"makeFinalizeObserver()",
diff --git a/js/src/jsapi-tests/moz.build b/js/src/jsapi-tests/moz.build
index c176fbf0ad..f3757f5a4a 100644
--- a/js/src/jsapi-tests/moz.build
+++ b/js/src/jsapi-tests/moz.build
@@ -77,6 +77,7 @@ UNIFIED_SOURCES += [
'testPrintf.cpp',
'testPrivateGCThingValue.cpp',
'testProfileStrings.cpp',
+ 'testPromise.cpp',
'testPropCache.cpp',
'testRegExp.cpp',
'testResolveRecursion.cpp',
@@ -124,11 +125,6 @@ if CONFIG['ENABLE_ION']:
'testJitRValueAlloc.cpp',
]
-if CONFIG['SPIDERMONKEY_PROMISE']:
- UNIFIED_SOURCES += [
- 'testPromise.cpp',
- ]
-
DEFINES['EXPORT_JS_API'] = True
LOCAL_INCLUDES += [
diff --git a/js/src/jsprototypes.h b/js/src/jsprototypes.h
index dc7cdb85af..3cf8621ccc 100644
--- a/js/src/jsprototypes.h
+++ b/js/src/jsprototypes.h
@@ -57,12 +57,6 @@
#define IF_SAB(real,imaginary) imaginary
#endif
-#ifdef SPIDERMONKEY_PROMISE
-#define IF_PROMISE(real,imaginary) real
-#else
-#define IF_PROMISE(real,imaginary) imaginary
-#endif
-
#define JS_FOR_PROTOTYPES(real,imaginary) \
imaginary(Null, 0, InitNullClass, dummy) \
real(Object, 1, InitViaClassSpec, OCLASP(Plain)) \
@@ -118,7 +112,7 @@ IF_SAB(real,imaginary)(Atomics, 47, InitAtomicsClass, OCLASP(Atomics)) \
imaginary(WasmInstance, 51, dummy, dummy) \
imaginary(WasmMemory, 52, dummy, dummy) \
imaginary(WasmTable, 53, dummy, dummy) \
-IF_PROMISE(real,imaginary)(Promise, 54, InitViaClassSpec, OCLASP(Promise)) \
+ real(Promise, 54, InitViaClassSpec, OCLASP(Promise)) \
#define JS_FOR_EACH_PROTOTYPE(macro) JS_FOR_PROTOTYPES(macro,macro)
diff --git a/js/src/moz.build b/js/src/moz.build
index d6c2a426b8..5287aef00a 100644
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -761,6 +761,7 @@ selfhosted.inputs = [
'builtin/Module.js',
'builtin/Number.js',
'builtin/Object.js',
+ 'builtin/Promise.js',
'builtin/Reflect.js',
'builtin/RegExp.js',
'builtin/RegExpGlobalReplaceOpt.h.js',
@@ -774,9 +775,6 @@ selfhosted.inputs = [
'builtin/WeakSet.js'
]
-if CONFIG['SPIDERMONKEY_PROMISE']:
- selfhosted.inputs += ['builtin/Promise.js']
-
if CONFIG['JS_HAS_CTYPES']:
if CONFIG['MOZ_SYSTEM_FFI']:
CXXFLAGS += CONFIG['MOZ_FFI_CFLAGS']
diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
index 33f7d6bdcc..36558a694b 100644
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -154,7 +154,6 @@ static const double MAX_TIMEOUT_SECONDS = 1800.0;
# define SHARED_MEMORY_DEFAULT 0
#endif
-#ifdef SPIDERMONKEY_PROMISE
using JobQueue = GCVector<JSObject*, 0, SystemAllocPolicy>;
struct ShellAsyncTasks
@@ -167,7 +166,6 @@ struct ShellAsyncTasks
size_t outstanding;
Vector<JS::AsyncTask*> finished;
};
-#endif // SPIDERMONKEY_PROMISE
enum class ScriptKind
{
@@ -272,12 +270,10 @@ struct ShellContext
JS::PersistentRootedValue interruptFunc;
bool lastWarningEnabled;
JS::PersistentRootedValue lastWarning;
-#ifdef SPIDERMONKEY_PROMISE
JS::PersistentRootedValue promiseRejectionTrackerCallback;
JS::PersistentRooted<JobQueue> jobQueue;
ExclusiveData<ShellAsyncTasks> asyncTasks;
bool drainingJobQueue;
-#endif // SPIDERMONKEY_PROMISE
/*
* Watchdog thread state.
@@ -435,11 +431,9 @@ ShellContext::ShellContext(JSContext* cx)
interruptFunc(cx, NullValue()),
lastWarningEnabled(false),
lastWarning(cx, NullValue()),
-#ifdef SPIDERMONKEY_PROMISE
promiseRejectionTrackerCallback(cx, NullValue()),
asyncTasks(mutexid::ShellAsyncTasks, cx),
drainingJobQueue(false),
-#endif // SPIDERMONKEY_PROMISE
watchdogLock(mutexid::ShellContextWatchdog),
exitCode(0),
quitting(false),
@@ -739,7 +733,6 @@ RunModule(JSContext* cx, const char* filename, FILE* file, bool compileOnly)
return JS_CallFunction(cx, loaderObj, importFun, args, &value);
}
-#ifdef SPIDERMONKEY_PROMISE
static JSObject*
ShellGetIncumbentGlobalCallback(JSContext* cx)
{
@@ -776,12 +769,10 @@ ShellFinishAsyncTaskCallback(JS::AsyncTask* task)
asyncTasks->outstanding--;
return asyncTasks->finished.append(task);
}
-#endif // SPIDERMONKEY_PROMISE
static bool
DrainJobQueue(JSContext* cx)
{
-#ifdef SPIDERMONKEY_PROMISE
ShellContext* sc = GetShellContext(cx);
if (sc->quitting || sc->drainingJobQueue)
return true;
@@ -832,7 +823,6 @@ DrainJobQueue(JSContext* cx)
}
sc->jobQueue.clear();
sc->drainingJobQueue = false;
-#endif // SPIDERMONKEY_PROMISE
return true;
}
@@ -847,7 +837,6 @@ DrainJobQueue(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-#ifdef SPIDERMONKEY_PROMISE
static void
ForwardingPromiseRejectionTrackerCallback(JSContext* cx, JS::HandleObject promise,
PromiseRejectionHandlingState state, void* data)
@@ -870,14 +859,12 @@ ForwardingPromiseRejectionTrackerCallback(JSContext* cx, JS::HandleObject promis
if (!Call(cx, callback, UndefinedHandleValue, args, &rval))
JS_ClearPendingException(cx);
}
-#endif // SPIDERMONKEY_PROMISE
static bool
SetPromiseRejectionTrackerCallback(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
-#ifdef SPIDERMONKEY_PROMISE
if (!IsCallable(args.get(0))) {
JS_ReportErrorASCII(cx,
"setPromiseRejectionTrackerCallback expects a function as its sole "
@@ -888,7 +875,6 @@ SetPromiseRejectionTrackerCallback(JSContext* cx, unsigned argc, Value* vp)
GetShellContext(cx)->promiseRejectionTrackerCallback = args[0];
JS::SetPromiseRejectionTrackerCallback(cx, ForwardingPromiseRejectionTrackerCallback);
-#endif // SPIDERMONKEY_PROMISE
args.rval().setUndefined();
return true;
}
@@ -3349,12 +3335,10 @@ WorkerMain(void* arg)
return;
}
-#ifdef SPIDERMONKEY_PROMISE
sc->jobQueue.init(cx, JobQueue(SystemAllocPolicy()));
JS::SetEnqueuePromiseJobCallback(cx, ShellEnqueuePromiseJobCallback);
JS::SetGetIncumbentGlobalCallback(cx, ShellGetIncumbentGlobalCallback);
JS::SetAsyncTaskCallbacks(cx, ShellStartAsyncTaskCallback, ShellFinishAsyncTaskCallback);
-#endif // SPIDERMONKEY_PROMISE
EnvironmentPreparer environmentPreparer(cx);
@@ -3385,11 +3369,9 @@ WorkerMain(void* arg)
JS::SetLargeAllocationFailureCallback(cx, nullptr, nullptr);
-#ifdef SPIDERMONKEY_PROMISE
JS::SetGetIncumbentGlobalCallback(cx, nullptr);
JS::SetEnqueuePromiseJobCallback(cx, nullptr);
sc->jobQueue.reset();
-#endif // SPIDERMONKEY_PROMISE
KillWatchdog(cx);
@@ -7945,12 +7927,10 @@ main(int argc, char** argv, char** envp)
if (!JS::InitSelfHostedCode(cx))
return 1;
-#ifdef SPIDERMONKEY_PROMISE
sc->jobQueue.init(cx, JobQueue(SystemAllocPolicy()));
JS::SetEnqueuePromiseJobCallback(cx, ShellEnqueuePromiseJobCallback);
JS::SetGetIncumbentGlobalCallback(cx, ShellGetIncumbentGlobalCallback);
JS::SetAsyncTaskCallbacks(cx, ShellStartAsyncTaskCallback, ShellFinishAsyncTaskCallback);
-#endif // SPIDERMONKEY_PROMISE
EnvironmentPreparer environmentPreparer(cx);
@@ -7980,11 +7960,9 @@ main(int argc, char** argv, char** envp)
JS::SetLargeAllocationFailureCallback(cx, nullptr, nullptr);
-#ifdef SPIDERMONKEY_PROMISE
JS::SetGetIncumbentGlobalCallback(cx, nullptr);
JS::SetEnqueuePromiseJobCallback(cx, nullptr);
sc->jobQueue.reset();
-#endif // SPIDERMONKEY_PROMISE
KillWatchdog(cx);
diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp
index 2680699a46..c49df5aa91 100644
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -8728,7 +8728,6 @@ DebuggerObject::proxyHandlerGetter(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-#ifdef SPIDERMONKEY_PROMISE
/* static */ bool
DebuggerObject::isPromiseGetter(JSContext* cx, unsigned argc, Value* vp)
{
@@ -8897,7 +8896,6 @@ DebuggerObject::promiseDependentPromisesGetter(JSContext* cx, unsigned argc, Val
args.rval().setObject(*promises);
return true;
}
-#endif // SPIDERMONKEY_PROMISE
/* static */ bool
DebuggerObject::isExtensibleMethod(JSContext* cx, unsigned argc, Value* vp)
@@ -9336,7 +9334,6 @@ const JSPropertySpec DebuggerObject::properties_[] = {
JS_PS_END
};
-#ifdef SPIDERMONKEY_PROMISE
const JSPropertySpec DebuggerObject::promiseProperties_[] = {
JS_PSG("isPromise", DebuggerObject::isPromiseGetter, 0),
JS_PSG("promiseState", DebuggerObject::promiseStateGetter, 0),
@@ -9350,7 +9347,6 @@ const JSPropertySpec DebuggerObject::promiseProperties_[] = {
JS_PSG("promiseDependentPromises", DebuggerObject::promiseDependentPromisesGetter, 0),
JS_PS_END
};
-#endif // SPIDERMONKEY_PROMISE
const JSFunctionSpec DebuggerObject::methods_[] = {
JS_FN("isExtensible", DebuggerObject::isExtensibleMethod, 0, 0),
@@ -9390,10 +9386,8 @@ DebuggerObject::initClass(JSContext* cx, HandleObject obj, HandleObject debugCto
if (!objectProto)
return nullptr;
-#ifdef SPIDERMONKEY_PROMISE
if (!DefinePropertiesAndFunctions(cx, objectProto, promiseProperties_, nullptr))
return nullptr;
-#endif // SPIDERMONKEY_PROMISE
return objectProto;
}
@@ -9461,7 +9455,6 @@ DebuggerObject::isScriptedProxy() const
return js::IsScriptedProxy(referent());
}
-#ifdef SPIDERMONKEY_PROMISE
bool
DebuggerObject::isPromise() const
{
@@ -9475,7 +9468,6 @@ DebuggerObject::isPromise() const
return referent->is<PromiseObject>();
}
-#endif // SPIDERMONKEY_PROMISE
/* static */ bool
DebuggerObject::getClassName(JSContext* cx, HandleDebuggerObject object,
@@ -9758,7 +9750,6 @@ DebuggerObject::getErrorColumnNumber(JSContext* cx, HandleDebuggerObject object,
return true;
}
-#ifdef SPIDERMONKEY_PROMISE
/* static */ bool
DebuggerObject::getPromiseValue(JSContext* cx, HandleDebuggerObject object,
MutableHandleValue result)
@@ -9778,7 +9769,6 @@ DebuggerObject::getPromiseReason(JSContext* cx, HandleDebuggerObject object,
result.set(object->promise()->reason());
return object->owner()->wrapDebuggeeValue(cx, result);
}
-#endif // SPIDERMONKEY_PROMISE
/* static */ bool
DebuggerObject::isExtensible(JSContext* cx, HandleDebuggerObject object, bool& result)
@@ -10248,7 +10238,6 @@ DebuggerObject::requireGlobal(JSContext* cx, HandleDebuggerObject object)
return true;
}
-#ifdef SPIDERMONKEY_PROMISE
/* static */ bool
DebuggerObject::requirePromise(JSContext* cx, HandleDebuggerObject object)
{
@@ -10270,7 +10259,6 @@ DebuggerObject::requirePromise(JSContext* cx, HandleDebuggerObject object)
return true;
}
-#endif // SPIDERMONKEY_PROMISE
/* static */ bool
DebuggerObject::getScriptedProxyTarget(JSContext* cx, HandleDebuggerObject object,
diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h
index cdcf2d67fb..204d1ca3ea 100644
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -1256,12 +1256,10 @@ class DebuggerObject : public NativeObject
MutableHandleDebuggerObject result);
static MOZ_MUST_USE bool getScriptedProxyHandler(JSContext* cx, HandleDebuggerObject object,
MutableHandleDebuggerObject result);
-#ifdef SPIDERMONKEY_PROMISE
static MOZ_MUST_USE bool getPromiseValue(JSContext* cx, HandleDebuggerObject object,
MutableHandleValue result);
static MOZ_MUST_USE bool getPromiseReason(JSContext* cx, HandleDebuggerObject object,
MutableHandleValue result);
-#endif // SPIDERMONKEY_PROMISE
// Methods
static MOZ_MUST_USE bool isExtensible(JSContext* cx, HandleDebuggerObject object,
@@ -1311,16 +1309,12 @@ class DebuggerObject : public NativeObject
bool isArrowFunction() const;
bool isGlobal() const;
bool isScriptedProxy() const;
-#ifdef SPIDERMONKEY_PROMISE
bool isPromise() const;
-#endif // SPIDERMONKEY_PROMISE
JSAtom* name() const;
JSAtom* displayName() const;
-#ifdef SPIDERMONKEY_PROMISE
JS::PromiseState promiseState() const;
double promiseLifetime() const;
double promiseTimeToResolution() const;
-#endif // SPIDERMONKEY_PROMISE
private:
enum {
@@ -1332,9 +1326,7 @@ class DebuggerObject : public NativeObject
static const ClassOps classOps_;
static const JSPropertySpec properties_[];
-#ifdef SPIDERMONKEY_PROMISE
static const JSPropertySpec promiseProperties_[];
-#endif // SPIDERMONKEY_PROMISE
static const JSFunctionSpec methods_[];
JSObject* referent() const {
@@ -1345,14 +1337,10 @@ class DebuggerObject : public NativeObject
Debugger* owner() const;
-#ifdef SPIDERMONKEY_PROMISE
PromiseObject* promise() const;
-#endif // SPIDERMONKEY_PROMISE
static MOZ_MUST_USE bool requireGlobal(JSContext* cx, HandleDebuggerObject object);
-#ifdef SPIDERMONKEY_PROMISE
static MOZ_MUST_USE bool requirePromise(JSContext* cx, HandleDebuggerObject object);
-#endif // SPIDERMONKEY_PROMISE
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp);
@@ -1379,7 +1367,6 @@ class DebuggerObject : public NativeObject
static MOZ_MUST_USE bool isProxyGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool proxyTargetGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool proxyHandlerGetter(JSContext* cx, unsigned argc, Value* vp);
-#ifdef SPIDERMONKEY_PROMISE
static MOZ_MUST_USE bool isPromiseGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseStateGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseValueGetter(JSContext* cx, unsigned argc, Value* vp);
@@ -1390,7 +1377,6 @@ class DebuggerObject : public NativeObject
static MOZ_MUST_USE bool promiseResolutionSiteGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseIDGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseDependentPromisesGetter(JSContext* cx, unsigned argc, Value* vp);
-#endif // SPIDERMONKEY_PROMISE
// JSNative methods
static MOZ_MUST_USE bool isExtensibleMethod(JSContext* cx, unsigned argc, Value* vp);
diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp
index 70c33c6473..a8d401af43 100644
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -21,9 +21,7 @@
#include "builtin/MapObject.h"
#include "builtin/ModuleObject.h"
#include "builtin/Object.h"
-#ifdef SPIDERMONKEY_PROMISE
#include "builtin/Promise.h"
-#endif
#include "builtin/RegExp.h"
#include "builtin/SelfHostingDefines.h"
#include "builtin/SymbolObject.h"
diff --git a/js/src/wasm/WasmJS.cpp b/js/src/wasm/WasmJS.cpp
index 8d4f575b23..fd9530e203 100644
--- a/js/src/wasm/WasmJS.cpp
+++ b/js/src/wasm/WasmJS.cpp
@@ -1640,7 +1640,6 @@ WebAssembly_toSource(JSContext* cx, unsigned argc, Value* vp)
}
#endif
-#ifdef SPIDERMONKEY_PROMISE
static bool
Nop(JSContext* cx, unsigned argc, Value* vp)
{
@@ -1914,7 +1913,6 @@ WebAssembly_instantiate(JSContext* cx, unsigned argc, Value* vp)
callArgs.rval().setObject(*promise);
return true;
}
-#endif
static bool
WebAssembly_validate(JSContext* cx, unsigned argc, Value* vp)
@@ -1949,10 +1947,8 @@ static const JSFunctionSpec WebAssembly_static_methods[] =
#if JS_HAS_TOSOURCE
JS_FN(js_toSource_str, WebAssembly_toSource, 0, 0),
#endif
-#ifdef SPIDERMONKEY_PROMISE
JS_FN("compile", WebAssembly_compile, 1, 0),
JS_FN("instantiate", WebAssembly_instantiate, 2, 0),
-#endif
JS_FN("validate", WebAssembly_validate, 1, 0),
JS_FS_END
};