OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 3739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3750 } | 3750 } |
3751 Struct::cast(result)->InitializeBody(size); | 3751 Struct::cast(result)->InitializeBody(size); |
3752 return result; | 3752 return result; |
3753 } | 3753 } |
3754 | 3754 |
3755 | 3755 |
3756 bool Heap::IdleNotification() { | 3756 bool Heap::IdleNotification() { |
3757 static const int kIdlesBeforeScavenge = 4; | 3757 static const int kIdlesBeforeScavenge = 4; |
3758 static const int kIdlesBeforeMarkSweep = 7; | 3758 static const int kIdlesBeforeMarkSweep = 7; |
3759 static const int kIdlesBeforeMarkCompact = 8; | 3759 static const int kIdlesBeforeMarkCompact = 8; |
3760 static const int kMaxIdleCount = 9; | |
antonm
2010/12/13 12:06:20
do we need it at all? maybe use something like kI
Mads Ager (chromium)
2010/12/13 12:12:58
I'm just being paranoid to avoid overflows. I'll c
| |
3761 static const int kGCsBetweenCleanup = 4; | |
3760 static int number_idle_notifications = 0; | 3762 static int number_idle_notifications = 0; |
3761 static int last_gc_count = gc_count_; | 3763 static int last_gc_count = gc_count_; |
3762 | 3764 |
3763 bool uncommit = true; | 3765 bool uncommit = true; |
3764 bool finished = false; | 3766 bool finished = false; |
3765 | 3767 |
3766 if (last_gc_count == gc_count_) { | 3768 // Reset the number of idle notifications received when a number of |
3767 number_idle_notifications++; | 3769 // GCs have taken place. This allows another round of cleanup based |
3770 // on idle notifications if enough work has been carried out to | |
3771 // provoke a number of garbage collections. | |
3772 if (gc_count_ < last_gc_count + kGCsBetweenCleanup) { | |
3773 number_idle_notifications = | |
3774 Min(number_idle_notifications + 1, kMaxIdleCount); | |
3768 } else { | 3775 } else { |
3769 number_idle_notifications = 0; | 3776 number_idle_notifications = 0; |
3770 last_gc_count = gc_count_; | 3777 last_gc_count = gc_count_; |
3771 } | 3778 } |
3772 | 3779 |
3780 // If we have received more than kIdlesBeforeMarkCompact idle | |
3781 // notifications we do not perform any cleanup because we don't | |
3782 // expect to gain much by doing so. | |
3783 if (number_idle_notifications > kIdlesBeforeMarkCompact) return true; | |
Kasper Lund
2010/12/13 11:45:44
Have you consider getting rid of this code and jus
Mads Ager (chromium)
2010/12/13 11:58:06
Good idea. I have moved this to an else-if part th
| |
3784 | |
3773 if (number_idle_notifications == kIdlesBeforeScavenge) { | 3785 if (number_idle_notifications == kIdlesBeforeScavenge) { |
3774 if (contexts_disposed_ > 0) { | 3786 if (contexts_disposed_ > 0) { |
3775 HistogramTimerScope scope(&Counters::gc_context); | 3787 HistogramTimerScope scope(&Counters::gc_context); |
3776 CollectAllGarbage(false); | 3788 CollectAllGarbage(false); |
3777 } else { | 3789 } else { |
3778 CollectGarbage(NEW_SPACE); | 3790 CollectGarbage(NEW_SPACE); |
3779 } | 3791 } |
3780 new_space_.Shrink(); | 3792 new_space_.Shrink(); |
3781 last_gc_count = gc_count_; | 3793 last_gc_count = gc_count_; |
3782 | 3794 |
3783 } else if (number_idle_notifications == kIdlesBeforeMarkSweep) { | 3795 } else if (number_idle_notifications == kIdlesBeforeMarkSweep) { |
3784 // Before doing the mark-sweep collections we clear the | 3796 // Before doing the mark-sweep collections we clear the |
3785 // compilation cache to avoid hanging on to source code and | 3797 // compilation cache to avoid hanging on to source code and |
3786 // generated code for cached functions. | 3798 // generated code for cached functions. |
3787 CompilationCache::Clear(); | 3799 CompilationCache::Clear(); |
3788 | 3800 |
3789 CollectAllGarbage(false); | 3801 CollectAllGarbage(false); |
3790 new_space_.Shrink(); | 3802 new_space_.Shrink(); |
3791 last_gc_count = gc_count_; | 3803 last_gc_count = gc_count_; |
3792 | 3804 |
3793 } else if (number_idle_notifications == kIdlesBeforeMarkCompact) { | 3805 } else if (number_idle_notifications == kIdlesBeforeMarkCompact) { |
3794 CollectAllGarbage(true); | 3806 CollectAllGarbage(true); |
3795 new_space_.Shrink(); | 3807 new_space_.Shrink(); |
3796 last_gc_count = gc_count_; | 3808 last_gc_count = gc_count_; |
3797 number_idle_notifications = 0; | |
3798 finished = true; | 3809 finished = true; |
3799 | 3810 |
3800 } else if (contexts_disposed_ > 0) { | 3811 } else if (contexts_disposed_ > 0) { |
3801 if (FLAG_expose_gc) { | 3812 if (FLAG_expose_gc) { |
3802 contexts_disposed_ = 0; | 3813 contexts_disposed_ = 0; |
3803 } else { | 3814 } else { |
3804 HistogramTimerScope scope(&Counters::gc_context); | 3815 HistogramTimerScope scope(&Counters::gc_context); |
3805 CollectAllGarbage(false); | 3816 CollectAllGarbage(false); |
3806 last_gc_count = gc_count_; | 3817 last_gc_count = gc_count_; |
3807 } | 3818 } |
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5438 void ExternalStringTable::TearDown() { | 5449 void ExternalStringTable::TearDown() { |
5439 new_space_strings_.Free(); | 5450 new_space_strings_.Free(); |
5440 old_space_strings_.Free(); | 5451 old_space_strings_.Free(); |
5441 } | 5452 } |
5442 | 5453 |
5443 | 5454 |
5444 List<Object*> ExternalStringTable::new_space_strings_; | 5455 List<Object*> ExternalStringTable::new_space_strings_; |
5445 List<Object*> ExternalStringTable::old_space_strings_; | 5456 List<Object*> ExternalStringTable::old_space_strings_; |
5446 | 5457 |
5447 } } // namespace v8::internal | 5458 } } // namespace v8::internal |
OLD | NEW |