| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 isolate()->sweeper_threads()[i]->StartSweeping(); | 580 isolate()->sweeper_threads()[i]->StartSweeping(); |
| 581 } | 581 } |
| 582 } | 582 } |
| 583 | 583 |
| 584 | 584 |
| 585 void MarkCompactCollector::WaitUntilSweepingCompleted() { | 585 void MarkCompactCollector::WaitUntilSweepingCompleted() { |
| 586 ASSERT(sweeping_pending_ == true); | 586 ASSERT(sweeping_pending_ == true); |
| 587 for (int i = 0; i < isolate()->num_sweeper_threads(); i++) { | 587 for (int i = 0; i < isolate()->num_sweeper_threads(); i++) { |
| 588 isolate()->sweeper_threads()[i]->WaitForSweeperThread(); | 588 isolate()->sweeper_threads()[i]->WaitForSweeperThread(); |
| 589 } | 589 } |
| 590 ParallelSweepSpacesComplete(); |
| 590 sweeping_pending_ = false; | 591 sweeping_pending_ = false; |
| 591 RefillFreeLists(heap()->paged_space(OLD_DATA_SPACE)); | 592 RefillFreeLists(heap()->paged_space(OLD_DATA_SPACE)); |
| 592 RefillFreeLists(heap()->paged_space(OLD_POINTER_SPACE)); | 593 RefillFreeLists(heap()->paged_space(OLD_POINTER_SPACE)); |
| 593 heap()->paged_space(OLD_DATA_SPACE)->ResetUnsweptFreeBytes(); | 594 heap()->paged_space(OLD_DATA_SPACE)->ResetUnsweptFreeBytes(); |
| 594 heap()->paged_space(OLD_POINTER_SPACE)->ResetUnsweptFreeBytes(); | 595 heap()->paged_space(OLD_POINTER_SPACE)->ResetUnsweptFreeBytes(); |
| 595 } | 596 } |
| 596 | 597 |
| 597 | 598 |
| 598 intptr_t MarkCompactCollector::RefillFreeLists(PagedSpace* space) { | 599 intptr_t MarkCompactCollector::RefillFreeLists(PagedSpace* space) { |
| 599 FreeList* free_list; | 600 FreeList* free_list; |
| (...skipping 3304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3904 Page* p) { | 3905 Page* p) { |
| 3905 // TODO(hpayer): This check is just used for debugging purpose and | 3906 // TODO(hpayer): This check is just used for debugging purpose and |
| 3906 // should be removed or turned into an assert after investigating the | 3907 // should be removed or turned into an assert after investigating the |
| 3907 // crash in concurrent sweeping. | 3908 // crash in concurrent sweeping. |
| 3908 CHECK(!p->IsEvacuationCandidate() && !p->WasSwept()); | 3909 CHECK(!p->IsEvacuationCandidate() && !p->WasSwept()); |
| 3909 ASSERT((mode == MarkCompactCollector::SWEEP_IN_PARALLEL && | 3910 ASSERT((mode == MarkCompactCollector::SWEEP_IN_PARALLEL && |
| 3910 free_list != NULL) || | 3911 free_list != NULL) || |
| 3911 (mode == MarkCompactCollector::SWEEP_SEQUENTIALLY && | 3912 (mode == MarkCompactCollector::SWEEP_SEQUENTIALLY && |
| 3912 free_list == NULL)); | 3913 free_list == NULL)); |
| 3913 | 3914 |
| 3914 p->MarkSweptConservatively(); | 3915 // When parallel sweeping is active, the page will be marked after |
| 3916 // sweeping by the main thread. |
| 3917 if (mode != MarkCompactCollector::SWEEP_IN_PARALLEL) { |
| 3918 p->MarkSweptConservatively(); |
| 3919 } |
| 3915 | 3920 |
| 3916 intptr_t freed_bytes = 0; | 3921 intptr_t freed_bytes = 0; |
| 3917 size_t size = 0; | 3922 size_t size = 0; |
| 3918 | 3923 |
| 3919 // Skip over all the dead objects at the start of the page and mark them free. | 3924 // Skip over all the dead objects at the start of the page and mark them free. |
| 3920 Address cell_base = 0; | 3925 Address cell_base = 0; |
| 3921 MarkBit::CellType* cell = NULL; | 3926 MarkBit::CellType* cell = NULL; |
| 3922 MarkBitCellIterator it(p); | 3927 MarkBitCellIterator it(p); |
| 3923 for (; !it.Done(); it.Advance()) { | 3928 for (; !it.Done(); it.Advance()) { |
| 3924 cell_base = it.CurrentCellBase(); | 3929 cell_base = it.CurrentCellBase(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4016 PageIterator it(space); | 4021 PageIterator it(space); |
| 4017 | 4022 |
| 4018 int pages_swept = 0; | 4023 int pages_swept = 0; |
| 4019 bool lazy_sweeping_active = false; | 4024 bool lazy_sweeping_active = false; |
| 4020 bool unused_page_present = false; | 4025 bool unused_page_present = false; |
| 4021 bool parallel_sweeping_active = false; | 4026 bool parallel_sweeping_active = false; |
| 4022 | 4027 |
| 4023 while (it.has_next()) { | 4028 while (it.has_next()) { |
| 4024 Page* p = it.next(); | 4029 Page* p = it.next(); |
| 4025 | 4030 |
| 4026 ASSERT(p->parallel_sweeping() == 0); | 4031 ASSERT(p->parallel_sweeping() == MemoryChunk::PARALLEL_SWEEPING_DONE); |
| 4027 ASSERT(!p->IsEvacuationCandidate()); | 4032 ASSERT(!p->IsEvacuationCandidate()); |
| 4028 | 4033 |
| 4029 // Clear sweeping flags indicating that marking bits are still intact. | 4034 // Clear sweeping flags indicating that marking bits are still intact. |
| 4030 p->ClearSweptPrecisely(); | 4035 p->ClearSweptPrecisely(); |
| 4031 p->ClearSweptConservatively(); | 4036 p->ClearSweptConservatively(); |
| 4032 | 4037 |
| 4033 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { | 4038 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { |
| 4034 // Will be processed in EvacuateNewSpaceAndCandidates. | 4039 // Will be processed in EvacuateNewSpaceAndCandidates. |
| 4035 ASSERT(evacuation_candidates_.length() > 0); | 4040 ASSERT(evacuation_candidates_.length() > 0); |
| 4036 continue; | 4041 continue; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4089 reinterpret_cast<intptr_t>(p)); | 4094 reinterpret_cast<intptr_t>(p)); |
| 4090 } | 4095 } |
| 4091 SweepConservatively<SWEEP_SEQUENTIALLY>(space, NULL, p); | 4096 SweepConservatively<SWEEP_SEQUENTIALLY>(space, NULL, p); |
| 4092 pages_swept++; | 4097 pages_swept++; |
| 4093 parallel_sweeping_active = true; | 4098 parallel_sweeping_active = true; |
| 4094 } else { | 4099 } else { |
| 4095 if (FLAG_gc_verbose) { | 4100 if (FLAG_gc_verbose) { |
| 4096 PrintF("Sweeping 0x%" V8PRIxPTR " conservatively in parallel.\n", | 4101 PrintF("Sweeping 0x%" V8PRIxPTR " conservatively in parallel.\n", |
| 4097 reinterpret_cast<intptr_t>(p)); | 4102 reinterpret_cast<intptr_t>(p)); |
| 4098 } | 4103 } |
| 4099 p->set_parallel_sweeping(1); | 4104 p->set_parallel_sweeping(MemoryChunk::PARALLEL_SWEEPING_PENDING); |
| 4100 space->IncreaseUnsweptFreeBytes(p); | 4105 space->IncreaseUnsweptFreeBytes(p); |
| 4101 } | 4106 } |
| 4102 break; | 4107 break; |
| 4103 } | 4108 } |
| 4104 case PRECISE: { | 4109 case PRECISE: { |
| 4105 if (FLAG_gc_verbose) { | 4110 if (FLAG_gc_verbose) { |
| 4106 PrintF("Sweeping 0x%" V8PRIxPTR " precisely.\n", | 4111 PrintF("Sweeping 0x%" V8PRIxPTR " precisely.\n", |
| 4107 reinterpret_cast<intptr_t>(p)); | 4112 reinterpret_cast<intptr_t>(p)); |
| 4108 } | 4113 } |
| 4109 if (space->identity() == CODE_SPACE) { | 4114 if (space->identity() == CODE_SPACE) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4181 SweepSpace(heap()->map_space(), PRECISE); | 4186 SweepSpace(heap()->map_space(), PRECISE); |
| 4182 | 4187 |
| 4183 // Deallocate unmarked objects and clear marked bits for marked objects. | 4188 // Deallocate unmarked objects and clear marked bits for marked objects. |
| 4184 heap_->lo_space()->FreeUnmarkedObjects(); | 4189 heap_->lo_space()->FreeUnmarkedObjects(); |
| 4185 | 4190 |
| 4186 // Deallocate evacuated candidate pages. | 4191 // Deallocate evacuated candidate pages. |
| 4187 ReleaseEvacuationCandidates(); | 4192 ReleaseEvacuationCandidates(); |
| 4188 } | 4193 } |
| 4189 | 4194 |
| 4190 | 4195 |
| 4196 void MarkCompactCollector::ParallelSweepSpaceComplete(PagedSpace* space) { |
| 4197 PageIterator it(space); |
| 4198 while (it.has_next()) { |
| 4199 Page* p = it.next(); |
| 4200 if (p->parallel_sweeping() == MemoryChunk::PARALLEL_SWEEPING_COMPLETE) { |
| 4201 p->set_parallel_sweeping(MemoryChunk::PARALLEL_SWEEPING_DONE); |
| 4202 p->MarkSweptConservatively(); |
| 4203 } |
| 4204 } |
| 4205 } |
| 4206 |
| 4207 |
| 4208 void MarkCompactCollector::ParallelSweepSpacesComplete() { |
| 4209 ParallelSweepSpaceComplete(heap()->old_pointer_space()); |
| 4210 ParallelSweepSpaceComplete(heap()->old_data_space()); |
| 4211 } |
| 4212 |
| 4213 |
| 4191 void MarkCompactCollector::EnableCodeFlushing(bool enable) { | 4214 void MarkCompactCollector::EnableCodeFlushing(bool enable) { |
| 4192 #ifdef ENABLE_DEBUGGER_SUPPORT | 4215 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 4193 if (isolate()->debug()->IsLoaded() || | 4216 if (isolate()->debug()->IsLoaded() || |
| 4194 isolate()->debug()->has_break_points()) { | 4217 isolate()->debug()->has_break_points()) { |
| 4195 enable = false; | 4218 enable = false; |
| 4196 } | 4219 } |
| 4197 #endif | 4220 #endif |
| 4198 | 4221 |
| 4199 if (enable) { | 4222 if (enable) { |
| 4200 if (code_flusher_ != NULL) return; | 4223 if (code_flusher_ != NULL) return; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4389 while (buffer != NULL) { | 4412 while (buffer != NULL) { |
| 4390 SlotsBuffer* next_buffer = buffer->next(); | 4413 SlotsBuffer* next_buffer = buffer->next(); |
| 4391 DeallocateBuffer(buffer); | 4414 DeallocateBuffer(buffer); |
| 4392 buffer = next_buffer; | 4415 buffer = next_buffer; |
| 4393 } | 4416 } |
| 4394 *buffer_address = NULL; | 4417 *buffer_address = NULL; |
| 4395 } | 4418 } |
| 4396 | 4419 |
| 4397 | 4420 |
| 4398 } } // namespace v8::internal | 4421 } } // namespace v8::internal |
| OLD | NEW |