Changeset 246620 in webkit


Ignore:
Timestamp:
Jun 19, 2019 5:38:20 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Optimize resolve method lookup in Promise static methods
https://bugs.webkit.org/show_bug.cgi?id=198864

Patch by Alexey Shvayka <Alexey Shvayka> on 2019-06-19
Reviewed by Yusuke Suzuki.

JSTests:

  • test262/expectations.yaml: Mark 18 test cases as passing.

Source/JavaScriptCore:

Lookup resolve method only once in Promise.{all,allSettled,race}.
(https://github.com/tc39/ecma262/pull/1506)

Already implemented in V8.

  • builtins/PromiseConstructor.js:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r246589 r246620  
     12019-06-19  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Optimize `resolve` method lookup in Promise static methods
     4        https://bugs.webkit.org/show_bug.cgi?id=198864
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * test262/expectations.yaml: Mark 18 test cases as passing.
     9
    1102019-06-19  Justin Michaud  <justin_michaud@apple.com>
    211
  • trunk/JSTests/test262/expectations.yaml

    r246499 r246620  
    10961096  default: 'Test262Error: Expected SameValue(«undefined», «1») to be true'
    10971097  strict mode: 'Test262Error: Expected SameValue(«undefined», «1») to be true'
    1098 test/built-ins/Promise/all/invoke-resolve-get-error-close.js:
    1099   default: 'Test262Error: Expected SameValue(«1», «0») to be true'
    1100   strict mode: 'Test262Error: Expected SameValue(«1», «0») to be true'
    1101 test/built-ins/Promise/all/invoke-resolve-get-once-multiple-calls.js:
    1102   default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
    1103   strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
    1104 test/built-ins/Promise/all/invoke-resolve-get-once-no-calls.js:
    1105   default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
    1106   strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
    11071098test/built-ins/Promise/all/resolve-element-function-nonconstructor.js:
    11081099  default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    11091100  strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    1110 test/built-ins/Promise/allSettled/invoke-resolve-get-error-close.js:
    1111   default: 'Test262Error: Expected SameValue(«1», «0») to be true'
    1112   strict mode: 'Test262Error: Expected SameValue(«1», «0») to be true'
    1113 test/built-ins/Promise/allSettled/invoke-resolve-get-once-multiple-calls.js:
    1114   default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
    1115   strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
    1116 test/built-ins/Promise/allSettled/invoke-resolve-get-once-no-calls.js:
    1117   default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
    1118   strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
    11191101test/built-ins/Promise/allSettled/reject-element-function-nonconstructor.js:
    11201102  default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
     
    11291111  default: 'Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true'
    11301112  strict mode: 'Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true'
    1131 test/built-ins/Promise/race/invoke-resolve-get-error-close.js:
    1132   default: 'Test262Error: Expected SameValue(«1», «0») to be true'
    1133   strict mode: 'Test262Error: Expected SameValue(«1», «0») to be true'
    1134 test/built-ins/Promise/race/invoke-resolve-get-once-multiple-calls.js:
    1135   default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
    1136   strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
    1137 test/built-ins/Promise/race/invoke-resolve-get-once-no-calls.js:
    1138   default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
    1139   strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
    11401113test/built-ins/Promise/reject-function-nonconstructor.js:
    11411114  default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
  • trunk/Source/JavaScriptCore/ChangeLog

    r246610 r246620  
     12019-06-19  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Optimize `resolve` method lookup in Promise static methods
     4        https://bugs.webkit.org/show_bug.cgi?id=198864
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Lookup `resolve` method only once in Promise.{all,allSettled,race}.
     9        (https://github.com/tc39/ecma262/pull/1506)
     10
     11        Already implemented in V8.
     12
     13        * builtins/PromiseConstructor.js:
     14
    1152019-06-19  Tadeu Zagallo  <tzagallo@apple.com>
    216
  • trunk/Source/JavaScriptCore/builtins/PromiseConstructor.js

    r245869 r246620  
    5757
    5858    try {
     59        var promiseResolve = this.resolve;
     60        if (typeof promiseResolve !== "function")
     61            @throwTypeError("Promise resolve is not a function");
     62
    5963        for (var value of iterable) {
    6064            @putByValDirect(values, index, @undefined);
    61             var nextPromise = this.resolve(value);
     65            var nextPromise = promiseResolve.@call(this, value);
    6266            var resolveElement = newResolveElement(index);
    6367            ++remainingElementsCount;
     
    137141
    138142    try {
     143        var promiseResolve = this.resolve;
     144        if (typeof promiseResolve !== "function")
     145            @throwTypeError("Promise resolve is not a function");
     146
    139147        for (var value of iterable) {
    140148            @putByValDirect(values, index, @undefined);
    141             var nextPromise = this.resolve(value);
     149            var nextPromise = promiseResolve.@call(this, value);
    142150            var [resolveElement, rejectElement] = newResolveRejectElements(index);
    143151            ++remainingElementsCount;
     
    166174
    167175    try {
     176        var promiseResolve = this.resolve;
     177        if (typeof promiseResolve !== "function")
     178            @throwTypeError("Promise resolve is not a function");
     179
    168180        for (var value of iterable) {
    169             var nextPromise = this.resolve(value);
     181            var nextPromise = promiseResolve.@call(this, value);
    170182            nextPromise.then(promiseCapability.@resolve, promiseCapability.@reject);
    171183        }
Note: See TracChangeset for help on using the changeset viewer.