[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
|
||||
* for given key.
|
||||
* TODO(hlopko) Remove once migration to reporter is finished.
|
||||
* Call V8::RegisterExternallyReferencedObject with the map value for given
|
||||
* key.
|
||||
*/
|
||||
void RegisterExternallyReferencedObject(K& key) {}
|
||||
|
||||
/**
|
||||
* Use EmbedderReachableReferenceReporter with the map value for given key.
|
||||
*/
|
||||
void RegisterExternallyReferencedObject(
|
||||
EmbedderReachableReferenceReporter* reporter, K& key) {
|
||||
void RegisterExternallyReferencedObject(K& 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.
|
||||
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
|
||||
* 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.
|
||||
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
|
||||
* is alive. Only allowed when the embedder is asked to trace its heap by
|
||||
* EmbedderHeapTracer.
|
||||
*/
|
||||
V8_INLINE void RegisterExternalReference(
|
||||
EmbedderReachableReferenceReporter* reporter) const;
|
||||
V8_INLINE void RegisterExternalReference(Isolate* isolate) const;
|
||||
|
||||
/**
|
||||
* 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 };
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
* from any of the given wrappers.
|
||||
* trace through its heap and use reporter to report each JavaScript object
|
||||
* reachable from any of the given wrappers.
|
||||
*
|
||||
* Before the first call to the TraceWrappersFrom function TracePrologue 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
|
||||
* embedder is expected to store them in its marking deque and trace
|
||||
* reachable wrappers from them when called through |AdvanceTracing|.
|
||||
* Called by v8 to register internal fields of found wrappers.
|
||||
*
|
||||
* The embedder is expected to store them somewhere and trace reachable
|
||||
* wrappers from them when called through |AdvanceTracing|.
|
||||
*/
|
||||
virtual void RegisterV8References(
|
||||
const std::vector<std::pair<void*, void*> >& internal_fields) = 0;
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* TODO(hlopko) Remove once the migration to reporter is finished.
|
||||
* Called at the beginning of a GC cycle.
|
||||
*/
|
||||
virtual void TracePrologue() {}
|
||||
virtual void TracePrologue() = 0;
|
||||
|
||||
/**
|
||||
* V8 will call this method at the beginning of a GC cycle. Embedder is
|
||||
* expected to use EmbedderReachableReferenceReporter for reporting all
|
||||
* reachable v8 objects.
|
||||
*/
|
||||
virtual void TracePrologue(EmbedderReachableReferenceReporter* reporter) {}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Called to to make a tracing step in the embedder.
|
||||
*
|
||||
* The embedder is expected to trace its heap starting from wrappers reported
|
||||
* by RegisterV8References method, and report back all reachable wrappers.
|
||||
* Furthermore, the embedder is expected to stop tracing by the given
|
||||
* deadline.
|
||||
*
|
||||
* Returns true if there is still work to do.
|
||||
*/
|
||||
@ -6232,22 +6211,25 @@ class V8_EXPORT EmbedderHeapTracer {
|
||||
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|.
|
||||
*/
|
||||
virtual void TraceEpilogue() = 0;
|
||||
|
||||
/**
|
||||
* Let embedder know v8 entered final marking pause (no more incremental steps
|
||||
* will follow).
|
||||
* Called upon entering the final marking pause. No more incremental marking
|
||||
* 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.
|
||||
@ -7560,6 +7542,9 @@ class V8_EXPORT V8 {
|
||||
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>
|
||||
friend class PersistentValueMapBase;
|
||||
|
||||
@ -8621,10 +8606,11 @@ P* PersistentBase<T>::ClearWeak() {
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void PersistentBase<T>::RegisterExternalReference(
|
||||
EmbedderReachableReferenceReporter* reporter) const {
|
||||
void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
|
||||
if (IsEmpty()) return;
|
||||
reporter->ReportExternalReference(this->val_);
|
||||
V8::RegisterExternallyReferencedObject(
|
||||
reinterpret_cast<internal::Object**>(this->val_),
|
||||
reinterpret_cast<internal::Isolate*>(isolate));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -812,6 +812,11 @@ i::Object** V8::CopyPersistent(i::Object** obj) {
|
||||
return result.location();
|
||||
}
|
||||
|
||||
void V8::RegisterExternallyReferencedObject(i::Object** object,
|
||||
i::Isolate* isolate) {
|
||||
isolate->heap()->RegisterExternallyReferencedObject(object);
|
||||
}
|
||||
|
||||
void V8::MakeWeak(i::Object** location, void* parameter,
|
||||
int internal_field_index1, int internal_field_index2,
|
||||
WeakCallbackInfo<void>::Callback weak_callback) {
|
||||
|
@ -156,7 +156,6 @@ Heap::Heap()
|
||||
strong_roots_list_(NULL),
|
||||
heap_iterator_depth_(0),
|
||||
embedder_heap_tracer_(nullptr),
|
||||
embedder_reference_reporter_(new TracePossibleWrapperReporter(this)),
|
||||
force_oom_(false),
|
||||
delay_sweeper_tasks_for_testing_(false) {
|
||||
// Allow build-time customization of the max semispace size. Building
|
||||
@ -5708,9 +5707,6 @@ void Heap::TearDown() {
|
||||
|
||||
delete memory_allocator_;
|
||||
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_; }
|
||||
|
||||
EmbedderReachableReferenceReporter* embedder_reachable_reference_reporter() {
|
||||
return embedder_reference_reporter_;
|
||||
}
|
||||
|
||||
size_t wrappers_to_trace() { return wrappers_to_trace_.size(); }
|
||||
|
||||
// ===========================================================================
|
||||
@ -2309,7 +2305,6 @@ class Heap {
|
||||
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.
|
||||
@ -2633,18 +2628,6 @@ 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
|
||||
|
||||
|
@ -528,8 +528,7 @@ void IncrementalMarking::StartMarking() {
|
||||
if (heap_->UsingEmbedderHeapTracer()) {
|
||||
TRACE_GC(heap()->tracer(),
|
||||
GCTracer::Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE);
|
||||
heap_->embedder_heap_tracer()->TracePrologue(
|
||||
heap_->embedder_reachable_reference_reporter());
|
||||
heap_->embedder_heap_tracer()->TracePrologue();
|
||||
}
|
||||
|
||||
RecordWriteStub::Mode mode = is_compacting_
|
||||
|
@ -811,8 +811,7 @@ void MarkCompactCollector::Prepare() {
|
||||
if (!was_marked_incrementally_) {
|
||||
if (heap_->UsingEmbedderHeapTracer()) {
|
||||
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_PROLOGUE);
|
||||
heap_->embedder_heap_tracer()->TracePrologue(
|
||||
heap_->embedder_reachable_reference_reporter());
|
||||
heap_->embedder_heap_tracer()->TracePrologue();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user