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

Side by Side Diff: src/heap.cc

Issue 174219: Shrink new space on compacting collections. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 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 | src/spaces.h » ('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 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 EnsureFromSpaceIsCommitted(); 458 EnsureFromSpaceIsCommitted();
459 if (collector == MARK_COMPACTOR) { 459 if (collector == MARK_COMPACTOR) {
460 MarkCompact(tracer); 460 MarkCompact(tracer);
461 461
462 int old_gen_size = PromotedSpaceSize(); 462 int old_gen_size = PromotedSpaceSize();
463 old_gen_promotion_limit_ = 463 old_gen_promotion_limit_ =
464 old_gen_size + Max(kMinimumPromotionLimit, old_gen_size / 3); 464 old_gen_size + Max(kMinimumPromotionLimit, old_gen_size / 3);
465 old_gen_allocation_limit_ = 465 old_gen_allocation_limit_ =
466 old_gen_size + Max(kMinimumAllocationLimit, old_gen_size / 2); 466 old_gen_size + Max(kMinimumAllocationLimit, old_gen_size / 2);
467 old_gen_exhausted_ = false; 467 old_gen_exhausted_ = false;
468 } else {
469 Scavenge();
468 } 470 }
469 Scavenge();
470 Counters::objs_since_last_young.Set(0); 471 Counters::objs_since_last_young.Set(0);
471 472
472 PostGarbageCollectionProcessing(); 473 PostGarbageCollectionProcessing();
473 474
474 if (collector == MARK_COMPACTOR) { 475 if (collector == MARK_COMPACTOR) {
475 // Register the amount of external allocated memory. 476 // Register the amount of external allocated memory.
476 amount_of_external_allocated_memory_at_last_global_gc_ = 477 amount_of_external_allocated_memory_at_last_global_gc_ =
477 amount_of_external_allocated_memory_; 478 amount_of_external_allocated_memory_;
478 } 479 }
479 480
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 MarkCompactEpilogue(is_compacting); 514 MarkCompactEpilogue(is_compacting);
514 515
515 LOG(ResourceEvent("markcompact", "end")); 516 LOG(ResourceEvent("markcompact", "end"));
516 517
517 gc_state_ = NOT_IN_GC; 518 gc_state_ = NOT_IN_GC;
518 519
519 Shrink(); 520 Shrink();
520 521
521 Counters::objs_since_last_full.Set(0); 522 Counters::objs_since_last_full.Set(0);
522 context_disposed_pending_ = false; 523 context_disposed_pending_ = false;
524
525 Scavenge();
526
527 // Shrink new space as much as possible after compacting full
528 // garbage collections.
529 if (is_compacting) new_space_.Shrink();
523 } 530 }
524 531
525 532
526 void Heap::MarkCompactPrologue(bool is_compacting) { 533 void Heap::MarkCompactPrologue(bool is_compacting) {
527 // At any old GC clear the keyed lookup cache to enable collection of unused 534 // At any old GC clear the keyed lookup cache to enable collection of unused
528 // maps. 535 // maps.
529 KeyedLookupCache::Clear(); 536 KeyedLookupCache::Clear();
530 ContextSlotCache::Clear(); 537 ContextSlotCache::Clear();
531 DescriptorLookupCache::Clear(); 538 DescriptorLookupCache::Clear();
532 539
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // Clear descriptor cache. 668 // Clear descriptor cache.
662 DescriptorLookupCache::Clear(); 669 DescriptorLookupCache::Clear();
663 670
664 // Used for updating survived_since_last_expansion_ at function end. 671 // Used for updating survived_since_last_expansion_ at function end.
665 int survived_watermark = PromotedSpaceSize(); 672 int survived_watermark = PromotedSpaceSize();
666 673
667 if (new_space_.Capacity() < new_space_.MaximumCapacity() && 674 if (new_space_.Capacity() < new_space_.MaximumCapacity() &&
668 survived_since_last_expansion_ > new_space_.Capacity()) { 675 survived_since_last_expansion_ > new_space_.Capacity()) {
669 // Grow the size of new space if there is room to grow and enough 676 // Grow the size of new space if there is room to grow and enough
670 // data has survived scavenge since the last expansion. 677 // data has survived scavenge since the last expansion.
671 // TODO(1240712): NewSpace::Grow has a return value which is
672 // ignored here.
673 new_space_.Grow(); 678 new_space_.Grow();
674 survived_since_last_expansion_ = 0; 679 survived_since_last_expansion_ = 0;
675 } 680 }
676 681
677 // Flip the semispaces. After flipping, to space is empty, from space has 682 // Flip the semispaces. After flipping, to space is empty, from space has
678 // live objects. 683 // live objects.
679 new_space_.Flip(); 684 new_space_.Flip();
680 new_space_.ResetAllocationInfo(); 685 new_space_.ResetAllocationInfo();
681 686
682 // We need to sweep newly copied objects which can be either in the 687 // We need to sweep newly copied objects which can be either in the
(...skipping 3238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 #ifdef DEBUG 3926 #ifdef DEBUG
3922 bool Heap::GarbageCollectionGreedyCheck() { 3927 bool Heap::GarbageCollectionGreedyCheck() {
3923 ASSERT(FLAG_gc_greedy); 3928 ASSERT(FLAG_gc_greedy);
3924 if (Bootstrapper::IsActive()) return true; 3929 if (Bootstrapper::IsActive()) return true;
3925 if (disallow_allocation_failure()) return true; 3930 if (disallow_allocation_failure()) return true;
3926 return CollectGarbage(0, NEW_SPACE); 3931 return CollectGarbage(0, NEW_SPACE);
3927 } 3932 }
3928 #endif 3933 #endif
3929 3934
3930 } } // namespace v8::internal 3935 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698