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

Unified Diff: src/global-handles.cc

Issue 13341: Improve mark-compact object grouping interface. (Closed)
Patch Set: Tests. Created 12 years 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.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/global-handles.cc
diff --git a/src/global-handles.cc b/src/global-handles.cc
index 29ad86e0514fd6089a46572f00a578c8352454cc..a92f0df30656ac625b1fc203fb0aae5fcb99d4df 100644
--- a/src/global-handles.cc
+++ b/src/global-handles.cc
@@ -352,29 +352,26 @@ void GlobalHandles::Print() {
#endif
-List<ObjectGroup*> GlobalHandles::object_groups_(4);
-
-void GlobalHandles::AddToGroup(void* id, Object** handle) {
- for (int i = 0; i < object_groups_.length(); i++) {
- ObjectGroup* entry = object_groups_[i];
- if (entry->id_ == id) {
- entry->objects_.Add(handle);
- return;
- }
- }
+List<ObjectGroup*>* GlobalHandles::ObjectGroups() {
+ // Lazily initialize the list to avoid startup time static constructors.
+ static List<ObjectGroup*> groups(4);
+ return &groups;
+}
- // not found
- ObjectGroup* new_entry = new ObjectGroup(id);
- new_entry->objects_.Add(handle);
- object_groups_.Add(new_entry);
+void GlobalHandles::AddGroup(Object*** handles, size_t length) {
+ ObjectGroup* new_entry = new ObjectGroup(length);
+ for (size_t i = 0; i < length; ++i)
+ new_entry->objects_.Add(handles[i]);
+ ObjectGroups()->Add(new_entry);
}
void GlobalHandles::RemoveObjectGroups() {
- for (int i = 0; i< object_groups_.length(); i++) {
- delete object_groups_[i];
+ List<ObjectGroup*>* object_groups = ObjectGroups();
+ for (int i = 0; i< object_groups->length(); i++) {
+ delete object_groups->at(i);
}
- object_groups_.Clear();
+ object_groups->Clear();
}
« no previous file with comments | « src/global-handles.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698