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)
This commit is contained in:
Brian Smith 2023-04-11 16:42:04 -05:00 committed by roytam1
commit c3daecc218
4 changed files with 19 additions and 27 deletions

View file

@ -4536,9 +4536,14 @@ SetPromiseRejectionTrackerCallback(JSContext* cx, JSPromiseRejectionTrackerCallb
/**
* Returns a new instance of the Promise builtin class in the current
* compartment, with the right slot layout. If a `proto` is passed, that gets
* set as the instance's [[Prototype]] instead of the original value of
* `Promise.prototype`.
* compartment, with the right slot layout.
*
* The `executor` can be a `nullptr`. In that case, the only way to resolve or
* reject the returned promise is via the `JS::ResolvePromise` and
* `JS::RejectPromise` JSAPI functions.
*
* If a `proto` is passed, that gets set as the instance's [[Prototype]]
* instead of the original value of `Promise.prototype`.
*/
extern JS_PUBLIC_API(JSObject*)
NewPromiseObject(JSContext* cx, JS::HandleObject executor, JS::HandleObject proto = nullptr);