Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: src/mark-compact.cc

Issue 68203029: Make number of available threads isolate-dependent and expose it to ResourceConstraints. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/isolate.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 mark_bit.Clear(); 557 mark_bit.Clear();
558 mark_bit.Next().Clear(); 558 mark_bit.Next().Clear();
559 Page::FromAddress(obj->address())->ResetProgressBar(); 559 Page::FromAddress(obj->address())->ResetProgressBar();
560 Page::FromAddress(obj->address())->ResetLiveBytes(); 560 Page::FromAddress(obj->address())->ResetLiveBytes();
561 } 561 }
562 } 562 }
563 563
564 564
565 void MarkCompactCollector::StartSweeperThreads() { 565 void MarkCompactCollector::StartSweeperThreads() {
566 sweeping_pending_ = true; 566 sweeping_pending_ = true;
567 for (int i = 0; i < FLAG_sweeper_threads; i++) { 567 for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
568 isolate()->sweeper_threads()[i]->StartSweeping(); 568 isolate()->sweeper_threads()[i]->StartSweeping();
569 } 569 }
570 } 570 }
571 571
572 572
573 void MarkCompactCollector::WaitUntilSweepingCompleted() { 573 void MarkCompactCollector::WaitUntilSweepingCompleted() {
574 ASSERT(sweeping_pending_ == true); 574 ASSERT(sweeping_pending_ == true);
575 for (int i = 0; i < FLAG_sweeper_threads; i++) { 575 for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
576 isolate()->sweeper_threads()[i]->WaitForSweeperThread(); 576 isolate()->sweeper_threads()[i]->WaitForSweeperThread();
577 } 577 }
578 sweeping_pending_ = false; 578 sweeping_pending_ = false;
579 StealMemoryFromSweeperThreads(heap()->paged_space(OLD_DATA_SPACE)); 579 StealMemoryFromSweeperThreads(heap()->paged_space(OLD_DATA_SPACE));
580 StealMemoryFromSweeperThreads(heap()->paged_space(OLD_POINTER_SPACE)); 580 StealMemoryFromSweeperThreads(heap()->paged_space(OLD_POINTER_SPACE));
581 heap()->paged_space(OLD_DATA_SPACE)->ResetUnsweptFreeBytes(); 581 heap()->paged_space(OLD_DATA_SPACE)->ResetUnsweptFreeBytes();
582 heap()->paged_space(OLD_POINTER_SPACE)->ResetUnsweptFreeBytes(); 582 heap()->paged_space(OLD_POINTER_SPACE)->ResetUnsweptFreeBytes();
583 } 583 }
584 584
585 585
586 intptr_t MarkCompactCollector:: 586 intptr_t MarkCompactCollector::
587 StealMemoryFromSweeperThreads(PagedSpace* space) { 587 StealMemoryFromSweeperThreads(PagedSpace* space) {
588 intptr_t freed_bytes = 0; 588 intptr_t freed_bytes = 0;
589 for (int i = 0; i < FLAG_sweeper_threads; i++) { 589 for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
590 freed_bytes += isolate()->sweeper_threads()[i]->StealMemory(space); 590 freed_bytes += isolate()->sweeper_threads()[i]->StealMemory(space);
591 } 591 }
592 space->AddToAccountingStats(freed_bytes); 592 space->AddToAccountingStats(freed_bytes);
593 space->DecrementUnsweptFreeBytes(freed_bytes); 593 space->DecrementUnsweptFreeBytes(freed_bytes);
594 return freed_bytes; 594 return freed_bytes;
595 } 595 }
596 596
597 597
598 bool MarkCompactCollector::AreSweeperThreadsActivated() { 598 bool MarkCompactCollector::AreSweeperThreadsActivated() {
599 return isolate()->sweeper_threads() != NULL; 599 return isolate()->sweeper_threads() != NULL;
(...skipping 3494 matching lines...) Expand 10 before | Expand all | Expand 10 after
4094 } 4094 }
4095 4095
4096 4096
4097 void MarkCompactCollector::SweepSpaces() { 4097 void MarkCompactCollector::SweepSpaces() {
4098 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); 4098 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP);
4099 #ifdef DEBUG 4099 #ifdef DEBUG
4100 state_ = SWEEP_SPACES; 4100 state_ = SWEEP_SPACES;
4101 #endif 4101 #endif
4102 SweeperType how_to_sweep = 4102 SweeperType how_to_sweep =
4103 FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE; 4103 FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE;
4104 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE; 4104 if (isolate()->num_sweeper_threads() > 0) {
4105 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE; 4105 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE;
4106 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE;
4107 }
4106 if (FLAG_expose_gc) how_to_sweep = CONSERVATIVE; 4108 if (FLAG_expose_gc) how_to_sweep = CONSERVATIVE;
4107 if (sweep_precisely_) how_to_sweep = PRECISE; 4109 if (sweep_precisely_) how_to_sweep = PRECISE;
4108 4110
4109 // Unlink evacuation candidates before sweeper threads access the list of 4111 // Unlink evacuation candidates before sweeper threads access the list of
4110 // pages to avoid race condition. 4112 // pages to avoid race condition.
4111 UnlinkEvacuationCandidates(); 4113 UnlinkEvacuationCandidates();
4112 4114
4113 // Noncompacting collections simply sweep the spaces to clear the mark 4115 // Noncompacting collections simply sweep the spaces to clear the mark
4114 // bits and free the nonlive blocks (for old and map spaces). We sweep 4116 // bits and free the nonlive blocks (for old and map spaces). We sweep
4115 // the map space last because freeing non-live maps overwrites them and 4117 // the map space last because freeing non-live maps overwrites them and
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
4351 while (buffer != NULL) { 4353 while (buffer != NULL) {
4352 SlotsBuffer* next_buffer = buffer->next(); 4354 SlotsBuffer* next_buffer = buffer->next();
4353 DeallocateBuffer(buffer); 4355 DeallocateBuffer(buffer);
4354 buffer = next_buffer; 4356 buffer = next_buffer;
4355 } 4357 }
4356 *buffer_address = NULL; 4358 *buffer_address = NULL;
4357 } 4359 }
4358 4360
4359 4361
4360 } } // namespace v8::internal 4362 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698