56 void StringCleaningTask::work(uint worker_id) {
57 size_t strings_processed = 0;
58 size_t strings_removed = 0;
59 if (_process_strings) {
60 StringTable::possibly_parallel_unlink(&_par_state_string, _is_alive, &strings_processed, &strings_removed);
61 Atomic::add(strings_processed, &_strings_processed);
62 Atomic::add(strings_removed, &_strings_removed);
63 }
64 if (_dedup_closure != NULL) {
65 StringDedup::parallel_unlink(_dedup_closure, worker_id);
66 }
67 }
68
69 CodeCacheUnloadingTask::CodeCacheUnloadingTask(uint num_workers, BoolObjectClosure* is_alive, bool unloading_occurred) :
70 _unloading_scope(is_alive),
71 _unloading_occurred(unloading_occurred),
72 _num_workers(num_workers),
73 _first_nmethod(NULL),
74 _claimed_nmethod(NULL) {
75 // Get first alive nmethod
76 CompiledMethodIterator iter = CompiledMethodIterator();
77 if(iter.next_alive()) {
78 _first_nmethod = iter.method();
79 }
80 _claimed_nmethod = _first_nmethod;
81 }
82
83 CodeCacheUnloadingTask::~CodeCacheUnloadingTask() {
84 CodeCache::verify_clean_inline_caches();
85
86 guarantee(CodeCache::scavenge_root_nmethods() == NULL, "Must be");
87
88 CodeCache::verify_icholder_relocations();
89 }
90
91 void CodeCacheUnloadingTask::claim_nmethods(CompiledMethod** claimed_nmethods, int *num_claimed_nmethods) {
92 CompiledMethod* first;
93 CompiledMethodIterator last;
94
95 do {
96 *num_claimed_nmethods = 0;
97
98 first = _claimed_nmethod;
99 last = CompiledMethodIterator(first);
100
101 if (first != NULL) {
102
103 for (int i = 0; i < MaxClaimNmethods; i++) {
104 if (!last.next_alive()) {
105 break;
106 }
107 claimed_nmethods[i] = last.method();
108 (*num_claimed_nmethods)++;
109 }
110 }
111
112 } while (Atomic::cmpxchg(last.method(), &_claimed_nmethod, first) != first);
113 }
114
115 void CodeCacheUnloadingTask::work(uint worker_id) {
116 // The first nmethods is claimed by the first worker.
117 if (worker_id == 0 && _first_nmethod != NULL) {
118 _first_nmethod->do_unloading(_unloading_occurred);
119 _first_nmethod = NULL;
120 }
121
122 int num_claimed_nmethods;
123 CompiledMethod* claimed_nmethods[MaxClaimNmethods];
|
56 void StringCleaningTask::work(uint worker_id) {
57 size_t strings_processed = 0;
58 size_t strings_removed = 0;
59 if (_process_strings) {
60 StringTable::possibly_parallel_unlink(&_par_state_string, _is_alive, &strings_processed, &strings_removed);
61 Atomic::add(strings_processed, &_strings_processed);
62 Atomic::add(strings_removed, &_strings_removed);
63 }
64 if (_dedup_closure != NULL) {
65 StringDedup::parallel_unlink(_dedup_closure, worker_id);
66 }
67 }
68
69 CodeCacheUnloadingTask::CodeCacheUnloadingTask(uint num_workers, BoolObjectClosure* is_alive, bool unloading_occurred) :
70 _unloading_scope(is_alive),
71 _unloading_occurred(unloading_occurred),
72 _num_workers(num_workers),
73 _first_nmethod(NULL),
74 _claimed_nmethod(NULL) {
75 // Get first alive nmethod
76 CompiledMethodIterator iter(true /* only_alive */, false /* only_not_unloading */);
77 if(iter.next()) {
78 _first_nmethod = iter.method();
79 }
80 _claimed_nmethod = _first_nmethod;
81 }
82
83 CodeCacheUnloadingTask::~CodeCacheUnloadingTask() {
84 CodeCache::verify_clean_inline_caches();
85
86 guarantee(CodeCache::scavenge_root_nmethods() == NULL, "Must be");
87
88 CodeCache::verify_icholder_relocations();
89 }
90
91 void CodeCacheUnloadingTask::claim_nmethods(CompiledMethod** claimed_nmethods, int *num_claimed_nmethods) {
92 CompiledMethod* first;
93 CompiledMethodIterator last(true /* only_alive */, false /* only_not_unloading */);
94
95 do {
96 *num_claimed_nmethods = 0;
97
98 first = _claimed_nmethod;
99 last = CompiledMethodIterator(true /* only_alive */, false /* only_not_unloading */, first);
100
101 if (first != NULL) {
102
103 for (int i = 0; i < MaxClaimNmethods; i++) {
104 if (!last.next()) {
105 break;
106 }
107 claimed_nmethods[i] = last.method();
108 (*num_claimed_nmethods)++;
109 }
110 }
111
112 } while (Atomic::cmpxchg(last.method(), &_claimed_nmethod, first) != first);
113 }
114
115 void CodeCacheUnloadingTask::work(uint worker_id) {
116 // The first nmethods is claimed by the first worker.
117 if (worker_id == 0 && _first_nmethod != NULL) {
118 _first_nmethod->do_unloading(_unloading_occurred);
119 _first_nmethod = NULL;
120 }
121
122 int num_claimed_nmethods;
123 CompiledMethod* claimed_nmethods[MaxClaimNmethods];
|