Commit 0d8b253c authored by gsathya's avatar gsathya Committed by Commit bot

Move PromiseNextMicrotaskID to cpp

BUG=v8:5343

Review-Url: https://codereview.chromium.org/2425553003
Cr-Commit-Position: refs/heads/master@{#40405}
parent 8bb2cef9
......@@ -403,6 +403,7 @@ typedef List<HeapObject*> DebugObjectCache;
V(base::HashMap*, external_reference_map, nullptr) \
V(base::HashMap*, root_index_map, nullptr) \
V(int, pending_microtask_count, 0) \
V(int, debug_microtask_count, 0) \
V(HStatistics*, hstatistics, nullptr) \
V(CompilationStatistics*, turbo_statistics, nullptr) \
V(HTracer*, htracer, nullptr) \
......@@ -1104,6 +1105,7 @@ class Isolate {
void EnqueueMicrotask(Handle<Object> microtask);
void RunMicrotasks();
bool IsRunningMicrotasks() const { return is_running_microtasks_; }
int GetNextDebugMicrotaskId() { return debug_microtask_count_++; }
void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback);
void CountUsage(v8::Isolate::UseCounterFeature feature);
......
......@@ -30,7 +30,6 @@ utils.Import(function(from) {
NewPromiseCapability = from.NewPromiseCapability;
PerformPromiseThen = from.PerformPromiseThen;
PromiseCreate = from.PromiseCreate;
PromiseNextMicrotaskID = from.PromiseNextMicrotaskID;
RejectPromise = from.RejectPromise;
ResolvePromise = from.ResolvePromise;
});
......@@ -143,7 +142,7 @@ function AsyncFunctionPromiseCreate() {
%DebugPushPromise(promise);
// Assign ID and create a recurring task to save stack for future
// resumptions from await.
var id = PromiseNextMicrotaskID();
var id = %DebugNextMicrotaskId();
SET_PRIVATE(promise, promiseAsyncStackIDSymbol, id);
%DebugAsyncTaskEvent("enqueueRecurring", id, "async function");
}
......
......@@ -48,12 +48,6 @@ const kPending = 0;
const kFulfilled = +1;
const kRejected = -1;
var lastMicrotaskId = 0;
function PromiseNextMicrotaskID() {
return ++lastMicrotaskId;
}
// ES#sec-createresolvingfunctions
// CreateResolvingFunctions ( promise )
function CreateResolvingFunctions(promise, debugEvent) {
......@@ -202,7 +196,7 @@ function PromiseEnqueue(value, tasks, deferreds, status) {
promiseAsyncStackIDSymbol);
name = "async function";
} else {
id = PromiseNextMicrotaskID();
id = %DebugNextMicrotaskId();
name = status === kFulfilled ? "Promise.resolve" : "Promise.reject";
%DebugAsyncTaskEvent("enqueue", id, name);
}
......@@ -307,7 +301,7 @@ function ResolvePromise(promise, resolution) {
// Mark the dependency of the new promise on the resolution
SET_PRIVATE(resolution, promiseHandledBySymbol, promise);
}
id = PromiseNextMicrotaskID();
id = %DebugNextMicrotaskId();
name = "PromiseResolveThenableJob";
%DebugAsyncTaskEvent("enqueue", id, name);
}
......@@ -687,7 +681,6 @@ utils.Export(function(to) {
to.IsPromise = IsPromise;
to.PromiseCreate = PromiseCreate;
to.PromiseThen = PromiseThen;
to.PromiseNextMicrotaskID = PromiseNextMicrotaskID;
to.GlobalPromise = GlobalPromise;
to.NewPromiseCapability = NewPromiseCapability;
......
......@@ -1822,6 +1822,11 @@ RUNTIME_FUNCTION(Runtime_DebugPopPromise) {
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugNextMicrotaskId) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
return Smi::FromInt(isolate->GetNextDebugMicrotaskId());
}
RUNTIME_FUNCTION(Runtime_DebugAsyncTaskEvent) {
DCHECK(args.length() == 3);
......
......@@ -194,6 +194,7 @@ namespace internal {
F(DebugRecordAsyncFunction, 1, 1) \
F(DebugPushPromise, 1, 1) \
F(DebugPopPromise, 0, 1) \
F(DebugNextMicrotaskId, 0, 1) \
F(DebugAsyncTaskEvent, 3, 1) \
F(DebugIsActive, 0, 1) \
F(DebugBreakInOptimizedCode, 0, 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