[api] Remove EmbedderReachableReferenceReporter
API was highly experimental. Embedders should use V8::RegisterExternalReference instead. BUG=chromium:468240 R=jochen@chromium.org Review-Url: https://codereview.chromium.org/2474163002 Cr-Commit-Position: refs/heads/master@{#40769}
This commit is contained in:
parent
581614eeea
commit
5b1de36d93
@ -206,19 +206,14 @@ class PersistentValueMapBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deprecated. Call V8::RegisterExternallyReferencedObject with the map value
|
* Call V8::RegisterExternallyReferencedObject with the map value for given
|
||||||
* for given key.
|
* key.
|
||||||
* TODO(hlopko) Remove once migration to reporter is finished.
|
|
||||||
*/
|
*/
|
||||||
void RegisterExternallyReferencedObject(K& key) {}
|
void RegisterExternallyReferencedObject(K& key) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Use EmbedderReachableReferenceReporter with the map value for given key.
|
|
||||||
*/
|
|
||||||
void RegisterExternallyReferencedObject(
|
|
||||||
EmbedderReachableReferenceReporter* reporter, K& key) {
|
|
||||||
DCHECK(Contains(key));
|
DCHECK(Contains(key));
|
||||||
reporter->ReportExternalReference(FromVal(Traits::Get(&impl_, key)));
|
V8::RegisterExternallyReferencedObject(
|
||||||
|
reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))),
|
||||||
|
reinterpret_cast<internal::Isolate*>(GetIsolate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
78
include/v8.h
78
include/v8.h
@ -462,16 +462,6 @@ class WeakCallbackInfo {
|
|||||||
// possible to request a second pass callback.
|
// possible to request a second pass callback.
|
||||||
enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer };
|
enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer };
|
||||||
|
|
||||||
/**
|
|
||||||
* A reporter class that embedder will use to report reachable references found
|
|
||||||
* by EmbedderHeapTracer.
|
|
||||||
*/
|
|
||||||
class V8_EXPORT EmbedderReachableReferenceReporter {
|
|
||||||
public:
|
|
||||||
virtual void ReportExternalReference(Value* object) = 0;
|
|
||||||
virtual ~EmbedderReachableReferenceReporter() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object reference that is independent of any handle scope. Where
|
* An object reference that is independent of any handle scope. Where
|
||||||
* a Local handle only lives as long as the HandleScope in which it was
|
* a Local handle only lives as long as the HandleScope in which it was
|
||||||
@ -568,19 +558,12 @@ template <class T> class PersistentBase {
|
|||||||
// TODO(dcarney): remove this.
|
// TODO(dcarney): remove this.
|
||||||
V8_INLINE void ClearWeak() { ClearWeak<void>(); }
|
V8_INLINE void ClearWeak() { ClearWeak<void>(); }
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated.
|
|
||||||
* TODO(hlopko): remove once migration to reporter is finished.
|
|
||||||
*/
|
|
||||||
V8_INLINE void RegisterExternalReference(Isolate* isolate) const {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the embedder to tell the v8 garbage collector that a certain object
|
* Allows the embedder to tell the v8 garbage collector that a certain object
|
||||||
* is alive. Only allowed when the embedder is asked to trace its heap by
|
* is alive. Only allowed when the embedder is asked to trace its heap by
|
||||||
* EmbedderHeapTracer.
|
* EmbedderHeapTracer.
|
||||||
*/
|
*/
|
||||||
V8_INLINE void RegisterExternalReference(
|
V8_INLINE void RegisterExternalReference(Isolate* isolate) const;
|
||||||
EmbedderReachableReferenceReporter* reporter) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the reference to this object independent. Garbage collector is free
|
* Marks the reference to this object independent. Garbage collector is free
|
||||||
@ -6179,11 +6162,11 @@ class V8_EXPORT PersistentHandleVisitor { // NOLINT
|
|||||||
enum class MemoryPressureLevel { kNone, kModerate, kCritical };
|
enum class MemoryPressureLevel { kNone, kModerate, kCritical };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for tracing through the embedder heap. During the v8 garbage
|
* Interface for tracing through the embedder heap. During a v8 garbage
|
||||||
* collection, v8 collects hidden fields of all potential wrappers, and at the
|
* 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
|
* end of its marking phase iterates the collection and asks the embedder to
|
||||||
* trace through its heap and use reporter to report each js object reachable
|
* trace through its heap and use reporter to report each JavaScript object
|
||||||
* from any of the given wrappers.
|
* reachable from any of the given wrappers.
|
||||||
*
|
*
|
||||||
* Before the first call to the TraceWrappersFrom function TracePrologue will be
|
* Before the first call to the TraceWrappersFrom function TracePrologue will be
|
||||||
* called. When the garbage collection cycle is finished, TraceEpilogue will be
|
* called. When the garbage collection cycle is finished, TraceEpilogue will be
|
||||||
@ -6201,30 +6184,26 @@ class V8_EXPORT EmbedderHeapTracer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* V8 will call this method with internal fields of found wrappers. The
|
* Called by v8 to register internal fields of found wrappers.
|
||||||
* embedder is expected to store them in its marking deque and trace
|
*
|
||||||
* reachable wrappers from them when called through |AdvanceTracing|.
|
* The embedder is expected to store them somewhere and trace reachable
|
||||||
|
* wrappers from them when called through |AdvanceTracing|.
|
||||||
*/
|
*/
|
||||||
virtual void RegisterV8References(
|
virtual void RegisterV8References(
|
||||||
const std::vector<std::pair<void*, void*> >& internal_fields) = 0;
|
const std::vector<std::pair<void*, void*> >& internal_fields) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deprecated.
|
* Called at the beginning of a GC cycle.
|
||||||
* TODO(hlopko) Remove once the migration to reporter is finished.
|
|
||||||
*/
|
*/
|
||||||
virtual void TracePrologue() {}
|
virtual void TracePrologue() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* V8 will call this method at the beginning of a GC cycle. Embedder is
|
* Called to to make a tracing step in the embedder.
|
||||||
* expected to use EmbedderReachableReferenceReporter for reporting all
|
*
|
||||||
* reachable v8 objects.
|
* The embedder is expected to trace its heap starting from wrappers reported
|
||||||
*/
|
* by RegisterV8References method, and report back all reachable wrappers.
|
||||||
virtual void TracePrologue(EmbedderReachableReferenceReporter* reporter) {}
|
* Furthermore, the embedder is expected to stop tracing by the given
|
||||||
|
* deadline.
|
||||||
/**
|
|
||||||
* Embedder is expected to trace its heap starting from wrappers reported by
|
|
||||||
* RegisterV8References method, and use reporter for all reachable wrappers.
|
|
||||||
* Embedder is expected to stop tracing by the given deadline.
|
|
||||||
*
|
*
|
||||||
* Returns true if there is still work to do.
|
* Returns true if there is still work to do.
|
||||||
*/
|
*/
|
||||||
@ -6232,22 +6211,25 @@ class V8_EXPORT EmbedderHeapTracer {
|
|||||||
AdvanceTracingActions actions) = 0;
|
AdvanceTracingActions actions) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* V8 will call this method at the end of a GC cycle.
|
* Called at the end of a GC cycle.
|
||||||
*
|
*
|
||||||
* Note that allocation is *not* allowed within |TraceEpilogue|.
|
* Note that allocation is *not* allowed within |TraceEpilogue|.
|
||||||
*/
|
*/
|
||||||
virtual void TraceEpilogue() = 0;
|
virtual void TraceEpilogue() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Let embedder know v8 entered final marking pause (no more incremental steps
|
* Called upon entering the final marking pause. No more incremental marking
|
||||||
* will follow).
|
* steps will follow this call.
|
||||||
*/
|
*/
|
||||||
virtual void EnterFinalPause() {}
|
virtual void EnterFinalPause() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw away all intermediate data and reset to the initial state.
|
* Called when tracing is aborted.
|
||||||
|
*
|
||||||
|
* The embedder is expected to throw away all intermediate data and reset to
|
||||||
|
* the initial state.
|
||||||
*/
|
*/
|
||||||
virtual void AbortTracing() {}
|
virtual void AbortTracing() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of wrappers that are still to be traced by the embedder.
|
* Returns the number of wrappers that are still to be traced by the embedder.
|
||||||
@ -7560,6 +7542,9 @@ class V8_EXPORT V8 {
|
|||||||
int* index);
|
int* index);
|
||||||
static Local<Value> GetEternal(Isolate* isolate, int index);
|
static Local<Value> GetEternal(Isolate* isolate, int index);
|
||||||
|
|
||||||
|
static void RegisterExternallyReferencedObject(internal::Object** object,
|
||||||
|
internal::Isolate* isolate);
|
||||||
|
|
||||||
template <class K, class V, class T>
|
template <class K, class V, class T>
|
||||||
friend class PersistentValueMapBase;
|
friend class PersistentValueMapBase;
|
||||||
|
|
||||||
@ -8621,10 +8606,11 @@ P* PersistentBase<T>::ClearWeak() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PersistentBase<T>::RegisterExternalReference(
|
void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
|
||||||
EmbedderReachableReferenceReporter* reporter) const {
|
|
||||||
if (IsEmpty()) return;
|
if (IsEmpty()) return;
|
||||||
reporter->ReportExternalReference(this->val_);
|
V8::RegisterExternallyReferencedObject(
|
||||||
|
reinterpret_cast<internal::Object**>(this->val_),
|
||||||
|
reinterpret_cast<internal::Isolate*>(isolate));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -812,6 +812,11 @@ i::Object** V8::CopyPersistent(i::Object** obj) {
|
|||||||
return result.location();
|
return result.location();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V8::RegisterExternallyReferencedObject(i::Object** object,
|
||||||
|
i::Isolate* isolate) {
|
||||||
|
isolate->heap()->RegisterExternallyReferencedObject(object);
|
||||||
|
}
|
||||||
|
|
||||||
void V8::MakeWeak(i::Object** location, void* parameter,
|
void V8::MakeWeak(i::Object** location, void* parameter,
|
||||||
int internal_field_index1, int internal_field_index2,
|
int internal_field_index1, int internal_field_index2,
|
||||||
WeakCallbackInfo<void>::Callback weak_callback) {
|
WeakCallbackInfo<void>::Callback weak_callback) {
|
||||||
|
@ -156,7 +156,6 @@ Heap::Heap()
|
|||||||
strong_roots_list_(NULL),
|
strong_roots_list_(NULL),
|
||||||
heap_iterator_depth_(0),
|
heap_iterator_depth_(0),
|
||||||
embedder_heap_tracer_(nullptr),
|
embedder_heap_tracer_(nullptr),
|
||||||
embedder_reference_reporter_(new TracePossibleWrapperReporter(this)),
|
|
||||||
force_oom_(false),
|
force_oom_(false),
|
||||||
delay_sweeper_tasks_for_testing_(false) {
|
delay_sweeper_tasks_for_testing_(false) {
|
||||||
// Allow build-time customization of the max semispace size. Building
|
// Allow build-time customization of the max semispace size. Building
|
||||||
@ -5708,9 +5707,6 @@ void Heap::TearDown() {
|
|||||||
|
|
||||||
delete memory_allocator_;
|
delete memory_allocator_;
|
||||||
memory_allocator_ = nullptr;
|
memory_allocator_ = nullptr;
|
||||||
|
|
||||||
delete embedder_reference_reporter_;
|
|
||||||
embedder_reference_reporter_ = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1199,10 +1199,6 @@ class Heap {
|
|||||||
|
|
||||||
EmbedderHeapTracer* embedder_heap_tracer() { return embedder_heap_tracer_; }
|
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(); }
|
size_t wrappers_to_trace() { return wrappers_to_trace_.size(); }
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@ -2309,7 +2305,6 @@ class Heap {
|
|||||||
int heap_iterator_depth_;
|
int heap_iterator_depth_;
|
||||||
|
|
||||||
EmbedderHeapTracer* embedder_heap_tracer_;
|
EmbedderHeapTracer* embedder_heap_tracer_;
|
||||||
EmbedderReachableReferenceReporter* embedder_reference_reporter_;
|
|
||||||
std::vector<std::pair<void*, void*>> wrappers_to_trace_;
|
std::vector<std::pair<void*, void*>> wrappers_to_trace_;
|
||||||
|
|
||||||
// Used for testing purposes.
|
// Used for testing purposes.
|
||||||
@ -2633,18 +2628,6 @@ class AllocationObserver {
|
|||||||
DISALLOW_COPY_AND_ASSIGN(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 internal
|
||||||
} // namespace v8
|
} // namespace v8
|
||||||
|
|
||||||
|
@ -528,8 +528,7 @@ void IncrementalMarking::StartMarking() {
|
|||||||
if (heap_->UsingEmbedderHeapTracer()) {
|
if (heap_->UsingEmbedderHeapTracer()) {
|
||||||
TRACE_GC(heap()->tracer(),
|
TRACE_GC(heap()->tracer(),
|
||||||
GCTracer::Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE);
|
GCTracer::Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE);
|
||||||
heap_->embedder_heap_tracer()->TracePrologue(
|
heap_->embedder_heap_tracer()->TracePrologue();
|
||||||
heap_->embedder_reachable_reference_reporter());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordWriteStub::Mode mode = is_compacting_
|
RecordWriteStub::Mode mode = is_compacting_
|
||||||
|
@ -811,8 +811,7 @@ void MarkCompactCollector::Prepare() {
|
|||||||
if (!was_marked_incrementally_) {
|
if (!was_marked_incrementally_) {
|
||||||
if (heap_->UsingEmbedderHeapTracer()) {
|
if (heap_->UsingEmbedderHeapTracer()) {
|
||||||
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_PROLOGUE);
|
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_PROLOGUE);
|
||||||
heap_->embedder_heap_tracer()->TracePrologue(
|
heap_->embedder_heap_tracer()->TracePrologue();
|
||||||
heap_->embedder_reachable_reference_reporter());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user