OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 if (IntrusiveMarking::IsMarked(object)) { | 231 if (IntrusiveMarking::IsMarked(object)) { |
232 return IntrusiveMarking::SizeOfMarkedObject(object); | 232 return IntrusiveMarking::SizeOfMarkedObject(object); |
233 } | 233 } |
234 return object->SizeFromMap(object->map()); | 234 return object->SizeFromMap(object->map()); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space, | 238 GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space, |
239 const char** reason) { | 239 const char** reason) { |
240 // Is global GC requested? | 240 // Is global GC requested? |
241 if (space != NEW_SPACE || FLAG_gc_global) { | 241 if (space != NEW_SPACE) { |
242 isolate_->counters()->gc_compactor_caused_by_request()->Increment(); | 242 isolate_->counters()->gc_compactor_caused_by_request()->Increment(); |
243 *reason = "GC in old space requested"; | 243 *reason = "GC in old space requested"; |
244 return MARK_COMPACTOR; | 244 return MARK_COMPACTOR; |
245 } | 245 } |
246 | 246 |
| 247 if (FLAG_gc_global || (FLAG_stress_compaction && (gc_count_ & 1) != 0)) { |
| 248 *reason = "GC in old space forced by flags"; |
| 249 return MARK_COMPACTOR; |
| 250 } |
| 251 |
247 // Is enough data promoted to justify a global GC? | 252 // Is enough data promoted to justify a global GC? |
248 if (OldGenerationPromotionLimitReached()) { | 253 if (OldGenerationPromotionLimitReached()) { |
249 isolate_->counters()->gc_compactor_caused_by_promoted_data()->Increment(); | 254 isolate_->counters()->gc_compactor_caused_by_promoted_data()->Increment(); |
250 *reason = "promotion limit reached"; | 255 *reason = "promotion limit reached"; |
251 return MARK_COMPACTOR; | 256 return MARK_COMPACTOR; |
252 } | 257 } |
253 | 258 |
254 // Have allocation in OLD and LO failed? | 259 // Have allocation in OLD and LO failed? |
255 if (old_gen_exhausted_) { | 260 if (old_gen_exhausted_) { |
256 isolate_->counters()-> | 261 isolate_->counters()-> |
(...skipping 5431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5688 | 5693 |
5689 | 5694 |
5690 // TODO(1236194): Since the heap size is configurable on the command line | 5695 // TODO(1236194): Since the heap size is configurable on the command line |
5691 // and through the API, we should gracefully handle the case that the heap | 5696 // and through the API, we should gracefully handle the case that the heap |
5692 // size is not big enough to fit all the initial objects. | 5697 // size is not big enough to fit all the initial objects. |
5693 bool Heap::ConfigureHeap(int max_semispace_size, | 5698 bool Heap::ConfigureHeap(int max_semispace_size, |
5694 intptr_t max_old_gen_size, | 5699 intptr_t max_old_gen_size, |
5695 intptr_t max_executable_size) { | 5700 intptr_t max_executable_size) { |
5696 if (HasBeenSetUp()) return false; | 5701 if (HasBeenSetUp()) return false; |
5697 | 5702 |
| 5703 if (FLAG_stress_compaction) { |
| 5704 // This will cause more frequent GCs when stressing. |
| 5705 max_semispace_size_ = Page::kPageSize; |
| 5706 } |
| 5707 |
5698 if (max_semispace_size > 0) { | 5708 if (max_semispace_size > 0) { |
5699 if (max_semispace_size < Page::kPageSize) { | 5709 if (max_semispace_size < Page::kPageSize) { |
5700 max_semispace_size = Page::kPageSize; | 5710 max_semispace_size = Page::kPageSize; |
5701 if (FLAG_trace_gc) { | 5711 if (FLAG_trace_gc) { |
5702 PrintF("Max semispace size cannot be less than %dkbytes\n", | 5712 PrintF("Max semispace size cannot be less than %dkbytes\n", |
5703 Page::kPageSize >> 10); | 5713 Page::kPageSize >> 10); |
5704 } | 5714 } |
5705 } | 5715 } |
5706 max_semispace_size_ = max_semispace_size; | 5716 max_semispace_size_ = max_semispace_size; |
5707 } | 5717 } |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6124 roots_[kStackLimitRootIndex] = | 6134 roots_[kStackLimitRootIndex] = |
6125 reinterpret_cast<Object*>( | 6135 reinterpret_cast<Object*>( |
6126 (isolate_->stack_guard()->jslimit() & ~kSmiTagMask) | kSmiTag); | 6136 (isolate_->stack_guard()->jslimit() & ~kSmiTagMask) | kSmiTag); |
6127 roots_[kRealStackLimitRootIndex] = | 6137 roots_[kRealStackLimitRootIndex] = |
6128 reinterpret_cast<Object*>( | 6138 reinterpret_cast<Object*>( |
6129 (isolate_->stack_guard()->real_jslimit() & ~kSmiTagMask) | kSmiTag); | 6139 (isolate_->stack_guard()->real_jslimit() & ~kSmiTagMask) | kSmiTag); |
6130 } | 6140 } |
6131 | 6141 |
6132 | 6142 |
6133 void Heap::TearDown() { | 6143 void Heap::TearDown() { |
| 6144 if (FLAG_verify_heap) { |
| 6145 Verify(); |
| 6146 } |
6134 if (FLAG_print_cumulative_gc_stat) { | 6147 if (FLAG_print_cumulative_gc_stat) { |
6135 PrintF("\n\n"); | 6148 PrintF("\n\n"); |
6136 PrintF("gc_count=%d ", gc_count_); | 6149 PrintF("gc_count=%d ", gc_count_); |
6137 PrintF("mark_sweep_count=%d ", ms_count_); | 6150 PrintF("mark_sweep_count=%d ", ms_count_); |
6138 PrintF("max_gc_pause=%d ", get_max_gc_pause()); | 6151 PrintF("max_gc_pause=%d ", get_max_gc_pause()); |
6139 PrintF("min_in_mutator=%d ", get_min_in_mutator()); | 6152 PrintF("min_in_mutator=%d ", get_min_in_mutator()); |
6140 PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", | 6153 PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", |
6141 get_max_alive_after_gc()); | 6154 get_max_alive_after_gc()); |
6142 PrintF("\n\n"); | 6155 PrintF("\n\n"); |
6143 } | 6156 } |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7123 } else { | 7136 } else { |
7124 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. | 7137 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. |
7125 } | 7138 } |
7126 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = | 7139 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = |
7127 reinterpret_cast<Address>(p); | 7140 reinterpret_cast<Address>(p); |
7128 remembered_unmapped_pages_index_++; | 7141 remembered_unmapped_pages_index_++; |
7129 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; | 7142 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; |
7130 } | 7143 } |
7131 | 7144 |
7132 } } // namespace v8::internal | 7145 } } // namespace v8::internal |
OLD | NEW |