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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/global-handles.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 void GlobalHandles::Print() { 345 void GlobalHandles::Print() {
346 PrintF("Global handles:\n"); 346 PrintF("Global handles:\n");
347 for (Node* current = head_; current != NULL; current = current->next()) { 347 for (Node* current = head_; current != NULL; current = current->next()) {
348 PrintF(" handle %p to %p (weak=%d)\n", current->handle().location(), 348 PrintF(" handle %p to %p (weak=%d)\n", current->handle().location(),
349 *current->handle(), current->state_ == Node::WEAK); 349 *current->handle(), current->state_ == Node::WEAK);
350 } 350 }
351 } 351 }
352 352
353 #endif 353 #endif
354 354
355 List<ObjectGroup*> GlobalHandles::object_groups_(4); 355 List<ObjectGroup*>* GlobalHandles::ObjectGroups() {
356 // Lazily initialize the list to avoid startup time static constructors.
357 static List<ObjectGroup*> groups(4);
358 return &groups;
359 }
356 360
357 void GlobalHandles::AddToGroup(void* id, Object** handle) { 361 void GlobalHandles::AddGroup(Object*** handles, size_t length) {
358 for (int i = 0; i < object_groups_.length(); i++) { 362 ObjectGroup* new_entry = new ObjectGroup(length);
359 ObjectGroup* entry = object_groups_[i]; 363 for (size_t i = 0; i < length; ++i)
360 if (entry->id_ == id) { 364 new_entry->objects_.Add(handles[i]);
361 entry->objects_.Add(handle); 365 ObjectGroups()->Add(new_entry);
362 return;
363 }
364 }
365
366 // not found
367 ObjectGroup* new_entry = new ObjectGroup(id);
368 new_entry->objects_.Add(handle);
369 object_groups_.Add(new_entry);
370 } 366 }
371 367
372 368
373 void GlobalHandles::RemoveObjectGroups() { 369 void GlobalHandles::RemoveObjectGroups() {
374 for (int i = 0; i< object_groups_.length(); i++) { 370 List<ObjectGroup*>* object_groups = ObjectGroups();
375 delete object_groups_[i]; 371 for (int i = 0; i< object_groups->length(); i++) {
372 delete object_groups->at(i);
376 } 373 }
377 object_groups_.Clear(); 374 object_groups->Clear();
378 } 375 }
379 376
380 377
381 } } // namespace v8::internal 378 } } // namespace v8::internal
OLDNEW
« 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