| OLD | NEW |
| 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 3058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3069 } | 3069 } |
| 3070 | 3070 |
| 3071 | 3071 |
| 3072 bool Heap::IdleNotification() { | 3072 bool Heap::IdleNotification() { |
| 3073 static const int kIdlesBeforeScavenge = 4; | 3073 static const int kIdlesBeforeScavenge = 4; |
| 3074 static const int kIdlesBeforeMarkSweep = 7; | 3074 static const int kIdlesBeforeMarkSweep = 7; |
| 3075 static const int kIdlesBeforeMarkCompact = 8; | 3075 static const int kIdlesBeforeMarkCompact = 8; |
| 3076 static int number_idle_notifications = 0; | 3076 static int number_idle_notifications = 0; |
| 3077 static int last_gc_count = gc_count_; | 3077 static int last_gc_count = gc_count_; |
| 3078 | 3078 |
| 3079 if (!FLAG_expose_gc && (contexts_disposed_ > 0)) { | 3079 bool uncommit = true; |
| 3080 HistogramTimerScope scope(&Counters::gc_context); | |
| 3081 CollectAllGarbage(false); | |
| 3082 ASSERT(contexts_disposed_ == 0); | |
| 3083 last_gc_count = gc_count_; | |
| 3084 return false; | |
| 3085 } | |
| 3086 | |
| 3087 bool finished = false; | 3080 bool finished = false; |
| 3088 | 3081 |
| 3089 if (last_gc_count == gc_count_) { | 3082 if (last_gc_count == gc_count_) { |
| 3090 number_idle_notifications++; | 3083 number_idle_notifications++; |
| 3091 } else { | 3084 } else { |
| 3092 number_idle_notifications = 0; | 3085 number_idle_notifications = 0; |
| 3093 last_gc_count = gc_count_; | 3086 last_gc_count = gc_count_; |
| 3094 } | 3087 } |
| 3095 | 3088 |
| 3096 if (number_idle_notifications == kIdlesBeforeScavenge) { | 3089 if (number_idle_notifications == kIdlesBeforeScavenge) { |
| 3097 CollectGarbage(0, NEW_SPACE); | 3090 if (contexts_disposed_ > 0) { |
| 3091 HistogramTimerScope scope(&Counters::gc_context); |
| 3092 CollectAllGarbage(false); |
| 3093 } else { |
| 3094 CollectGarbage(0, NEW_SPACE); |
| 3095 } |
| 3098 new_space_.Shrink(); | 3096 new_space_.Shrink(); |
| 3099 last_gc_count = gc_count_; | 3097 last_gc_count = gc_count_; |
| 3100 | 3098 |
| 3101 } else if (number_idle_notifications == kIdlesBeforeMarkSweep) { | 3099 } else if (number_idle_notifications == kIdlesBeforeMarkSweep) { |
| 3102 // Before doing the mark-sweep collections we clear the | 3100 // Before doing the mark-sweep collections we clear the |
| 3103 // compilation cache to avoid hanging on to source code and | 3101 // compilation cache to avoid hanging on to source code and |
| 3104 // generated code for cached functions. | 3102 // generated code for cached functions. |
| 3105 CompilationCache::Clear(); | 3103 CompilationCache::Clear(); |
| 3106 | 3104 |
| 3107 CollectAllGarbage(false); | 3105 CollectAllGarbage(false); |
| 3108 new_space_.Shrink(); | 3106 new_space_.Shrink(); |
| 3109 last_gc_count = gc_count_; | 3107 last_gc_count = gc_count_; |
| 3110 | 3108 |
| 3111 } else if (number_idle_notifications == kIdlesBeforeMarkCompact) { | 3109 } else if (number_idle_notifications == kIdlesBeforeMarkCompact) { |
| 3112 CollectAllGarbage(true); | 3110 CollectAllGarbage(true); |
| 3113 new_space_.Shrink(); | 3111 new_space_.Shrink(); |
| 3114 last_gc_count = gc_count_; | 3112 last_gc_count = gc_count_; |
| 3115 number_idle_notifications = 0; | 3113 number_idle_notifications = 0; |
| 3116 finished = true; | 3114 finished = true; |
| 3115 |
| 3116 } else if (contexts_disposed_ > 0) { |
| 3117 if (FLAG_expose_gc) { |
| 3118 contexts_disposed_ = 0; |
| 3119 } else { |
| 3120 HistogramTimerScope scope(&Counters::gc_context); |
| 3121 CollectAllGarbage(false); |
| 3122 last_gc_count = gc_count_; |
| 3123 } |
| 3124 // If this is the first idle notification, we reset the |
| 3125 // notification count to avoid letting idle notifications for |
| 3126 // context disposal garbage collections start a potentially too |
| 3127 // aggressive idle GC cycle. |
| 3128 if (number_idle_notifications <= 1) { |
| 3129 number_idle_notifications = 0; |
| 3130 uncommit = false; |
| 3131 } |
| 3117 } | 3132 } |
| 3118 | 3133 |
| 3119 // Uncommit unused memory in new space. | 3134 // Make sure that we have no pending context disposals and |
| 3120 Heap::UncommitFromSpace(); | 3135 // conditionally uncommit from space. |
| 3136 ASSERT(contexts_disposed_ == 0); |
| 3137 if (uncommit) Heap::UncommitFromSpace(); |
| 3121 return finished; | 3138 return finished; |
| 3122 } | 3139 } |
| 3123 | 3140 |
| 3124 | 3141 |
| 3125 #ifdef DEBUG | 3142 #ifdef DEBUG |
| 3126 | 3143 |
| 3127 void Heap::Print() { | 3144 void Heap::Print() { |
| 3128 if (!HasBeenSetup()) return; | 3145 if (!HasBeenSetup()) return; |
| 3129 Top::PrintStack(); | 3146 Top::PrintStack(); |
| 3130 AllSpaces spaces; | 3147 AllSpaces spaces; |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4234 void ExternalStringTable::TearDown() { | 4251 void ExternalStringTable::TearDown() { |
| 4235 new_space_strings_.Free(); | 4252 new_space_strings_.Free(); |
| 4236 old_space_strings_.Free(); | 4253 old_space_strings_.Free(); |
| 4237 } | 4254 } |
| 4238 | 4255 |
| 4239 | 4256 |
| 4240 List<Object*> ExternalStringTable::new_space_strings_; | 4257 List<Object*> ExternalStringTable::new_space_strings_; |
| 4241 List<Object*> ExternalStringTable::old_space_strings_; | 4258 List<Object*> ExternalStringTable::old_space_strings_; |
| 4242 | 4259 |
| 4243 } } // namespace v8::internal | 4260 } } // namespace v8::internal |
| OLD | NEW |