On Tue, Jan 15, 2019 at 7:12 PM 'Kenton Varda' via v8-users <
[email protected]> wrote:

> Thanks, Michael, this gives me a better idea of what to look for.
>
> I'm a little surprised because I had always assumed that tracing was
> triggered during allocation. When else does it run?
>

We used to run the embedder tracing only as part of incremental tasks. For
Blink this guarantees V8 that there's no relevant C++ stack when invoking
the EmbedderHeapTracer.

Since 7.2 we are also able to run it as part of allocations.


>
> Also, what counts as allocation? Does allocating a new persistent handle
> in itself count, or is it strictly allocating objects?
>

Allocating JS objects on the managed heap. This does not include persistent
handles themselves


>
> I've designed my code such that when a reference to an object exists on
> the C++ stack, I call ClearWeak() on the persistent handle. Once all C++
> stack references go away, I call SetWeak() again. Could this possibly
> confuse the tracer if a trace is in-progress? Should I, for example, be
> calling RegisterExternalReference() after SetWeak()?
>

- The ClearWeak part should work if there's a final GC pause interrupting
whatever is done with C++ stack.
- The SetWeak after being done may or may not require a manual registering
call, depending on how EmbedderHeapTracer is implemented.

In Blink we implemented regular traced garbage collection for the
EmbedderHeapTracer. This means that the object containing such an
interesting references may have been processed by the EmbedderHeapTracer
already. If the reference is then just marked as weak with SetWeak() the GC
misses out on it as it never sees the containing object again. Blink emits
a RegisterExternalReference() call for such objects. The general concept
for solving mutation in the graph while a garbage collector is running is
called (write barrier).

You can check whether this is the problem by disabling incremental marking
for wrappers (--no_incremental_marking_wrappers).

-Michael

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to