| 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 2528 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 | 2539 // This counter will be increased for pages which will be swept by the |
| 2540 // sweeper threads. | 2540 // sweeper threads. |
| 2541 unswept_free_bytes_ = 0; | 2541 unswept_free_bytes_ = 0; |
| 2542 | 2542 |
| 2543 // Clear the free list before a full GC---it will be rebuilt afterward. | 2543 // Clear the free list before a full GC---it will be rebuilt afterward. |
| 2544 free_list_.Reset(); | 2544 free_list_.Reset(); |
| 2545 } | 2545 } |
| 2546 | 2546 |
| 2547 | 2547 |
| 2548 intptr_t PagedSpace::SizeOfObjects() { | 2548 intptr_t PagedSpace::SizeOfObjects() { |
| 2549 ASSERT(heap()->mark_compact_collector()->IsConcurrentSweepingInProgress() || | 2549 ASSERT(heap()->mark_compact_collector()-> |
| 2550 (unswept_free_bytes_ == 0)); | 2550 IsConcurrentSweepingInProgress(this) || (unswept_free_bytes_ == 0)); |
| 2551 return Size() - unswept_free_bytes_ - (limit() - top()); | 2551 return Size() - unswept_free_bytes_ - (limit() - top()); |
| 2552 } | 2552 } |
| 2553 | 2553 |
| 2554 | 2554 |
| 2555 // After we have booted, we have created a map which represents free space | 2555 // 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 | 2556 // 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 | 2557 // were created with the wrong FreeSpaceMap (normally NULL), so we need to |
| 2558 // fix them. | 2558 // fix them. |
| 2559 void PagedSpace::RepairFreeListsAfterBoot() { | 2559 void PagedSpace::RepairFreeListsAfterBoot() { |
| 2560 free_list_.RepairLists(heap()); | 2560 free_list_.RepairLists(heap()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2575 allocation_info_.set_limit(NULL); | 2575 allocation_info_.set_limit(NULL); |
| 2576 } | 2576 } |
| 2577 } | 2577 } |
| 2578 | 2578 |
| 2579 | 2579 |
| 2580 HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation( | 2580 HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation( |
| 2581 int size_in_bytes) { | 2581 int size_in_bytes) { |
| 2582 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2582 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
| 2583 | 2583 |
| 2584 // If sweeper threads are still running, wait for them. | 2584 // If sweeper threads are still running, wait for them. |
| 2585 if (collector->IsConcurrentSweepingInProgress()) { | 2585 if (collector->IsConcurrentSweepingInProgress(this)) { |
| 2586 collector->WaitUntilSweepingCompleted(); | 2586 collector->WaitUntilSweepingCompleted(); |
| 2587 | 2587 |
| 2588 // After waiting for the sweeper threads, there may be new free-list | 2588 // After waiting for the sweeper threads, there may be new free-list |
| 2589 // entries. | 2589 // entries. |
| 2590 return free_list_.Allocate(size_in_bytes); | 2590 return free_list_.Allocate(size_in_bytes); |
| 2591 } | 2591 } |
| 2592 return NULL; | 2592 return NULL; |
| 2593 } | 2593 } |
| 2594 | 2594 |
| 2595 | 2595 |
| 2596 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { | 2596 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { |
| 2597 // Allocation in this space has failed. | 2597 // Allocation in this space has failed. |
| 2598 | 2598 |
| 2599 // If sweeper threads are active, try to re-fill the free-lists. | 2599 // If sweeper threads are active, try to re-fill the free-lists. |
| 2600 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2600 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
| 2601 if (collector->IsConcurrentSweepingInProgress()) { | 2601 if (collector->IsConcurrentSweepingInProgress(this)) { |
| 2602 collector->RefillFreeList(this); | 2602 collector->RefillFreeList(this); |
| 2603 | 2603 |
| 2604 // Retry the free list allocation. | 2604 // Retry the free list allocation. |
| 2605 HeapObject* object = free_list_.Allocate(size_in_bytes); | 2605 HeapObject* object = free_list_.Allocate(size_in_bytes); |
| 2606 if (object != NULL) return object; | 2606 if (object != NULL) return object; |
| 2607 } | 2607 } |
| 2608 | 2608 |
| 2609 // Free list allocation failed and there is no next page. Fail if we have | 2609 // 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 | 2610 // hit the old generation size limit that should cause a garbage |
| 2611 // collection. | 2611 // collection. |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3136 object->ShortPrint(); | 3136 object->ShortPrint(); |
| 3137 PrintF("\n"); | 3137 PrintF("\n"); |
| 3138 } | 3138 } |
| 3139 printf(" --------------------------------------\n"); | 3139 printf(" --------------------------------------\n"); |
| 3140 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3140 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3141 } | 3141 } |
| 3142 | 3142 |
| 3143 #endif // DEBUG | 3143 #endif // DEBUG |
| 3144 | 3144 |
| 3145 } } // namespace v8::internal | 3145 } } // namespace v8::internal |
| OLD | NEW |