Skip to content

Commit fd4b2f2

Browse files
xmas92fisk
authored andcommitted
8291718: Remove mark_for_deoptimization from klass unloading
Reviewed-by: eosterlund, dlong
1 parent 9d7c13e commit fd4b2f2

18 files changed

+41
-36
lines changed

src/hotspot/share/code/codeCache.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,8 @@ int CodeCache::alignment_offset() {
758758
}
759759

760760
// Mark nmethods for unloading if they contain otherwise unreachable oops.
761-
void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) {
761+
void CodeCache::do_unloading(bool unloading_occurred) {
762762
assert_locked_or_safepoint(CodeCache_lock);
763-
UnloadingScope scope(is_alive);
764763
CompiledMethodIterator iter(CompiledMethodIterator::only_alive);
765764
while(iter.next()) {
766765
iter.method()->do_unloading(unloading_occurred);

src/hotspot/share/code/codeCache.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class CodeCache : AllStatic {
197197
~UnloadingScope();
198198
};
199199

200-
static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
200+
static void do_unloading(bool unloading_occurred);
201201
static uint8_t unloading_cycle() { return _unloading_cycle; }
202202

203203
static void increment_unloading_cycle();

src/hotspot/share/code/dependencyContext.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,26 +205,31 @@ void DependencyContext::clean_unloading_dependents() {
205205
}
206206
}
207207

208+
nmethodBucket* DependencyContext::release_and_get_next_not_unloading(nmethodBucket* b) {
209+
nmethodBucket* next = b->next_not_unloading();
210+
release(b);
211+
return next;
212+
}
213+
208214
//
209215
// Invalidate all dependencies in the context
210-
int DependencyContext::remove_all_dependents() {
216+
void DependencyContext::remove_all_dependents() {
217+
nmethodBucket* b = dependencies_not_unloading();
218+
set_dependencies(NULL);
219+
assert(b == nullptr, "All dependents should be unloading");
220+
}
221+
222+
int DependencyContext::remove_and_mark_for_deoptimization_all_dependents() {
211223
nmethodBucket* b = dependencies_not_unloading();
212224
set_dependencies(NULL);
213225
int marked = 0;
214-
int removed = 0;
215226
while (b != NULL) {
216227
nmethod* nm = b->get_nmethod();
217228
if (b->count() > 0 && nm->is_alive() && !nm->is_marked_for_deoptimization()) {
218229
nm->mark_for_deoptimization();
219230
marked++;
220231
}
221-
nmethodBucket* next = b->next_not_unloading();
222-
removed++;
223-
release(b);
224-
b = next;
225-
}
226-
if (UsePerfData && removed > 0) {
227-
_perf_total_buckets_deallocated_count->inc(removed);
232+
b = release_and_get_next_not_unloading(b);
228233
}
229234
return marked;
230235
}

src/hotspot/share/code/dependencyContext.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ class DependencyContext : public StackObj {
120120
int mark_dependent_nmethods(DepChange& changes);
121121
void add_dependent_nmethod(nmethod* nm);
122122
void remove_dependent_nmethod(nmethod* nm);
123-
int remove_all_dependents();
123+
void remove_all_dependents();
124+
int remove_and_mark_for_deoptimization_all_dependents();
124125
void clean_unloading_dependents();
126+
static nmethodBucket* release_and_get_next_not_unloading(nmethodBucket* b);
125127
static void purge_dependency_contexts();
126128
static void release(nmethodBucket* b);
127129
static void cleaning_start();

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,10 +2882,9 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
28822882
}
28832883
}
28842884

2885-
void G1CollectedHeap::complete_cleaning(BoolObjectClosure* is_alive,
2886-
bool class_unloading_occurred) {
2885+
void G1CollectedHeap::complete_cleaning(bool class_unloading_occurred) {
28872886
uint num_workers = workers()->active_workers();
2888-
G1ParallelCleaningTask unlink_task(is_alive, num_workers, class_unloading_occurred);
2887+
G1ParallelCleaningTask unlink_task(num_workers, class_unloading_occurred);
28892888
workers()->run_task(&unlink_task);
28902889
}
28912890

src/hotspot/share/gc/g1/g1CollectedHeap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ class G1CollectedHeap : public CollectedHeap {
12611261
void rebuild_code_roots();
12621262

12631263
// Performs cleaning of data structures after class unloading.
1264-
void complete_cleaning(BoolObjectClosure* is_alive, bool class_unloading_occurred);
1264+
void complete_cleaning(bool class_unloading_occurred);
12651265

12661266
// Verification
12671267

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,8 +1689,9 @@ void G1ConcurrentMark::weak_refs_work() {
16891689
// Unload Klasses, String, Code Cache, etc.
16901690
if (ClassUnloadingWithConcurrentMark) {
16911691
GCTraceTime(Debug, gc, phases) debug("Class Unloading", _gc_timer_cm);
1692+
CodeCache::UnloadingScope scope(&g1_is_alive);
16921693
bool purged_classes = SystemDictionary::do_unloading(_gc_timer_cm);
1693-
_g1h->complete_cleaning(&g1_is_alive, purged_classes);
1694+
_g1h->complete_cleaning(purged_classes);
16941695
}
16951696
}
16961697

src/hotspot/share/gc/g1/g1FullCollector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,10 @@ void G1FullCollector::phase1_mark_live_objects() {
301301
// Class unloading and cleanup.
302302
if (ClassUnloading) {
303303
GCTraceTime(Debug, gc, phases) debug("Phase 1: Class Unloading and Cleanup", scope()->timer());
304+
CodeCache::UnloadingScope unloading_scope(&_is_alive);
304305
// Unload classes and purge the SystemDictionary.
305306
bool purged_class = SystemDictionary::do_unloading(scope()->timer());
306-
_heap->complete_cleaning(&_is_alive, purged_class);
307+
_heap->complete_cleaning(purged_class);
307308
}
308309

309310
scope()->tracer()->report_object_count_after_gc(&_is_alive);

src/hotspot/share/gc/g1/g1ParallelCleaning.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ void JVMCICleaningTask::work(bool unloading_occurred) {
5151
}
5252
#endif // INCLUDE_JVMCI
5353

54-
G1ParallelCleaningTask::G1ParallelCleaningTask(BoolObjectClosure* is_alive,
55-
uint num_workers,
54+
G1ParallelCleaningTask::G1ParallelCleaningTask(uint num_workers,
5655
bool unloading_occurred) :
5756
WorkerTask("G1 Parallel Cleaning"),
5857
_unloading_occurred(unloading_occurred),
59-
_code_cache_task(num_workers, is_alive, unloading_occurred),
58+
_code_cache_task(num_workers, unloading_occurred),
6059
JVMCI_ONLY(_jvmci_cleaning_task() COMMA)
6160
_klass_cleaning_task() {
6261
}

src/hotspot/share/gc/g1/g1ParallelCleaning.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ class G1ParallelCleaningTask : public WorkerTask {
5454

5555
public:
5656
// The constructor is run in the VMThread.
57-
G1ParallelCleaningTask(BoolObjectClosure* is_alive,
58-
uint num_workers,
57+
G1ParallelCleaningTask(uint num_workers,
5958
bool unloading_occurred);
6059

6160
void work(uint worker_id);

0 commit comments

Comments
 (0)