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

Unified Diff: src/heap-snapshot-generator.cc

Issue 13786002: [WIP] New GC related APIs. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: use old testing machinery Created 7 years, 8 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/global-handles.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap-snapshot-generator.cc
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index fb239aa3cf6dd82cc04af83c7be2afdcac8ac470..4bc3fe1d7b58fd7a16e45d02dfc107f19aa47cf0 100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -1940,17 +1940,43 @@ void NativeObjectsExplorer::FillRetainedObjects() {
const GCType major_gc_type = kGCTypeMarkSweepCompact;
// Record objects that are joined into ObjectGroups.
isolate->heap()->CallGCPrologueCallbacks(major_gc_type);
- List<ObjectGroup*>* groups = isolate->global_handles()->object_groups();
- for (int i = 0; i < groups->length(); ++i) {
- ObjectGroup* group = groups->at(i);
- if (group->info_ == NULL) continue;
- List<HeapObject*>* list = GetListMaybeDisposeInfo(group->info_);
- for (size_t j = 0; j < group->length_; ++j) {
- HeapObject* obj = HeapObject::cast(*group->objects_[j]);
- list->Add(obj);
- in_groups_.Insert(obj);
+
+ List<ObjectGroupConnection>* groups =
+ isolate->global_handles()->object_groups();
+ List<ObjectGroupRetainerInfo>* infos =
+ isolate->global_handles()->retainer_infos();
+ groups->Sort();
+ infos->Sort();
+
+ int info_ix = 0;
+ UniqueId current_group_id(0);
+ size_t current_group_start = 0;
+
+ if (groups->length() > 0) {
+ for (int i = 0; i <= groups->length(); ++i) {
+ if (i == 0)
+ current_group_id = groups->at(i).id;
+ if (i == groups->length() ||
+ current_group_id != groups->at(i).id) {
+ // Group detected: objects in indices [current_group_start, i[.
+ if (info_ix < infos->length() &&
+ infos->at(info_ix).id == groups->at(current_group_start).id) {
+ // Transfer the ownership of info.
+ List<HeapObject*>* list =
+ GetListMaybeDisposeInfo(infos->at(info_ix).info);
+ infos->at(info_ix).info = NULL;
+ for (int j = current_group_start; j < i; ++j) {
+ HeapObject* obj = HeapObject::cast(*(groups->at(j).object));
+ list->Add(obj);
+ in_groups_.Insert(obj);
+ }
+ }
+ if (i < groups->length()) {
+ current_group_id = groups->at(i).id;
+ current_group_start = i;
+ }
+ }
}
- group->info_ = NULL; // Acquire info object ownership.
}
isolate->global_handles()->RemoveObjectGroups();
isolate->heap()->CallGCEpilogueCallbacks(major_gc_type);
« no previous file with comments | « src/global-handles.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698