Skip to content

Commit 7ed8ba1

Browse files
author
Kim Barrett
committed
8256814: WeakProcessorPhases may be redundant
Remove WeakProcessorPhase, adding scoped enum categories to OopStorageSet. Reviewed-by: stefank, tschatzl, rkennke
1 parent bfac3fb commit 7ed8ba1

23 files changed

+345
-412
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
3131
#include "gc/g1/g1StringDedup.hpp"
3232
#include "gc/g1/heapRegionManager.hpp"
3333
#include "gc/shared/parallelCleaning.hpp"
34-
#include "gc/shared/weakProcessorPhaseTimes.hpp"
3534
#include "gc/shared/weakProcessor.hpp"
3635
#include "utilities/ticks.hpp"
3736

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@
3131
#include "gc/g1/g1StringDedup.hpp"
3232
#include "gc/shared/gcTimer.hpp"
3333
#include "gc/shared/oopStorage.hpp"
34+
#include "gc/shared/oopStorageSet.hpp"
3435
#include "gc/shared/tlab_globals.hpp"
3536
#include "gc/shared/workerDataArray.inline.hpp"
3637
#include "memory/resourceArea.hpp"
3738
#include "logging/log.hpp"
3839
#include "logging/logStream.hpp"
3940
#include "runtime/timer.hpp"
4041
#include "runtime/os.hpp"
42+
#include "utilities/enumIterator.hpp"
4143
#include "utilities/macros.hpp"
4244

4345
static const char* indent(uint level) {
@@ -64,13 +66,14 @@ G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) :
6466
AOT_ONLY(_gc_par_phases[AOTCodeRoots] = new WorkerDataArray<double>("AOTCodeRoots", "AOT Root Scan (ms):", max_gc_threads);)
6567
_gc_par_phases[CMRefRoots] = new WorkerDataArray<double>("CMRefRoots", "CM RefProcessor Roots (ms):", max_gc_threads);
6668

67-
int index = G1GCPhaseTimes::StrongOopStorageSetRoots;
68-
for (OopStorageSet::Iterator it = OopStorageSet::strong_iterator(); !it.is_end(); ++it, ++index) {
69+
for (auto id : EnumRange<OopStorageSet::StrongId>()) {
70+
GCParPhases phase = strong_oopstorage_phase(id);
6971
const char* phase_name_postfix = " Roots (ms):";
70-
char* oop_storage_phase_name = NEW_C_HEAP_ARRAY(char, strlen(phase_name_postfix) + strlen(it->name()) + 1, mtGC);
71-
strcpy(oop_storage_phase_name, it->name());
72+
const char* storage_name = OopStorageSet::storage(id)->name();
73+
char* oop_storage_phase_name = NEW_C_HEAP_ARRAY(char, strlen(phase_name_postfix) + strlen(storage_name) + 1, mtGC);
74+
strcpy(oop_storage_phase_name, storage_name);
7275
strcat(oop_storage_phase_name, phase_name_postfix);
73-
_gc_par_phases[index] = new WorkerDataArray<double>(it->name(), oop_storage_phase_name, max_gc_threads);
76+
_gc_par_phases[phase] = new WorkerDataArray<double>(storage_name, oop_storage_phase_name, max_gc_threads);
7477
}
7578

7679
_gc_par_phases[MergeER] = new WorkerDataArray<double>("MergeER", "Eager Reclaim (ms):", max_gc_threads);
@@ -487,7 +490,8 @@ double G1GCPhaseTimes::print_post_evacuate_collection_set() const {
487490

488491
debug_time_for_reference("Reference Processing", _cur_ref_proc_time_ms);
489492
_ref_phase_times.print_all_references(2, false);
490-
_weak_phase_times.log_print(2);
493+
_weak_phase_times.log_total(2);
494+
_weak_phase_times.log_subtotals(3);
491495

492496
if (G1StringDedup::is_enabled()) {
493497
debug_time("String Deduplication", _cur_string_deduplication_time_ms);

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,9 +27,10 @@
2727

2828
#include "gc/shared/oopStorageSet.hpp"
2929
#include "gc/shared/referenceProcessorPhaseTimes.hpp"
30-
#include "gc/shared/weakProcessorPhaseTimes.hpp"
30+
#include "gc/shared/weakProcessorTimes.hpp"
3131
#include "logging/logLevel.hpp"
3232
#include "memory/allocation.hpp"
33+
#include "utilities/enumIterator.hpp"
3334
#include "utilities/macros.hpp"
3435

3536
class LineBuffer;
@@ -51,10 +52,10 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
5152
CLDGRoots,
5253
AOT_ONLY(AOTCodeRoots COMMA)
5354
CMRefRoots,
54-
// For every OopStorage there will be one element in the enum, starting with
55-
// StrongOopStorageSetRoots.
55+
// For every strong OopStorage there will be one element in this enum,
56+
// starting with StrongOopStorageSetRoots.
5657
StrongOopStorageSetRoots,
57-
MergeER = StrongOopStorageSetRoots + OopStorageSet::strong_count,
58+
MergeER = StrongOopStorageSetRoots + EnumRange<OopStorageSet::StrongId>().size(),
5859
MergeRS,
5960
OptMergeRS,
6061
MergeLB,
@@ -84,6 +85,11 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
8485
static const GCParPhases ExtRootScanSubPhasesFirst = ThreadRoots;
8586
static const GCParPhases ExtRootScanSubPhasesLast = GCParPhases(MergeER - 1);
8687

88+
static constexpr GCParPhases strong_oopstorage_phase(OopStorageSet::StrongId id) {
89+
size_t index = EnumRange<OopStorageSet::StrongId>().index(id);
90+
return GCParPhases(StrongOopStorageSetRoots + index);
91+
}
92+
8793
enum GCMergeRSWorkTimes {
8894
MergeRSMergedSparse,
8995
MergeRSMergedFine,
@@ -187,7 +193,7 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
187193
double _cur_verify_after_time_ms;
188194

189195
ReferenceProcessorPhaseTimes _ref_phase_times;
190-
WeakProcessorPhaseTimes _weak_phase_times;
196+
WeakProcessorTimes _weak_phase_times;
191197

192198
double worker_time(GCParPhases phase, uint worker);
193199
void note_gc_end();
@@ -436,7 +442,7 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
436442

437443
ReferenceProcessorPhaseTimes* ref_phase_times() { return &_ref_phase_times; }
438444

439-
WeakProcessorPhaseTimes* weak_phase_times() { return &_weak_phase_times; }
445+
WeakProcessorTimes* weak_phase_times() { return &_weak_phase_times; }
440446
};
441447

442448
class G1EvacPhaseWithTrimTimeTracker : public StackObj {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,7 @@
4444
#include "gc/shared/referenceProcessor.hpp"
4545
#include "memory/allocation.inline.hpp"
4646
#include "runtime/mutex.hpp"
47+
#include "utilities/enumIterator.hpp"
4748
#include "utilities/macros.hpp"
4849

4950
G1RootProcessor::G1RootProcessor(G1CollectedHeap* g1h, uint n_workers) :
@@ -195,10 +196,10 @@ void G1RootProcessor::process_vm_roots(G1RootClosures* closures,
195196
}
196197
#endif
197198

198-
for (int i = 0; i < _oop_storage_set_strong_par_state.par_state_count(); ++i) {
199-
G1GCPhaseTimes::GCParPhases phase = G1GCPhaseTimes::GCParPhases(G1GCPhaseTimes::StrongOopStorageSetRoots + i);
199+
for (auto id : EnumRange<OopStorageSet::StrongId>()) {
200+
G1GCPhaseTimes::GCParPhases phase = G1GCPhaseTimes::strong_oopstorage_phase(id);
200201
G1GCParPhaseTimesTracker x(phase_times, phase, worker_id);
201-
_oop_storage_set_strong_par_state.par_state(i)->oops_do(closures->strong_oops());
202+
_oop_storage_set_strong_par_state.par_state(id)->oops_do(closures->strong_oops());
202203
}
203204
}
204205

src/hotspot/share/gc/shared/oopStorageSet.cpp

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,62 +29,64 @@
2929
#include "utilities/globalDefinitions.hpp"
3030
#include "utilities/macros.hpp"
3131

32-
// +1 for NULL singular entry.
33-
OopStorage* OopStorageSet::storages[all_count + 1] = {};
32+
OopStorage* OopStorageSet::_storages[all_count] = {};
3433

3534
OopStorage* OopStorageSet::create_strong(const char* name) {
3635
static uint registered_strong = 0;
3736
assert(registered_strong < strong_count, "More registered strong storages than slots");
3837
OopStorage* storage = new OopStorage(name);
39-
storages[strong_start + registered_strong++] = storage;
38+
_storages[strong_start + registered_strong++] = storage;
4039
return storage;
4140
}
4241

4342
OopStorage* OopStorageSet::create_weak(const char* name) {
4443
static uint registered_weak = 0;
4544
assert(registered_weak < weak_count, "More registered strong storages than slots");
4645
OopStorage* storage = new OopStorage(name);
47-
storages[weak_start + registered_weak++] = storage;
46+
_storages[weak_start + registered_weak++] = storage;
4847
return storage;
4948
}
5049

5150

5251
void OopStorageSet::fill_strong(OopStorage* to[strong_count]) {
5352
for (uint i = 0; i < OopStorageSet::strong_count; i++) {
54-
to[i] = storage(strong_start + i);
53+
to[i] = get_storage(strong_start + i);
5554
}
5655
}
5756

5857
void OopStorageSet::fill_weak(OopStorage* to[weak_count]) {
5958
for (uint i = 0; i < OopStorageSet::weak_count; i++) {
60-
to[i] = storage(weak_start + i);
59+
to[i] = get_storage(weak_start + i);
6160
}
6261
}
6362

6463
void OopStorageSet::fill_all(OopStorage* to[all_count]) {
6564
for (uint i = 0; i < OopStorageSet::all_count; i++) {
66-
to[i] = storage(all_start + i);
65+
to[i] = get_storage(all_start + i);
6766
}
6867
}
6968

70-
#ifdef ASSERT
71-
72-
void OopStorageSet::verify_initialized(uint index) {
73-
assert(storages[index] != NULL, "oopstorage_init not yet called");
69+
OopStorage* OopStorageSet::get_storage(uint index) {
70+
verify_initialized(index);
71+
return _storages[index];
7472
}
7573

76-
void OopStorageSet::Iterator::verify_nonsingular() const {
77-
assert(_category != singular, "precondition");
74+
template<typename E>
75+
OopStorage* OopStorageSet::get_storage(E id) {
76+
assert(EnumRange<E>().first() <= id, "invalid id");
77+
assert(id <= EnumRange<E>().last(), "invalid id");
78+
return get_storage(static_cast<uint>(id));
7879
}
7980

80-
void OopStorageSet::Iterator::verify_category_match(const Iterator& other) const {
81-
verify_nonsingular();
82-
assert(_category == other._category, "precondition");
83-
}
81+
template OopStorage* OopStorageSet::get_storage(StrongId);
82+
template OopStorage* OopStorageSet::get_storage(WeakId);
83+
template OopStorage* OopStorageSet::get_storage(Id);
8484

85-
void OopStorageSet::Iterator::verify_dereferenceable() const {
86-
verify_nonsingular();
87-
assert(!is_end(), "precondition");
85+
#ifdef ASSERT
86+
87+
void OopStorageSet::verify_initialized(uint index) {
88+
assert(index < ARRAY_SIZE(_storages), "invalid index");
89+
assert(_storages[index] != NULL, "oopstorage_init not yet called");
8890
}
8991

9092
#endif // ASSERT

0 commit comments

Comments
 (0)