OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/spaces.h" | 5 #include "src/heap/spaces.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 void MemoryAllocator::ZapBlock(Address start, size_t size) { | 1030 void MemoryAllocator::ZapBlock(Address start, size_t size) { |
1031 for (size_t s = 0; s + kPointerSize <= size; s += kPointerSize) { | 1031 for (size_t s = 0; s + kPointerSize <= size; s += kPointerSize) { |
1032 Memory::Address_at(start + s) = kZapValue; | 1032 Memory::Address_at(start + s) = kZapValue; |
1033 } | 1033 } |
1034 } | 1034 } |
1035 | 1035 |
1036 #ifdef DEBUG | 1036 #ifdef DEBUG |
1037 void MemoryAllocator::ReportStatistics() { | 1037 void MemoryAllocator::ReportStatistics() { |
1038 size_t size = Size(); | 1038 size_t size = Size(); |
1039 float pct = static_cast<float>(capacity_ - size) / capacity_; | 1039 float pct = static_cast<float>(capacity_ - size) / capacity_; |
1040 PrintF(" capacity: %zu , used: %" V8PRIdPTR ", available: %%%d\n\n", | 1040 PrintF(" capacity: %zu , used: %" PRIuS ", available: %%%d\n\n", |
1041 capacity_, size, static_cast<int>(pct * 100)); | 1041 capacity_, size, static_cast<int>(pct * 100)); |
1042 } | 1042 } |
1043 #endif | 1043 #endif |
1044 | 1044 |
1045 size_t MemoryAllocator::CodePageGuardStartOffset() { | 1045 size_t MemoryAllocator::CodePageGuardStartOffset() { |
1046 // We are guarding code pages: the first OS page after the header | 1046 // We are guarding code pages: the first OS page after the header |
1047 // will be protected as non-writable. | 1047 // will be protected as non-writable. |
1048 return RoundUp(Page::kObjectStartOffset, GetCommitPageSize()); | 1048 return RoundUp(Page::kObjectStartOffset, GetCommitPageSize()); |
1049 } | 1049 } |
1050 | 1050 |
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 } | 2327 } |
2328 } | 2328 } |
2329 LOG(isolate, HeapSampleEndEvent("NewSpace", description)); | 2329 LOG(isolate, HeapSampleEndEvent("NewSpace", description)); |
2330 } | 2330 } |
2331 | 2331 |
2332 | 2332 |
2333 void NewSpace::ReportStatistics() { | 2333 void NewSpace::ReportStatistics() { |
2334 #ifdef DEBUG | 2334 #ifdef DEBUG |
2335 if (FLAG_heap_stats) { | 2335 if (FLAG_heap_stats) { |
2336 float pct = static_cast<float>(Available()) / TotalCapacity(); | 2336 float pct = static_cast<float>(Available()) / TotalCapacity(); |
2337 PrintF(" capacity: %" V8PRIdPTR ", available: %" V8PRIdPTR ", %%%d\n", | 2337 PrintF(" capacity: %" PRIuS ", available: %" PRIuS ", %%%d\n", |
2338 TotalCapacity(), Available(), static_cast<int>(pct * 100)); | 2338 TotalCapacity(), Available(), static_cast<int>(pct * 100)); |
2339 PrintF("\n Object Histogram:\n"); | 2339 PrintF("\n Object Histogram:\n"); |
2340 for (int i = 0; i <= LAST_TYPE; i++) { | 2340 for (int i = 0; i <= LAST_TYPE; i++) { |
2341 if (allocated_histogram_[i].number() > 0) { | 2341 if (allocated_histogram_[i].number() > 0) { |
2342 PrintF(" %-34s%10d (%10d bytes)\n", allocated_histogram_[i].name(), | 2342 PrintF(" %-34s%10d (%10d bytes)\n", allocated_histogram_[i].name(), |
2343 allocated_histogram_[i].number(), | 2343 allocated_histogram_[i].number(), |
2344 allocated_histogram_[i].bytes()); | 2344 allocated_histogram_[i].bytes()); |
2345 } | 2345 } |
2346 } | 2346 } |
2347 PrintF("\n"); | 2347 PrintF("\n"); |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2911 | 2911 |
2912 // If sweeper threads are active, wait for them at that point and steal | 2912 // If sweeper threads are active, wait for them at that point and steal |
2913 // elements form their free-lists. Allocation may still fail their which | 2913 // elements form their free-lists. Allocation may still fail their which |
2914 // would indicate that there is not enough memory for the given allocation. | 2914 // would indicate that there is not enough memory for the given allocation. |
2915 return SweepAndRetryAllocation(size_in_bytes); | 2915 return SweepAndRetryAllocation(size_in_bytes); |
2916 } | 2916 } |
2917 | 2917 |
2918 #ifdef DEBUG | 2918 #ifdef DEBUG |
2919 void PagedSpace::ReportStatistics() { | 2919 void PagedSpace::ReportStatistics() { |
2920 int pct = static_cast<int>(Available() * 100 / Capacity()); | 2920 int pct = static_cast<int>(Available() * 100 / Capacity()); |
2921 PrintF(" capacity: %" V8PRIdPTR ", waste: %" V8PRIdPTR | 2921 PrintF(" capacity: %" PRIuS ", waste: %" PRIuS |
2922 ", available: %" V8PRIdPTR ", %%%d\n", | 2922 ", available: %" PRIuS ", %%%d\n", |
2923 Capacity(), Waste(), Available(), pct); | 2923 Capacity(), Waste(), Available(), pct); |
2924 | 2924 |
2925 heap()->mark_compact_collector()->EnsureSweepingCompleted(); | 2925 heap()->mark_compact_collector()->EnsureSweepingCompleted(); |
2926 ClearHistograms(heap()->isolate()); | 2926 ClearHistograms(heap()->isolate()); |
2927 HeapObjectIterator obj_it(this); | 2927 HeapObjectIterator obj_it(this); |
2928 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) | 2928 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) |
2929 CollectHistogramInfo(obj); | 2929 CollectHistogramInfo(obj); |
2930 ReportHistogram(heap()->isolate(), true); | 2930 ReportHistogram(heap()->isolate(), true); |
2931 } | 2931 } |
2932 #endif | 2932 #endif |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3253 void LargeObjectSpace::Print() { | 3253 void LargeObjectSpace::Print() { |
3254 OFStream os(stdout); | 3254 OFStream os(stdout); |
3255 LargeObjectIterator it(this); | 3255 LargeObjectIterator it(this); |
3256 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 3256 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
3257 obj->Print(os); | 3257 obj->Print(os); |
3258 } | 3258 } |
3259 } | 3259 } |
3260 | 3260 |
3261 | 3261 |
3262 void LargeObjectSpace::ReportStatistics() { | 3262 void LargeObjectSpace::ReportStatistics() { |
3263 PrintF(" size: %" V8PRIdPTR "\n", size_); | 3263 PrintF(" size: %" PRIuS "\n", size_); |
3264 int num_objects = 0; | 3264 int num_objects = 0; |
3265 ClearHistograms(heap()->isolate()); | 3265 ClearHistograms(heap()->isolate()); |
3266 LargeObjectIterator it(this); | 3266 LargeObjectIterator it(this); |
3267 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 3267 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
3268 num_objects++; | 3268 num_objects++; |
3269 CollectHistogramInfo(obj); | 3269 CollectHistogramInfo(obj); |
3270 } | 3270 } |
3271 | 3271 |
3272 PrintF( | 3272 PrintF( |
3273 " number of objects %d, " | 3273 " number of objects %d, " |
3274 "size of objects %" V8PRIdPTR "\n", | 3274 "size of objects %" PRIuS "\n", |
3275 num_objects, objects_size_); | 3275 num_objects, objects_size_); |
3276 if (num_objects > 0) ReportHistogram(heap()->isolate(), false); | 3276 if (num_objects > 0) ReportHistogram(heap()->isolate(), false); |
3277 } | 3277 } |
3278 | 3278 |
3279 | 3279 |
3280 void Page::Print() { | 3280 void Page::Print() { |
3281 // Make a best-effort to print the objects in the page. | 3281 // Make a best-effort to print the objects in the page. |
3282 PrintF("Page@%p in %s\n", static_cast<void*>(this->address()), | 3282 PrintF("Page@%p in %s\n", static_cast<void*>(this->address()), |
3283 AllocationSpaceName(this->owner()->identity())); | 3283 AllocationSpaceName(this->owner()->identity())); |
3284 printf(" --------------------------------------\n"); | 3284 printf(" --------------------------------------\n"); |
3285 HeapObjectIterator objects(this); | 3285 HeapObjectIterator objects(this); |
3286 unsigned mark_size = 0; | 3286 unsigned mark_size = 0; |
3287 for (HeapObject* object = objects.Next(); object != NULL; | 3287 for (HeapObject* object = objects.Next(); object != NULL; |
3288 object = objects.Next()) { | 3288 object = objects.Next()) { |
3289 bool is_marked = ObjectMarking::IsBlackOrGrey(object); | 3289 bool is_marked = ObjectMarking::IsBlackOrGrey(object); |
3290 PrintF(" %c ", (is_marked ? '!' : ' ')); // Indent a little. | 3290 PrintF(" %c ", (is_marked ? '!' : ' ')); // Indent a little. |
3291 if (is_marked) { | 3291 if (is_marked) { |
3292 mark_size += object->Size(); | 3292 mark_size += object->Size(); |
3293 } | 3293 } |
3294 object->ShortPrint(); | 3294 object->ShortPrint(); |
3295 PrintF("\n"); | 3295 PrintF("\n"); |
3296 } | 3296 } |
3297 printf(" --------------------------------------\n"); | 3297 printf(" --------------------------------------\n"); |
3298 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3298 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3299 } | 3299 } |
3300 | 3300 |
3301 #endif // DEBUG | 3301 #endif // DEBUG |
3302 } // namespace internal | 3302 } // namespace internal |
3303 } // namespace v8 | 3303 } // namespace v8 |
OLD | NEW |