OLD | NEW |
---|---|
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 Loading... | |
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 f) { | |
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 (!f(isolate_->heap(), &object)) { | |
ulan
2012/12/04 09:41:46
Maybe rename "f" to something more descriptive lik
Michael Starzinger
2012/12/04 10:18:14
Done.
| |
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 Loading... | |
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 |
OLD | NEW |