| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 int free_bytes = area_size - live_bytes; | 752 int free_bytes = area_size - live_bytes; |
| 753 if (FLAG_always_compact || | 753 if (FLAG_always_compact || |
| 754 ((free_bytes >= free_bytes_threshold) && | 754 ((free_bytes >= free_bytes_threshold) && |
| 755 ((total_live_bytes + live_bytes) <= max_evacuated_bytes))) { | 755 ((total_live_bytes + live_bytes) <= max_evacuated_bytes))) { |
| 756 candidate_count++; | 756 candidate_count++; |
| 757 total_live_bytes += live_bytes; | 757 total_live_bytes += live_bytes; |
| 758 } | 758 } |
| 759 if (FLAG_trace_fragmentation_verbose) { | 759 if (FLAG_trace_fragmentation_verbose) { |
| 760 PrintIsolate(isolate(), | 760 PrintIsolate(isolate(), |
| 761 "compaction-selection-page: space=%s free_bytes_page=%d " | 761 "compaction-selection-page: space=%s free_bytes_page=%d " |
| 762 "fragmentation_limit_kb=%" V8PRIdPTR | 762 "fragmentation_limit_kb=%d fragmentation_limit_percent=%d " |
| 763 " fragmentation_limit_percent=%d sum_compaction_kb=%d " | 763 "sum_compaction_kb=%d " |
| 764 "compaction_limit_kb=%d\n", | 764 "compaction_limit_kb=%d\n", |
| 765 AllocationSpaceName(space->identity()), free_bytes / KB, | 765 AllocationSpaceName(space->identity()), free_bytes / KB, |
| 766 free_bytes_threshold / KB, target_fragmentation_percent, | 766 free_bytes_threshold / KB, target_fragmentation_percent, |
| 767 total_live_bytes / KB, max_evacuated_bytes / KB); | 767 total_live_bytes / KB, max_evacuated_bytes / KB); |
| 768 } | 768 } |
| 769 } | 769 } |
| 770 // How many pages we will allocated for the evacuated objects | 770 // How many pages we will allocated for the evacuated objects |
| 771 // in the worst case: ceil(total_live_bytes / area_size) | 771 // in the worst case: ceil(total_live_bytes / area_size) |
| 772 int estimated_new_pages = (total_live_bytes + area_size - 1) / area_size; | 772 int estimated_new_pages = (total_live_bytes + area_size - 1) / area_size; |
| 773 DCHECK_LE(estimated_new_pages, candidate_count); | 773 DCHECK_LE(estimated_new_pages, candidate_count); |
| (...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3135 evacuators[i] = new Evacuator(this); | 3135 evacuators[i] = new Evacuator(this); |
| 3136 } | 3136 } |
| 3137 job.Run(wanted_num_tasks, [evacuators](int i) { return evacuators[i]; }); | 3137 job.Run(wanted_num_tasks, [evacuators](int i) { return evacuators[i]; }); |
| 3138 for (int i = 0; i < wanted_num_tasks; i++) { | 3138 for (int i = 0; i < wanted_num_tasks; i++) { |
| 3139 evacuators[i]->Finalize(); | 3139 evacuators[i]->Finalize(); |
| 3140 delete evacuators[i]; | 3140 delete evacuators[i]; |
| 3141 } | 3141 } |
| 3142 delete[] evacuators; | 3142 delete[] evacuators; |
| 3143 | 3143 |
| 3144 if (FLAG_trace_evacuation) { | 3144 if (FLAG_trace_evacuation) { |
| 3145 PrintIsolate(isolate(), | 3145 PrintIsolate( |
| 3146 "%8.0f ms: evacuation-summary: parallel=%s pages=%d " | 3146 isolate(), |
| 3147 "aborted=%d wanted_tasks=%d tasks=%d cores=%" PRIuS | 3147 "%8.0f ms: evacuation-summary: parallel=%s pages=%d aborted=%d " |
| 3148 " live_bytes=%" V8PRIdPTR " compaction_speed=%.f\n", | 3148 "wanted_tasks=%d tasks=%d cores=%d live_bytes=%" V8_PTR_PREFIX |
| 3149 isolate()->time_millis_since_init(), | 3149 "d compaction_speed=%.f\n", |
| 3150 FLAG_parallel_compaction ? "yes" : "no", job.NumberOfPages(), | 3150 isolate()->time_millis_since_init(), |
| 3151 abandoned_pages, wanted_num_tasks, job.NumberOfTasks(), | 3151 FLAG_parallel_compaction ? "yes" : "no", job.NumberOfPages(), |
| 3152 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads(), | 3152 abandoned_pages, wanted_num_tasks, job.NumberOfTasks(), |
| 3153 live_bytes, compaction_speed); | 3153 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads(), |
| 3154 live_bytes, compaction_speed); |
| 3154 } | 3155 } |
| 3155 } | 3156 } |
| 3156 | 3157 |
| 3157 class EvacuationWeakObjectRetainer : public WeakObjectRetainer { | 3158 class EvacuationWeakObjectRetainer : public WeakObjectRetainer { |
| 3158 public: | 3159 public: |
| 3159 virtual Object* RetainAs(Object* object) { | 3160 virtual Object* RetainAs(Object* object) { |
| 3160 if (object->IsHeapObject()) { | 3161 if (object->IsHeapObject()) { |
| 3161 HeapObject* heap_object = HeapObject::cast(object); | 3162 HeapObject* heap_object = HeapObject::cast(object); |
| 3162 MapWord map_word = heap_object->map_word(); | 3163 MapWord map_word = heap_object->map_word(); |
| 3163 if (map_word.IsForwardingAddress()) { | 3164 if (map_word.IsForwardingAddress()) { |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3805 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3806 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 3806 if (Marking::IsBlack(mark_bit)) { | 3807 if (Marking::IsBlack(mark_bit)) { |
| 3807 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3808 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
| 3808 RecordRelocSlot(host, &rinfo, target); | 3809 RecordRelocSlot(host, &rinfo, target); |
| 3809 } | 3810 } |
| 3810 } | 3811 } |
| 3811 } | 3812 } |
| 3812 | 3813 |
| 3813 } // namespace internal | 3814 } // namespace internal |
| 3814 } // namespace v8 | 3815 } // namespace v8 |
| OLD | NEW |