Commit 0eae5650 authored by hlopko's avatar hlopko Committed by Commit bot

Polish EmbedderHeapTracer and move some checks from blink to v8

Quick one, ptal.

BUG=468240
LOG=no

Review URL: https://codereview.chromium.org/1895753002

Cr-Commit-Position: refs/heads/master@{#35578}
parent a36ff8f0
......@@ -5413,16 +5413,16 @@ enum class MemoryPressureLevel { kNone, kModerate, kCritical };
* trace through its heap and call PersistentBase::RegisterExternalReference on
* each js object reachable from any of the given wrappers.
*
* Before the first call to the TraceWrappableFrom function v8 will call
* TraceRoots. When the v8 garbage collection is finished, v8 will call
* ClearTracingMarks.
* Before the first call to the TraceWrappersFrom function v8 will call
* TracePrologue. When the v8 garbage collection is finished, v8 will call
* TraceEpilogue.
*/
class EmbedderHeapTracer {
public:
/**
* V8 will call this method at the beginning of the gc cycle.
*/
virtual void TraceRoots(Isolate* isolate) = 0;
virtual void TracePrologue(Isolate* isolate) = 0;
/**
* V8 will call this method with internal fields of a potential wrappers.
......@@ -5430,14 +5430,14 @@ class EmbedderHeapTracer {
* PersistentBase::RegisterExternalReference() on all wrappers reachable from
* any of the given wrappers.
*/
virtual void TraceWrappableFrom(
virtual void TraceWrappersFrom(
Isolate* isolate,
const std::vector<std::pair<void*, void*> >& internal_fields) = 0;
/**
* V8 will call this method at the end of the gc cycle. Allocation is *not*
* allowed in the ClearTracingMarks.
* allowed in the TraceEpilogue.
*/
virtual void ClearTracingMarks(Isolate* isolate) = 0;
virtual void TraceEpilogue(Isolate* isolate) = 0;
protected:
virtual ~EmbedderHeapTracer() = default;
......
......@@ -2024,7 +2024,7 @@ void MarkCompactCollector::ProcessEphemeralMarking(
DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed());
while (work_to_do) {
if (UsingEmbedderHeapTracer()) {
embedder_heap_tracer()->TraceWrappableFrom(
embedder_heap_tracer()->TraceWrappersFrom(
reinterpret_cast<v8::Isolate*>(isolate()), wrappers_to_trace_);
wrappers_to_trace_.clear();
} else if (!only_process_harmony_weak_collections) {
......@@ -2145,8 +2145,10 @@ void MarkCompactCollector::SetEmbedderHeapTracer(EmbedderHeapTracer* tracer) {
void MarkCompactCollector::TracePossibleWrapper(JSObject* js_object) {
DCHECK(js_object->WasConstructedFromApiFunction());
if (js_object->GetInternalFieldCount() >= 2 &&
js_object->GetInternalField(0) &&
js_object->GetInternalField(0) != heap_->undefined_value() &&
js_object->GetInternalField(1) != heap_->undefined_value()) {
DCHECK(reinterpret_cast<intptr_t>(js_object->GetInternalField(0)) % 2 == 1);
wrappers_to_trace().push_back(std::pair<void*, void*>(
reinterpret_cast<void*>(js_object->GetInternalField(0)),
reinterpret_cast<void*>(js_object->GetInternalField(1))));
......@@ -2217,7 +2219,7 @@ void MarkCompactCollector::MarkLiveObjects() {
TRACE_GC(heap()->tracer(),
GCTracer::Scope::MC_MARK_WEAK_CLOSURE_EPHEMERAL);
if (UsingEmbedderHeapTracer()) {
embedder_heap_tracer()->TraceRoots(
embedder_heap_tracer()->TracePrologue(
reinterpret_cast<v8::Isolate*>(isolate()));
}
ProcessEphemeralMarking(&root_visitor, false);
......@@ -2257,7 +2259,7 @@ void MarkCompactCollector::MarkLiveObjects() {
ProcessEphemeralMarking(&root_visitor, true);
ProcessMarkingDeque();
if (UsingEmbedderHeapTracer()) {
embedder_heap_tracer()->ClearTracingMarks(
embedder_heap_tracer()->TraceEpilogue(
reinterpret_cast<v8::Isolate*>(isolate()));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment