| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/base/platform/platform.h" | 7 #include "src/base/platform/platform.h" |
| 8 #include "src/full-codegen.h" | 8 #include "src/full-codegen.h" |
| 9 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
| 10 #include "src/mark-compact.h" | 10 #include "src/mark-compact.h" |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 // ----------------------------------------------------------------------------- | 929 // ----------------------------------------------------------------------------- |
| 930 // PagedSpace implementation | 930 // PagedSpace implementation |
| 931 | 931 |
| 932 PagedSpace::PagedSpace(Heap* heap, | 932 PagedSpace::PagedSpace(Heap* heap, |
| 933 intptr_t max_capacity, | 933 intptr_t max_capacity, |
| 934 AllocationSpace id, | 934 AllocationSpace id, |
| 935 Executability executable) | 935 Executability executable) |
| 936 : Space(heap, id, executable), | 936 : Space(heap, id, executable), |
| 937 free_list_(this), | 937 free_list_(this), |
| 938 was_swept_conservatively_(false), | 938 was_swept_conservatively_(false), |
| 939 was_swept_concurrently_(false), |
| 939 unswept_free_bytes_(0), | 940 unswept_free_bytes_(0), |
| 940 end_of_unswept_pages_(NULL) { | 941 end_of_unswept_pages_(NULL) { |
| 941 if (id == CODE_SPACE) { | 942 if (id == CODE_SPACE) { |
| 942 area_size_ = heap->isolate()->memory_allocator()-> | 943 area_size_ = heap->isolate()->memory_allocator()-> |
| 943 CodePageAreaSize(); | 944 CodePageAreaSize(); |
| 944 } else { | 945 } else { |
| 945 area_size_ = Page::kPageSize - Page::kObjectStartOffset; | 946 area_size_ = Page::kPageSize - Page::kObjectStartOffset; |
| 946 } | 947 } |
| 947 max_capacity_ = (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) | 948 max_capacity_ = (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) |
| 948 * AreaSize(); | 949 * AreaSize(); |
| (...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2539 // This counter will be increased for pages which will be swept by the | 2540 // This counter will be increased for pages which will be swept by the |
| 2540 // sweeper threads. | 2541 // sweeper threads. |
| 2541 unswept_free_bytes_ = 0; | 2542 unswept_free_bytes_ = 0; |
| 2542 | 2543 |
| 2543 // Clear the free list before a full GC---it will be rebuilt afterward. | 2544 // Clear the free list before a full GC---it will be rebuilt afterward. |
| 2544 free_list_.Reset(); | 2545 free_list_.Reset(); |
| 2545 } | 2546 } |
| 2546 | 2547 |
| 2547 | 2548 |
| 2548 intptr_t PagedSpace::SizeOfObjects() { | 2549 intptr_t PagedSpace::SizeOfObjects() { |
| 2549 ASSERT(heap()->mark_compact_collector()->IsConcurrentSweepingInProgress() || | 2550 ASSERT(heap()->mark_compact_collector()-> |
| 2550 (unswept_free_bytes_ == 0)); | 2551 IsConcurrentSweepingInProgress(this) || (unswept_free_bytes_ == 0)); |
| 2551 return Size() - unswept_free_bytes_ - (limit() - top()); | 2552 return Size() - unswept_free_bytes_ - (limit() - top()); |
| 2552 } | 2553 } |
| 2553 | 2554 |
| 2554 | 2555 |
| 2555 // After we have booted, we have created a map which represents free space | 2556 // After we have booted, we have created a map which represents free space |
| 2556 // on the heap. If there was already a free list then the elements on it | 2557 // on the heap. If there was already a free list then the elements on it |
| 2557 // were created with the wrong FreeSpaceMap (normally NULL), so we need to | 2558 // were created with the wrong FreeSpaceMap (normally NULL), so we need to |
| 2558 // fix them. | 2559 // fix them. |
| 2559 void PagedSpace::RepairFreeListsAfterBoot() { | 2560 void PagedSpace::RepairFreeListsAfterBoot() { |
| 2560 free_list_.RepairLists(heap()); | 2561 free_list_.RepairLists(heap()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2575 allocation_info_.set_limit(NULL); | 2576 allocation_info_.set_limit(NULL); |
| 2576 } | 2577 } |
| 2577 } | 2578 } |
| 2578 | 2579 |
| 2579 | 2580 |
| 2580 HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation( | 2581 HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation( |
| 2581 int size_in_bytes) { | 2582 int size_in_bytes) { |
| 2582 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2583 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
| 2583 | 2584 |
| 2584 // If sweeper threads are still running, wait for them. | 2585 // If sweeper threads are still running, wait for them. |
| 2585 if (collector->IsConcurrentSweepingInProgress()) { | 2586 if (collector->IsConcurrentSweepingInProgress(this)) { |
| 2586 collector->WaitUntilSweepingCompleted(); | 2587 collector->WaitUntilSweepingCompleted(); |
| 2587 | 2588 |
| 2588 // After waiting for the sweeper threads, there may be new free-list | 2589 // After waiting for the sweeper threads, there may be new free-list |
| 2589 // entries. | 2590 // entries. |
| 2590 return free_list_.Allocate(size_in_bytes); | 2591 return free_list_.Allocate(size_in_bytes); |
| 2591 } | 2592 } |
| 2592 return NULL; | 2593 return NULL; |
| 2593 } | 2594 } |
| 2594 | 2595 |
| 2595 | 2596 |
| 2596 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { | 2597 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { |
| 2597 // Allocation in this space has failed. | 2598 // Allocation in this space has failed. |
| 2598 | 2599 |
| 2599 // If sweeper threads are active, try to re-fill the free-lists. | 2600 // If sweeper threads are active, try to re-fill the free-lists. |
| 2600 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2601 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
| 2601 if (collector->IsConcurrentSweepingInProgress()) { | 2602 if (collector->IsConcurrentSweepingInProgress(this)) { |
| 2602 collector->RefillFreeList(this); | 2603 collector->RefillFreeList(this); |
| 2603 | 2604 |
| 2604 // Retry the free list allocation. | 2605 // Retry the free list allocation. |
| 2605 HeapObject* object = free_list_.Allocate(size_in_bytes); | 2606 HeapObject* object = free_list_.Allocate(size_in_bytes); |
| 2606 if (object != NULL) return object; | 2607 if (object != NULL) return object; |
| 2607 } | 2608 } |
| 2608 | 2609 |
| 2609 // Free list allocation failed and there is no next page. Fail if we have | 2610 // Free list allocation failed and there is no next page. Fail if we have |
| 2610 // hit the old generation size limit that should cause a garbage | 2611 // hit the old generation size limit that should cause a garbage |
| 2611 // collection. | 2612 // collection. |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3136 object->ShortPrint(); | 3137 object->ShortPrint(); |
| 3137 PrintF("\n"); | 3138 PrintF("\n"); |
| 3138 } | 3139 } |
| 3139 printf(" --------------------------------------\n"); | 3140 printf(" --------------------------------------\n"); |
| 3140 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3141 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3141 } | 3142 } |
| 3142 | 3143 |
| 3143 #endif // DEBUG | 3144 #endif // DEBUG |
| 3144 | 3145 |
| 3145 } } // namespace v8::internal | 3146 } } // namespace v8::internal |
| OLD | NEW |