Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(889)

Unified Diff: src/js/promise.js

Issue 1448933002: Introduce a BuiltinsConstructStub that sets up new.target and does a [[call]] per ES6 9.3.2 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/js/macros.py ('k') | src/js/proxy.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/promise.js
diff --git a/src/js/promise.js b/src/js/promise.js
index d84d70df4ec8eadcb700c260117759ebeac2195f..f0c9bb3b520ca1bda70fff1ad1f3baae3933a00d 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -61,11 +61,15 @@ function CreateResolvingFunctions(promise) {
var GlobalPromise = function Promise(resolver) {
- if (resolver === promiseRawSymbol) return;
- if (!%_IsConstructCall()) throw MakeTypeError(kNotAPromise, this);
+ if (resolver === promiseRawSymbol) {
+ return %NewObject(GlobalPromise, new.target);
+ }
+ if (IS_UNDEFINED(new.target)) throw MakeTypeError(kNotAPromise, this);
if (!IS_CALLABLE(resolver))
throw MakeTypeError(kResolverNotAFunction, resolver);
- var promise = PromiseInit(this);
+
+ var promise = PromiseInit(%NewObject(GlobalPromise, new.target));
+
try {
%DebugPushPromise(promise, Promise, resolver);
var callbacks = CreateResolvingFunctions(promise);
@@ -75,6 +79,8 @@ var GlobalPromise = function Promise(resolver) {
} finally {
%DebugPopPromise();
}
+
+ return promise;
}
// Core functionality.
« no previous file with comments | « src/js/macros.py ('k') | src/js/proxy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698