43 #include "oops/compressedOops.inline.hpp"
44
45 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL;
46 PSPromotionManager::OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL;
47 PreservedMarksSet* PSPromotionManager::_preserved_marks_set = NULL;
48 PSOldGen* PSPromotionManager::_old_gen = NULL;
49 MutableSpace* PSPromotionManager::_young_space = NULL;
50
51 void PSPromotionManager::initialize() {
52 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
53
54 _old_gen = heap->old_gen();
55 _young_space = heap->young_gen()->to_space();
56
57 const uint promotion_manager_num = ParallelGCThreads + 1;
58
59 // To prevent false sharing, we pad the PSPromotionManagers
60 // and make sure that the first instance starts at a cache line.
61 assert(_manager_array == NULL, "Attempt to initialize twice");
62 _manager_array = PaddedArray<PSPromotionManager, mtGC>::create_unfreeable(promotion_manager_num);
63 guarantee(_manager_array != NULL, "Could not initialize promotion manager");
64
65 _stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads);
66 guarantee(_stack_array_depth != NULL, "Could not initialize promotion manager");
67
68 // Create and register the PSPromotionManager(s) for the worker threads.
69 for(uint i=0; i<ParallelGCThreads; i++) {
70 stack_array_depth()->register_queue(i, _manager_array[i].claimed_stack_depth());
71 }
72 // The VMThread gets its own PSPromotionManager, which is not available
73 // for work stealing.
74
75 assert(_preserved_marks_set == NULL, "Attempt to initialize twice");
76 _preserved_marks_set = new PreservedMarksSet(true /* in_c_heap */);
77 guarantee(_preserved_marks_set != NULL, "Could not initialize preserved marks set");
78 _preserved_marks_set->init(promotion_manager_num);
79 for (uint i = 0; i < promotion_manager_num; i += 1) {
80 _manager_array[i].register_preserved_marks(_preserved_marks_set->get(i));
81 }
82 }
83
84 // Helper functions to get around the circular dependency between
85 // psScavenge.inline.hpp and psPromotionManager.inline.hpp.
86 bool PSPromotionManager::should_scavenge(oop* p, bool check_to_space) {
87 return PSScavenge::should_scavenge(p, check_to_space);
88 }
89 bool PSPromotionManager::should_scavenge(narrowOop* p, bool check_to_space) {
90 return PSScavenge::should_scavenge(p, check_to_space);
91 }
92
93 PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(uint index) {
94 assert(index < ParallelGCThreads, "index out of range");
95 assert(_manager_array != NULL, "Sanity");
96 return &_manager_array[index];
97 }
|
43 #include "oops/compressedOops.inline.hpp"
44
45 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL;
46 PSPromotionManager::OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL;
47 PreservedMarksSet* PSPromotionManager::_preserved_marks_set = NULL;
48 PSOldGen* PSPromotionManager::_old_gen = NULL;
49 MutableSpace* PSPromotionManager::_young_space = NULL;
50
51 void PSPromotionManager::initialize() {
52 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
53
54 _old_gen = heap->old_gen();
55 _young_space = heap->young_gen()->to_space();
56
57 const uint promotion_manager_num = ParallelGCThreads + 1;
58
59 // To prevent false sharing, we pad the PSPromotionManagers
60 // and make sure that the first instance starts at a cache line.
61 assert(_manager_array == NULL, "Attempt to initialize twice");
62 _manager_array = PaddedArray<PSPromotionManager, mtGC>::create_unfreeable(promotion_manager_num);
63
64 _stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads);
65
66 // Create and register the PSPromotionManager(s) for the worker threads.
67 for(uint i=0; i<ParallelGCThreads; i++) {
68 stack_array_depth()->register_queue(i, _manager_array[i].claimed_stack_depth());
69 }
70 // The VMThread gets its own PSPromotionManager, which is not available
71 // for work stealing.
72
73 assert(_preserved_marks_set == NULL, "Attempt to initialize twice");
74 _preserved_marks_set = new PreservedMarksSet(true /* in_c_heap */);
75 _preserved_marks_set->init(promotion_manager_num);
76 for (uint i = 0; i < promotion_manager_num; i += 1) {
77 _manager_array[i].register_preserved_marks(_preserved_marks_set->get(i));
78 }
79 }
80
81 // Helper functions to get around the circular dependency between
82 // psScavenge.inline.hpp and psPromotionManager.inline.hpp.
83 bool PSPromotionManager::should_scavenge(oop* p, bool check_to_space) {
84 return PSScavenge::should_scavenge(p, check_to_space);
85 }
86 bool PSPromotionManager::should_scavenge(narrowOop* p, bool check_to_space) {
87 return PSScavenge::should_scavenge(p, check_to_space);
88 }
89
90 PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(uint index) {
91 assert(index < ParallelGCThreads, "index out of range");
92 assert(_manager_array != NULL, "Sanity");
93 return &_manager_array[index];
94 }
|