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

Side by Side Diff: src/spaces.cc

Issue 12313131: Shrinking of PagedSpace is done only by sweeper. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | « src/spaces.h ('k') | 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 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 heap()->isolate()->memory_allocator()->Free(page); 1074 heap()->isolate()->memory_allocator()->Free(page);
1075 } else { 1075 } else {
1076 heap()->QueueMemoryChunkForFree(page); 1076 heap()->QueueMemoryChunkForFree(page);
1077 } 1077 }
1078 1078
1079 ASSERT(Capacity() > 0); 1079 ASSERT(Capacity() > 0);
1080 accounting_stats_.ShrinkSpace(AreaSize()); 1080 accounting_stats_.ShrinkSpace(AreaSize());
1081 } 1081 }
1082 1082
1083 1083
1084 void PagedSpace::ReleaseAllUnusedPages() {
1085 PageIterator it(this);
1086 while (it.has_next()) {
1087 Page* page = it.next();
1088 if (!page->WasSwept()) {
1089 if (page->LiveBytes() == 0) ReleasePage(page);
1090 } else {
1091 HeapObject* obj = HeapObject::FromAddress(page->area_start());
1092 if (obj->IsFreeSpace() &&
1093 FreeSpace::cast(obj)->size() == AreaSize()) {
1094 // Sometimes we allocate memory from free list but don't
1095 // immediately initialize it (e.g. see PagedSpace::ReserveSpace
1096 // called from Heap::ReserveSpace that can cause GC before
1097 // reserved space is actually initialized).
1098 // Thus we can't simply assume that obj represents a valid
1099 // node still owned by a free list
1100 // Instead we should verify that the page is fully covered
1101 // by free list items.
1102 FreeList::SizeStats sizes;
1103 free_list_.CountFreeListItems(page, &sizes);
1104 if (sizes.Total() == AreaSize()) {
1105 ReleasePage(page);
1106 }
1107 }
1108 }
1109 }
1110 heap()->FreeQueuedChunks();
1111 }
1112
1113
1114 #ifdef DEBUG 1084 #ifdef DEBUG
1115 void PagedSpace::Print() { } 1085 void PagedSpace::Print() { }
1116 #endif 1086 #endif
1117 1087
1118 #ifdef VERIFY_HEAP 1088 #ifdef VERIFY_HEAP
1119 void PagedSpace::Verify(ObjectVisitor* visitor) { 1089 void PagedSpace::Verify(ObjectVisitor* visitor) {
1120 // We can only iterate over the pages if they were swept precisely. 1090 // We can only iterate over the pages if they were swept precisely.
1121 if (was_swept_conservatively_) return; 1091 if (was_swept_conservatively_) return;
1122 1092
1123 bool allocation_pointer_found_in_space = 1093 bool allocation_pointer_found_in_space =
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after
3152 object->ShortPrint(); 3122 object->ShortPrint();
3153 PrintF("\n"); 3123 PrintF("\n");
3154 } 3124 }
3155 printf(" --------------------------------------\n"); 3125 printf(" --------------------------------------\n");
3156 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3126 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3157 } 3127 }
3158 3128
3159 #endif // DEBUG 3129 #endif // DEBUG
3160 3130
3161 } } // namespace v8::internal 3131 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698