Title: [273605] trunk/Source/_javascript_Core
Revision
273605
Author
[email protected]
Date
2021-02-26 16:37:31 -0800 (Fri, 26 Feb 2021)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (273604 => 273605)


--- trunk/Source/_javascript_Core/ChangeLog	2021-02-27 00:32:12 UTC (rev 273604)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-02-27 00:37:31 UTC (rev 273605)
@@ -1,3 +1,20 @@
+2021-02-26  Yusuke Suzuki  <[email protected]>
+
+        [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.
+
 2021-02-26  Michael Saboff  <[email protected]>
 
         unexpected minimumInputSize in setupDisjunctionOffsets for regexp engine(yarr)

Modified: trunk/Source/_javascript_Core/builtins/PromiseOperations.js (273604 => 273605)


--- trunk/Source/_javascript_Core/builtins/PromiseOperations.js	2021-02-27 00:32:12 UTC (rev 273604)
+++ trunk/Source/_javascript_Core/builtins/PromiseOperations.js	2021-02-27 00:37:31 UTC (rev 273605)
@@ -520,15 +520,31 @@
 }
 
 @globalPrivate
+function promiseEmptyOnFulfilled(argument)
+{
+    "use strict";
+
+    return argument;
+}
+
+@globalPrivate
+function promiseEmptyOnRejected(argument)
+{
+    "use strict";
+
+    throw argument;
+}
+
+@globalPrivate
 function performPromiseThen(promise, onFulfilled, onRejected, promiseOrCapability)
 {
     "use strict";
 
     if (!@isCallable(onFulfilled))
-        _onFulfilled_ = function (argument) { return argument; };
+        _onFulfilled_ = @promiseEmptyOnFulfilled;
 
     if (!@isCallable(onRejected))
-        _onRejected_ = function (argument) { throw argument; };
+        _onRejected_ = @promiseEmptyOnRejected;
 
     var reaction = @newPromiseReaction(promiseOrCapability, onFulfilled, onRejected);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to