| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 3704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3715 if (p->TryParallelSweeping()) { | 3715 if (p->TryParallelSweeping()) { |
| 3716 SweepConservatively<SWEEP_IN_PARALLEL>(space, private_free_list, p); | 3716 SweepConservatively<SWEEP_IN_PARALLEL>(space, private_free_list, p); |
| 3717 free_list->Concatenate(private_free_list); | 3717 free_list->Concatenate(private_free_list); |
| 3718 } | 3718 } |
| 3719 } | 3719 } |
| 3720 } | 3720 } |
| 3721 | 3721 |
| 3722 | 3722 |
| 3723 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { | 3723 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { |
| 3724 space->set_was_swept_conservatively(sweeper == CONSERVATIVE || | 3724 space->set_was_swept_conservatively(sweeper == CONSERVATIVE || |
| 3725 sweeper == LAZY_CONSERVATIVE); | 3725 sweeper == LAZY_CONSERVATIVE || |
| 3726 sweeper == PARALLEL_CONSERVATIVE); |
| 3726 space->ClearStats(); | 3727 space->ClearStats(); |
| 3727 | 3728 |
| 3728 PageIterator it(space); | 3729 PageIterator it(space); |
| 3729 | 3730 |
| 3730 intptr_t freed_bytes = 0; | 3731 intptr_t freed_bytes = 0; |
| 3731 int pages_swept = 0; | 3732 int pages_swept = 0; |
| 3732 bool lazy_sweeping_active = false; | 3733 bool lazy_sweeping_active = false; |
| 3733 bool unused_page_present = false; | 3734 bool unused_page_present = false; |
| 3734 | 3735 |
| 3735 while (it.has_next()) { | 3736 while (it.has_next()) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3834 } | 3835 } |
| 3835 | 3836 |
| 3836 | 3837 |
| 3837 void MarkCompactCollector::SweepSpaces() { | 3838 void MarkCompactCollector::SweepSpaces() { |
| 3838 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); | 3839 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); |
| 3839 #ifdef DEBUG | 3840 #ifdef DEBUG |
| 3840 state_ = SWEEP_SPACES; | 3841 state_ = SWEEP_SPACES; |
| 3841 #endif | 3842 #endif |
| 3842 SweeperType how_to_sweep = | 3843 SweeperType how_to_sweep = |
| 3843 FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE; | 3844 FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE; |
| 3845 if (AreSweeperThreadsActivated()) how_to_sweep = PARALLEL_CONSERVATIVE; |
| 3844 if (FLAG_expose_gc) how_to_sweep = CONSERVATIVE; | 3846 if (FLAG_expose_gc) how_to_sweep = CONSERVATIVE; |
| 3845 if (sweep_precisely_) how_to_sweep = PRECISE; | 3847 if (sweep_precisely_) how_to_sweep = PRECISE; |
| 3846 if (AreSweeperThreadsActivated()) how_to_sweep = PARALLEL_CONSERVATIVE; | |
| 3847 // Noncompacting collections simply sweep the spaces to clear the mark | 3848 // Noncompacting collections simply sweep the spaces to clear the mark |
| 3848 // bits and free the nonlive blocks (for old and map spaces). We sweep | 3849 // bits and free the nonlive blocks (for old and map spaces). We sweep |
| 3849 // the map space last because freeing non-live maps overwrites them and | 3850 // the map space last because freeing non-live maps overwrites them and |
| 3850 // the other spaces rely on possibly non-live maps to get the sizes for | 3851 // the other spaces rely on possibly non-live maps to get the sizes for |
| 3851 // non-live objects. | 3852 // non-live objects. |
| 3852 | 3853 |
| 3853 SweepSpace(heap()->old_pointer_space(), how_to_sweep); | 3854 SweepSpace(heap()->old_pointer_space(), how_to_sweep); |
| 3854 SweepSpace(heap()->old_data_space(), how_to_sweep); | 3855 SweepSpace(heap()->old_data_space(), how_to_sweep); |
| 3855 | 3856 |
| 3856 RemoveDeadInvalidatedCode(); | 3857 RemoveDeadInvalidatedCode(); |
| 3857 SweepSpace(heap()->code_space(), PRECISE); | 3858 SweepSpace(heap()->code_space(), PRECISE); |
| 3858 | 3859 |
| 3859 SweepSpace(heap()->cell_space(), PRECISE); | 3860 SweepSpace(heap()->cell_space(), PRECISE); |
| 3860 | 3861 |
| 3861 EvacuateNewSpaceAndCandidates(); | 3862 EvacuateNewSpaceAndCandidates(); |
| 3862 | 3863 |
| 3863 if (AreSweeperThreadsActivated()) { | 3864 if (how_to_sweep == PARALLEL_CONSERVATIVE) { |
| 3864 // TODO(hpayer): The starting of the sweeper threads should be after | 3865 // TODO(hpayer): The starting of the sweeper threads should be after |
| 3865 // SweepSpace old data space. | 3866 // SweepSpace old data space. |
| 3866 StartSweeperThreads(); | 3867 StartSweeperThreads(); |
| 3867 if (FLAG_parallel_sweeping && !FLAG_concurrent_sweeping) { | 3868 if (FLAG_parallel_sweeping && !FLAG_concurrent_sweeping) { |
| 3868 WaitUntilSweepingCompleted(); | 3869 WaitUntilSweepingCompleted(); |
| 3869 } | 3870 } |
| 3870 } | 3871 } |
| 3871 | 3872 |
| 3872 // ClearNonLiveTransitions depends on precise sweeping of map space to | 3873 // ClearNonLiveTransitions depends on precise sweeping of map space to |
| 3873 // detect whether unmarked map became dead in this collection or in one | 3874 // detect whether unmarked map became dead in this collection or in one |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4069 while (buffer != NULL) { | 4070 while (buffer != NULL) { |
| 4070 SlotsBuffer* next_buffer = buffer->next(); | 4071 SlotsBuffer* next_buffer = buffer->next(); |
| 4071 DeallocateBuffer(buffer); | 4072 DeallocateBuffer(buffer); |
| 4072 buffer = next_buffer; | 4073 buffer = next_buffer; |
| 4073 } | 4074 } |
| 4074 *buffer_address = NULL; | 4075 *buffer_address = NULL; |
| 4075 } | 4076 } |
| 4076 | 4077 |
| 4077 | 4078 |
| 4078 } } // namespace v8::internal | 4079 } } // namespace v8::internal |
| OLD | NEW |