Changeset 273605 in webkit


Ignore:
Timestamp:
Feb 26, 2021 4:37:31 PM (17 months ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Avoid function allocations for non-user-provided Promise then callbacks
https://bugs.webkit.org/show_bug.cgi?id=222490

Reviewed by Keith Miller.

At @performPromiseThen point, callback function objects themselves are not accessible from users
if they are not passed from users. So, we can reuse functions if users do not pass functions.

  • builtins/PromiseOperations.js:

(globalPrivate.promiseEmptyOnFulfilled):
(globalPrivate.promiseEmptyOnRejected):
(globalPrivate.performPromiseThen):
(onFulfilled): Deleted.
(onRejected): Deleted.

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r273594 r273605  
     12021-02-26  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Avoid function allocations for non-user-provided Promise then callbacks
     4        https://bugs.webkit.org/show_bug.cgi?id=222490
     5
     6        Reviewed by Keith Miller.
     7
     8        At @performPromiseThen point, callback function objects themselves are not accessible from users
     9        if they are not passed from users. So, we can reuse functions if users do not pass functions.
     10
     11        * builtins/PromiseOperations.js:
     12        (globalPrivate.promiseEmptyOnFulfilled):
     13        (globalPrivate.promiseEmptyOnRejected):
     14        (globalPrivate.performPromiseThen):
     15        (onFulfilled): Deleted.
     16        (onRejected): Deleted.
     17
    1182021-02-26  Michael Saboff  <msaboff@apple.com>
    219
  • trunk/Source/JavaScriptCore/builtins/PromiseOperations.js

    r272005 r273605  
    521521
    522522@globalPrivate
     523function promiseEmptyOnFulfilled(argument)
     524{
     525    "use strict";
     526
     527    return argument;
     528}
     529
     530@globalPrivate
     531function promiseEmptyOnRejected(argument)
     532{
     533    "use strict";
     534
     535    throw argument;
     536}
     537
     538@globalPrivate
    523539function performPromiseThen(promise, onFulfilled, onRejected, promiseOrCapability)
    524540{
     
    526542
    527543    if (!@isCallable(onFulfilled))
    528         onFulfilled = function (argument) { return argument; };
     544        onFulfilled = @promiseEmptyOnFulfilled;
    529545
    530546    if (!@isCallable(onRejected))
    531         onRejected = function (argument) { throw argument; };
     547        onRejected = @promiseEmptyOnRejected;
    532548
    533549    var reaction = @newPromiseReaction(promiseOrCapability, onFulfilled, onRejected);
Note: See TracChangeset for help on using the changeset viewer.