On Tue, Feb 27, 2018 at 5:49 AM, A.M. <cis74...@gmail.com> wrote: > Calling `SetWeak` like this: > > global_handle.SetWeak(parameter, &X::WeakCallback, > v8::WeakCallbackType::kInternalFields); > > , against a handle that contains an object with internal fields calls > `X::WeakCallback` with the parameter and both internal fields of > `v8::WeakCallbackInfo<v8::Global<v8::Object>>` always return `NULL`. > > Looking at > `v8::internal::GlobalHandles::Node::PostGarbageCollectionProcessing`, which > calls the weak callback, those internal fields are always `NULL`: > > void* embedder_fields[v8::kEmbedderFieldsInWeakCallback] = {nullptr, > nullptr}; > v8::WeakCallbackInfo<void> data(reinterpret_cast<v8::Isolate*>(isolate), > parameter(), embedder_fields, nullptr); > weak_callback_(data); > > > Is that some experimental feature or there's some way to make object's > internal fields available within the weak callback? > > Thanks
You're looking at the wrong code. GlobalHandles::Node::PostGarbageCollectionProcessing() only deals with weak handles, not phantom handles. WeakCallbackType::kInternalFields creates a phantom handle (confusing, I know) and those are dispatched in GlobalHandles::PostGarbageCollectionProcessing(). 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. :-) -- -- 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.