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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 543 |
544 void MarkCompactCollector::StartSweeperThreads() { | 544 void MarkCompactCollector::StartSweeperThreads() { |
545 sweeping_pending_ = true; | 545 sweeping_pending_ = true; |
546 for (int i = 0; i < FLAG_sweeper_threads; i++) { | 546 for (int i = 0; i < FLAG_sweeper_threads; i++) { |
547 heap()->isolate()->sweeper_threads()[i]->StartSweeping(); | 547 heap()->isolate()->sweeper_threads()[i]->StartSweeping(); |
548 } | 548 } |
549 } | 549 } |
550 | 550 |
551 | 551 |
552 void MarkCompactCollector::WaitUntilSweepingCompleted() { | 552 void MarkCompactCollector::WaitUntilSweepingCompleted() { |
553 if (sweeping_pending_) { | 553 ASSERT(sweeping_pending_ == true); |
554 for (int i = 0; i < FLAG_sweeper_threads; i++) { | 554 for (int i = 0; i < FLAG_sweeper_threads; i++) { |
555 heap()->isolate()->sweeper_threads()[i]->WaitForSweeperThread(); | 555 heap()->isolate()->sweeper_threads()[i]->WaitForSweeperThread(); |
556 } | |
557 sweeping_pending_ = false; | |
558 StealMemoryFromSweeperThreads(heap()->paged_space(OLD_DATA_SPACE)); | |
559 StealMemoryFromSweeperThreads(heap()->paged_space(OLD_POINTER_SPACE)); | |
560 heap()->paged_space(OLD_DATA_SPACE)->ResetUnsweptFreeBytes(); | |
561 heap()->paged_space(OLD_POINTER_SPACE)->ResetUnsweptFreeBytes(); | |
562 } | 556 } |
| 557 sweeping_pending_ = false; |
| 558 StealMemoryFromSweeperThreads(heap()->paged_space(OLD_DATA_SPACE)); |
| 559 StealMemoryFromSweeperThreads(heap()->paged_space(OLD_POINTER_SPACE)); |
| 560 heap()->paged_space(OLD_DATA_SPACE)->ResetUnsweptFreeBytes(); |
| 561 heap()->paged_space(OLD_POINTER_SPACE)->ResetUnsweptFreeBytes(); |
563 } | 562 } |
564 | 563 |
565 | 564 |
566 intptr_t MarkCompactCollector:: | 565 intptr_t MarkCompactCollector:: |
567 StealMemoryFromSweeperThreads(PagedSpace* space) { | 566 StealMemoryFromSweeperThreads(PagedSpace* space) { |
568 intptr_t freed_bytes = 0; | 567 intptr_t freed_bytes = 0; |
569 for (int i = 0; i < FLAG_sweeper_threads; i++) { | 568 for (int i = 0; i < FLAG_sweeper_threads; i++) { |
570 freed_bytes += heap()->isolate()->sweeper_threads()[i]->StealMemory(space); | 569 freed_bytes += heap()->isolate()->sweeper_threads()[i]->StealMemory(space); |
571 } | 570 } |
572 space->AddToAccountingStats(freed_bytes); | 571 space->AddToAccountingStats(freed_bytes); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 // variable. | 900 // variable. |
902 tracer_ = tracer; | 901 tracer_ = tracer; |
903 | 902 |
904 #ifdef DEBUG | 903 #ifdef DEBUG |
905 ASSERT(state_ == IDLE); | 904 ASSERT(state_ == IDLE); |
906 state_ = PREPARE_GC; | 905 state_ = PREPARE_GC; |
907 #endif | 906 #endif |
908 | 907 |
909 ASSERT(!FLAG_never_compact || !FLAG_always_compact); | 908 ASSERT(!FLAG_never_compact || !FLAG_always_compact); |
910 | 909 |
911 if (AreSweeperThreadsActivated() && FLAG_concurrent_sweeping) { | 910 if (IsConcurrentSweepingInProgress()) { |
912 // Instead of waiting we could also abort the sweeper threads here. | 911 // Instead of waiting we could also abort the sweeper threads here. |
913 WaitUntilSweepingCompleted(); | 912 WaitUntilSweepingCompleted(); |
914 FinalizeSweeping(); | 913 FinalizeSweeping(); |
915 } | 914 } |
916 | 915 |
917 // Clear marking bits if incremental marking is aborted. | 916 // Clear marking bits if incremental marking is aborted. |
918 if (was_marked_incrementally_ && abort_incremental_marking_) { | 917 if (was_marked_incrementally_ && abort_incremental_marking_) { |
919 heap()->incremental_marking()->Abort(); | 918 heap()->incremental_marking()->Abort(); |
920 ClearMarkbits(); | 919 ClearMarkbits(); |
921 AbortCompaction(); | 920 AbortCompaction(); |
(...skipping 3199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4121 while (buffer != NULL) { | 4120 while (buffer != NULL) { |
4122 SlotsBuffer* next_buffer = buffer->next(); | 4121 SlotsBuffer* next_buffer = buffer->next(); |
4123 DeallocateBuffer(buffer); | 4122 DeallocateBuffer(buffer); |
4124 buffer = next_buffer; | 4123 buffer = next_buffer; |
4125 } | 4124 } |
4126 *buffer_address = NULL; | 4125 *buffer_address = NULL; |
4127 } | 4126 } |
4128 | 4127 |
4129 | 4128 |
4130 } } // namespace v8::internal | 4129 } } // namespace v8::internal |
OLD | NEW |