https://codereview.chromium.org/649563006/diff/20001/include/v8.h
File include/v8.h (right):
https://codereview.chromium.org/649563006/diff/20001/include/v8.h#newcode520
include/v8.h:520: V8_INLINE void SetPhantom(P* parameter,
On 2014/10/20 14:03:10, ulan wrote:
Shouldn't phantom reference be in its own class, separate from
PersistentBase to
completely disallow dereferencing?
I think you want to allow deref before the object dies, otherwise I
don't think it is very useful.
What prevents the embedder stash a phantom reference p and then just
dereference
it in the finalizer like this:
Local<Object> obj = Local<Object>::New(isolate, p)?
and access a potentialy dead object (*obj)
I think nothing prevents this, but you can do that with normal weak
references too (not in the finalizer, but after resetting the
persistent/global). But because it is zapped, it is not until the
location is reused for something else or freed up entirely that you can
really run into problems - during the finalizer you will get the same
zapped value that the persistent looks at - just a Smi.
https://codereview.chromium.org/649563006/diff/20001/src/global-handles.cc
File src/global-handles.cc (right):
https://codereview.chromium.org/649563006/diff/20001/src/global-handles.cc#newcode256
src/global-handles.cc:256: DCHECK(*handle ==
Smi::FromInt(kPhantomReferenceZap));
On 2014/10/20 14:11:46, jochen wrote:
should we set handle to a null-handle here?
I think that's not so useful. The callback then doesn't have an
indication of which handle is being cleared. By just zapping the
contents, the callback still has the location to key on if it has a hash
map or similar. This is the value the callback gets by doing operator*
on the handle.
There is the parameter, but often that is used to identify the
per-isolate object that holds state, not the individual reference that
is dying. We could add a second parameter, but that seems
over-engineered somehow.
https://codereview.chromium.org/649563006/
--
--
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].
For more options, visit https://groups.google.com/d/optout.