Diff
Modified: trunk/JSTests/ChangeLog (266895 => 266896)
--- trunk/JSTests/ChangeLog 2020-09-10 22:57:50 UTC (rev 266895)
+++ trunk/JSTests/ChangeLog 2020-09-10 23:02:57 UTC (rev 266896)
@@ -1,5 +1,14 @@
2020-09-10 Alexey Shvayka <[email protected]>
+ Promise.prototype.finally should perform PromiseResolve
+ https://bugs.webkit.org/show_bug.cgi?id=176006
+
+ Reviewed by Yusuke Suzuki.
+
+ * test262/expectations.yaml: Mark 4 test cases as passing.
+
+2020-09-10 Alexey Shvayka <[email protected]>
+
Update test262 to commit 323905b70e64
https://bugs.webkit.org/show_bug.cgi?id=216379
Modified: trunk/JSTests/test262/expectations.yaml (266895 => 266896)
--- trunk/JSTests/test262/expectations.yaml 2020-09-10 22:57:50 UTC (rev 266895)
+++ trunk/JSTests/test262/expectations.yaml 2020-09-10 23:02:57 UTC (rev 266896)
@@ -838,12 +838,6 @@
test/built-ins/Object/seal/proxy-no-ownkeys-returned-keys-order.js:
default: 'Test262Error: Expected [0, Symbol(), foo] and [0, foo, Symbol()] to have the same contents. '
strict mode: 'Test262Error: Expected [0, Symbol(), foo] and [0, foo, Symbol()] to have the same contents. '
-test/built-ins/Promise/prototype/finally/rejected-observable-then-calls-PromiseResolve.js:
- default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«6», «5») to be true'
- strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«6», «5») to be true'
-test/built-ins/Promise/prototype/finally/resolved-observable-then-calls-PromiseResolve.js:
- default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«6», «5») to be true'
- strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«6», «5») to be true'
test/built-ins/Proxy/apply/arguments-realm.js:
default: 'Test262Error: Expected SameValue(«function Array() {'
strict mode: 'Test262Error: Expected SameValue(«function Array() {'
Modified: trunk/Source/_javascript_Core/ChangeLog (266895 => 266896)
--- trunk/Source/_javascript_Core/ChangeLog 2020-09-10 22:57:50 UTC (rev 266895)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-09-10 23:02:57 UTC (rev 266896)
@@ -1,3 +1,24 @@
+2020-09-10 Alexey Shvayka <[email protected]>
+
+ Promise.prototype.finally should perform PromiseResolve
+ https://bugs.webkit.org/show_bug.cgi?id=176006
+
+ Reviewed by Yusuke Suzuki.
+
+ This patch extracts @promiseResolve global private function and utilizes it in
+ Promise.prototype.finally then/catch functions [1] to avoid creating an extra
+ Promise Capability. Aligns JSC with V8 and SpiderMonkey.
+
+ [1]: https://tc39.es/ecma262/#sec-thenfinallyfunctions (step 7)
+
+ * builtins/PromiseConstructor.js:
+ (resolve):
+ * builtins/PromiseOperations.js:
+ (globalPrivate.promiseResolve):
+ * builtins/PromisePrototype.js:
+ (globalPrivate.getThenFinally):
+ (globalPrivate.getCatchFinally):
+
2020-09-10 Devin Rousso <[email protected]>
Web Inspector: modernize generated backend protocol code
Modified: trunk/Source/_javascript_Core/builtins/PromiseConstructor.js (266895 => 266896)
--- trunk/Source/_javascript_Core/builtins/PromiseConstructor.js 2020-09-10 22:57:50 UTC (rev 266895)
+++ trunk/Source/_javascript_Core/builtins/PromiseConstructor.js 2020-09-10 23:02:57 UTC (rev 266896)
@@ -263,19 +263,7 @@
if (!@isObject(this))
@throwTypeError("|this| is not an object");
- if (@isPromise(value)) {
- var valueConstructor = value.constructor;
- if (valueConstructor === this)
- return value;
- }
-
- if (this === @Promise) {
- var promise = @newPromise();
- @resolvePromiseWithFirstResolvingFunctionCallCheck(promise, value);
- return promise;
- }
-
- return @promiseResolveSlow(this, value);
+ return @promiseResolve(this, value);
}
@nakedConstructor
Modified: trunk/Source/_javascript_Core/builtins/PromiseOperations.js (266895 => 266896)
--- trunk/Source/_javascript_Core/builtins/PromiseOperations.js 2020-09-10 22:57:50 UTC (rev 266895)
+++ trunk/Source/_javascript_Core/builtins/PromiseOperations.js 2020-09-10 23:02:57 UTC (rev 266896)
@@ -90,6 +90,21 @@
}
@globalPrivate
+function promiseResolve(constructor, value)
+{
+ if (@isPromise(value) && value.constructor === constructor)
+ return value;
+
+ if (constructor === @Promise) {
+ var promise = @newPromise();
+ @resolvePromiseWithFirstResolvingFunctionCallCheck(promise, value);
+ return promise;
+ }
+
+ return @promiseResolveSlow(constructor, value);
+}
+
+@globalPrivate
function promiseResolveSlow(constructor, value)
{
@assert(constructor !== @Promise);
Modified: trunk/Source/_javascript_Core/builtins/PromisePrototype.js (266895 => 266896)
--- trunk/Source/_javascript_Core/builtins/PromisePrototype.js 2020-09-10 22:57:50 UTC (rev 266895)
+++ trunk/Source/_javascript_Core/builtins/PromisePrototype.js 2020-09-10 23:02:57 UTC (rev 266896)
@@ -89,11 +89,8 @@
var result = onFinally();
@assert(@isConstructor(constructor));
- var resultCapability = @newPromiseCapability(constructor);
+ var promise = @promiseResolve(constructor, result);
- resultCapability.@resolve.@call(@undefined, result);
-
- var promise = resultCapability.@promise;
return promise.then(() => value);
}
}
@@ -109,11 +106,8 @@
var result = onFinally();
@assert(@isConstructor(constructor));
- var resultCapability = @newPromiseCapability(constructor);
+ var promise = @promiseResolve(constructor, result);
- resultCapability.@resolve.@call(@undefined, result);
-
- var promise = resultCapability.@promise;
return promise.then(() => { throw reason; });
}
}