Not much help or documentation from Google here. I suppose they expect 
everybody just to Google it. Anyway, just in case if anyone is interested, 
here's what's going on here.

The method `v8::internal::GlobalHandles::Node::CollectPhantomCallbackData` 
packs internal fields in this loop:

    if (weakness_type() != PHANTOM_WEAK && object()->IsJSObject()) {
      auto jsobject = JSObject::cast(object());
      int field_count = jsobject->GetEmbedderFieldCount();
      for (int i = 0; i < v8::kEmbedderFieldsInWeakCallback; ++i) {
        if (field_count == i) break;
        auto field = jsobject->GetEmbedderField(i);
        if (field->IsSmi()) embedder_fields[i] = field;
      }
    }

The call `IsSmi` checks whether the least significant bit is zero or not, 
as follows:

const int kSmiTag = 0;
const int kSmiTagSize = 1;
const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
...

#define HAS_SMI_TAG(value) \
  ((reinterpret_cast<intptr_t>(value) & ::i::kSmiTagMask) == ::i::kSmiTag)

So, internal fields in weak handle callbacks only passed in as non-NULL 
values for v8 integer object type, which has this bit set, and not for 
arbitrary object types. 

A comment about this around where `kInternalFields` is defined would be 
nice. 







-- 
-- 
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