Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Unified Diff: include/v8.h

Issue 1815153002: Introduce EmbedderHeapTracer (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Gave the api a week to settle down and this is the result Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/api.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index db2178b73becb2c7ad76a5f28e8b81e4c14d1c33..053010e7bde738dc87302704d54055c86d281a21 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5361,6 +5361,53 @@ class V8_EXPORT PersistentHandleVisitor { // NOLINT
enum class MemoryPressureLevel { kNone, kModerate, kCritical };
/**
+ * Structure representing hidden fields of the v8 object. Embedder sets these
+ * fields on wrapper creation to be able to access the object wrapped by the
+ * wrapper.
+ */
+struct WrapperHiddenFields {
jochen (gone - plz use gerrit) 2016/03/30 16:44:45 why not just std::pair<void*,void*>?
Marcel Hlopko 2016/03/30 18:51:12 Because I didn't know it exists :) Done.
+ WrapperHiddenFields(void* wrapper_info_ptr, void* wrapper_source_ptr)
+ : wrapper_info(wrapper_info_ptr), wrapper_source(wrapper_source_ptr) {}
+ void* wrapper_info;
+ void* wrapper_source;
+};
+
+/**
+ * Interface for tracing through the embedder heap. During the v8 garbage
+ * collection, v8 collects hidden fields of all potential wrappers, and at the
+ * end of its marking phase iterates the collection and asks the embedder to
+ * trace through its heap and call Isolate::AddObjectToMarkingDeque for each js
+ * object reachable from the given one.
+ *
+ * Before the first call to the TraceWrappableFrom function v8 will call
+ * TraceRoots. When the v8 garbage collection is finished, v8 will call
+ * ClearTracingMarks.
+ */
+class EmbedderHeapTracer {
+ public:
+ /**
+ * V8 will call this method at the beginning of the gc cycle.
+ */
+ virtual void TraceRoots(Isolate* isolate) {}
jochen (gone - plz use gerrit) 2016/03/30 16:44:45 = 0; also add an empty line after this one
Marcel Hlopko 2016/03/30 18:51:12 done
+ /**
+ * V8 will call this method with internal fields of a potential wrapper.
+ * Embedder is expected to trace its heap (synchronously) and call
+ * Isolate::AddObjectToMarkingDeque() with all wrappers reachable from the
+ * given one.
+ */
+ virtual void TraceWrappableFrom(Isolate* isolate,
+ WrapperHiddenFields internal_fields) {}
jochen (gone - plz use gerrit) 2016/03/30 16:44:45 same here. why not pass a const std::vector<Hidde
Marcel Hlopko 2016/03/30 18:51:12 Done
+ /**
+ * V8 will call this method at the end of the gc cycle. Allocation is *not*
+ * allowed in the ClearTracingMarks.
+ */
+ virtual void ClearTracingMarks(Isolate* isolate) {}
jochen (gone - plz use gerrit) 2016/03/30 16:44:45 = 0;
Marcel Hlopko 2016/03/30 18:51:11 Done
+
+ protected:
+ virtual ~EmbedderHeapTracer() {}
jochen (gone - plz use gerrit) 2016/03/30 16:44:45 = default;
Marcel Hlopko 2016/03/30 18:51:12 Done
+};
+
+/**
* Isolate represents an isolated instance of the V8 engine. V8 isolates have
* completely separate states. Objects from one isolate must not be used in
* other isolates. The embedder can create multiple isolates and use them in
@@ -5587,6 +5634,13 @@ class V8_EXPORT Isolate {
static Isolate* GetCurrent();
/**
+ * Allows the embedder to add objects to the marking deque of the v8 garbage
+ * collector. Only allowed when the embedder is asked to trace its heap by
+ * EmbedderHeapTracer.
+ */
+ void AddObjectToMarkingDeque(PersistentBase<Object>* handle);
jochen (gone - plz use gerrit) 2016/03/30 16:44:45 why not make this a member of PersistentBase?
Marcel Hlopko 2016/03/30 18:51:11 Done
+
+ /**
* Custom callback used by embedders to help V8 determine if it should abort
* when it throws and no internal handler is predicted to catch the
* exception. If --abort-on-uncaught-exception is used on the command line,
@@ -5829,6 +5883,16 @@ class V8_EXPORT Isolate {
void RemoveGCPrologueCallback(GCCallback callback);
/**
+ * Sets the embedder heap tracer for the isolate.
+ */
+ void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
+
+ /**
+ * Gets embedder heap tracer associated with the isolate, or nullptr.
+ */
+ EmbedderHeapTracer* embedder_heap_tracer();
jochen (gone - plz use gerrit) 2016/03/30 16:44:45 shouldn't be needed
Marcel Hlopko 2016/03/30 18:51:11 Sure it's not :) Removed.
+
+ /**
* Enables the host application to receive a notification after a
* garbage collection. Allocations are allowed in the callback function,
* but the callback is not re-entrant: if the allocation inside it will
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698