Skip to content

Commit 1ab717d

Browse files
tzikCommit Bot
authored andcommitted
Expose the depth of MicrotasksScope per MicrotaskQueue
Blink used to use v8::MicrotasksScope::GetCurrentDepth() to get the number of nested MicrotasksScope for the default microtask queue. However, there was no corresponding one for non-default queues. Change-Id: I1c2472ba19b1a11cb968f02119d91d92867c6e02 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1567705 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Taiju Tsuiki <tzik@chromium.org> Cr-Commit-Position: refs/heads/master@{#60862}
1 parent 886c658 commit 1ab717d

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

include/v8.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6817,6 +6817,12 @@ class V8_EXPORT MicrotaskQueue {
68176817
*/
68186818
virtual bool IsRunningMicrotasks() const = 0;
68196819

6820+
/**
6821+
* Returns the current depth of nested MicrotasksScope that has
6822+
* kRunMicrotasks.
6823+
*/
6824+
virtual int GetMicrotasksScopeDepth() const = 0;
6825+
68206826
private:
68216827
friend class internal::MicrotaskQueue;
68226828
MicrotaskQueue() = default;

src/microtask-queue.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ void MicrotaskQueue::IterateMicrotasks(RootVisitor* visitor) {
211211
}
212212
}
213213

214+
int MicrotaskQueue::GetMicrotasksScopeDepth() const {
215+
return microtasks_depth_;
216+
}
217+
214218
void MicrotaskQueue::AddMicrotasksCompletedCallback(
215219
MicrotasksCompletedCallbackWithData callback, void* data) {
216220
CallbackWithData callback_with_data(callback, data);

src/microtask-queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class V8_EXPORT_PRIVATE MicrotaskQueue final : public v8::MicrotaskQueue {
6262
// invocation, which happens when depth reaches zero.
6363
void IncrementMicrotasksScopeDepth() { ++microtasks_depth_; }
6464
void DecrementMicrotasksScopeDepth() { --microtasks_depth_; }
65-
int GetMicrotasksScopeDepth() const { return microtasks_depth_; }
65+
int GetMicrotasksScopeDepth() const override;
6666

6767
// Possibly nested microtasks suppression scopes prevent microtasks
6868
// from running.

0 commit comments

Comments
 (0)