Chromium Code Reviews| 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/full-codegen.h" | 7 #include "src/full-codegen.h" |
| 8 #include "src/macro-assembler.h" | 8 #include "src/macro-assembler.h" |
| 9 #include "src/mark-compact.h" | 9 #include "src/mark-compact.h" |
| 10 #include "src/msan.h" | 10 #include "src/msan.h" |
| (...skipping 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2570 int remaining = | 2570 int remaining = |
| 2571 static_cast<int>(allocation_info_.limit() - allocation_info_.top()); | 2571 static_cast<int>(allocation_info_.limit() - allocation_info_.top()); |
| 2572 heap()->CreateFillerObjectAt(allocation_info_.top(), remaining); | 2572 heap()->CreateFillerObjectAt(allocation_info_.top(), remaining); |
| 2573 | 2573 |
| 2574 allocation_info_.set_top(NULL); | 2574 allocation_info_.set_top(NULL); |
| 2575 allocation_info_.set_limit(NULL); | 2575 allocation_info_.set_limit(NULL); |
| 2576 } | 2576 } |
| 2577 } | 2577 } |
| 2578 | 2578 |
| 2579 | 2579 |
| 2580 HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation( | |
| 2581 int size_in_bytes) { | |
| 2582 MarkCompactCollector* collector = heap()->mark_compact_collector(); | |
| 2583 | |
| 2584 // If sweeper threads are still running, wait for them. | |
| 2585 if (collector->IsConcurrentSweepingInProgress()) { | |
| 2586 collector->WaitUntilSweepingCompleted(); | |
| 2587 | |
| 2588 // After waiting for the sweeper threads, there may be new free-list | |
| 2589 // entries. | |
| 2590 return free_list_.Allocate(size_in_bytes); | |
| 2591 } | |
| 2592 return NULL; | |
| 2593 } | |
| 2594 | |
| 2595 | |
| 2580 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { | 2596 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { |
| 2581 // Allocation in this space has failed. | 2597 // Allocation in this space has failed. |
| 2582 | 2598 |
| 2583 // 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. |
| 2584 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2600 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
| 2585 if (collector->IsConcurrentSweepingInProgress()) { | 2601 if (collector->IsConcurrentSweepingInProgress()) { |
| 2586 collector->RefillFreeList(this); | 2602 collector->RefillFreeList(this); |
| 2587 | 2603 |
| 2588 // Retry the free list allocation. | 2604 // Retry the free list allocation. |
| 2589 HeapObject* object = free_list_.Allocate(size_in_bytes); | 2605 HeapObject* object = free_list_.Allocate(size_in_bytes); |
| 2590 if (object != NULL) return object; | 2606 if (object != NULL) |
| 2607 return object; | |
| 2591 } | 2608 } |
| 2592 | 2609 |
| 2593 // 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 |
| 2594 // hit the old generation size limit that should cause a garbage | 2611 // hit the old generation size limit that should cause a garbage |
| 2595 // collection. | 2612 // collection. |
| 2596 if (!heap()->always_allocate() && | 2613 if (!heap()->always_allocate() |
| 2597 heap()->OldGenerationAllocationLimitReached()) { | 2614 && heap()->OldGenerationAllocationLimitReached()) { |
| 2598 // If sweeper threads are active, wait for them at that point. | 2615 // If sweeper threads are active, wait for them at that point and steal |
| 2599 if (collector->IsConcurrentSweepingInProgress()) { | 2616 // elements form their free-lists. |
| 2600 collector->WaitUntilSweepingCompleted(); | 2617 HeapObject* object = WaitForSweeperThreadsAndRetryAllocation(size_in_bytes); |
| 2601 | 2618 if (object != NULL) |
|
ulan
2014/06/30 09:32:47
Nit: it should be either a single line or use {}
Hannes Payer (out of office)
2014/06/30 12:38:25
Done.
| |
| 2602 // After waiting for the sweeper threads, there may be new free-list | 2619 return object; |
| 2603 // entries. | |
| 2604 HeapObject* object = free_list_.Allocate(size_in_bytes); | |
| 2605 if (object != NULL) return object; | |
| 2606 } | |
| 2607 | |
| 2608 return NULL; | |
| 2609 } | 2620 } |
| 2610 | 2621 |
| 2611 // Try to expand the space and allocate in the new next page. | 2622 // Try to expand the space and allocate in the new next page. |
| 2612 if (Expand()) { | 2623 if (Expand()) { |
| 2613 ASSERT(CountTotalPages() > 1 || size_in_bytes <= free_list_.available()); | 2624 ASSERT(CountTotalPages() > 1 || size_in_bytes <= free_list_.available()); |
| 2614 return free_list_.Allocate(size_in_bytes); | 2625 return free_list_.Allocate(size_in_bytes); |
| 2615 } | 2626 } |
| 2616 | 2627 |
| 2617 // Finally, fail. | 2628 // If sweeper threads are active, wait for them at that point and steal |
| 2618 return NULL; | 2629 // elements form their free-lists. Allocation may still fail their which |
| 2630 // would indicate that there is not enough memory for the given allocation. | |
| 2631 return WaitForSweeperThreadsAndRetryAllocation(size_in_bytes); | |
| 2619 } | 2632 } |
| 2620 | 2633 |
| 2621 | 2634 |
| 2622 #ifdef DEBUG | 2635 #ifdef DEBUG |
| 2623 void PagedSpace::ReportCodeStatistics(Isolate* isolate) { | 2636 void PagedSpace::ReportCodeStatistics(Isolate* isolate) { |
| 2624 CommentStatistic* comments_statistics = | 2637 CommentStatistic* comments_statistics = |
| 2625 isolate->paged_space_comments_statistics(); | 2638 isolate->paged_space_comments_statistics(); |
| 2626 ReportCodeKindStatistics(isolate->code_kind_statistics()); | 2639 ReportCodeKindStatistics(isolate->code_kind_statistics()); |
| 2627 PrintF("Code comment statistics (\" [ comment-txt : size/ " | 2640 PrintF("Code comment statistics (\" [ comment-txt : size/ " |
| 2628 "count (average)\"):\n"); | 2641 "count (average)\"):\n"); |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3125 object->ShortPrint(); | 3138 object->ShortPrint(); |
| 3126 PrintF("\n"); | 3139 PrintF("\n"); |
| 3127 } | 3140 } |
| 3128 printf(" --------------------------------------\n"); | 3141 printf(" --------------------------------------\n"); |
| 3129 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3142 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3130 } | 3143 } |
| 3131 | 3144 |
| 3132 #endif // DEBUG | 3145 #endif // DEBUG |
| 3133 | 3146 |
| 3134 } } // namespace v8::internal | 3147 } } // namespace v8::internal |
| OLD | NEW |