Index: src/heap/heap.h |
diff --git a/src/heap/heap.h b/src/heap/heap.h |
index 55914d66c0169f8d49c123b4aacfae65dd123742..b67f7c7a21d271d4775b04b4513a9f57ae263062 100644 |
--- a/src/heap/heap.h |
+++ b/src/heap/heap.h |
@@ -337,6 +337,7 @@ class Scavenger; |
class ScavengeJob; |
class Space; |
class StoreBuffer; |
+class TracePossibleWrapperReporter; |
class WeakObjectRetainer; |
typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); |
@@ -1204,12 +1205,26 @@ class Heap { |
void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer); |
- bool UsingEmbedderHeapTracer(); |
+ bool UsingEmbedderHeapTracer() { return embedder_heap_tracer() != nullptr; } |
void TracePossibleWrapper(JSObject* js_object); |
void RegisterExternallyReferencedObject(Object** object); |
+ void RegisterWrappersWithEmbedderHeapTracer(); |
+ |
+ // In order to avoid running out of memory we force tracing wrappers if there |
+ // are too many of them. |
+ bool RequiresImmediateWrapperProcessing(); |
+ |
+ EmbedderHeapTracer* embedder_heap_tracer() { return embedder_heap_tracer_; } |
+ |
+ EmbedderReachableReferenceReporter* embedder_reachable_reference_reporter() { |
+ return embedder_reference_reporter_; |
+ } |
+ |
+ size_t wrappers_to_trace() { return wrappers_to_trace_.size(); } |
+ |
// =========================================================================== |
// External string table API. ================================================ |
// =========================================================================== |
@@ -2321,6 +2336,10 @@ class Heap { |
// The depth of HeapIterator nestings. |
int heap_iterator_depth_; |
+ EmbedderHeapTracer* embedder_heap_tracer_; |
+ EmbedderReachableReferenceReporter* embedder_reference_reporter_; |
+ std::vector<std::pair<void*, void*>> wrappers_to_trace_; |
+ |
// Used for testing purposes. |
bool force_oom_; |
@@ -2644,6 +2663,18 @@ class AllocationObserver { |
DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
}; |
+class TracePossibleWrapperReporter : public EmbedderReachableReferenceReporter { |
+ public: |
+ explicit TracePossibleWrapperReporter(Heap* heap) : heap_(heap) {} |
+ void ReportExternalReference(Value* object) override { |
+ heap_->RegisterExternallyReferencedObject( |
+ reinterpret_cast<Object**>(object)); |
+ } |
+ |
+ private: |
+ Heap* heap_; |
+}; |
+ |
} // namespace internal |
} // namespace v8 |