v8::Persistent MarkIndependent, what does this method exactly do?
Asked Answered
X

1

11

Following is v8 code comment, I don't quite understand explaination.

/**
 * Marks the reference to this object independent. Garbage collector
 * is free to ignore any object groups containing this object.
 * Weak callback for an independent handle should not
 * assume that it will be preceded by a global GC prologue callback
 * or followed by a global GC epilogue callback.
 */
inline void MarkIndependent();
inline void MarkIndependent(Isolate* isolate);
Xiphoid answered 24/5, 2013 at 9:3 Comment(0)
S
0

From a post on v8-users:

I think the exact meaning of 'independent' has shifted a little since 3.24. Here is my understanding of what it does in recent versions of V8:

  1. It avoids the cost of object group handling. We don't use object groups in node.js but I think chromium does for DOM objects; if one DOM object in the collection is alive, then logically all are. Defining an object group lets the garbage collector take a shortcut at a cost of some processing overhead per individual handle.

  2. Independent handles can be reclaimed during minor garbage collections (scavenges). Dependent handles are only reclaimed during major collections and thus remain alive longer, which is usually undesirable; I think they only become eligible for collection once the object they point to has been promoted from the new space (the nursery) to the old space.

Sikko answered 1/10, 2016 at 15:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.