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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 #elif defined(ENABLE_LOGGING_AND_PROFILING) | 200 #elif defined(ENABLE_LOGGING_AND_PROFILING) |
201 if (FLAG_log_gc) { | 201 if (FLAG_log_gc) { |
202 new_space_.CollectStatistics(); | 202 new_space_.CollectStatistics(); |
203 new_space_.ReportStatistics(); | 203 new_space_.ReportStatistics(); |
204 new_space_.ClearHistograms(); | 204 new_space_.ClearHistograms(); |
205 } | 205 } |
206 #endif | 206 #endif |
207 } | 207 } |
208 | 208 |
209 | 209 |
| 210 #if defined(ENABLE_LOGGING_AND_PROFILING) |
| 211 void Heap::PrintShortHeapStatistics() { |
| 212 if (!FLAG_trace_gc_verbose) return; |
| 213 PrintF("Memory allocator, used: %8d, available: %8d\n", |
| 214 MemoryAllocator::Size(), MemoryAllocator::Available()); |
| 215 PrintF("New space, used: %8d, available: %8d\n", |
| 216 Heap::new_space_.Size(), new_space_.Available()); |
| 217 PrintF("Old pointers, used: %8d, available: %8d\n", |
| 218 old_pointer_space_->Size(), old_pointer_space_->Available()); |
| 219 PrintF("Old data space, used: %8d, available: %8d\n", |
| 220 old_data_space_->Size(), old_data_space_->Available()); |
| 221 PrintF("Code space, used: %8d, available: %8d\n", |
| 222 code_space_->Size(), code_space_->Available()); |
| 223 PrintF("Map space, used: %8d, available: %8d\n", |
| 224 map_space_->Size(), map_space_->Available()); |
| 225 PrintF("Large object space, used: %8d, avaialble: %8d\n", |
| 226 map_space_->Size(), map_space_->Available()); |
| 227 } |
| 228 #endif |
| 229 |
| 230 |
210 // TODO(1238405): Combine the infrastructure for --heap-stats and | 231 // TODO(1238405): Combine the infrastructure for --heap-stats and |
211 // --log-gc to avoid the complicated preprocessor and flag testing. | 232 // --log-gc to avoid the complicated preprocessor and flag testing. |
212 void Heap::ReportStatisticsAfterGC() { | 233 void Heap::ReportStatisticsAfterGC() { |
213 // Similar to the before GC, we use some complicated logic to ensure that | 234 // Similar to the before GC, we use some complicated logic to ensure that |
214 // NewSpace statistics are logged exactly once when --log-gc is turned on. | 235 // NewSpace statistics are logged exactly once when --log-gc is turned on. |
215 #if defined(DEBUG) && defined(ENABLE_LOGGING_AND_PROFILING) | 236 #if defined(DEBUG) && defined(ENABLE_LOGGING_AND_PROFILING) |
216 if (FLAG_heap_stats) { | 237 if (FLAG_heap_stats) { |
217 new_space_.CollectStatistics(); | 238 new_space_.CollectStatistics(); |
218 ReportHeapStatistics("After GC"); | 239 ReportHeapStatistics("After GC"); |
219 } else if (FLAG_log_gc) { | 240 } else if (FLAG_log_gc) { |
(...skipping 3393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3613 } | 3634 } |
3614 | 3635 |
3615 | 3636 |
3616 GCTracer::~GCTracer() { | 3637 GCTracer::~GCTracer() { |
3617 if (!FLAG_trace_gc) return; | 3638 if (!FLAG_trace_gc) return; |
3618 // Printf ONE line iff flag is set. | 3639 // Printf ONE line iff flag is set. |
3619 PrintF("%s %.1f -> %.1f MB, %d ms.\n", | 3640 PrintF("%s %.1f -> %.1f MB, %d ms.\n", |
3620 CollectorString(), | 3641 CollectorString(), |
3621 start_size_, SizeOfHeapObjects(), | 3642 start_size_, SizeOfHeapObjects(), |
3622 static_cast<int>(OS::TimeCurrentMillis() - start_time_)); | 3643 static_cast<int>(OS::TimeCurrentMillis() - start_time_)); |
| 3644 |
| 3645 #if defined(ENABLE_LOGGING_AND_PROFILING) |
| 3646 Heap::PrintShortHeapStatistics(); |
| 3647 #endif |
3623 } | 3648 } |
3624 | 3649 |
3625 | 3650 |
3626 const char* GCTracer::CollectorString() { | 3651 const char* GCTracer::CollectorString() { |
3627 switch (collector_) { | 3652 switch (collector_) { |
3628 case SCAVENGER: | 3653 case SCAVENGER: |
3629 return "Scavenge"; | 3654 return "Scavenge"; |
3630 case MARK_COMPACTOR: | 3655 case MARK_COMPACTOR: |
3631 return MarkCompactCollector::HasCompacted() ? "Mark-compact" | 3656 return MarkCompactCollector::HasCompacted() ? "Mark-compact" |
3632 : "Mark-sweep"; | 3657 : "Mark-sweep"; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3690 #ifdef DEBUG | 3715 #ifdef DEBUG |
3691 bool Heap::GarbageCollectionGreedyCheck() { | 3716 bool Heap::GarbageCollectionGreedyCheck() { |
3692 ASSERT(FLAG_gc_greedy); | 3717 ASSERT(FLAG_gc_greedy); |
3693 if (Bootstrapper::IsActive()) return true; | 3718 if (Bootstrapper::IsActive()) return true; |
3694 if (disallow_allocation_failure()) return true; | 3719 if (disallow_allocation_failure()) return true; |
3695 return CollectGarbage(0, NEW_SPACE); | 3720 return CollectGarbage(0, NEW_SPACE); |
3696 } | 3721 } |
3697 #endif | 3722 #endif |
3698 | 3723 |
3699 } } // namespace v8::internal | 3724 } } // namespace v8::internal |
OLD | NEW |