9c0c876129
In the PerformPromise{All, Race, AllSettled} operations, the resolve property of the constructor is looked up only once. In the implementation, for the fast path, where the constructor's resolve property is untainted, the resolve function is set to undefined. Since undefined can't be a valid value for the resolve function, we can switch on it (in CallResolve) to directly call the PromiseResolve builtin. If the resolve property is tainted, we do an observable property lookup, save this value, and call this property later (in CallResolve). I ran this CL against the test262 tests locally and they all pass: https://github.com/tc39/test262/pull/2131 Spec: - https://github.com/tc39/ecma262/pull/1506 - https://github.com/tc39/proposal-promise-allSettled/pull/40 Bug: v8:9152 Change-Id: Icb36a90b5a244a67a729611c7b3315d2c29de6e9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1574705 Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#60957}
29 lines
612 B
JavaScript
29 lines
612 B
JavaScript
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
//
|
|
// Flags: --allow-natives-syntax
|
|
|
|
let count = 0;
|
|
class MyPromise extends Promise {
|
|
static get resolve() {
|
|
count++;
|
|
return super.resolve;
|
|
}
|
|
}
|
|
|
|
MyPromise.race([1, 2, 3, 4, 5]);
|
|
assertEquals(1, count);
|
|
%PerformMicrotaskCheckpoint();
|
|
assertEquals(1, count);
|
|
|
|
count = 0;
|
|
MyPromise.race([
|
|
Promise.resolve(1),
|
|
Promise.resolve(2),
|
|
Promise.reject(3)
|
|
]);
|
|
assertEquals(1, count);
|
|
%PerformMicrotaskCheckpoint();
|
|
assertEquals(1, count);
|