We have a library wrapping v8, that is used both in Node (where the 
MicrotasksPolicy is kExplicit) and Chromium (where it's kScoped).

There is a DCHECK in ~CallDepthScope 
<https://github.com/v8/v8/blob/lkgr/src/api/api-inl.h#L181-L189> that means 
a MicrotasksScope object is needed for every call into v8, if the policy is 
set to kScoped.

When the policy is set to kExplicit, however, these scopes are not 
required.  Instead it is assumed the embedder will call PerformCheckpoint 
at the correct spot(s).

The implementation of PerformCheckpoint, however, first checks whether it 
should 
actually perform a checkpoint 
<https://github.com/v8/v8/blob/lkgr/src/execution/microtask-queue.h#L49-L52>. 
 This check includes whether microtasks are currently being executed, 
whether there are any SupressMicrotaskExecutionScope objects, and whether 
there are any MicrotasksScope objects (with kRunMicrotasks).

This means that the presence of MicrotasksScope objects (required for 
kScoped) inhibit the execution of microtasks when the policy is set to 
kExplicit.

For us, this means we have been conditionally compiling in MicrotasksScope 
objects when building for an environment where we know the policy will be 
kScoped.  This is fragile though, as the policy is a runtime setting, not a 
build time setting.

Is there any reason why PerformCheckpoint needs to check the 
MicrotasksScope depth when the policy is not kScoped?

Thanks,
Daryl.

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/36e28142-e8bb-47fd-95c5-362498d27cd9n%40googlegroups.com.

Reply via email to