[promises] Remove unneeded PromiseCreate function from promise.js
This function was only needed for extrasUtils. Since it was simply calling a builtin function, just expose that builtin instead. This requires an arguments adapter frame for the builtin. As a drive-by fix, also added an arguments adapter for the extrasUtils.resolvePromise (and a regression test). Other cleanup: removed unused native context slot for PROMISE_SET_AND_CREATE. R=gsathya@chromium.org BUG=v8:5343 Review-Url: https://codereview.chromium.org/2626793003 Cr-Commit-Position: refs/heads/master@{#42284}
This commit is contained in:
parent
166ed96901
commit
a0e3a8ee89
@ -7222,7 +7222,7 @@ MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) {
|
||||
PREPARE_FOR_EXECUTION(context, Promise_Resolver, New, Resolver);
|
||||
i::Handle<i::Object> result;
|
||||
has_pending_exception =
|
||||
!i::Execution::Call(isolate, isolate->promise_create(),
|
||||
!i::Execution::Call(isolate, isolate->promise_internal_constructor(),
|
||||
isolate->factory()->undefined_value(), 0, NULL)
|
||||
.ToHandle(&result);
|
||||
RETURN_ON_FAILED_EXECUTION(Promise::Resolver);
|
||||
|
@ -1919,9 +1919,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
native_context()->set_promise_prototype_map(*prototype_map);
|
||||
|
||||
{ // Internal: PromiseInternalConstructor
|
||||
// Also exposed as extrasUtils.createPromise.
|
||||
Handle<JSFunction> function =
|
||||
SimpleCreateFunction(isolate, factory->empty_string(),
|
||||
Builtins::kPromiseInternalConstructor, 1, false);
|
||||
Builtins::kPromiseInternalConstructor, 1, true);
|
||||
InstallWithIntrinsicDefaultProto(
|
||||
isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX);
|
||||
}
|
||||
@ -1942,9 +1943,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
}
|
||||
|
||||
{ // Internal: ResolvePromise
|
||||
Handle<JSFunction> function =
|
||||
SimpleCreateFunction(isolate, factory->empty_string(),
|
||||
Builtins::kResolvePromise, 2, false);
|
||||
// Also exposed as extrasUtils.resolvePromise.
|
||||
Handle<JSFunction> function = SimpleCreateFunction(
|
||||
isolate, factory->empty_string(), Builtins::kResolvePromise, 2, true);
|
||||
InstallWithIntrinsicDefaultProto(isolate, function,
|
||||
Context::PROMISE_RESOLVE_INDEX);
|
||||
}
|
||||
@ -3652,6 +3653,8 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
|
||||
|
||||
InstallInternalArray(extras_utils, "InternalPackedArray", FAST_ELEMENTS);
|
||||
|
||||
InstallFunction(extras_utils, isolate()->promise_internal_constructor(),
|
||||
factory()->NewStringFromAsciiChecked("createPromise"));
|
||||
InstallFunction(extras_utils, isolate()->promise_resolve(),
|
||||
factory()->NewStringFromAsciiChecked("resolvePromise"));
|
||||
|
||||
|
@ -66,7 +66,6 @@ enum ContextLookupFlags {
|
||||
promise_internal_constructor) \
|
||||
V(IS_PROMISE_INDEX, JSFunction, is_promise) \
|
||||
V(PERFORM_PROMISE_THEN_INDEX, JSFunction, perform_promise_then) \
|
||||
V(PROMISE_CREATE_AND_SET_INDEX, JSFunction, promise_create_and_set) \
|
||||
V(PROMISE_RESOLVE_INDEX, JSFunction, promise_resolve) \
|
||||
V(PROMISE_THEN_INDEX, JSFunction, promise_then) \
|
||||
V(PROMISE_HANDLE_INDEX, JSFunction, promise_handle) \
|
||||
@ -103,7 +102,6 @@ enum ContextLookupFlags {
|
||||
V(OBJECT_VALUE_OF, JSFunction, object_value_of) \
|
||||
V(OBJECT_TO_STRING, JSFunction, object_to_string) \
|
||||
V(PROMISE_CATCH_INDEX, JSFunction, promise_catch) \
|
||||
V(PROMISE_CREATE_INDEX, JSFunction, promise_create) \
|
||||
V(PROMISE_FUNCTION_INDEX, JSFunction, promise_function) \
|
||||
V(PROMISE_REJECT_INDEX, JSFunction, promise_reject) \
|
||||
V(PROMISE_ID_RESOLVE_HANDLER_INDEX, JSFunction, promise_id_resolve_handler) \
|
||||
|
@ -31,11 +31,6 @@ SET_PRIVATE(PromiseIdRejectHandler, promiseForwardingHandlerSymbol, true);
|
||||
|
||||
// For bootstrapper.
|
||||
|
||||
// This is used by utils and v8-extras.
|
||||
function PromiseCreate(parent) {
|
||||
return %promise_internal_constructor(parent);
|
||||
}
|
||||
|
||||
// Export to bindings
|
||||
function DoRejectPromise(promise, reason) {
|
||||
%PromiseReject(promise, reason, true);
|
||||
@ -154,7 +149,6 @@ utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
|
||||
]);
|
||||
|
||||
%InstallToContext([
|
||||
"promise_create", PromiseCreate,
|
||||
"promise_reject", DoRejectPromise,
|
||||
"promise_id_resolve_handler", PromiseIdResolveHandler,
|
||||
"promise_id_reject_handler", PromiseIdRejectHandler
|
||||
@ -164,7 +158,6 @@ utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
|
||||
// resolve/reject closures, and allows them to later resolve and reject any
|
||||
// promise without having to hold on to those closures forever.
|
||||
utils.InstallFunctions(extrasUtils, 0, [
|
||||
"createPromise", PromiseCreate,
|
||||
"rejectPromise", DoRejectPromise,
|
||||
"markPromiseAsHandled", MarkPromiseAsHandled
|
||||
]);
|
||||
|
@ -53,7 +53,8 @@
|
||||
const fulfilledPromise = v8.createPromise();
|
||||
v8.resolvePromise(
|
||||
fulfilledPromise,
|
||||
hasOwn({ test: 'test' }, 'test') ? 1 : -1
|
||||
hasOwn({ test: 'test' }, 'test') ? 1 : -1,
|
||||
undefined // pass an extra arg to test arguments adapter frame
|
||||
);
|
||||
|
||||
const fulfilledPromise2 = Promise_resolve(call(function (arg1, arg2) {
|
||||
|
Loading…
Reference in New Issue
Block a user