12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" 27 #include "gc_implementation/parallelScavenge/psOldGen.hpp" 28 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" 29 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" 30 #include "gc_implementation/shared/gcTrace.hpp" 31 #include "gc_implementation/shared/mutableSpace.hpp" 32 #include "memory/memRegion.hpp" 33 #include "oops/oop.inline.hpp" 34 #include "oops/oop.psgc.inline.hpp" 35 36 PSPromotionManager** PSPromotionManager::_manager_array = NULL; 37 OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL; 38 PSOldGen* PSPromotionManager::_old_gen = NULL; 39 MutableSpace* PSPromotionManager::_young_space = NULL; 40 41 void PSPromotionManager::initialize() { 42 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 43 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 44 45 _old_gen = heap->old_gen(); 46 _young_space = heap->young_gen()->to_space(); 47 48 assert(_manager_array == NULL, "Attempt to initialize twice"); 49 _manager_array = NEW_C_HEAP_ARRAY(PSPromotionManager*, ParallelGCThreads+1, mtGC); 50 guarantee(_manager_array != NULL, "Could not initialize promotion manager"); 51 52 _stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads); 53 guarantee(_stack_array_depth != NULL, "Could not initialize promotion manager"); 54 55 // Create and register the PSPromotionManager(s) for the worker threads. 56 for(uint i=0; i<ParallelGCThreads; i++) { 57 _manager_array[i] = new PSPromotionManager(); 58 guarantee(_manager_array[i] != NULL, "Could not create PSPromotionManager"); 59 stack_array_depth()->register_queue(i, _manager_array[i]->claimed_stack_depth()); 60 } 61 62 // The VMThread gets its own PSPromotionManager, which is not available 63 // for work stealing. 64 _manager_array[ParallelGCThreads] = new PSPromotionManager(); 65 guarantee(_manager_array[ParallelGCThreads] != NULL, "Could not create PSPromotionManager"); 66 } 67 68 PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(int index) { 69 assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range"); 70 assert(_manager_array != NULL, "Sanity"); 71 return _manager_array[index]; 72 } 73 74 PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() { 75 assert(_manager_array != NULL, "Sanity"); 76 return _manager_array[ParallelGCThreads]; 77 } 78 79 void PSPromotionManager::pre_scavenge() { 80 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 81 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 82 83 _young_space = heap->young_gen()->to_space(); 84 85 for(uint i=0; i<ParallelGCThreads+1; i++) { 86 manager_array(i)->reset(); 87 } 88 } 89 90 bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) { 91 bool promotion_failure_occurred = false; 92 93 TASKQUEUE_STATS_ONLY(if (PrintGCDetails && ParallelGCVerbose) print_stats()); 94 for (uint i = 0; i < ParallelGCThreads + 1; i++) { 95 PSPromotionManager* manager = manager_array(i); 96 assert(manager->claimed_stack_depth()->is_empty(), "should be empty"); | 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" 27 #include "gc_implementation/parallelScavenge/psOldGen.hpp" 28 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" 29 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" 30 #include "gc_implementation/shared/gcTrace.hpp" 31 #include "gc_implementation/shared/mutableSpace.hpp" 32 #include "memory/allocation.inline.hpp" 33 #include "memory/memRegion.hpp" 34 #include "memory/padded.inline.hpp" 35 #include "oops/oop.inline.hpp" 36 #include "oops/oop.psgc.inline.hpp" 37 38 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL; 39 OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL; 40 PSOldGen* PSPromotionManager::_old_gen = NULL; 41 MutableSpace* PSPromotionManager::_young_space = NULL; 42 43 void PSPromotionManager::initialize() { 44 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 45 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 46 47 _old_gen = heap->old_gen(); 48 _young_space = heap->young_gen()->to_space(); 49 50 // To prevent false sharing, we pad the PSPromotionManagers 51 // and make sure that the first instance starts at a cache line. 52 assert(_manager_array == NULL, "Attempt to initialize twice"); 53 _manager_array = PaddedArray<PSPromotionManager, mtGC>::create_immortal(ParallelGCThreads + 1); 54 guarantee(_manager_array != NULL, "Could not initialize promotion manager"); 55 56 _stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads); 57 guarantee(_stack_array_depth != NULL, "Could not initialize promotion manager"); 58 59 // Create and register the PSPromotionManager(s) for the worker threads. 60 for(uint i=0; i<ParallelGCThreads; i++) { 61 stack_array_depth()->register_queue(i, _manager_array[i].claimed_stack_depth()); 62 } 63 // The VMThread gets its own PSPromotionManager, which is not available 64 // for work stealing. 65 } 66 67 PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(int index) { 68 assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range"); 69 assert(_manager_array != NULL, "Sanity"); 70 return &_manager_array[index]; 71 } 72 73 PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() { 74 assert(_manager_array != NULL, "Sanity"); 75 return &_manager_array[ParallelGCThreads]; 76 } 77 78 void PSPromotionManager::pre_scavenge() { 79 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 80 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 81 82 _young_space = heap->young_gen()->to_space(); 83 84 for(uint i=0; i<ParallelGCThreads+1; i++) { 85 manager_array(i)->reset(); 86 } 87 } 88 89 bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) { 90 bool promotion_failure_occurred = false; 91 92 TASKQUEUE_STATS_ONLY(if (PrintGCDetails && ParallelGCVerbose) print_stats()); 93 for (uint i = 0; i < ParallelGCThreads + 1; i++) { 94 PSPromotionManager* manager = manager_array(i); 95 assert(manager->claimed_stack_depth()->is_empty(), "should be empty"); |