summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-04-11 16:42:04 -0500
committerBrian Smith <brian@dbsoft.org>2023-04-27 13:33:56 -0500
commita28f3edf2a081c26a60236cc151a29d2ca99998f (patch)
tree6460d4b504174e9c4ef5616cee26414d60e06601 /dom
parent6b69dad2aa76481c1850bc0f88e1993103bf49c4 (diff)
downloaduxp-a28f3edf2a081c26a60236cc151a29d2ca99998f.tar.gz
Issue #1691 - Part 6d: Optimize handling of internally-created Promise objects.
https://bugzilla.mozilla.org/show_bug.cgi?id=1358879 The patch uses a different test: PROMISE_FLAG_DEFAULT_REJECT_FUNCTION which doesn't exist in our codebase. It was added in this bug, which appears to be partly complete: https://bugzilla.mozilla.org/show_bug.cgi?id=1313049 (cherry picked from commit 97fc74b693813eaaa9ab833d9c51fc5868ff039f)
Diffstat (limited to 'dom')
-rw-r--r--dom/promise/Promise.cpp21
1 files changed, 1 insertions, 20 deletions
diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp
index 38db74b020..0e1349d087 100644
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -227,15 +227,6 @@ Promise::Then(JSContext* aCx,
aRetval.setObject(*retval);
}
-// We need a dummy function to pass to JS::NewPromiseObject.
-static bool
-DoNothingPromiseExecutor(JSContext*, unsigned aArgc, JS::Value* aVp)
-{
- JS::CallArgs args = CallArgsFromVp(aArgc, aVp);
- args.rval().setUndefined();
- return true;
-}
-
void
Promise::CreateWrapper(JS::Handle<JSObject*> aDesiredProto, ErrorResult& aRv)
{
@@ -246,17 +237,7 @@ Promise::CreateWrapper(JS::Handle<JSObject*> aDesiredProto, ErrorResult& aRv)
}
JSContext* cx = jsapi.cx();
- JSFunction* doNothingFunc =
- JS_NewFunction(cx, DoNothingPromiseExecutor, /* nargs = */ 2,
- /* flags = */ 0, nullptr);
- if (!doNothingFunc) {
- JS_ClearPendingException(cx);
- aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
- return;
- }
-
- JS::Rooted<JSObject*> doNothingObj(cx, JS_GetFunctionObject(doNothingFunc));
- mPromiseObj = JS::NewPromiseObject(cx, doNothingObj, aDesiredProto);
+ mPromiseObj = JS::NewPromiseObject(cx, nullptr, aDesiredProto);
if (!mPromiseObj) {
JS_ClearPendingException(cx);
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);