Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 Object* Heap::roots_[Heap::kRootListLength]; | 56 Object* Heap::roots_[Heap::kRootListLength]; |
| 57 | 57 |
| 58 NewSpace Heap::new_space_; | 58 NewSpace Heap::new_space_; |
| 59 OldSpace* Heap::old_pointer_space_ = NULL; | 59 OldSpace* Heap::old_pointer_space_ = NULL; |
| 60 OldSpace* Heap::old_data_space_ = NULL; | 60 OldSpace* Heap::old_data_space_ = NULL; |
| 61 OldSpace* Heap::code_space_ = NULL; | 61 OldSpace* Heap::code_space_ = NULL; |
| 62 MapSpace* Heap::map_space_ = NULL; | 62 MapSpace* Heap::map_space_ = NULL; |
| 63 CellSpace* Heap::cell_space_ = NULL; | 63 CellSpace* Heap::cell_space_ = NULL; |
| 64 LargeObjectSpace* Heap::lo_space_ = NULL; | 64 LargeObjectSpace* Heap::lo_space_ = NULL; |
| 65 | 65 |
| 66 int Heap::old_gen_promotion_limit_ = kMinimumPromotionLimit; | 66 intptr_t Heap::old_gen_promotion_limit_ = kMinimumPromotionLimit; |
| 67 int Heap::old_gen_allocation_limit_ = kMinimumAllocationLimit; | 67 intptr_t Heap::old_gen_allocation_limit_ = kMinimumAllocationLimit; |
| 68 | 68 |
| 69 int Heap::old_gen_exhausted_ = false; | 69 int Heap::old_gen_exhausted_ = false; |
| 70 | 70 |
| 71 int Heap::amount_of_external_allocated_memory_ = 0; | 71 int Heap::amount_of_external_allocated_memory_ = 0; |
| 72 int Heap::amount_of_external_allocated_memory_at_last_global_gc_ = 0; | 72 int Heap::amount_of_external_allocated_memory_at_last_global_gc_ = 0; |
| 73 | 73 |
| 74 // semispace_size_ should be a power of 2 and old_generation_size_ should be | 74 // semispace_size_ should be a power of 2 and old_generation_size_ should be |
| 75 // a multiple of Page::kPageSize. | 75 // a multiple of Page::kPageSize. |
| 76 #if defined(ANDROID) | 76 #if defined(ANDROID) |
| 77 int Heap::max_semispace_size_ = 2*MB; | 77 int Heap::max_semispace_size_ = 2*MB; |
| 78 int Heap::max_old_generation_size_ = 192*MB; | 78 intptr_t Heap::max_old_generation_size_ = 192*MB; |
| 79 int Heap::initial_semispace_size_ = 128*KB; | 79 int Heap::initial_semispace_size_ = 128*KB; |
| 80 size_t Heap::code_range_size_ = 0; | 80 intptr_t Heap::code_range_size_ = 0; |
| 81 #elif defined(V8_TARGET_ARCH_X64) | 81 #elif defined(V8_TARGET_ARCH_X64) |
| 82 int Heap::max_semispace_size_ = 16*MB; | 82 int Heap::max_semispace_size_ = 16*MB; |
| 83 int Heap::max_old_generation_size_ = 1*GB; | 83 intptr_t Heap::max_old_generation_size_ = 1*GB; |
| 84 int Heap::initial_semispace_size_ = 1*MB; | 84 int Heap::initial_semispace_size_ = 1*MB; |
| 85 size_t Heap::code_range_size_ = 512*MB; | 85 intptr_t Heap::code_range_size_ = 512*MB; |
| 86 #else | 86 #else |
| 87 int Heap::max_semispace_size_ = 8*MB; | 87 int Heap::max_semispace_size_ = 8*MB; |
| 88 int Heap::max_old_generation_size_ = 512*MB; | 88 intptr_t Heap::max_old_generation_size_ = 512*MB; |
| 89 int Heap::initial_semispace_size_ = 512*KB; | 89 int Heap::initial_semispace_size_ = 512*KB; |
| 90 size_t Heap::code_range_size_ = 0; | 90 intptr_t Heap::code_range_size_ = 0; |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 // The snapshot semispace size will be the default semispace size if | 93 // The snapshot semispace size will be the default semispace size if |
| 94 // snapshotting is used and will be the requested semispace size as | 94 // snapshotting is used and will be the requested semispace size as |
| 95 // set up by ConfigureHeap otherwise. | 95 // set up by ConfigureHeap otherwise. |
| 96 int Heap::reserved_semispace_size_ = Heap::max_semispace_size_; | 96 int Heap::reserved_semispace_size_ = Heap::max_semispace_size_; |
| 97 | 97 |
| 98 List<Heap::GCPrologueCallbackPair> Heap::gc_prologue_callbacks_; | 98 List<Heap::GCPrologueCallbackPair> Heap::gc_prologue_callbacks_; |
| 99 List<Heap::GCEpilogueCallbackPair> Heap::gc_epilogue_callbacks_; | 99 List<Heap::GCEpilogueCallbackPair> Heap::gc_epilogue_callbacks_; |
| 100 | 100 |
| 101 GCCallback Heap::global_gc_prologue_callback_ = NULL; | 101 GCCallback Heap::global_gc_prologue_callback_ = NULL; |
| 102 GCCallback Heap::global_gc_epilogue_callback_ = NULL; | 102 GCCallback Heap::global_gc_epilogue_callback_ = NULL; |
| 103 HeapObjectCallback Heap::gc_safe_size_of_old_object_ = NULL; | 103 HeapObjectCallback Heap::gc_safe_size_of_old_object_ = NULL; |
| 104 | 104 |
| 105 // Variables set based on semispace_size_ and old_generation_size_ in | 105 // Variables set based on semispace_size_ and old_generation_size_ in |
| 106 // ConfigureHeap. | 106 // ConfigureHeap. |
| 107 | 107 |
| 108 // Will be 4 * reserved_semispace_size_ to ensure that young | 108 // Will be 4 * reserved_semispace_size_ to ensure that young |
| 109 // generation can be aligned to its size. | 109 // generation can be aligned to its size. |
| 110 int Heap::survived_since_last_expansion_ = 0; | 110 int Heap::survived_since_last_expansion_ = 0; |
| 111 int Heap::external_allocation_limit_ = 0; | 111 intptr_t Heap::external_allocation_limit_ = 0; |
| 112 | 112 |
| 113 Heap::HeapState Heap::gc_state_ = NOT_IN_GC; | 113 Heap::HeapState Heap::gc_state_ = NOT_IN_GC; |
| 114 | 114 |
| 115 int Heap::mc_count_ = 0; | 115 int Heap::mc_count_ = 0; |
| 116 int Heap::ms_count_ = 0; | 116 int Heap::ms_count_ = 0; |
| 117 int Heap::gc_count_ = 0; | 117 int Heap::gc_count_ = 0; |
| 118 | 118 |
| 119 GCTracer* Heap::tracer_ = NULL; | 119 GCTracer* Heap::tracer_ = NULL; |
| 120 | 120 |
| 121 int Heap::unflattened_strings_length_ = 0; | 121 int Heap::unflattened_strings_length_ = 0; |
| 122 | 122 |
| 123 int Heap::always_allocate_scope_depth_ = 0; | 123 int Heap::always_allocate_scope_depth_ = 0; |
| 124 int Heap::linear_allocation_scope_depth_ = 0; | 124 int Heap::linear_allocation_scope_depth_ = 0; |
| 125 int Heap::contexts_disposed_ = 0; | 125 int Heap::contexts_disposed_ = 0; |
| 126 | 126 |
| 127 int Heap::young_survivors_after_last_gc_ = 0; | 127 int Heap::young_survivors_after_last_gc_ = 0; |
| 128 int Heap::high_survival_rate_period_length_ = 0; | 128 int Heap::high_survival_rate_period_length_ = 0; |
| 129 double Heap::survival_rate_ = 0; | 129 double Heap::survival_rate_ = 0; |
| 130 Heap::SurvivalRateTrend Heap::previous_survival_rate_trend_ = Heap::STABLE; | 130 Heap::SurvivalRateTrend Heap::previous_survival_rate_trend_ = Heap::STABLE; |
| 131 Heap::SurvivalRateTrend Heap::survival_rate_trend_ = Heap::STABLE; | 131 Heap::SurvivalRateTrend Heap::survival_rate_trend_ = Heap::STABLE; |
| 132 | 132 |
| 133 #ifdef DEBUG | 133 #ifdef DEBUG |
| 134 bool Heap::allocation_allowed_ = true; | 134 bool Heap::allocation_allowed_ = true; |
| 135 | 135 |
| 136 int Heap::allocation_timeout_ = 0; | 136 int Heap::allocation_timeout_ = 0; |
| 137 bool Heap::disallow_allocation_failure_ = false; | 137 bool Heap::disallow_allocation_failure_ = false; |
| 138 #endif // DEBUG | 138 #endif // DEBUG |
| 139 | 139 |
| 140 int GCTracer::alive_after_last_gc_ = 0; | 140 intptr_t GCTracer::alive_after_last_gc_ = 0; |
| 141 double GCTracer::last_gc_end_timestamp_ = 0.0; | 141 double GCTracer::last_gc_end_timestamp_ = 0.0; |
| 142 int GCTracer::max_gc_pause_ = 0; | 142 int GCTracer::max_gc_pause_ = 0; |
| 143 int GCTracer::max_alive_after_gc_ = 0; | 143 intptr_t GCTracer::max_alive_after_gc_ = 0; |
| 144 int GCTracer::min_in_mutator_ = kMaxInt; | 144 int GCTracer::min_in_mutator_ = kMaxInt; |
| 145 | 145 |
| 146 int Heap::Capacity() { | 146 intptr_t Heap::Capacity() { |
| 147 if (!HasBeenSetup()) return 0; | 147 if (!HasBeenSetup()) return 0; |
| 148 | 148 |
| 149 return new_space_.Capacity() + | 149 return new_space_.Capacity() + |
| 150 old_pointer_space_->Capacity() + | 150 old_pointer_space_->Capacity() + |
| 151 old_data_space_->Capacity() + | 151 old_data_space_->Capacity() + |
| 152 code_space_->Capacity() + | 152 code_space_->Capacity() + |
| 153 map_space_->Capacity() + | 153 map_space_->Capacity() + |
| 154 cell_space_->Capacity(); | 154 cell_space_->Capacity(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 int Heap::CommittedMemory() { | 158 intptr_t Heap::CommittedMemory() { |
| 159 if (!HasBeenSetup()) return 0; | 159 if (!HasBeenSetup()) return 0; |
| 160 | 160 |
| 161 return new_space_.CommittedMemory() + | 161 return new_space_.CommittedMemory() + |
| 162 old_pointer_space_->CommittedMemory() + | 162 old_pointer_space_->CommittedMemory() + |
| 163 old_data_space_->CommittedMemory() + | 163 old_data_space_->CommittedMemory() + |
| 164 code_space_->CommittedMemory() + | 164 code_space_->CommittedMemory() + |
| 165 map_space_->CommittedMemory() + | 165 map_space_->CommittedMemory() + |
| 166 cell_space_->CommittedMemory() + | 166 cell_space_->CommittedMemory() + |
| 167 lo_space_->Size(); | 167 lo_space_->Size(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 | 170 |
| 171 int Heap::Available() { | 171 intptr_t Heap::Available() { |
| 172 if (!HasBeenSetup()) return 0; | 172 if (!HasBeenSetup()) return 0; |
| 173 | 173 |
| 174 return new_space_.Available() + | 174 return new_space_.Available() + |
| 175 old_pointer_space_->Available() + | 175 old_pointer_space_->Available() + |
| 176 old_data_space_->Available() + | 176 old_data_space_->Available() + |
| 177 code_space_->Available() + | 177 code_space_->Available() + |
| 178 map_space_->Available() + | 178 map_space_->Available() + |
| 179 cell_space_->Available(); | 179 cell_space_->Available(); |
| 180 } | 180 } |
| 181 | 181 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 new_space_.ReportStatistics(); | 282 new_space_.ReportStatistics(); |
| 283 new_space_.ClearHistograms(); | 283 new_space_.ClearHistograms(); |
| 284 } | 284 } |
| 285 #endif | 285 #endif |
| 286 } | 286 } |
| 287 | 287 |
| 288 | 288 |
| 289 #if defined(ENABLE_LOGGING_AND_PROFILING) | 289 #if defined(ENABLE_LOGGING_AND_PROFILING) |
| 290 void Heap::PrintShortHeapStatistics() { | 290 void Heap::PrintShortHeapStatistics() { |
| 291 if (!FLAG_trace_gc_verbose) return; | 291 if (!FLAG_trace_gc_verbose) return; |
| 292 PrintF("Memory allocator, used: %8d, available: %8d\n", | 292 PrintF("Memory allocator, used: %8" V8_PTR_PREFIX "d" |
| 293 ", available: %8" V8_PTR_PREFIX "d\n", | |
| 293 MemoryAllocator::Size(), | 294 MemoryAllocator::Size(), |
| 294 MemoryAllocator::Available()); | 295 MemoryAllocator::Available()); |
| 295 PrintF("New space, used: %8d, available: %8d\n", | 296 PrintF("New space, used: %8" V8_PTR_PREFIX "d" |
| 297 ", available: %8" V8_PTR_PREFIX "d\n", | |
| 296 Heap::new_space_.Size(), | 298 Heap::new_space_.Size(), |
| 297 new_space_.Available()); | 299 new_space_.Available()); |
| 298 PrintF("Old pointers, used: %8d, available: %8d, waste: %8d\n", | 300 PrintF("Old pointers, used: %8" V8_PTR_PREFIX "d" |
| 301 ", available: %8" V8_PTR_PREFIX "d" | |
| 302 ", waste: %8" V8_PTR_PREFIX "d\n", | |
| 299 old_pointer_space_->Size(), | 303 old_pointer_space_->Size(), |
| 300 old_pointer_space_->Available(), | 304 old_pointer_space_->Available(), |
| 301 old_pointer_space_->Waste()); | 305 old_pointer_space_->Waste()); |
| 302 PrintF("Old data space, used: %8d, available: %8d, waste: %8d\n", | 306 PrintF("Old data space, used: %8" V8_PTR_PREFIX "d" |
| 307 ", available: %8" V8_PTR_PREFIX "d" | |
| 308 ", waste: %8" V8_PTR_PREFIX "d\n", | |
| 303 old_data_space_->Size(), | 309 old_data_space_->Size(), |
| 304 old_data_space_->Available(), | 310 old_data_space_->Available(), |
| 305 old_data_space_->Waste()); | 311 old_data_space_->Waste()); |
| 306 PrintF("Code space, used: %8d, available: %8d, waste: %8d\n", | 312 PrintF("Code space, used: %8" V8_PTR_PREFIX "d" |
| 313 ", available: %8" V8_PTR_PREFIX "d" | |
| 314 ", waste: %8" V8_PTR_PREFIX "d\n", | |
| 307 code_space_->Size(), | 315 code_space_->Size(), |
| 308 code_space_->Available(), | 316 code_space_->Available(), |
| 309 code_space_->Waste()); | 317 code_space_->Waste()); |
| 310 PrintF("Map space, used: %8d, available: %8d, waste: %8d\n", | 318 PrintF("Map space, used: %8" V8_PTR_PREFIX "d" |
| 319 ", available: %8" V8_PTR_PREFIX "d" | |
| 320 ", waste: %8" V8_PTR_PREFIX "d\n", | |
| 311 map_space_->Size(), | 321 map_space_->Size(), |
| 312 map_space_->Available(), | 322 map_space_->Available(), |
| 313 map_space_->Waste()); | 323 map_space_->Waste()); |
| 314 PrintF("Cell space, used: %8d, available: %8d, waste: %8d\n", | 324 PrintF("Cell space, used: %8" V8_PTR_PREFIX "d" |
| 325 ", available: %8" V8_PTR_PREFIX "d" | |
| 326 ", waste: %8" V8_PTR_PREFIX "d\n", | |
| 315 cell_space_->Size(), | 327 cell_space_->Size(), |
| 316 cell_space_->Available(), | 328 cell_space_->Available(), |
| 317 cell_space_->Waste()); | 329 cell_space_->Waste()); |
| 318 PrintF("Large object space, used: %8d, avaialble: %8d\n", | 330 PrintF("Large object space, used: %8" V8_PTR_PREFIX "d" |
| 331 ", available: %8" V8_PTR_PREFIX "d\n", | |
| 319 lo_space_->Size(), | 332 lo_space_->Size(), |
| 320 lo_space_->Available()); | 333 lo_space_->Available()); |
| 321 } | 334 } |
| 322 #endif | 335 #endif |
| 323 | 336 |
| 324 | 337 |
| 325 // TODO(1238405): Combine the infrastructure for --heap-stats and | 338 // TODO(1238405): Combine the infrastructure for --heap-stats and |
| 326 // --log-gc to avoid the complicated preprocessor and flag testing. | 339 // --log-gc to avoid the complicated preprocessor and flag testing. |
| 327 void Heap::ReportStatisticsAfterGC() { | 340 void Heap::ReportStatisticsAfterGC() { |
| 328 // Similar to the before GC, we use some complicated logic to ensure that | 341 // Similar to the before GC, we use some complicated logic to ensure that |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 357 } | 370 } |
| 358 | 371 |
| 359 if (FLAG_gc_verbose) Print(); | 372 if (FLAG_gc_verbose) Print(); |
| 360 #endif | 373 #endif |
| 361 | 374 |
| 362 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) | 375 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) |
| 363 ReportStatisticsBeforeGC(); | 376 ReportStatisticsBeforeGC(); |
| 364 #endif | 377 #endif |
| 365 } | 378 } |
| 366 | 379 |
| 367 int Heap::SizeOfObjects() { | 380 intptr_t Heap::SizeOfObjects() { |
| 368 int total = 0; | 381 intptr_t total = 0; |
| 369 AllSpaces spaces; | 382 AllSpaces spaces; |
| 370 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { | 383 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { |
| 371 total += space->Size(); | 384 total += space->Size(); |
| 372 } | 385 } |
| 373 return total; | 386 return total; |
| 374 } | 387 } |
| 375 | 388 |
| 376 void Heap::GarbageCollectionEpilogue() { | 389 void Heap::GarbageCollectionEpilogue() { |
| 377 #ifdef DEBUG | 390 #ifdef DEBUG |
| 378 allow_allocation(true); | 391 allow_allocation(true); |
| 379 ZapFromSpace(); | 392 ZapFromSpace(); |
| 380 | 393 |
| 381 if (FLAG_verify_heap) { | 394 if (FLAG_verify_heap) { |
| 382 Verify(); | 395 Verify(); |
| 383 } | 396 } |
| 384 | 397 |
| 385 if (FLAG_print_global_handles) GlobalHandles::Print(); | 398 if (FLAG_print_global_handles) GlobalHandles::Print(); |
| 386 if (FLAG_print_handles) PrintHandles(); | 399 if (FLAG_print_handles) PrintHandles(); |
| 387 if (FLAG_gc_verbose) Print(); | 400 if (FLAG_gc_verbose) Print(); |
| 388 if (FLAG_code_stats) ReportCodeStatistics("After GC"); | 401 if (FLAG_code_stats) ReportCodeStatistics("After GC"); |
| 389 #endif | 402 #endif |
| 390 | 403 |
| 391 Counters::alive_after_last_gc.Set(SizeOfObjects()); | 404 Counters::alive_after_last_gc.Set(static_cast<int>(SizeOfObjects())); |
| 392 | 405 |
| 393 Counters::symbol_table_capacity.Set(symbol_table()->Capacity()); | 406 Counters::symbol_table_capacity.Set(symbol_table()->Capacity()); |
| 394 Counters::number_of_symbols.Set(symbol_table()->NumberOfElements()); | 407 Counters::number_of_symbols.Set(symbol_table()->NumberOfElements()); |
| 395 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) | 408 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) |
| 396 ReportStatisticsAfterGC(); | 409 ReportStatisticsAfterGC(); |
| 397 #endif | 410 #endif |
| 398 #ifdef ENABLE_DEBUGGER_SUPPORT | 411 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 399 Debug::AfterGarbageCollection(); | 412 Debug::AfterGarbageCollection(); |
| 400 #endif | 413 #endif |
| 401 } | 414 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 collector == MARK_COMPACTOR ? kGCTypeMarkSweepCompact : kGCTypeScavenge; | 696 collector == MARK_COMPACTOR ? kGCTypeMarkSweepCompact : kGCTypeScavenge; |
| 684 | 697 |
| 685 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { | 698 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { |
| 686 if (gc_type & gc_prologue_callbacks_[i].gc_type) { | 699 if (gc_type & gc_prologue_callbacks_[i].gc_type) { |
| 687 gc_prologue_callbacks_[i].callback(gc_type, kNoGCCallbackFlags); | 700 gc_prologue_callbacks_[i].callback(gc_type, kNoGCCallbackFlags); |
| 688 } | 701 } |
| 689 } | 702 } |
| 690 | 703 |
| 691 EnsureFromSpaceIsCommitted(); | 704 EnsureFromSpaceIsCommitted(); |
| 692 | 705 |
| 693 int start_new_space_size = Heap::new_space()->Size(); | 706 int start_new_space_size = static_cast<int>(Heap::new_space()->IntSize()); |
|
Vyacheslav Egorov (Chromium)
2010/09/29 14:55:20
seems wrong.
Erik Corry
2010/09/30 07:09:38
Done.
| |
| 694 | 707 |
| 695 if (collector == MARK_COMPACTOR) { | 708 if (collector == MARK_COMPACTOR) { |
| 696 // Perform mark-sweep with optional compaction. | 709 // Perform mark-sweep with optional compaction. |
| 697 MarkCompact(tracer); | 710 MarkCompact(tracer); |
| 698 | 711 |
| 699 bool high_survival_rate_during_scavenges = IsHighSurvivalRate() && | 712 bool high_survival_rate_during_scavenges = IsHighSurvivalRate() && |
| 700 IsStableOrIncreasingSurvivalTrend(); | 713 IsStableOrIncreasingSurvivalTrend(); |
| 701 | 714 |
| 702 UpdateSurvivalRateTrend(start_new_space_size); | 715 UpdateSurvivalRateTrend(start_new_space_size); |
| 703 | 716 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 955 old_pointer_space_->FlushTopPageWatermark(); | 968 old_pointer_space_->FlushTopPageWatermark(); |
| 956 map_space_->FlushTopPageWatermark(); | 969 map_space_->FlushTopPageWatermark(); |
| 957 | 970 |
| 958 // Implements Cheney's copying algorithm | 971 // Implements Cheney's copying algorithm |
| 959 LOG(ResourceEvent("scavenge", "begin")); | 972 LOG(ResourceEvent("scavenge", "begin")); |
| 960 | 973 |
| 961 // Clear descriptor cache. | 974 // Clear descriptor cache. |
| 962 DescriptorLookupCache::Clear(); | 975 DescriptorLookupCache::Clear(); |
| 963 | 976 |
| 964 // Used for updating survived_since_last_expansion_ at function end. | 977 // Used for updating survived_since_last_expansion_ at function end. |
| 965 int survived_watermark = PromotedSpaceSize(); | 978 intptr_t survived_watermark = PromotedSpaceSize(); |
| 966 | 979 |
| 967 CheckNewSpaceExpansionCriteria(); | 980 CheckNewSpaceExpansionCriteria(); |
| 968 | 981 |
| 969 // Flip the semispaces. After flipping, to space is empty, from space has | 982 // Flip the semispaces. After flipping, to space is empty, from space has |
| 970 // live objects. | 983 // live objects. |
| 971 new_space_.Flip(); | 984 new_space_.Flip(); |
| 972 new_space_.ResetAllocationInfo(); | 985 new_space_.ResetAllocationInfo(); |
| 973 | 986 |
| 974 // We need to sweep newly copied objects which can be either in the | 987 // We need to sweep newly copied objects which can be either in the |
| 975 // to space or promoted to the old generation. For to-space | 988 // to space or promoted to the old generation. For to-space |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1025 | 1038 |
| 1026 UpdateNewSpaceReferencesInExternalStringTable( | 1039 UpdateNewSpaceReferencesInExternalStringTable( |
| 1027 &UpdateNewSpaceReferenceInExternalStringTableEntry); | 1040 &UpdateNewSpaceReferenceInExternalStringTableEntry); |
| 1028 | 1041 |
| 1029 ASSERT(new_space_front == new_space_.top()); | 1042 ASSERT(new_space_front == new_space_.top()); |
| 1030 | 1043 |
| 1031 // Set age mark. | 1044 // Set age mark. |
| 1032 new_space_.set_age_mark(new_space_.top()); | 1045 new_space_.set_age_mark(new_space_.top()); |
| 1033 | 1046 |
| 1034 // Update how much has survived scavenge. | 1047 // Update how much has survived scavenge. |
| 1035 IncrementYoungSurvivorsCounter( | 1048 IncrementYoungSurvivorsCounter(static_cast<int>( |
| 1036 (PromotedSpaceSize() - survived_watermark) + new_space_.Size()); | 1049 (PromotedSpaceSize() - survived_watermark) + new_space_.Size())); |
| 1037 | 1050 |
| 1038 LOG(ResourceEvent("scavenge", "end")); | 1051 LOG(ResourceEvent("scavenge", "end")); |
| 1039 | 1052 |
| 1040 gc_state_ = NOT_IN_GC; | 1053 gc_state_ = NOT_IN_GC; |
| 1041 } | 1054 } |
| 1042 | 1055 |
| 1043 | 1056 |
| 1044 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Object** p) { | 1057 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Object** p) { |
| 1045 MapWord first_word = HeapObject::cast(*p)->map_word(); | 1058 MapWord first_word = HeapObject::cast(*p)->map_word(); |
| 1046 | 1059 |
| (...skipping 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3489 | 3502 |
| 3490 | 3503 |
| 3491 // This function expects that NewSpace's allocated objects histogram is | 3504 // This function expects that NewSpace's allocated objects histogram is |
| 3492 // populated (via a call to CollectStatistics or else as a side effect of a | 3505 // populated (via a call to CollectStatistics or else as a side effect of a |
| 3493 // just-completed scavenge collection). | 3506 // just-completed scavenge collection). |
| 3494 void Heap::ReportHeapStatistics(const char* title) { | 3507 void Heap::ReportHeapStatistics(const char* title) { |
| 3495 USE(title); | 3508 USE(title); |
| 3496 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", | 3509 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", |
| 3497 title, gc_count_); | 3510 title, gc_count_); |
| 3498 PrintF("mark-compact GC : %d\n", mc_count_); | 3511 PrintF("mark-compact GC : %d\n", mc_count_); |
| 3499 PrintF("old_gen_promotion_limit_ %d\n", old_gen_promotion_limit_); | 3512 PrintF("old_gen_promotion_limit_ %" V8_PTR_PREFIX "d\n", |
| 3500 PrintF("old_gen_allocation_limit_ %d\n", old_gen_allocation_limit_); | 3513 old_gen_promotion_limit_); |
| 3514 PrintF("old_gen_allocation_limit_ %" V8_PTR_PREFIX "d\n", | |
| 3515 old_gen_allocation_limit_); | |
| 3501 | 3516 |
| 3502 PrintF("\n"); | 3517 PrintF("\n"); |
| 3503 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles()); | 3518 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles()); |
| 3504 GlobalHandles::PrintStats(); | 3519 GlobalHandles::PrintStats(); |
| 3505 PrintF("\n"); | 3520 PrintF("\n"); |
| 3506 | 3521 |
| 3507 PrintF("Heap statistics : "); | 3522 PrintF("Heap statistics : "); |
| 3508 MemoryAllocator::ReportStatistics(); | 3523 MemoryAllocator::ReportStatistics(); |
| 3509 PrintF("To space : "); | 3524 PrintF("To space : "); |
| 3510 new_space_.ReportStatistics(); | 3525 new_space_.ReportStatistics(); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4062 | 4077 |
| 4063 // The old generation is paged. | 4078 // The old generation is paged. |
| 4064 max_old_generation_size_ = RoundUp(max_old_generation_size_, Page::kPageSize); | 4079 max_old_generation_size_ = RoundUp(max_old_generation_size_, Page::kPageSize); |
| 4065 | 4080 |
| 4066 heap_configured = true; | 4081 heap_configured = true; |
| 4067 return true; | 4082 return true; |
| 4068 } | 4083 } |
| 4069 | 4084 |
| 4070 | 4085 |
| 4071 bool Heap::ConfigureHeapDefault() { | 4086 bool Heap::ConfigureHeapDefault() { |
| 4072 return ConfigureHeap(FLAG_max_new_space_size / 2, FLAG_max_old_space_size); | 4087 return ConfigureHeap( |
| 4088 FLAG_max_new_space_size * (KB / 2), FLAG_max_old_space_size * MB); | |
| 4073 } | 4089 } |
| 4074 | 4090 |
| 4075 | 4091 |
| 4076 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { | 4092 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { |
| 4077 *stats->start_marker = HeapStats::kStartMarker; | 4093 *stats->start_marker = HeapStats::kStartMarker; |
| 4078 *stats->end_marker = HeapStats::kEndMarker; | 4094 *stats->end_marker = HeapStats::kEndMarker; |
| 4079 *stats->new_space_size = new_space_.Size(); | 4095 *stats->new_space_size = new_space_.IntSize(); |
|
Vyacheslav Egorov (Chromium)
2010/09/29 14:55:20
Better call this method SizeAsInt
Erik Corry
2010/09/30 07:09:38
Done.
| |
| 4080 *stats->new_space_capacity = new_space_.Capacity(); | 4096 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); |
| 4081 *stats->old_pointer_space_size = old_pointer_space_->Size(); | 4097 *stats->old_pointer_space_size = old_pointer_space_->Size(); |
| 4082 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); | 4098 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); |
| 4083 *stats->old_data_space_size = old_data_space_->Size(); | 4099 *stats->old_data_space_size = old_data_space_->Size(); |
| 4084 *stats->old_data_space_capacity = old_data_space_->Capacity(); | 4100 *stats->old_data_space_capacity = old_data_space_->Capacity(); |
| 4085 *stats->code_space_size = code_space_->Size(); | 4101 *stats->code_space_size = code_space_->Size(); |
| 4086 *stats->code_space_capacity = code_space_->Capacity(); | 4102 *stats->code_space_capacity = code_space_->Capacity(); |
| 4087 *stats->map_space_size = map_space_->Size(); | 4103 *stats->map_space_size = map_space_->Size(); |
| 4088 *stats->map_space_capacity = map_space_->Capacity(); | 4104 *stats->map_space_capacity = map_space_->Capacity(); |
| 4089 *stats->cell_space_size = cell_space_->Size(); | 4105 *stats->cell_space_size = cell_space_->Size(); |
| 4090 *stats->cell_space_capacity = cell_space_->Capacity(); | 4106 *stats->cell_space_capacity = cell_space_->Capacity(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 4104 if (FreeListNode::IsFreeListNode(obj)) continue; | 4120 if (FreeListNode::IsFreeListNode(obj)) continue; |
| 4105 InstanceType type = obj->map()->instance_type(); | 4121 InstanceType type = obj->map()->instance_type(); |
| 4106 ASSERT(0 <= type && type <= LAST_TYPE); | 4122 ASSERT(0 <= type && type <= LAST_TYPE); |
| 4107 stats->objects_per_type[type]++; | 4123 stats->objects_per_type[type]++; |
| 4108 stats->size_per_type[type] += obj->Size(); | 4124 stats->size_per_type[type] += obj->Size(); |
| 4109 } | 4125 } |
| 4110 } | 4126 } |
| 4111 } | 4127 } |
| 4112 | 4128 |
| 4113 | 4129 |
| 4114 int Heap::PromotedSpaceSize() { | 4130 intptr_t Heap::PromotedSpaceSize() { |
| 4115 return old_pointer_space_->Size() | 4131 return old_pointer_space_->Size() |
| 4116 + old_data_space_->Size() | 4132 + old_data_space_->Size() |
| 4117 + code_space_->Size() | 4133 + code_space_->Size() |
| 4118 + map_space_->Size() | 4134 + map_space_->Size() |
| 4119 + cell_space_->Size() | 4135 + cell_space_->Size() |
| 4120 + lo_space_->Size(); | 4136 + lo_space_->Size(); |
| 4121 } | 4137 } |
| 4122 | 4138 |
| 4123 | 4139 |
| 4124 int Heap::PromotedExternalMemorySize() { | 4140 int Heap::PromotedExternalMemorySize() { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4215 | 4231 |
| 4216 if (create_heap_objects) { | 4232 if (create_heap_objects) { |
| 4217 // Create initial maps. | 4233 // Create initial maps. |
| 4218 if (!CreateInitialMaps()) return false; | 4234 if (!CreateInitialMaps()) return false; |
| 4219 if (!CreateApiObjects()) return false; | 4235 if (!CreateApiObjects()) return false; |
| 4220 | 4236 |
| 4221 // Create initial objects | 4237 // Create initial objects |
| 4222 if (!CreateInitialObjects()) return false; | 4238 if (!CreateInitialObjects()) return false; |
| 4223 } | 4239 } |
| 4224 | 4240 |
| 4225 LOG(IntEvent("heap-capacity", Capacity())); | 4241 LOG(IntPtrTEvent("heap-capacity", Capacity())); |
| 4226 LOG(IntEvent("heap-available", Available())); | 4242 LOG(IntPtrTEvent("heap-available", Available())); |
| 4227 | 4243 |
| 4228 #ifdef ENABLE_LOGGING_AND_PROFILING | 4244 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 4229 // This should be called only after initial objects have been created. | 4245 // This should be called only after initial objects have been created. |
| 4230 ProducerHeapProfile::Setup(); | 4246 ProducerHeapProfile::Setup(); |
| 4231 #endif | 4247 #endif |
| 4232 | 4248 |
| 4233 return true; | 4249 return true; |
| 4234 } | 4250 } |
| 4235 | 4251 |
| 4236 | 4252 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 4250 | 4266 |
| 4251 | 4267 |
| 4252 void Heap::TearDown() { | 4268 void Heap::TearDown() { |
| 4253 if (FLAG_print_cumulative_gc_stat) { | 4269 if (FLAG_print_cumulative_gc_stat) { |
| 4254 PrintF("\n\n"); | 4270 PrintF("\n\n"); |
| 4255 PrintF("gc_count=%d ", gc_count_); | 4271 PrintF("gc_count=%d ", gc_count_); |
| 4256 PrintF("mark_sweep_count=%d ", ms_count_); | 4272 PrintF("mark_sweep_count=%d ", ms_count_); |
| 4257 PrintF("mark_compact_count=%d ", mc_count_); | 4273 PrintF("mark_compact_count=%d ", mc_count_); |
| 4258 PrintF("max_gc_pause=%d ", GCTracer::get_max_gc_pause()); | 4274 PrintF("max_gc_pause=%d ", GCTracer::get_max_gc_pause()); |
| 4259 PrintF("min_in_mutator=%d ", GCTracer::get_min_in_mutator()); | 4275 PrintF("min_in_mutator=%d ", GCTracer::get_min_in_mutator()); |
| 4260 PrintF("max_alive_after_gc=%d ", GCTracer::get_max_alive_after_gc()); | 4276 PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", |
| 4277 GCTracer::get_max_alive_after_gc()); | |
| 4261 PrintF("\n\n"); | 4278 PrintF("\n\n"); |
| 4262 } | 4279 } |
| 4263 | 4280 |
| 4264 GlobalHandles::TearDown(); | 4281 GlobalHandles::TearDown(); |
| 4265 | 4282 |
| 4266 ExternalStringTable::TearDown(); | 4283 ExternalStringTable::TearDown(); |
| 4267 | 4284 |
| 4268 new_space_.TearDown(); | 4285 new_space_.TearDown(); |
| 4269 | 4286 |
| 4270 if (old_pointer_space_ != NULL) { | 4287 if (old_pointer_space_ != NULL) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4376 UNREACHABLE(); | 4393 UNREACHABLE(); |
| 4377 } | 4394 } |
| 4378 | 4395 |
| 4379 | 4396 |
| 4380 #ifdef DEBUG | 4397 #ifdef DEBUG |
| 4381 | 4398 |
| 4382 class PrintHandleVisitor: public ObjectVisitor { | 4399 class PrintHandleVisitor: public ObjectVisitor { |
| 4383 public: | 4400 public: |
| 4384 void VisitPointers(Object** start, Object** end) { | 4401 void VisitPointers(Object** start, Object** end) { |
| 4385 for (Object** p = start; p < end; p++) | 4402 for (Object** p = start; p < end; p++) |
| 4386 PrintF(" handle %p to %p\n", p, *p); | 4403 PrintF(" handle %p to %p\n", |
| 4404 reinterpret_cast<void*>(p), | |
| 4405 reinterpret_cast<void*>(*p)); | |
| 4387 } | 4406 } |
| 4388 }; | 4407 }; |
| 4389 | 4408 |
| 4390 void Heap::PrintHandles() { | 4409 void Heap::PrintHandles() { |
| 4391 PrintF("Handles:\n"); | 4410 PrintF("Handles:\n"); |
| 4392 PrintHandleVisitor v; | 4411 PrintHandleVisitor v; |
| 4393 HandleScopeImplementer::Iterate(&v); | 4412 HandleScopeImplementer::Iterate(&v); |
| 4394 } | 4413 } |
| 4395 | 4414 |
| 4396 #endif | 4415 #endif |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4729 void Heap::TracePathToGlobal() { | 4748 void Heap::TracePathToGlobal() { |
| 4730 search_target = NULL; | 4749 search_target = NULL; |
| 4731 search_for_any_global = true; | 4750 search_for_any_global = true; |
| 4732 | 4751 |
| 4733 MarkRootVisitor root_visitor; | 4752 MarkRootVisitor root_visitor; |
| 4734 IterateRoots(&root_visitor, VISIT_ONLY_STRONG); | 4753 IterateRoots(&root_visitor, VISIT_ONLY_STRONG); |
| 4735 } | 4754 } |
| 4736 #endif | 4755 #endif |
| 4737 | 4756 |
| 4738 | 4757 |
| 4739 static int CountTotalHolesSize() { | 4758 static intptr_t CountTotalHolesSize() { |
| 4740 int holes_size = 0; | 4759 intptr_t holes_size = 0; |
| 4741 OldSpaces spaces; | 4760 OldSpaces spaces; |
| 4742 for (OldSpace* space = spaces.next(); | 4761 for (OldSpace* space = spaces.next(); |
| 4743 space != NULL; | 4762 space != NULL; |
| 4744 space = spaces.next()) { | 4763 space = spaces.next()) { |
| 4745 holes_size += space->Waste() + space->AvailableFree(); | 4764 holes_size += space->Waste() + space->AvailableFree(); |
| 4746 } | 4765 } |
| 4747 return holes_size; | 4766 return holes_size; |
| 4748 } | 4767 } |
| 4749 | 4768 |
| 4750 | 4769 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4828 UNREACHABLE(); | 4847 UNREACHABLE(); |
| 4829 } | 4848 } |
| 4830 PrintF(" "); | 4849 PrintF(" "); |
| 4831 | 4850 |
| 4832 PrintF("external=%d ", static_cast<int>(scopes_[Scope::EXTERNAL])); | 4851 PrintF("external=%d ", static_cast<int>(scopes_[Scope::EXTERNAL])); |
| 4833 PrintF("mark=%d ", static_cast<int>(scopes_[Scope::MC_MARK])); | 4852 PrintF("mark=%d ", static_cast<int>(scopes_[Scope::MC_MARK])); |
| 4834 PrintF("sweep=%d ", static_cast<int>(scopes_[Scope::MC_SWEEP])); | 4853 PrintF("sweep=%d ", static_cast<int>(scopes_[Scope::MC_SWEEP])); |
| 4835 PrintF("sweepns=%d ", static_cast<int>(scopes_[Scope::MC_SWEEP_NEWSPACE])); | 4854 PrintF("sweepns=%d ", static_cast<int>(scopes_[Scope::MC_SWEEP_NEWSPACE])); |
| 4836 PrintF("compact=%d ", static_cast<int>(scopes_[Scope::MC_COMPACT])); | 4855 PrintF("compact=%d ", static_cast<int>(scopes_[Scope::MC_COMPACT])); |
| 4837 | 4856 |
| 4838 PrintF("total_size_before=%d ", start_size_); | 4857 PrintF("total_size_before=%" V8_PTR_PREFIX "d ", start_size_); |
| 4839 PrintF("total_size_after=%d ", Heap::SizeOfObjects()); | 4858 PrintF("total_size_after=%" V8_PTR_PREFIX "d ", Heap::SizeOfObjects()); |
| 4840 PrintF("holes_size_before=%d ", in_free_list_or_wasted_before_gc_); | 4859 PrintF("holes_size_before=%" V8_PTR_PREFIX "d ", |
| 4841 PrintF("holes_size_after=%d ", CountTotalHolesSize()); | 4860 in_free_list_or_wasted_before_gc_); |
| 4861 PrintF("holes_size_after=%" V8_PTR_PREFIX "d ", CountTotalHolesSize()); | |
| 4842 | 4862 |
| 4843 PrintF("allocated=%d ", allocated_since_last_gc_); | 4863 PrintF("allocated=%" V8_PTR_PREFIX "d ", allocated_since_last_gc_); |
| 4844 PrintF("promoted=%d ", promoted_objects_size_); | 4864 PrintF("promoted=%" V8_PTR_PREFIX "d ", promoted_objects_size_); |
| 4845 | 4865 |
| 4846 PrintF("\n"); | 4866 PrintF("\n"); |
| 4847 } | 4867 } |
| 4848 | 4868 |
| 4849 #if defined(ENABLE_LOGGING_AND_PROFILING) | 4869 #if defined(ENABLE_LOGGING_AND_PROFILING) |
| 4850 Heap::PrintShortHeapStatistics(); | 4870 Heap::PrintShortHeapStatistics(); |
| 4851 #endif | 4871 #endif |
| 4852 } | 4872 } |
| 4853 | 4873 |
| 4854 | 4874 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4976 void ExternalStringTable::TearDown() { | 4996 void ExternalStringTable::TearDown() { |
| 4977 new_space_strings_.Free(); | 4997 new_space_strings_.Free(); |
| 4978 old_space_strings_.Free(); | 4998 old_space_strings_.Free(); |
| 4979 } | 4999 } |
| 4980 | 5000 |
| 4981 | 5001 |
| 4982 List<Object*> ExternalStringTable::new_space_strings_; | 5002 List<Object*> ExternalStringTable::new_space_strings_; |
| 4983 List<Object*> ExternalStringTable::old_space_strings_; | 5003 List<Object*> ExternalStringTable::old_space_strings_; |
| 4984 | 5004 |
| 4985 } } // namespace v8::internal | 5005 } } // namespace v8::internal |
| OLD | NEW |