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

Side by Side Diff: src/spaces.cc

Issue 11280120: Sweep pages with lowest live memory first. 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 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 2496
2497 // You have to call this last, since the implementation from PagedSpace 2497 // You have to call this last, since the implementation from PagedSpace
2498 // doesn't know that memory was 'promised' to large object space. 2498 // doesn't know that memory was 'promised' to large object space.
2499 bool LargeObjectSpace::ReserveSpace(int bytes) { 2499 bool LargeObjectSpace::ReserveSpace(int bytes) {
2500 return heap()->OldGenerationCapacityAvailable() >= bytes && 2500 return heap()->OldGenerationCapacityAvailable() >= bytes &&
2501 (!heap()->incremental_marking()->IsStopped() || 2501 (!heap()->incremental_marking()->IsStopped() ||
2502 heap()->OldGenerationSpaceAvailable() >= bytes); 2502 heap()->OldGenerationSpaceAvailable() >= bytes);
2503 } 2503 }
2504 2504
2505 2505
2506 intptr_t PagedSpace::SweepPageWithLowestLiveMemory() {
2507 Page* p = first_unswept_page_;
2508 Page* sweep_canditate = NULL;
2509
2510 while (p != anchor()) {
2511 if (ShouldBeSweptLazily(p) && !p->WasSweptConservatively()) {
2512 if (sweep_canditate == NULL ||
2513 p->LiveBytes() < sweep_canditate->LiveBytes()) {
2514 sweep_canditate = p;
2515 }
2516 }
2517 p = p->next_page();
2518 }
2519
2520 if (sweep_canditate != NULL) {
2521 DecreaseUnsweptFreeBytes(sweep_canditate);
2522 return MarkCompactCollector::
2523 SweepConservatively<MarkCompactCollector::SWEEP_SEQUENTIALLY>(
2524 this, NULL, sweep_canditate);
2525 }
2526 return 0;
2527 }
2528
2529
2506 bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) { 2530 bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) {
2507 if (IsLazySweepingComplete()) return true; 2531 if (IsLazySweepingComplete()) return true;
2508 2532
2509 intptr_t freed_bytes = 0; 2533 intptr_t freed_bytes = SweepPageWithLowestLiveMemory();
2534
2510 Page* p = first_unswept_page_; 2535 Page* p = first_unswept_page_;
2511 do { 2536 while (freed_bytes < bytes_to_sweep && p != anchor()) {
2512 Page* next_page = p->next_page(); 2537 Page* next_page = p->next_page();
2513 if (ShouldBeSweptLazily(p)) { 2538 if (ShouldBeSweptLazily(p) && !p->WasSweptConservatively()) {
2514 if (FLAG_gc_verbose) { 2539 if (FLAG_gc_verbose) {
2515 PrintF("Sweeping 0x%" V8PRIxPTR " lazily advanced.\n", 2540 PrintF("Sweeping 0x%" V8PRIxPTR " lazily advanced.\n",
2516 reinterpret_cast<intptr_t>(p)); 2541 reinterpret_cast<intptr_t>(p));
2517 } 2542 }
2518 DecreaseUnsweptFreeBytes(p); 2543 DecreaseUnsweptFreeBytes(p);
2519 freed_bytes += 2544 freed_bytes +=
2520 MarkCompactCollector:: 2545 MarkCompactCollector::
2521 SweepConservatively<MarkCompactCollector::SWEEP_SEQUENTIALLY>( 2546 SweepConservatively<MarkCompactCollector::SWEEP_SEQUENTIALLY>(
2522 this, NULL, p); 2547 this, NULL, p);
2523 } 2548 }
2524 p = next_page; 2549 p = next_page;
2525 } while (p != anchor() && freed_bytes < bytes_to_sweep); 2550 }
2526 2551
2527 if (p == anchor()) { 2552 if (p == anchor()) {
2528 first_unswept_page_ = Page::FromAddress(NULL); 2553 first_unswept_page_ = Page::FromAddress(NULL);
2529 } else { 2554 } else {
2530 first_unswept_page_ = p; 2555 first_unswept_page_ = p;
2531 } 2556 }
2532 2557
2533 heap()->FreeQueuedChunks(); 2558 heap()->FreeQueuedChunks();
2534 2559
2535 return IsLazySweepingComplete(); 2560 return IsLazySweepingComplete();
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
3132 object->ShortPrint(); 3157 object->ShortPrint();
3133 PrintF("\n"); 3158 PrintF("\n");
3134 } 3159 }
3135 printf(" --------------------------------------\n"); 3160 printf(" --------------------------------------\n");
3136 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3161 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3137 } 3162 }
3138 3163
3139 #endif // DEBUG 3164 #endif // DEBUG
3140 3165
3141 } } // namespace v8::internal 3166 } } // 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