Commit 941251af authored by littledan's avatar littledan Committed by Commit bot

Disable non-standard Promise functions in staging

This patch removes Promise functions and methods which are absent
from the ES2015 specification when the --es-staging flag is on.

BUG=v8:3237
R=rossberg
LOG=Y

Review URL: https://codereview.chromium.org/1469543003

Cr-Commit-Position: refs/heads/master@{#32194}
parent 5aff14ad
......@@ -320,7 +320,8 @@ action("js2c_experimental") {
"src/js/harmony-reflect.js",
"src/js/harmony-object-observe.js",
"src/js/harmony-sharedarraybuffer.js",
"src/js/harmony-simd.js"
"src/js/harmony-simd.js",
"src/js/promise-extra.js"
]
outputs = [
......
......@@ -206,6 +206,7 @@ class Genesis BASE_EMBEDDED {
HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION)
HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION)
HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION)
DECLARE_FEATURE_INITIALIZATION(promise_extra, "")
#undef DECLARE_FEATURE_INITIALIZATION
Handle<JSFunction> InstallInternalArray(Handle<JSObject> target,
......@@ -1524,6 +1525,7 @@ void Genesis::InitializeExperimentalGlobal() {
HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL)
HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL)
HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL)
FEATURE_INITIALIZE_GLOBAL(promise_extra, "")
#undef FEATURE_INITIALIZE_GLOBAL
}
......@@ -2063,6 +2065,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_completion)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tolength)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(promise_extra)
static void SimpleInstallFunction(Handle<JSObject>& base, const char* name,
......@@ -2596,6 +2599,8 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_do_expressions_natives[] = {nullptr};
static const char* harmony_regexp_subclass_natives[] = {nullptr};
static const char* harmony_regexp_lookbehind_natives[] = {nullptr};
static const char* promise_extra_natives[] = {"native promise-extra.js",
nullptr};
for (int i = ExperimentalNatives::GetDebuggerCount();
i < ExperimentalNatives::GetBuiltinsCount(); i++) {
......@@ -2614,6 +2619,7 @@ bool Genesis::InstallExperimentalNatives() {
HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES);
HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES);
HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES);
INSTALL_EXPERIMENTAL_NATIVES(promise_extra, "");
#undef INSTALL_EXPERIMENTAL_NATIVES
}
......
......@@ -189,6 +189,10 @@ DEFINE_BOOL(legacy_const, true, "legacy semantics for const in sloppy mode")
// ES2015 const semantics are staged
DEFINE_NEG_IMPLICATION(harmony, legacy_const)
DEFINE_BOOL(promise_extra, true, "additional V8 Promise functions")
// Removing extra Promise functions is staged
DEFINE_NEG_IMPLICATION(es_staging, promise_extra)
// Activate on ClusterFuzz.
DEFINE_IMPLICATION(es_staging, harmony_destructuring_bind)
......
......@@ -202,6 +202,9 @@ function PostNatives(utils) {
"ObserveArrayMethods",
"ObserveObjectMethods",
"OwnPropertyKeys",
"PromiseChain",
"PromiseDeferred",
"PromiseResolved",
"SameValueZero",
"SetIterator",
"SetIteratorNext",
......
// Copyright 2015 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.
(function(global, utils) {
"use strict";
%CheckIsBootstrapping();
var GlobalPromise = global.Promise;
var PromiseChain = utils.ImportNow("PromiseChain");
var PromiseDeferred = utils.ImportNow("PromiseDeferred");
var PromiseResolved = utils.ImportNow("PromiseResolved");
utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
"chain", PromiseChain,
]);
%InstallToContext([
"promise_chain", PromiseChain,
]);
utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
"defer", PromiseDeferred,
"accept", PromiseResolved,
]);
})
......@@ -446,8 +446,6 @@ function PromiseHasUserDefinedRejectHandler() {
DONT_ENUM | READ_ONLY);
utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
"defer", PromiseDeferred,
"accept", PromiseResolved,
"reject", PromiseRejected,
"all", PromiseAll,
"race", PromiseRace,
......@@ -455,14 +453,12 @@ utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
]);
utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
"chain", PromiseChain,
"then", PromiseThen,
"catch", PromiseCatch
]);
%InstallToContext([
"promise_catch", PromiseCatch,
"promise_chain", PromiseChain,
"promise_create", PromiseCreate,
"promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler,
"promise_reject", PromiseReject,
......@@ -479,4 +475,14 @@ utils.InstallFunctions(extrasUtils, 0, [
"rejectPromise", PromiseReject
]);
// TODO(v8:4567): Allow experimental natives to remove function prototype
[PromiseChain, PromiseDeferred, PromiseResolved].forEach(
fn => %FunctionRemovePrototype(fn));
utils.Export(function(to) {
to.PromiseChain = PromiseChain;
to.PromiseDeferred = PromiseDeferred;
to.PromiseResolved = PromiseResolved;
});
})
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug
// Flags: --expose-debug-as debug --promise-extra
// Test reentry of special try catch for Promises.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we listen to uncaught exceptions and
// the Promise is rejected in a chained closure after it has been resolved.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we listen to all exceptions and
// there is a catch handler for the to-be-rejected Promise.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we only listen to uncaught exceptions, the Promise
// is rejected, and a catch handler is installed right before the rejection.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we only listen to uncaught exceptions and
// there is a catch handler for the to-be-rejected Promise.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we listen to all exceptions and
// there is a catch handler for the to-be-rejected Promise.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we only listen to uncaught exceptions and
// there is no catch handler for the to-be-rejected Promise.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when a Promise is rejected, which is caught by a custom
// promise, which has a number for reject closure. We expect an Exception debug
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when a Promise is rejected, which is caught by a
// custom promise, which throws a new exception in its reject handler.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when a Promise is rejected, which is caught by a custom
// promise, which has undefined for reject closure. We expect an Exception
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we listen to all exceptions and
// there is a catch handler for the exception thrown in a Promise.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we only listen to uncaught exceptions, the Promise
// throws, and a catch handler is installed right before throwing.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we only listen to uncaught exceptions and
// there is a catch handler for the exception thrown in a Promise.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we listen to all exceptions and
// there is no catch handler for the exception thrown in a Promise.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when we only listen to uncaught exceptions and
// there is a catch handler for the exception thrown in a Promise.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when an exception is thrown inside a Promise, which is
// caught by a custom promise, which throws a new exception in its reject
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra
// Test debug events when an exception is thrown inside a Promise, which is
// caught by a custom promise, which has no reject handler.
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --promise-extra
'use strict';
Object.defineProperties(Object.prototype, {
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --harmony-tostring
// Flags: --allow-natives-syntax --harmony-tostring --promise-extra
// Make sure we don't rely on functions patchable by monkeys.
var call = Function.prototype.call.call.bind(Function.prototype.call)
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax
// Flags: --allow-natives-syntax --promise-extra
var x = 0;
var y = 0;
......
......@@ -1879,6 +1879,7 @@
'../../src/js/harmony-object-observe.js',
'../../src/js/harmony-sharedarraybuffer.js',
'../../src/js/harmony-simd.js',
'../../src/js/promise-extra.js',
],
'code_stub_library_files': [
'../../src/js/macros.py',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment