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

Side by Side Diff: src/mark-compact.cc

Issue 8060004: Pass sweeping mode as template parameter. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2775 matching lines...) Expand 10 before | Expand all | Expand 10 after
2786 IGNORE_SKIP_LIST 2786 IGNORE_SKIP_LIST
2787 }; 2787 };
2788 2788
2789 2789
2790 // Sweep a space precisely. After this has been done the space can 2790 // Sweep a space precisely. After this has been done the space can
2791 // be iterated precisely, hitting only the live objects. Code space 2791 // be iterated precisely, hitting only the live objects. Code space
2792 // is always swept precisely because we want to be able to iterate 2792 // is always swept precisely because we want to be able to iterate
2793 // over it. Map space is swept precisely, because it is not compacted. 2793 // over it. Map space is swept precisely, because it is not compacted.
2794 // Slots in live objects pointing into evacuation candidates are updated 2794 // Slots in live objects pointing into evacuation candidates are updated
2795 // if requested. 2795 // if requested.
2796 template<SkipListRebuildingMode skip_list_mode> 2796 template<SweepingMode sweeping_mode, SkipListRebuildingMode skip_list_mode>
2797 static void SweepPrecisely(PagedSpace* space, 2797 static void SweepPrecisely(PagedSpace* space,
2798 Page* p, 2798 Page* p,
2799 SweepingMode mode,
2800 ObjectVisitor* v) { 2799 ObjectVisitor* v) {
2801 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); 2800 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept());
2802 ASSERT_EQ(skip_list_mode == REBUILD_SKIP_LIST, 2801 ASSERT_EQ(skip_list_mode == REBUILD_SKIP_LIST,
2803 space->identity() == CODE_SPACE); 2802 space->identity() == CODE_SPACE);
2804 ASSERT((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST)); 2803 ASSERT((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST));
2805 2804
2806 MarkBit::CellType* cells = p->markbits()->cells(); 2805 MarkBit::CellType* cells = p->markbits()->cells();
2807 p->MarkSweptPrecisely(); 2806 p->MarkSweptPrecisely();
2808 2807
2809 int last_cell_index = 2808 int last_cell_index =
(...skipping 24 matching lines...) Expand all
2834 int live_index = 0; 2833 int live_index = 0;
2835 for ( ; live_objects != 0; live_objects--) { 2834 for ( ; live_objects != 0; live_objects--) {
2836 Address free_end = object_address + offsets[live_index++] * kPointerSize; 2835 Address free_end = object_address + offsets[live_index++] * kPointerSize;
2837 if (free_end != free_start) { 2836 if (free_end != free_start) {
2838 space->Free(free_start, static_cast<int>(free_end - free_start)); 2837 space->Free(free_start, static_cast<int>(free_end - free_start));
2839 } 2838 }
2840 HeapObject* live_object = HeapObject::FromAddress(free_end); 2839 HeapObject* live_object = HeapObject::FromAddress(free_end);
2841 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(live_object))); 2840 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(live_object)));
2842 Map* map = live_object->map(); 2841 Map* map = live_object->map();
2843 int size = live_object->SizeFromMap(map); 2842 int size = live_object->SizeFromMap(map);
2844 if (mode == SWEEP_AND_VISIT_LIVE_OBJECTS) { 2843 if (sweeping_mode == SWEEP_AND_VISIT_LIVE_OBJECTS) {
2845 live_object->IterateBody(map->instance_type(), size, v); 2844 live_object->IterateBody(map->instance_type(), size, v);
2846 } 2845 }
2847 if ((skip_list_mode == REBUILD_SKIP_LIST) && skip_list != NULL) { 2846 if ((skip_list_mode == REBUILD_SKIP_LIST) && skip_list != NULL) {
2848 int new_region_start = 2847 int new_region_start =
2849 SkipList::RegionNumber(free_end); 2848 SkipList::RegionNumber(free_end);
2850 int new_region_end = 2849 int new_region_end =
2851 SkipList::RegionNumber(free_end + size - kPointerSize); 2850 SkipList::RegionNumber(free_end + size - kPointerSize);
2852 if (new_region_start != curr_region || 2851 if (new_region_start != curr_region ||
2853 new_region_end != curr_region) { 2852 new_region_end != curr_region) {
2854 skip_list->AddObject(free_end, size); 2853 skip_list->AddObject(free_end, size);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
3062 reinterpret_cast<intptr_t>(p)); 3061 reinterpret_cast<intptr_t>(p));
3063 } 3062 }
3064 PagedSpace* space = static_cast<PagedSpace*>(p->owner()); 3063 PagedSpace* space = static_cast<PagedSpace*>(p->owner());
3065 p->ClearFlag(MemoryChunk::RESCAN_ON_EVACUATION); 3064 p->ClearFlag(MemoryChunk::RESCAN_ON_EVACUATION);
3066 3065
3067 switch (space->identity()) { 3066 switch (space->identity()) {
3068 case OLD_DATA_SPACE: 3067 case OLD_DATA_SPACE:
3069 SweepConservatively(space, p); 3068 SweepConservatively(space, p);
3070 break; 3069 break;
3071 case OLD_POINTER_SPACE: 3070 case OLD_POINTER_SPACE:
3072 SweepPrecisely<IGNORE_SKIP_LIST>(space, 3071 SweepPrecisely<SWEEP_AND_VISIT_LIVE_OBJECTS, IGNORE_SKIP_LIST>(
3073 p, 3072 space, p, &updating_visitor);
3074 SWEEP_AND_VISIT_LIVE_OBJECTS,
3075 &updating_visitor);
3076 break; 3073 break;
3077 case CODE_SPACE: 3074 case CODE_SPACE:
3078 SweepPrecisely<REBUILD_SKIP_LIST>(space, 3075 SweepPrecisely<SWEEP_AND_VISIT_LIVE_OBJECTS, REBUILD_SKIP_LIST>(
3079 p, 3076 space, p, &updating_visitor);
3080 SWEEP_AND_VISIT_LIVE_OBJECTS,
3081 &updating_visitor);
3082 break; 3077 break;
3083 default: 3078 default:
3084 UNREACHABLE(); 3079 UNREACHABLE();
3085 break; 3080 break;
3086 } 3081 }
3087 } 3082 }
3088 } 3083 }
3089 3084
3090 // Update pointers from cells. 3085 // Update pointers from cells.
3091 HeapObjectIterator cell_iterator(heap_->cell_space()); 3086 HeapObjectIterator cell_iterator(heap_->cell_space());
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
3611 case LAZY_CONSERVATIVE: { 3606 case LAZY_CONSERVATIVE: {
3612 freed_bytes += SweepConservatively(space, p); 3607 freed_bytes += SweepConservatively(space, p);
3613 if (freed_bytes >= newspace_size && p != space->LastPage()) { 3608 if (freed_bytes >= newspace_size && p != space->LastPage()) {
3614 space->SetPagesToSweep(p->next_page(), space->LastPage()); 3609 space->SetPagesToSweep(p->next_page(), space->LastPage());
3615 lazy_sweeping_active = true; 3610 lazy_sweeping_active = true;
3616 } 3611 }
3617 break; 3612 break;
3618 } 3613 }
3619 case PRECISE: { 3614 case PRECISE: {
3620 if (space->identity() == CODE_SPACE) { 3615 if (space->identity() == CODE_SPACE) {
3621 SweepPrecisely<REBUILD_SKIP_LIST>(space, p, SWEEP_ONLY, NULL); 3616 SweepPrecisely<SWEEP_ONLY, REBUILD_SKIP_LIST>(space, p, NULL);
3622 } else { 3617 } else {
3623 SweepPrecisely<IGNORE_SKIP_LIST>(space, p, SWEEP_ONLY, NULL); 3618 SweepPrecisely<SWEEP_ONLY, IGNORE_SKIP_LIST>(space, p, NULL);
3624 } 3619 }
3625 break; 3620 break;
3626 } 3621 }
3627 default: { 3622 default: {
3628 UNREACHABLE(); 3623 UNREACHABLE();
3629 } 3624 }
3630 } 3625 }
3631 } 3626 }
3632 } 3627 }
3633 3628
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3836 while (buffer != NULL) { 3831 while (buffer != NULL) {
3837 SlotsBuffer* next_buffer = buffer->next(); 3832 SlotsBuffer* next_buffer = buffer->next();
3838 DeallocateBuffer(buffer); 3833 DeallocateBuffer(buffer);
3839 buffer = next_buffer; 3834 buffer = next_buffer;
3840 } 3835 }
3841 *buffer_address = NULL; 3836 *buffer_address = NULL;
3842 } 3837 }
3843 3838
3844 3839
3845 } } // namespace v8::internal 3840 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698