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

Side by Side Diff: src/heap/spaces.cc

Issue 1356363005: Revert of [heap] Add more tasks for parallel compaction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « src/heap/spaces.h ('k') | test/cctest/test-spaces.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/spaces.h" 5 #include "src/heap/spaces.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/full-codegen/full-codegen.h" 9 #include "src/full-codegen/full-codegen.h"
10 #include "src/heap/slots-buffer.h" 10 #include "src/heap/slots-buffer.h"
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 intptr_t FreeList::Concatenate(FreeList* free_list) { 2211 intptr_t FreeList::Concatenate(FreeList* free_list) {
2212 intptr_t free_bytes = 0; 2212 intptr_t free_bytes = 0;
2213 free_bytes += small_list_.Concatenate(free_list->small_list()); 2213 free_bytes += small_list_.Concatenate(free_list->small_list());
2214 free_bytes += medium_list_.Concatenate(free_list->medium_list()); 2214 free_bytes += medium_list_.Concatenate(free_list->medium_list());
2215 free_bytes += large_list_.Concatenate(free_list->large_list()); 2215 free_bytes += large_list_.Concatenate(free_list->large_list());
2216 free_bytes += huge_list_.Concatenate(free_list->huge_list()); 2216 free_bytes += huge_list_.Concatenate(free_list->huge_list());
2217 return free_bytes; 2217 return free_bytes;
2218 } 2218 }
2219 2219
2220 2220
2221 FreeSpace* PagedSpace::TryRemoveMemory() {
2222 FreeSpace* space = nullptr;
2223 int node_size = 0;
2224 space = free_list()->FindNodeIn(FreeList::kHuge, &node_size);
2225 if (space == nullptr)
2226 space = free_list()->FindNodeIn(FreeList::kLarge, &node_size);
2227 if (space == nullptr)
2228 space = free_list()->FindNodeIn(FreeList::kMedium, &node_size);
2229 if (space == nullptr)
2230 space = free_list()->FindNodeIn(FreeList::kSmall, &node_size);
2231 if (space != nullptr) {
2232 accounting_stats_.DecreaseCapacity(node_size);
2233 }
2234 return space;
2235 }
2236
2237
2238 void PagedSpace::DivideFreeLists(FreeList** free_lists, int num,
2239 intptr_t limit) {
2240 CHECK(num > 0);
2241 CHECK(free_lists != nullptr);
2242 if (limit == 0) {
2243 limit = std::numeric_limits<intptr_t>::max();
2244 }
2245 int index = 0;
2246 FreeSpace* space = nullptr;
2247 while (((space = TryRemoveMemory()) != nullptr) &&
2248 (free_lists[index]->available() < limit)) {
2249 free_lists[index]->owner()->AddMemory(space->address(), space->size());
2250 index = (index + 1) % num;
2251 }
2252 }
2253
2254
2255 void FreeList::Reset() { 2221 void FreeList::Reset() {
2256 small_list_.Reset(); 2222 small_list_.Reset();
2257 medium_list_.Reset(); 2223 medium_list_.Reset();
2258 large_list_.Reset(); 2224 large_list_.Reset();
2259 huge_list_.Reset(); 2225 huge_list_.Reset();
2260 } 2226 }
2261 2227
2262 2228
2263 int FreeList::Free(Address start, int size_in_bytes) { 2229 int FreeList::Free(Address start, int size_in_bytes) {
2264 if (size_in_bytes == 0) return 0; 2230 if (size_in_bytes == 0) return 0;
(...skipping 23 matching lines...) Expand all
2288 } else { 2254 } else {
2289 huge_list_.Free(free_space, size_in_bytes); 2255 huge_list_.Free(free_space, size_in_bytes);
2290 page->add_available_in_huge_free_list(size_in_bytes); 2256 page->add_available_in_huge_free_list(size_in_bytes);
2291 } 2257 }
2292 2258
2293 DCHECK(IsVeryLong() || available() == SumFreeLists()); 2259 DCHECK(IsVeryLong() || available() == SumFreeLists());
2294 return 0; 2260 return 0;
2295 } 2261 }
2296 2262
2297 2263
2298 void FreeList::UpdateFragmentationStats(FreeListCategoryType category,
2299 Address address, int size) {
2300 Page* page = Page::FromAddress(address);
2301 switch (category) {
2302 case kSmall:
2303 page->add_available_in_small_free_list(size);
2304 break;
2305 case kMedium:
2306 page->add_available_in_medium_free_list(size);
2307 break;
2308 case kLarge:
2309 page->add_available_in_large_free_list(size);
2310 break;
2311 case kHuge:
2312 page->add_available_in_huge_free_list(size);
2313 break;
2314 default:
2315 UNREACHABLE();
2316 }
2317 }
2318
2319
2320 FreeSpace* FreeList::FindNodeIn(FreeListCategoryType category, int* node_size) {
2321 FreeSpace* node = GetFreeListCategory(category)->PickNodeFromList(node_size);
2322 if (node != nullptr) {
2323 UpdateFragmentationStats(category, node->address(), -(*node_size));
2324 DCHECK(IsVeryLong() || available() == SumFreeLists());
2325 }
2326 return node;
2327 }
2328
2329
2330 FreeSpace* FreeList::FindNodeFor(int size_in_bytes, int* node_size) { 2264 FreeSpace* FreeList::FindNodeFor(int size_in_bytes, int* node_size) {
2331 FreeSpace* node = NULL; 2265 FreeSpace* node = NULL;
2332 Page* page = NULL; 2266 Page* page = NULL;
2333 2267
2334 if (size_in_bytes <= kSmallAllocationMax) { 2268 if (size_in_bytes <= kSmallAllocationMax) {
2335 node = FindNodeIn(kSmall, node_size); 2269 node = small_list_.PickNodeFromList(node_size);
2336 if (node != nullptr) { 2270 if (node != NULL) {
2337 DCHECK(size_in_bytes <= node->size()); 2271 DCHECK(size_in_bytes <= *node_size);
2272 page = Page::FromAddress(node->address());
2273 page->add_available_in_small_free_list(-(*node_size));
2274 DCHECK(IsVeryLong() || available() == SumFreeLists());
2338 return node; 2275 return node;
2339 } 2276 }
2340 } 2277 }
2341 2278
2342 if (size_in_bytes <= kMediumAllocationMax) { 2279 if (size_in_bytes <= kMediumAllocationMax) {
2343 node = FindNodeIn(kMedium, node_size); 2280 node = medium_list_.PickNodeFromList(node_size);
2344 if (node != nullptr) { 2281 if (node != NULL) {
2345 DCHECK(size_in_bytes <= node->size()); 2282 DCHECK(size_in_bytes <= *node_size);
2283 page = Page::FromAddress(node->address());
2284 page->add_available_in_medium_free_list(-(*node_size));
2285 DCHECK(IsVeryLong() || available() == SumFreeLists());
2346 return node; 2286 return node;
2347 } 2287 }
2348 } 2288 }
2349 2289
2350 if (size_in_bytes <= kLargeAllocationMax) { 2290 if (size_in_bytes <= kLargeAllocationMax) {
2351 node = FindNodeIn(kLarge, node_size); 2291 node = large_list_.PickNodeFromList(node_size);
2352 if (node != nullptr) { 2292 if (node != NULL) {
2353 DCHECK(size_in_bytes <= node->size()); 2293 DCHECK(size_in_bytes <= *node_size);
2294 page = Page::FromAddress(node->address());
2295 page->add_available_in_large_free_list(-(*node_size));
2296 DCHECK(IsVeryLong() || available() == SumFreeLists());
2354 return node; 2297 return node;
2355 } 2298 }
2356 } 2299 }
2357 2300
2358 int huge_list_available = huge_list_.available(); 2301 int huge_list_available = huge_list_.available();
2359 FreeSpace* top_node = huge_list_.top(); 2302 FreeSpace* top_node = huge_list_.top();
2360 for (FreeSpace** cur = &top_node; *cur != NULL; 2303 for (FreeSpace** cur = &top_node; *cur != NULL;
2361 cur = (*cur)->next_address()) { 2304 cur = (*cur)->next_address()) {
2362 FreeSpace* cur_node = *cur; 2305 FreeSpace* cur_node = *cur;
2363 while (cur_node != NULL && 2306 while (cur_node != NULL &&
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
3201 object->ShortPrint(); 3144 object->ShortPrint();
3202 PrintF("\n"); 3145 PrintF("\n");
3203 } 3146 }
3204 printf(" --------------------------------------\n"); 3147 printf(" --------------------------------------\n");
3205 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3148 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3206 } 3149 }
3207 3150
3208 #endif // DEBUG 3151 #endif // DEBUG
3209 } // namespace internal 3152 } // namespace internal
3210 } // namespace v8 3153 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/spaces.h ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698