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

Side by Side Diff: src/heap.cc

Issue 199057: Minor change to idle notification handling: perform a scavenge... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | 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 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 2777 matching lines...) Expand 10 before | Expand all | Expand 10 after
2788 AllocationSpace space = 2788 AllocationSpace space =
2789 (size > MaxObjectSizeInPagedSpace()) ? LO_SPACE : OLD_POINTER_SPACE; 2789 (size > MaxObjectSizeInPagedSpace()) ? LO_SPACE : OLD_POINTER_SPACE;
2790 Object* result = Heap::Allocate(map, space); 2790 Object* result = Heap::Allocate(map, space);
2791 if (result->IsFailure()) return result; 2791 if (result->IsFailure()) return result;
2792 Struct::cast(result)->InitializeBody(size); 2792 Struct::cast(result)->InitializeBody(size);
2793 return result; 2793 return result;
2794 } 2794 }
2795 2795
2796 2796
2797 bool Heap::IdleNotification() { 2797 bool Heap::IdleNotification() {
2798 static const int kIdlesBeforeCollection = 7; 2798 static const int kIdlesBeforeScavenge = 4;
2799 static const int kIdlesBeforeMarkSweep = 7;
2800 static const int kIdlesBeforeMarkCompact = 8;
2799 static int number_idle_notifications = 0; 2801 static int number_idle_notifications = 0;
2800 static int last_gc_count = gc_count_; 2802 static int last_gc_count = gc_count_;
2801 2803
2802 bool finished = false; 2804 bool finished = false;
2803 2805
2804 if (last_gc_count == gc_count_) { 2806 if (last_gc_count == gc_count_) {
2805 number_idle_notifications++; 2807 number_idle_notifications++;
2806 } else { 2808 } else {
2807 number_idle_notifications = 0; 2809 number_idle_notifications = 0;
2808 last_gc_count = gc_count_; 2810 last_gc_count = gc_count_;
2809 } 2811 }
2810 2812
2811 if (number_idle_notifications >= kIdlesBeforeCollection) { 2813 if (number_idle_notifications == kIdlesBeforeScavenge) {
2812 // The first time through we collect without forcing compaction. 2814 CollectGarbage(0, NEW_SPACE);
2813 // The second time through we force compaction and quit. 2815 new_space_.Shrink();
2814 bool force_compaction =
2815 number_idle_notifications > kIdlesBeforeCollection;
2816 CollectAllGarbage(force_compaction);
2817 last_gc_count = gc_count_; 2816 last_gc_count = gc_count_;
2818 if (force_compaction) { 2817
2819 // Shrink new space. 2818 } else if (number_idle_notifications == kIdlesBeforeMarkSweep) {
2820 new_space_.Shrink(); 2819 CollectAllGarbage(false);
2821 number_idle_notifications = 0; 2820 new_space_.Shrink();
2822 finished = true; 2821 last_gc_count = gc_count_;
2823 } 2822
2823 } else if (number_idle_notifications == kIdlesBeforeMarkCompact) {
2824 CollectAllGarbage(true);
2825 new_space_.Shrink();
2826 last_gc_count = gc_count_;
2827 number_idle_notifications = 0;
2828 finished = true;
2824 } 2829 }
2825 2830
2826 // Uncommit unused memory in new space. 2831 // Uncommit unused memory in new space.
2827 Heap::UncommitFromSpace(); 2832 Heap::UncommitFromSpace();
2828 return finished; 2833 return finished;
2829 } 2834 }
2830 2835
2831 2836
2832 #ifdef DEBUG 2837 #ifdef DEBUG
2833 2838
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
3993 for (int i = 0; i < kNumberOfCaches; i++) { 3998 for (int i = 0; i < kNumberOfCaches; i++) {
3994 if (caches_[i] != NULL) { 3999 if (caches_[i] != NULL) {
3995 delete caches_[i]; 4000 delete caches_[i];
3996 caches_[i] = NULL; 4001 caches_[i] = NULL;
3997 } 4002 }
3998 } 4003 }
3999 } 4004 }
4000 4005
4001 4006
4002 } } // namespace v8::internal 4007 } } // 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