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

Unified Diff: src/heap/mark-compact.cc

Issue 1844413002: Use EmbedderHeapTracer instead of object grouping when trace_embedder_heap flag is set (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporated Jochen's wonderful comments 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 | « src/heap/mark-compact.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 65ca4c3165359892dece9c134988c2661d5a917f..efe4412311fb7636eb58b2041b7e34da70018395 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -1916,6 +1916,19 @@ void MarkCompactCollector::EmptyMarkingDeque() {
MarkBit map_mark = Marking::MarkBitFrom(map);
MarkObject(map, map_mark);
+ if (UsingEmbedderHeapTracer() && object->IsJSObject()) {
Hannes Payer (out of office) 2016/04/01 11:13:36 As discussed offline, move this code to the proper
Marcel Hlopko 2016/04/01 12:47:20 Gave it a try, my tests still pass, so I hope I fo
+ JSObject* js_object = JSObject::cast(object);
+
+ if (js_object->GetInternalFieldCount() >= 2 &&
+ js_object->WasConstructedFromApiFunction() &&
+ js_object->GetInternalField(0) != heap()->undefined_value() &&
+ js_object->GetInternalField(1) != heap()->undefined_value()) {
+ wrappers_to_trace().push_back(std::pair<void*, void*>(
Hannes Payer (out of office) 2016/04/01 11:13:36 Could these be Object*?
Marcel Hlopko 2016/04/01 12:47:20 I'm afraid they cannot, from the v8 side they are
+ reinterpret_cast<void*>(js_object->GetInternalField(0)),
+ reinterpret_cast<void*>(js_object->GetInternalField(1))));
+ }
+ }
+
MarkCompactMarkingVisitor::IterateBody(map, object);
}
}
@@ -1962,6 +1975,9 @@ void MarkCompactCollector::ProcessMarkingDeque() {
}
}
+bool MarkCompactCollector::UsingEmbedderHeapTracer() const {
+ return FLAG_trace_embedder_heap && heap_->embedder_heap_tracer();
+}
// Mark all objects reachable (transitively) from objects on the marking
// stack including references only considered in the atomic marking pause.
@@ -1969,16 +1985,29 @@ void MarkCompactCollector::ProcessEphemeralMarking(
ObjectVisitor* visitor, bool only_process_harmony_weak_collections) {
bool work_to_do = true;
DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed());
+ v8::Isolate* api_isolate = reinterpret_cast<v8::Isolate*>(isolate());
Hannes Payer (out of office) 2016/04/01 11:13:36 This method now looks really complicated. Can we d
Marcel Hlopko 2016/04/01 12:47:20 I was not happy with the split into 2 methods, so
+ if (!only_process_harmony_weak_collections && UsingEmbedderHeapTracer()) {
+ heap()->embedder_heap_tracer()->TraceRoots(api_isolate);
+ }
while (work_to_do) {
if (!only_process_harmony_weak_collections) {
- isolate()->global_handles()->IterateObjectGroups(
- visitor, &IsUnmarkedHeapObjectWithHeap);
- MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject);
+ if (UsingEmbedderHeapTracer()) {
+ heap_->embedder_heap_tracer()->TraceWrappableFrom(api_isolate,
+ wrappers_to_trace_);
+ wrappers_to_trace_.clear();
+ } else {
+ isolate()->global_handles()->IterateObjectGroups(
+ visitor, &IsUnmarkedHeapObjectWithHeap);
+ MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject);
+ }
}
ProcessWeakCollections();
work_to_do = !marking_deque_.IsEmpty();
ProcessMarkingDeque();
}
+ if (!only_process_harmony_weak_collections && UsingEmbedderHeapTracer()) {
+ heap()->embedder_heap_tracer()->ClearTracingMarks(api_isolate);
+ }
}
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698