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

Side by Side Diff: src/global-handles.cc

Issue 11299248: Unify object groups iteration in global handles. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Ulan Degenbaev. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « src/global-handles.h ('k') | src/heap.h » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 Node* node = new_space_nodes_[i]; 544 Node* node = new_space_nodes_[i];
545 ASSERT(node->is_in_new_space_list()); 545 ASSERT(node->is_in_new_space_list());
546 if ((node->is_independent() || node->is_partially_dependent()) && 546 if ((node->is_independent() || node->is_partially_dependent()) &&
547 node->IsWeakRetainer()) { 547 node->IsWeakRetainer()) {
548 v->VisitPointer(node->location()); 548 v->VisitPointer(node->location());
549 } 549 }
550 } 550 }
551 } 551 }
552 552
553 553
554 bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v,
555 WeakSlotCallbackWithHeap can_skip) {
556 int last = 0;
557 bool any_group_was_visited = false;
558 for (int i = 0; i < object_groups_.length(); i++) {
559 ObjectGroup* entry = object_groups_.at(i);
560 ASSERT(entry != NULL);
561
562 Object*** objects = entry->objects_;
563 bool group_should_be_visited = false;
564 for (size_t j = 0; j < entry->length_; j++) {
565 Object* object = *objects[j];
566 if (object->IsHeapObject()) {
567 if (!can_skip(isolate_->heap(), &object)) {
568 group_should_be_visited = true;
569 break;
570 }
571 }
572 }
573
574 if (!group_should_be_visited) {
575 object_groups_[last++] = entry;
576 continue;
577 }
578
579 // An object in the group requires visiting, so iterate over all
580 // objects in the group.
581 for (size_t j = 0; j < entry->length_; ++j) {
582 Object* object = *objects[j];
583 if (object->IsHeapObject()) {
584 v->VisitPointer(&object);
585 any_group_was_visited = true;
586 }
587 }
588
589 // Once the entire group has been iterated over, set the object
590 // group to NULL so it won't be processed again.
591 entry->Dispose();
592 object_groups_.at(i) = NULL;
593 }
594 object_groups_.Rewind(last);
595 return any_group_was_visited;
596 }
597
598
554 bool GlobalHandles::PostGarbageCollectionProcessing( 599 bool GlobalHandles::PostGarbageCollectionProcessing(
555 GarbageCollector collector) { 600 GarbageCollector collector) {
556 // Process weak global handle callbacks. This must be done after the 601 // Process weak global handle callbacks. This must be done after the
557 // GC is completely done, because the callbacks may invoke arbitrary 602 // GC is completely done, because the callbacks may invoke arbitrary
558 // API functions. 603 // API functions.
559 ASSERT(isolate_->heap()->gc_state() == Heap::NOT_IN_GC); 604 ASSERT(isolate_->heap()->gc_state() == Heap::NOT_IN_GC);
560 const int initial_post_gc_processing_count = ++post_gc_processing_count_; 605 const int initial_post_gc_processing_count = ++post_gc_processing_count_;
561 bool next_gc_likely_to_collect_more = false; 606 bool next_gc_likely_to_collect_more = false;
562 if (collector == SCAVENGER) { 607 if (collector == SCAVENGER) {
563 for (int i = 0; i < new_space_nodes_.length(); ++i) { 608 for (int i = 0; i < new_space_nodes_.length(); ++i) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 implicit_ref_groups_.Clear(); 791 implicit_ref_groups_.Clear();
747 } 792 }
748 793
749 794
750 void GlobalHandles::TearDown() { 795 void GlobalHandles::TearDown() {
751 // TODO(1428): invoke weak callbacks. 796 // TODO(1428): invoke weak callbacks.
752 } 797 }
753 798
754 799
755 } } // namespace v8::internal 800 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698