Title: [246620] trunk
Revision
246620
Author
[email protected]
Date
2019-06-19 17:38:20 -0700 (Wed, 19 Jun 2019)

Log Message

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

Patch by Alexey Shvayka <[email protected]> on 2019-06-19
Reviewed by Yusuke Suzuki.

JSTests:

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

Source/_javascript_Core:

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

Already implemented in V8.

* builtins/PromiseConstructor.js:

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (246619 => 246620)


--- trunk/JSTests/ChangeLog	2019-06-20 00:18:22 UTC (rev 246619)
+++ trunk/JSTests/ChangeLog	2019-06-20 00:38:20 UTC (rev 246620)
@@ -1,3 +1,12 @@
+2019-06-19  Alexey Shvayka  <[email protected]>
+
+        Optimize `resolve` method lookup in Promise static methods
+        https://bugs.webkit.org/show_bug.cgi?id=198864
+
+        Reviewed by Yusuke Suzuki.
+
+        * test262/expectations.yaml: Mark 18 test cases as passing.
+
 2019-06-19  Justin Michaud  <[email protected]>
 
         [WASM-References] Rename anyfunc to funcref

Modified: trunk/JSTests/test262/expectations.yaml (246619 => 246620)


--- trunk/JSTests/test262/expectations.yaml	2019-06-20 00:18:22 UTC (rev 246619)
+++ trunk/JSTests/test262/expectations.yaml	2019-06-20 00:38:20 UTC (rev 246620)
@@ -1095,27 +1095,9 @@
 test/built-ins/Object/subclass-object-arg.js:
   default: 'Test262Error: Expected SameValue(«undefined», «1») to be true'
   strict mode: 'Test262Error: Expected SameValue(«undefined», «1») to be true'
-test/built-ins/Promise/all/invoke-resolve-get-error-close.js:
-  default: 'Test262Error: Expected SameValue(«1», «0») to be true'
-  strict mode: 'Test262Error: Expected SameValue(«1», «0») to be true'
-test/built-ins/Promise/all/invoke-resolve-get-once-multiple-calls.js:
-  default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
-  strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
-test/built-ins/Promise/all/invoke-resolve-get-once-no-calls.js:
-  default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
-  strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
 test/built-ins/Promise/all/resolve-element-function-nonconstructor.js:
   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
-test/built-ins/Promise/allSettled/invoke-resolve-get-error-close.js:
-  default: 'Test262Error: Expected SameValue(«1», «0») to be true'
-  strict mode: 'Test262Error: Expected SameValue(«1», «0») to be true'
-test/built-ins/Promise/allSettled/invoke-resolve-get-once-multiple-calls.js:
-  default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
-  strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
-test/built-ins/Promise/allSettled/invoke-resolve-get-once-no-calls.js:
-  default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
-  strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
 test/built-ins/Promise/allSettled/reject-element-function-nonconstructor.js:
   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
@@ -1128,15 +1110,6 @@
 test/built-ins/Promise/proto-from-ctor-realm.js:
   default: 'Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true'
   strict mode: 'Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true'
-test/built-ins/Promise/race/invoke-resolve-get-error-close.js:
-  default: 'Test262Error: Expected SameValue(«1», «0») to be true'
-  strict mode: 'Test262Error: Expected SameValue(«1», «0») to be true'
-test/built-ins/Promise/race/invoke-resolve-get-once-multiple-calls.js:
-  default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
-  strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«4», «1») to be true'
-test/built-ins/Promise/race/invoke-resolve-get-once-no-calls.js:
-  default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
-  strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(«0», «1») to be true'
 test/built-ins/Promise/reject-function-nonconstructor.js:
   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'

Modified: trunk/Source/_javascript_Core/ChangeLog (246619 => 246620)


--- trunk/Source/_javascript_Core/ChangeLog	2019-06-20 00:18:22 UTC (rev 246619)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-06-20 00:38:20 UTC (rev 246620)
@@ -1,3 +1,17 @@
+2019-06-19  Alexey Shvayka  <[email protected]>
+
+        Optimize `resolve` method lookup in Promise static methods
+        https://bugs.webkit.org/show_bug.cgi?id=198864
+
+        Reviewed by Yusuke Suzuki.
+
+        Lookup `resolve` method only once in Promise.{all,allSettled,race}.
+        (https://github.com/tc39/ecma262/pull/1506)
+
+        Already implemented in V8.
+
+        * builtins/PromiseConstructor.js:
+
 2019-06-19  Tadeu Zagallo  <[email protected]>
 
         Some of the ASSERTs in CachedTypes.cpp should be RELEASE_ASSERTs

Modified: trunk/Source/_javascript_Core/builtins/PromiseConstructor.js (246619 => 246620)


--- trunk/Source/_javascript_Core/builtins/PromiseConstructor.js	2019-06-20 00:18:22 UTC (rev 246619)
+++ trunk/Source/_javascript_Core/builtins/PromiseConstructor.js	2019-06-20 00:38:20 UTC (rev 246620)
@@ -56,9 +56,13 @@
     }
 
     try {
+        var promiseResolve = this.resolve;
+        if (typeof promiseResolve !== "function")
+            @throwTypeError("Promise resolve is not a function");
+
         for (var value of iterable) {
             @putByValDirect(values, index, @undefined);
-            var nextPromise = this.resolve(value);
+            var nextPromise = promiseResolve.@call(this, value);
             var resolveElement = newResolveElement(index);
             ++remainingElementsCount;
             nextPromise.then(resolveElement, promiseCapability.@reject);
@@ -136,9 +140,13 @@
     }
 
     try {
+        var promiseResolve = this.resolve;
+        if (typeof promiseResolve !== "function")
+            @throwTypeError("Promise resolve is not a function");
+
         for (var value of iterable) {
             @putByValDirect(values, index, @undefined);
-            var nextPromise = this.resolve(value);
+            var nextPromise = promiseResolve.@call(this, value);
             var [resolveElement, rejectElement] = newResolveRejectElements(index);
             ++remainingElementsCount;
             nextPromise.then(resolveElement, rejectElement);
@@ -165,8 +173,12 @@
     var promiseCapability = @newPromiseCapability(this);
 
     try {
+        var promiseResolve = this.resolve;
+        if (typeof promiseResolve !== "function")
+            @throwTypeError("Promise resolve is not a function");
+
         for (var value of iterable) {
-            var nextPromise = this.resolve(value);
+            var nextPromise = promiseResolve.@call(this, value);
             nextPromise.then(promiseCapability.@resolve, promiseCapability.@reject);
         }
     } catch (error) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to