Commit c6722aea authored by gsathya's avatar gsathya Committed by Commit bot

[promises] remove PromiseEnqueue

Removes PromiseEnqueue and moves debugging code to a separate
function which gets called when the debugger is active.

BUG=v8:5343

Review-Url: https://codereview.chromium.org/2450763002
Cr-Commit-Position: refs/heads/master@{#40562}
parent 9d5b307f
......@@ -95,6 +95,7 @@ enum ContextLookupFlags {
V(PROMISE_HANDLE_INDEX, JSFunction, promise_handle) \
V(PROMISE_HAS_USER_DEFINED_REJECT_HANDLER_INDEX, JSFunction, \
promise_has_user_defined_reject_handler) \
V(PROMISE_DEBUG_GET_INFO_INDEX, JSFunction, promise_debug_get_info) \
V(PROMISE_REJECT_INDEX, JSFunction, promise_reject) \
V(PROMISE_RESOLVE_INDEX, JSFunction, promise_resolve) \
V(PROMISE_THEN_INDEX, JSFunction, promise_then) \
......
......@@ -146,7 +146,7 @@ function FulfillPromise(promise, status, value, promiseQueue) {
var tasks = GET_PRIVATE(promise, promiseQueue);
if (!IS_UNDEFINED(tasks)) {
var deferred = GET_PRIVATE(promise, promiseDeferredReactionSymbol);
PromiseEnqueue(value, tasks, deferred, status);
%EnqueuePromiseReactionJob(value, tasks, deferred, status);
}
PromiseSet(promise, status, value);
}
......@@ -176,7 +176,7 @@ function PromiseHandle(value, handler, deferred) {
}
}
function PromiseEnqueue(value, tasks, deferreds, status) {
function PromiseDebugGetInfo(deferreds, status) {
var id, name, instrumenting = DEBUG_IS_ACTIVE;
if (instrumenting) {
......@@ -199,7 +199,7 @@ function PromiseEnqueue(value, tasks, deferreds, status) {
%DebugAsyncTaskEvent("enqueue", id, name);
}
}
%EnqueuePromiseReactionJob(value, tasks, deferreds, id, name);
return [id, name];
}
function PromiseAttachCallbacks(promise, deferred, onResolve, onReject) {
......@@ -388,8 +388,8 @@ function PerformPromiseThen(promise, onResolve, onReject, resultCapability) {
PromiseAttachCallbacks(promise, resultCapability, onResolve, onReject);
break;
case kFulfilled:
PromiseEnqueue(GET_PRIVATE(promise, promiseResultSymbol),
onResolve, resultCapability, kFulfilled);
%EnqueuePromiseReactionJob(GET_PRIVATE(promise, promiseResultSymbol),
onResolve, resultCapability, kFulfilled);
break;
case kRejected:
if (!HAS_DEFINED_PRIVATE(promise, promiseHasHandlerSymbol)) {
......@@ -397,8 +397,8 @@ function PerformPromiseThen(promise, onResolve, onReject, resultCapability) {
// Revoke previously triggered reject event.
%PromiseRevokeReject(promise);
}
PromiseEnqueue(GET_PRIVATE(promise, promiseResultSymbol),
onReject, resultCapability, kRejected);
%EnqueuePromiseReactionJob(GET_PRIVATE(promise, promiseResultSymbol),
onReject, resultCapability, kRejected);
break;
}
......@@ -657,7 +657,8 @@ utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
"promise_reject", DoRejectPromise,
"promise_resolve", ResolvePromise,
"promise_then", PromiseThen,
"promise_handle", PromiseHandle
"promise_handle", PromiseHandle,
"promise_debug_get_info", PromiseDebugGetInfo
]);
// This allows extras to create promises quickly without building extra
......
......@@ -11,6 +11,7 @@
#include "src/bootstrapper.h"
#include "src/conversions.h"
#include "src/debug/debug.h"
#include "src/elements.h"
#include "src/frames-inl.h"
#include "src/isolate-inl.h"
#include "src/messages.h"
......@@ -573,12 +574,29 @@ RUNTIME_FUNCTION(Runtime_GetAndResetRuntimeCallStats) {
RUNTIME_FUNCTION(Runtime_EnqueuePromiseReactionJob) {
HandleScope scope(isolate);
DCHECK(args.length() == 5);
DCHECK(args.length() == 4);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, tasks, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, deferred, 2);
CONVERT_ARG_HANDLE_CHECKED(Object, debug_id, 3);
CONVERT_ARG_HANDLE_CHECKED(Object, debug_name, 4);
CONVERT_ARG_HANDLE_CHECKED(Object, status, 3);
Handle<Object> debug_id = isolate->factory()->undefined_value();
Handle<Object> debug_name = isolate->factory()->undefined_value();
if (isolate->debug()->is_active()) {
Handle<Object> argv[] = {deferred, status};
MaybeHandle<Object> maybe_result = Execution::TryCall(
isolate, isolate->promise_debug_get_info(),
isolate->factory()->undefined_value(), arraysize(argv), argv);
Handle<Object> result;
if ((maybe_result).ToHandle(&result)) {
CHECK(result->IsJSArray());
Handle<JSArray> array = Handle<JSArray>::cast(result);
ElementsAccessor* accessor = array->GetElementsAccessor();
DCHECK(accessor->HasElement(array, 0));
DCHECK(accessor->HasElement(array, 1));
debug_id = accessor->Get(array, 0);
debug_name = accessor->Get(array, 1);
}
}
Handle<PromiseReactionJobInfo> info =
isolate->factory()->NewPromiseReactionJobInfo(value, tasks, deferred,
debug_id, debug_name,
......
......@@ -290,7 +290,7 @@ namespace internal {
F(CheckIsBootstrapping, 0, 1) \
F(CreateListFromArrayLike, 1, 1) \
F(EnqueueMicrotask, 1, 1) \
F(EnqueuePromiseReactionJob, 5, 1) \
F(EnqueuePromiseReactionJob, 4, 1) \
F(EnqueuePromiseResolveThenableJob, 4, 1) \
F(GetAndResetRuntimeCallStats, -1 /* <= 2 */, 1) \
F(ExportExperimentalFromRuntime, 1, 1) \
......
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