Update V8 to r7427: Initial merge by git
As required by WebKit r82507
Change-Id: I7ae83ef3f689356043b4929255b7c1dd31d8c5df
diff --git a/include/v8-profiler.h b/include/v8-profiler.h
index 675a229..db56e26 100644
--- a/include/v8-profiler.h
+++ b/include/v8-profiler.h
@@ -131,6 +131,16 @@
/** Returns the root node of the top down call tree. */
const CpuProfileNode* GetTopDownRoot() const;
+
+ /**
+ * Deletes the profile and removes it from CpuProfiler's list.
+ * All pointers to nodes previously returned become invalid.
+ * Profiles with the same uid but obtained using different
+ * security token are not deleted, but become inaccessible
+ * using FindProfile method. It is embedder's responsibility
+ * to call Delete on these profiles.
+ */
+ void Delete();
};
@@ -181,6 +191,13 @@
static const CpuProfile* StopProfiling(
Handle<String> title,
Handle<Value> security_token = Handle<Value>());
+
+ /**
+ * Deletes all existing profiles, also cancelling all profiling
+ * activity. All previously returned pointers to profiles and their
+ * contents become invalid after this call.
+ */
+ static void DeleteAllProfiles();
};
@@ -223,36 +240,21 @@
};
-class V8EXPORT HeapGraphPath {
- public:
- /** Returns the number of edges in the path. */
- int GetEdgesCount() const;
-
- /** Returns an edge from the path. */
- const HeapGraphEdge* GetEdge(int index) const;
-
- /** Returns origin node. */
- const HeapGraphNode* GetFromNode() const;
-
- /** Returns destination node. */
- const HeapGraphNode* GetToNode() const;
-};
-
-
/**
* HeapGraphNode represents a node in a heap graph.
*/
class V8EXPORT HeapGraphNode {
public:
enum Type {
- kHidden = 0, // Hidden node, may be filtered when shown to user.
- kArray = 1, // An array of elements.
- kString = 2, // A string.
- kObject = 3, // A JS object (except for arrays and strings).
- kCode = 4, // Compiled code.
- kClosure = 5, // Function closure.
- kRegExp = 6, // RegExp.
- kHeapNumber = 7 // Number stored in the heap.
+ kHidden = 0, // Hidden node, may be filtered when shown to user.
+ kArray = 1, // An array of elements.
+ kString = 2, // A string.
+ kObject = 3, // A JS object (except for arrays and strings).
+ kCode = 4, // Compiled code.
+ kClosure = 5, // Function closure.
+ kRegExp = 6, // RegExp.
+ kHeapNumber = 7, // Number stored in the heap.
+ kNative = 8 // Native object (not from V8 heap).
};
/** Returns node type (see HeapGraphNode::Type). */
@@ -307,12 +309,6 @@
/** Returns a retainer by index. */
const HeapGraphEdge* GetRetainer(int index) const;
- /** Returns the number of simple retaining paths from the root to the node. */
- int GetRetainingPathsCount() const;
-
- /** Returns a retaining path by index. */
- const HeapGraphPath* GetRetainingPath(int index) const;
-
/**
* Returns a dominator node. This is the node that participates in every
* path from the snapshot root to the current node.
@@ -321,16 +317,6 @@
};
-class V8EXPORT HeapSnapshotsDiff {
- public:
- /** Returns the root node for added nodes. */
- const HeapGraphNode* GetAdditionsRoot() const;
-
- /** Returns the root node for deleted nodes. */
- const HeapGraphNode* GetDeletionsRoot() const;
-};
-
-
/**
* HeapSnapshots record the state of the JS heap at some moment.
*/
@@ -361,10 +347,11 @@
const HeapGraphNode* GetNodeById(uint64_t id) const;
/**
- * Returns a diff between this snapshot and another one. Only snapshots
- * of the same type can be compared.
+ * Deletes the snapshot and removes it from HeapProfiler's list.
+ * All pointers to nodes, edges and paths previously returned become
+ * invalid.
*/
- const HeapSnapshotsDiff* CompareWith(const HeapSnapshot* snapshot) const;
+ void Delete();
/**
* Prepare a serialized representation of the snapshot. The result
@@ -392,11 +379,22 @@
};
+class RetainedObjectInfo;
+
/**
* Interface for controlling heap profiling.
*/
class V8EXPORT HeapProfiler {
public:
+ /**
+ * Callback function invoked for obtaining RetainedObjectInfo for
+ * the given JavaScript wrapper object. It is prohibited to enter V8
+ * while the callback is running: only getters on the handle and
+ * GetPointerFromInternalField on the objects are allowed.
+ */
+ typedef RetainedObjectInfo* (*WrapperInfoCallback)
+ (uint16_t class_id, Handle<Value> wrapper);
+
/** Returns the number of snapshots taken. */
static int GetSnapshotsCount();
@@ -414,6 +412,87 @@
Handle<String> title,
HeapSnapshot::Type type = HeapSnapshot::kFull,
ActivityControl* control = NULL);
+
+ /**
+ * Deletes all snapshots taken. All previously returned pointers to
+ * snapshots and their contents become invalid after this call.
+ */
+ static void DeleteAllSnapshots();
+
+ /** Binds a callback to embedder's class ID. */
+ static void DefineWrapperClass(
+ uint16_t class_id,
+ WrapperInfoCallback callback);
+
+ /**
+ * Default value of persistent handle class ID. Must not be used to
+ * define a class. Can be used to reset a class of a persistent
+ * handle.
+ */
+ static const uint16_t kPersistentHandleNoClassId = 0;
+};
+
+
+/**
+ * Interface for providing information about embedder's objects
+ * held by global handles. This information is reported in two ways:
+ *
+ * 1. When calling AddObjectGroup, an embedder may pass
+ * RetainedObjectInfo instance describing the group. To collect
+ * this information while taking a heap snapshot, V8 calls GC
+ * prologue and epilogue callbacks.
+ *
+ * 2. When a heap snapshot is collected, V8 additionally
+ * requests RetainedObjectInfos for persistent handles that
+ * were not previously reported via AddObjectGroup.
+ *
+ * Thus, if an embedder wants to provide information about native
+ * objects for heap snapshots, he can do it in a GC prologue
+ * handler, and / or by assigning wrapper class ids in the following way:
+ *
+ * 1. Bind a callback to class id by calling DefineWrapperClass.
+ * 2. Call SetWrapperClassId on certain persistent handles.
+ *
+ * V8 takes ownership of RetainedObjectInfo instances passed to it and
+ * keeps them alive only during snapshot collection. Afterwards, they
+ * are freed by calling the Dispose class function.
+ */
+class V8EXPORT RetainedObjectInfo { // NOLINT
+ public:
+ /** Called by V8 when it no longer needs an instance. */
+ virtual void Dispose() = 0;
+
+ /** Returns whether two instances are equivalent. */
+ virtual bool IsEquivalent(RetainedObjectInfo* other) = 0;
+
+ /**
+ * Returns hash value for the instance. Equivalent instances
+ * must have the same hash value.
+ */
+ virtual intptr_t GetHash() = 0;
+
+ /**
+ * Returns human-readable label. It must be a NUL-terminated UTF-8
+ * encoded string. V8 copies its contents during a call to GetLabel.
+ */
+ virtual const char* GetLabel() = 0;
+
+ /**
+ * Returns element count in case if a global handle retains
+ * a subgraph by holding one of its nodes.
+ */
+ virtual intptr_t GetElementCount() { return -1; }
+
+ /** Returns embedder's object size in bytes. */
+ virtual intptr_t GetSizeInBytes() { return -1; }
+
+ protected:
+ RetainedObjectInfo() {}
+ virtual ~RetainedObjectInfo() {}
+
+ private:
+ RetainedObjectInfo(const RetainedObjectInfo&);
+ RetainedObjectInfo& operator=(const RetainedObjectInfo&);
};