Chromium Code Reviews| 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 V8::FatalProcessOutOfMemory("Committing semi space failed."); | 551 V8::FatalProcessOutOfMemory("Committing semi space failed."); |
| 552 } | 552 } |
| 553 | 553 |
| 554 | 554 |
| 555 void Heap::PerformGarbageCollection(AllocationSpace space, | 555 void Heap::PerformGarbageCollection(AllocationSpace space, |
| 556 GarbageCollector collector, | 556 GarbageCollector collector, |
| 557 GCTracer* tracer) { | 557 GCTracer* tracer) { |
| 558 VerifySymbolTable(); | 558 VerifySymbolTable(); |
| 559 if (collector == MARK_COMPACTOR && global_gc_prologue_callback_) { | 559 if (collector == MARK_COMPACTOR && global_gc_prologue_callback_) { |
| 560 ASSERT(!allocation_allowed_); | 560 ASSERT(!allocation_allowed_); |
| 561 GCTracer::ExternalScope scope(tracer); | |
| 561 global_gc_prologue_callback_(); | 562 global_gc_prologue_callback_(); |
| 562 } | 563 } |
| 563 EnsureFromSpaceIsCommitted(); | 564 EnsureFromSpaceIsCommitted(); |
| 564 if (collector == MARK_COMPACTOR) { | 565 if (collector == MARK_COMPACTOR) { |
| 565 MarkCompact(tracer); | 566 MarkCompact(tracer); |
| 566 | 567 |
| 567 int old_gen_size = PromotedSpaceSize(); | 568 int old_gen_size = PromotedSpaceSize(); |
| 568 old_gen_promotion_limit_ = | 569 old_gen_promotion_limit_ = |
| 569 old_gen_size + Max(kMinimumPromotionLimit, old_gen_size / 3); | 570 old_gen_size + Max(kMinimumPromotionLimit, old_gen_size / 3); |
| 570 old_gen_allocation_limit_ = | 571 old_gen_allocation_limit_ = |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 584 Relocatable::PostGarbageCollectionProcessing(); | 585 Relocatable::PostGarbageCollectionProcessing(); |
| 585 | 586 |
| 586 if (collector == MARK_COMPACTOR) { | 587 if (collector == MARK_COMPACTOR) { |
| 587 // Register the amount of external allocated memory. | 588 // Register the amount of external allocated memory. |
| 588 amount_of_external_allocated_memory_at_last_global_gc_ = | 589 amount_of_external_allocated_memory_at_last_global_gc_ = |
| 589 amount_of_external_allocated_memory_; | 590 amount_of_external_allocated_memory_; |
| 590 } | 591 } |
| 591 | 592 |
| 592 if (collector == MARK_COMPACTOR && global_gc_epilogue_callback_) { | 593 if (collector == MARK_COMPACTOR && global_gc_epilogue_callback_) { |
| 593 ASSERT(!allocation_allowed_); | 594 ASSERT(!allocation_allowed_); |
| 595 GCTracer::ExternalScope scope(tracer); | |
| 594 global_gc_epilogue_callback_(); | 596 global_gc_epilogue_callback_(); |
| 595 } | 597 } |
| 596 VerifySymbolTable(); | 598 VerifySymbolTable(); |
| 597 } | 599 } |
| 598 | 600 |
| 599 | 601 |
| 600 void Heap::MarkCompact(GCTracer* tracer) { | 602 void Heap::MarkCompact(GCTracer* tracer) { |
| 601 gc_state_ = MARK_COMPACT; | 603 gc_state_ = MARK_COMPACT; |
| 602 mc_count_++; | 604 mc_count_++; |
| 603 tracer->set_full_gc_count(mc_count_); | 605 tracer->set_full_gc_count(mc_count_); |
| (...skipping 3456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4060 | 4062 |
| 4061 MarkRootVisitor root_visitor; | 4063 MarkRootVisitor root_visitor; |
| 4062 IterateRoots(&root_visitor, VISIT_ONLY_STRONG); | 4064 IterateRoots(&root_visitor, VISIT_ONLY_STRONG); |
| 4063 } | 4065 } |
| 4064 #endif | 4066 #endif |
| 4065 | 4067 |
| 4066 | 4068 |
| 4067 GCTracer::GCTracer() | 4069 GCTracer::GCTracer() |
| 4068 : start_time_(0.0), | 4070 : start_time_(0.0), |
| 4069 start_size_(0.0), | 4071 start_size_(0.0), |
| 4072 external_time_(0.0), | |
| 4070 gc_count_(0), | 4073 gc_count_(0), |
| 4071 full_gc_count_(0), | 4074 full_gc_count_(0), |
| 4072 is_compacting_(false), | 4075 is_compacting_(false), |
| 4073 marked_count_(0) { | 4076 marked_count_(0) { |
| 4074 // These two fields reflect the state of the previous full collection. | 4077 // These two fields reflect the state of the previous full collection. |
| 4075 // Set them before they are changed by the collector. | 4078 // Set them before they are changed by the collector. |
| 4076 previous_has_compacted_ = MarkCompactCollector::HasCompacted(); | 4079 previous_has_compacted_ = MarkCompactCollector::HasCompacted(); |
| 4077 previous_marked_count_ = MarkCompactCollector::previous_marked_count(); | 4080 previous_marked_count_ = MarkCompactCollector::previous_marked_count(); |
| 4078 if (!FLAG_trace_gc) return; | 4081 if (!FLAG_trace_gc) return; |
| 4079 start_time_ = OS::TimeCurrentMillis(); | 4082 start_time_ = OS::TimeCurrentMillis(); |
| 4080 start_size_ = SizeOfHeapObjects(); | 4083 start_size_ = SizeOfHeapObjects(); |
| 4081 } | 4084 } |
| 4082 | 4085 |
| 4083 | 4086 |
| 4084 GCTracer::~GCTracer() { | 4087 GCTracer::~GCTracer() { |
| 4085 if (!FLAG_trace_gc) return; | 4088 if (!FLAG_trace_gc) return; |
| 4086 // Printf ONE line iff flag is set. | 4089 // Printf ONE line iff flag is set. |
| 4087 PrintF("%s %.1f -> %.1f MB, %d ms.\n", | 4090 int time = static_cast<int>(OS::TimeCurrentMillis() - start_time_); |
| 4088 CollectorString(), | 4091 int external_time = static_cast<int>(external_time_); |
| 4089 start_size_, SizeOfHeapObjects(), | 4092 if (external_time > 0) { |
| 4090 static_cast<int>(OS::TimeCurrentMillis() - start_time_)); | 4093 PrintF("%s %.1f -> %.1f MB, %d / %d ms.\n", |
|
bak
2010/02/26 08:20:30
Refactor printing into:
PrintF(...);
if (external_
| |
| 4094 CollectorString(), | |
| 4095 start_size_, SizeOfHeapObjects(), | |
| 4096 external_time, time); | |
| 4097 } else { | |
| 4098 PrintF("%s %.1f -> %.1f MB, %d ms.\n", | |
| 4099 CollectorString(), | |
| 4100 start_size_, SizeOfHeapObjects(), | |
| 4101 time); | |
| 4102 } | |
| 4091 | 4103 |
| 4092 #if defined(ENABLE_LOGGING_AND_PROFILING) | 4104 #if defined(ENABLE_LOGGING_AND_PROFILING) |
| 4093 Heap::PrintShortHeapStatistics(); | 4105 Heap::PrintShortHeapStatistics(); |
| 4094 #endif | 4106 #endif |
| 4095 } | 4107 } |
| 4096 | 4108 |
| 4097 | 4109 |
| 4098 const char* GCTracer::CollectorString() { | 4110 const char* GCTracer::CollectorString() { |
| 4099 switch (collector_) { | 4111 switch (collector_) { |
| 4100 case SCAVENGER: | 4112 case SCAVENGER: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4219 void ExternalStringTable::TearDown() { | 4231 void ExternalStringTable::TearDown() { |
| 4220 new_space_strings_.Free(); | 4232 new_space_strings_.Free(); |
| 4221 old_space_strings_.Free(); | 4233 old_space_strings_.Free(); |
| 4222 } | 4234 } |
| 4223 | 4235 |
| 4224 | 4236 |
| 4225 List<Object*> ExternalStringTable::new_space_strings_; | 4237 List<Object*> ExternalStringTable::new_space_strings_; |
| 4226 List<Object*> ExternalStringTable::old_space_strings_; | 4238 List<Object*> ExternalStringTable::old_space_strings_; |
| 4227 | 4239 |
| 4228 } } // namespace v8::internal | 4240 } } // namespace v8::internal |
| OLD | NEW |