| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 heap()->old_data_space()->EvictEvacuationCandidatesFromFreeLists(); | 251 heap()->old_data_space()->EvictEvacuationCandidatesFromFreeLists(); |
| 252 heap()->code_space()->EvictEvacuationCandidatesFromFreeLists(); | 252 heap()->code_space()->EvictEvacuationCandidatesFromFreeLists(); |
| 253 | 253 |
| 254 compacting_ = evacuation_candidates_.length() > 0; | 254 compacting_ = evacuation_candidates_.length() > 0; |
| 255 } | 255 } |
| 256 | 256 |
| 257 return compacting_; | 257 return compacting_; |
| 258 } | 258 } |
| 259 | 259 |
| 260 | 260 |
| 261 void MarkCompactCollector::AbortCompaction() { |
| 262 if (compacting_) { |
| 263 int npages = evacuation_candidates_.length(); |
| 264 for (int i = 0; i < npages; i++) { |
| 265 Page* p = evacuation_candidates_[i]; |
| 266 slots_buffer_allocator_.DeallocateChain(p->slots_buffer_address()); |
| 267 p->ClearEvacuationCandidate(); |
| 268 p->ClearFlag(MemoryChunk::RESCAN_ON_EVACUATION); |
| 269 } |
| 270 compacting_ = false; |
| 271 evacuation_candidates_.Rewind(0); |
| 272 } |
| 273 ASSERT_EQ(0, evacuation_candidates_.length()); |
| 274 } |
| 275 |
| 276 |
| 261 void MarkCompactCollector::CollectGarbage() { | 277 void MarkCompactCollector::CollectGarbage() { |
| 262 // Make sure that Prepare() has been called. The individual steps below will | 278 // Make sure that Prepare() has been called. The individual steps below will |
| 263 // update the state as they proceed. | 279 // update the state as they proceed. |
| 264 ASSERT(state_ == PREPARE_GC); | 280 ASSERT(state_ == PREPARE_GC); |
| 265 ASSERT(encountered_weak_maps_ == Smi::FromInt(0)); | 281 ASSERT(encountered_weak_maps_ == Smi::FromInt(0)); |
| 266 | 282 |
| 267 MarkLiveObjects(); | 283 MarkLiveObjects(); |
| 268 ASSERT(heap_->incremental_marking()->IsStopped()); | 284 ASSERT(heap_->incremental_marking()->IsStopped()); |
| 269 | 285 |
| 270 if (collect_maps_) ClearNonLiveTransitions(); | 286 if (collect_maps_) ClearNonLiveTransitions(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 if (FLAG_gdbjit) { | 487 if (FLAG_gdbjit) { |
| 472 // If GDBJIT interface is active disable compaction. | 488 // If GDBJIT interface is active disable compaction. |
| 473 compacting_collection_ = false; | 489 compacting_collection_ = false; |
| 474 } | 490 } |
| 475 #endif | 491 #endif |
| 476 | 492 |
| 477 // Clear marking bits for precise sweeping to collect all garbage. | 493 // Clear marking bits for precise sweeping to collect all garbage. |
| 478 if (heap()->incremental_marking()->IsMarking() && PreciseSweepingRequired()) { | 494 if (heap()->incremental_marking()->IsMarking() && PreciseSweepingRequired()) { |
| 479 heap()->incremental_marking()->Abort(); | 495 heap()->incremental_marking()->Abort(); |
| 480 ClearMarkbits(heap_); | 496 ClearMarkbits(heap_); |
| 497 AbortCompaction(); |
| 481 } | 498 } |
| 482 | 499 |
| 483 if (!FLAG_never_compact) StartCompaction(); | 500 if (!FLAG_never_compact) StartCompaction(); |
| 484 | 501 |
| 485 PagedSpaces spaces; | 502 PagedSpaces spaces; |
| 486 for (PagedSpace* space = spaces.next(); | 503 for (PagedSpace* space = spaces.next(); |
| 487 space != NULL; | 504 space != NULL; |
| 488 space = spaces.next()) { | 505 space = spaces.next()) { |
| 489 space->PrepareForMarkCompact(); | 506 space->PrepareForMarkCompact(); |
| 490 } | 507 } |
| (...skipping 3133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3624 while (buffer != NULL) { | 3641 while (buffer != NULL) { |
| 3625 SlotsBuffer* next_buffer = buffer->next(); | 3642 SlotsBuffer* next_buffer = buffer->next(); |
| 3626 DeallocateBuffer(buffer); | 3643 DeallocateBuffer(buffer); |
| 3627 buffer = next_buffer; | 3644 buffer = next_buffer; |
| 3628 } | 3645 } |
| 3629 *buffer_address = NULL; | 3646 *buffer_address = NULL; |
| 3630 } | 3647 } |
| 3631 | 3648 |
| 3632 | 3649 |
| 3633 } } // namespace v8::internal | 3650 } } // namespace v8::internal |
| OLD | NEW |