OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 SYMBOL_LIST(SYMBOL_ALLOCATION) | 57 SYMBOL_LIST(SYMBOL_ALLOCATION) |
58 #undef SYMBOL_ALLOCATION | 58 #undef SYMBOL_ALLOCATION |
59 | 59 |
60 NewSpace Heap::new_space_; | 60 NewSpace Heap::new_space_; |
61 OldSpace* Heap::old_pointer_space_ = NULL; | 61 OldSpace* Heap::old_pointer_space_ = NULL; |
62 OldSpace* Heap::old_data_space_ = NULL; | 62 OldSpace* Heap::old_data_space_ = NULL; |
63 OldSpace* Heap::code_space_ = NULL; | 63 OldSpace* Heap::code_space_ = NULL; |
64 MapSpace* Heap::map_space_ = NULL; | 64 MapSpace* Heap::map_space_ = NULL; |
65 LargeObjectSpace* Heap::lo_space_ = NULL; | 65 LargeObjectSpace* Heap::lo_space_ = NULL; |
66 | 66 |
67 int Heap::promoted_space_limit_ = 0; | 67 static const int kMinimumPromotionLimit = 2*MB; |
| 68 static const int kMinimumAllocationLimit = 8*MB; |
| 69 |
| 70 int Heap::old_gen_promotion_limit_ = kMinimumPromotionLimit; |
| 71 int Heap::old_gen_allocation_limit_ = kMinimumAllocationLimit; |
| 72 |
68 int Heap::old_gen_exhausted_ = false; | 73 int Heap::old_gen_exhausted_ = false; |
69 | 74 |
70 int Heap::amount_of_external_allocated_memory_ = 0; | 75 int Heap::amount_of_external_allocated_memory_ = 0; |
71 int Heap::amount_of_external_allocated_memory_at_last_global_gc_ = 0; | 76 int Heap::amount_of_external_allocated_memory_at_last_global_gc_ = 0; |
72 | 77 |
73 // semispace_size_ should be a power of 2 and old_generation_size_ should be | 78 // semispace_size_ should be a power of 2 and old_generation_size_ should be |
74 // a multiple of Page::kPageSize. | 79 // a multiple of Page::kPageSize. |
75 int Heap::semispace_size_ = 2*MB; | 80 int Heap::semispace_size_ = 2*MB; |
76 int Heap::old_generation_size_ = 512*MB; | 81 int Heap::old_generation_size_ = 512*MB; |
77 int Heap::initial_semispace_size_ = 256*KB; | 82 int Heap::initial_semispace_size_ = 256*KB; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 136 |
132 | 137 |
133 GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space) { | 138 GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space) { |
134 // Is global GC requested? | 139 // Is global GC requested? |
135 if (space != NEW_SPACE || FLAG_gc_global) { | 140 if (space != NEW_SPACE || FLAG_gc_global) { |
136 Counters::gc_compactor_caused_by_request.Increment(); | 141 Counters::gc_compactor_caused_by_request.Increment(); |
137 return MARK_COMPACTOR; | 142 return MARK_COMPACTOR; |
138 } | 143 } |
139 | 144 |
140 // Is enough data promoted to justify a global GC? | 145 // Is enough data promoted to justify a global GC? |
141 if (PromotedSpaceSize() + PromotedExternalMemorySize() | 146 if (OldGenerationPromotionLimitReached()) { |
142 > promoted_space_limit_) { | |
143 Counters::gc_compactor_caused_by_promoted_data.Increment(); | 147 Counters::gc_compactor_caused_by_promoted_data.Increment(); |
144 return MARK_COMPACTOR; | 148 return MARK_COMPACTOR; |
145 } | 149 } |
146 | 150 |
147 // Have allocation in OLD and LO failed? | 151 // Have allocation in OLD and LO failed? |
148 if (old_gen_exhausted_) { | 152 if (old_gen_exhausted_) { |
149 Counters::gc_compactor_caused_by_oldspace_exhaustion.Increment(); | 153 Counters::gc_compactor_caused_by_oldspace_exhaustion.Increment(); |
150 return MARK_COMPACTOR; | 154 return MARK_COMPACTOR; |
151 } | 155 } |
152 | 156 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 GarbageCollector collector, | 357 GarbageCollector collector, |
354 GCTracer* tracer) { | 358 GCTracer* tracer) { |
355 if (collector == MARK_COMPACTOR && global_gc_prologue_callback_) { | 359 if (collector == MARK_COMPACTOR && global_gc_prologue_callback_) { |
356 ASSERT(!allocation_allowed_); | 360 ASSERT(!allocation_allowed_); |
357 global_gc_prologue_callback_(); | 361 global_gc_prologue_callback_(); |
358 } | 362 } |
359 | 363 |
360 if (collector == MARK_COMPACTOR) { | 364 if (collector == MARK_COMPACTOR) { |
361 MarkCompact(tracer); | 365 MarkCompact(tracer); |
362 | 366 |
363 int promoted_space_size = PromotedSpaceSize(); | 367 int old_gen_size = PromotedSpaceSize(); |
364 promoted_space_limit_ = | 368 old_gen_promotion_limit_ = |
365 promoted_space_size + Max(2 * MB, (promoted_space_size/100) * 35); | 369 old_gen_size + Max(kMinimumPromotionLimit, old_gen_size / 3); |
| 370 old_gen_allocation_limit_ = |
| 371 old_gen_size + Max(kMinimumAllocationLimit, old_gen_size / 3); |
366 old_gen_exhausted_ = false; | 372 old_gen_exhausted_ = false; |
367 | 373 |
368 // If we have used the mark-compact collector to collect the new | 374 // If we have used the mark-compact collector to collect the new |
369 // space, and it has not compacted the new space, we force a | 375 // space, and it has not compacted the new space, we force a |
370 // separate scavenge collection. This is a hack. It covers the | 376 // separate scavenge collection. This is a hack. It covers the |
371 // case where (1) a new space collection was requested, (2) the | 377 // case where (1) a new space collection was requested, (2) the |
372 // collector selection policy selected the mark-compact collector, | 378 // collector selection policy selected the mark-compact collector, |
373 // and (3) the mark-compact collector policy selected not to | 379 // and (3) the mark-compact collector policy selected not to |
374 // compact the new space. In that case, there is no more (usable) | 380 // compact the new space. In that case, there is no more (usable) |
375 // free space in the new space after the collection compared to | 381 // free space in the new space after the collection compared to |
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 | 2290 |
2285 | 2291 |
2286 // This function expects that NewSpace's allocated objects histogram is | 2292 // This function expects that NewSpace's allocated objects histogram is |
2287 // populated (via a call to CollectStatistics or else as a side effect of a | 2293 // populated (via a call to CollectStatistics or else as a side effect of a |
2288 // just-completed scavenge collection). | 2294 // just-completed scavenge collection). |
2289 void Heap::ReportHeapStatistics(const char* title) { | 2295 void Heap::ReportHeapStatistics(const char* title) { |
2290 USE(title); | 2296 USE(title); |
2291 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", | 2297 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", |
2292 title, gc_count_); | 2298 title, gc_count_); |
2293 PrintF("mark-compact GC : %d\n", mc_count_); | 2299 PrintF("mark-compact GC : %d\n", mc_count_); |
2294 PrintF("promoted_space_limit_ %d\n", promoted_space_limit_); | 2300 PrintF("old_gen_promotion_limit_ %d\n", old_gen_promotion_limit_); |
| 2301 PrintF("old_gen_allocation_limit_ %d\n", old_gen_allocation_limit_); |
2295 | 2302 |
2296 PrintF("\n"); | 2303 PrintF("\n"); |
2297 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles()); | 2304 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles()); |
2298 GlobalHandles::PrintStats(); | 2305 GlobalHandles::PrintStats(); |
2299 PrintF("\n"); | 2306 PrintF("\n"); |
2300 | 2307 |
2301 PrintF("Heap statistics : "); | 2308 PrintF("Heap statistics : "); |
2302 MemoryAllocator::ReportStatistics(); | 2309 MemoryAllocator::ReportStatistics(); |
2303 PrintF("To space : "); | 2310 PrintF("To space : "); |
2304 new_space_.ReportStatistics(); | 2311 new_space_.ReportStatistics(); |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3186 #ifdef DEBUG | 3193 #ifdef DEBUG |
3187 bool Heap::GarbageCollectionGreedyCheck() { | 3194 bool Heap::GarbageCollectionGreedyCheck() { |
3188 ASSERT(FLAG_gc_greedy); | 3195 ASSERT(FLAG_gc_greedy); |
3189 if (Bootstrapper::IsActive()) return true; | 3196 if (Bootstrapper::IsActive()) return true; |
3190 if (disallow_allocation_failure()) return true; | 3197 if (disallow_allocation_failure()) return true; |
3191 return CollectGarbage(0, NEW_SPACE); | 3198 return CollectGarbage(0, NEW_SPACE); |
3192 } | 3199 } |
3193 #endif | 3200 #endif |
3194 | 3201 |
3195 } } // namespace v8::internal | 3202 } } // namespace v8::internal |
OLD | NEW |