On Wed, Feb 28, 2018 at 6:05 AM, A.M. <cis74...@gmail.com> wrote:
> On Tuesday, 27 February 2018 19:21:03 UTC-5, Ben Noordhuis wrote:
>>
>> IIRC, it's a two-pass system: first pass should reset the persistent
>> handle, second pass is the real finalizer.  Preempting the question of
>> why it works that way: I don't know. :-)
>
> Thanks for the insights. I think I see what you are saying, but even if I
> set up the second pass callback, both internal fields within the second
> callback are still `NULL`. How can I set up the weak callback to receive
> internal fields of the object instance that is being destroyed?

I don't rightly know.  We never used this mechanism in Node.js and I
don't know if it's still used in Chromium.  It might have been an
experiment that didn't pan out.

V8 still seems to use it internally for a few things (i18n, mostly) so
I assume it must still be doing _something_.

> I also noticed that the second pass callback is called much less frequent
> than the first callback and if the actual clean-up is done in the second
> callback, allocations would pile up at a higher rate. From the code it
> appears that the second pass callbacks are done only if
> `synchronous_second_pass` is set. Can you elaborate how second pass
> callbacks are scheduled?

>From a background thread, unless `--optimize_for_size` or
`--predictable` is set, in which case they run on the foreground
thread.

> Further to this, my understanding is that in order to process phantom
> handles generated by weak callbacks, I need to call `PumpMessageLoop`
> periodically. The comment above this function says this:
>
>> The caller has to make sure that this is called from the right thread.
>
> What's the "right" thread in this context? If it's the same thread that runs
> the script, how can one pump the message loop if the script never returns?
> Am I supposed to synchronize with the script thread in v8 callbacks and pump
> for messages?

The foreground thread.  If the script never yields control, you can't
pump the message loop.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to