Skip to content

Commit fa20186

Browse files
author
Kim Barrett
committed
8257676: Simplify WeakProcessorPhase
Reviewed-by: iwalulya, ayang, tschatzl
1 parent b90b7f5 commit fa20186

File tree

7 files changed

+20
-153
lines changed

7 files changed

+20
-153
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "gc/shared/oopStorageSet.hpp"
3030
#include "gc/shared/weakProcessor.inline.hpp"
3131
#include "gc/shared/oopStorageSetParState.inline.hpp"
32-
#include "gc/shared/weakProcessorPhases.hpp"
3332
#include "gc/shared/weakProcessorPhaseTimes.hpp"
3433
#include "memory/allocation.inline.hpp"
3534
#include "memory/iterator.hpp"

src/hotspot/share/gc/shared/weakProcessor.inline.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "gc/shared/oopStorage.inline.hpp"
3030
#include "gc/shared/oopStorageParState.inline.hpp"
3131
#include "gc/shared/weakProcessor.hpp"
32-
#include "gc/shared/weakProcessorPhases.hpp"
32+
#include "gc/shared/weakProcessorPhase.hpp"
3333
#include "gc/shared/weakProcessorPhaseTimes.hpp"
3434
#include "gc/shared/workgroup.hpp"
3535
#include "prims/resolvedMethodTable.hpp"
@@ -81,13 +81,12 @@ void WeakProcessor::Task::work(uint worker_id,
8181
"worker_id (%u) exceeds task's configured workers (%u)",
8282
worker_id, _nworkers);
8383

84-
typedef WeakProcessorPhases::Iterator Iterator;
85-
86-
for (Iterator it = WeakProcessorPhases::oopstorage_iterator(); !it.is_end(); ++it) {
87-
WeakProcessorPhase phase = *it;
84+
constexpr EnumRange<WeakProcessorPhase> phase_range{};
85+
for (WeakProcessorPhase phase : phase_range) {
8886
CountingClosure<IsAlive, KeepAlive> cl(is_alive, keep_alive);
8987
WeakProcessorPhaseTimeTracker pt(_phase_times, phase, worker_id);
90-
StorageState* cur_state = _storage_states.par_state(phase);
88+
int state_index = checked_cast<int>(phase_range.index(phase));
89+
StorageState* cur_state = _storage_states.par_state(state_index);
9190
cur_state->oops_do(&cl);
9291
cur_state->increment_num_dead(cl.dead());
9392
if (_phase_times != NULL) {

src/hotspot/share/gc/shared/weakProcessorPhases.cpp renamed to src/hotspot/share/gc/shared/weakProcessorPhase.hpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,14 @@
2222
*
2323
*/
2424

25-
#include "precompiled.hpp"
26-
#include "gc/shared/weakProcessorPhases.hpp"
27-
#include "utilities/debug.hpp"
28-
#include "utilities/macros.hpp"
25+
#ifndef SHARE_GC_SHARED_WEAKPROCESSORPHASE_HPP
26+
#define SHARE_GC_SHARED_WEAKPROCESSORPHASE_HPP
2927

30-
#ifdef ASSERT
28+
#include "gc/shared/oopStorageSet.hpp"
29+
#include "utilities/enumIterator.hpp"
3130

32-
void WeakProcessorPhases::Iterator::verify_nonsingular() const {
33-
assert(_limit != singular_value, "precondition");
34-
}
31+
enum class WeakProcessorPhase : uint {};
3532

36-
void WeakProcessorPhases::Iterator::verify_category_match(const Iterator& other) const {
37-
verify_nonsingular();
38-
assert(_limit == other._limit, "precondition");
39-
}
33+
ENUMERATOR_VALUE_RANGE(WeakProcessorPhase, 0, OopStorageSet::weak_count);
4034

41-
void WeakProcessorPhases::Iterator::verify_dereferenceable() const {
42-
verify_nonsingular();
43-
assert(_index < _limit, "precondition");
44-
}
45-
46-
#endif // ASSERT
35+
#endif // SHARE_GC_SHARED_WEAKPROCESSORPHASE_HPP

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include "precompiled.hpp"
2626
#include "gc/shared/oopStorage.hpp"
27-
#include "gc/shared/weakProcessorPhases.hpp"
27+
#include "gc/shared/weakProcessorPhase.hpp"
2828
#include "gc/shared/weakProcessorPhaseTimes.hpp"
2929
#include "gc/shared/workerDataArray.inline.hpp"
3030
#include "logging/log.hpp"
@@ -100,7 +100,9 @@ void WeakProcessorPhaseTimes::record_total_time_sec(double time_sec) {
100100
}
101101

102102
WorkerDataArray<double>* WeakProcessorPhaseTimes::worker_data(WeakProcessorPhase phase) const {
103-
return _worker_data[phase];
103+
size_t index = EnumRange<WeakProcessorPhase>().index(phase);
104+
assert(index < ARRAY_SIZE(_worker_data), "invalid phase");
105+
return _worker_data[index];
104106
}
105107

106108
double WeakProcessorPhaseTimes::worker_time_sec(uint worker_id, WeakProcessorPhase phase) const {
@@ -203,9 +205,8 @@ void WeakProcessorPhaseTimes::log_phase_details(WorkerDataArray<T>* data,
203205

204206
void WeakProcessorPhaseTimes::log_print_phases(uint indent) const {
205207
if (log_is_enabled(Debug, gc, phases)) {
206-
typedef WeakProcessorPhases::Iterator Iterator;
207-
for (Iterator it = WeakProcessorPhases::oopstorage_iterator(); !it.is_end(); ++it) {
208-
log_phase_summary(*it, indent);
208+
for (WeakProcessorPhase phase : EnumRange<WeakProcessorPhase>()) {
209+
log_phase_summary(phase, indent);
209210
}
210211
}
211212
}

src/hotspot/share/gc/shared/weakProcessorPhaseTimes.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#ifndef SHARE_GC_SHARED_WEAKPROCESSORPHASETIMES_HPP
2626
#define SHARE_GC_SHARED_WEAKPROCESSORPHASETIMES_HPP
2727

28-
#include "gc/shared/weakProcessorPhases.hpp"
28+
#include "gc/shared/weakProcessorPhase.hpp"
2929
#include "memory/allocation.hpp"
3030
#include "utilities/globalDefinitions.hpp"
3131
#include "utilities/ticks.hpp"
@@ -44,9 +44,7 @@ class WeakProcessorPhaseTimes {
4444
double _total_time_sec;
4545

4646
// Per-worker times and linked items.
47-
static const uint worker_data_count = WeakProcessorPhases::oopstorage_phase_count;
48-
WorkerDataArray<double>* _worker_data[worker_data_count];
49-
47+
WorkerDataArray<double>* _worker_data[EnumRange<WeakProcessorPhase>().size()];
5048
WorkerDataArray<double>* worker_data(WeakProcessorPhase phase) const;
5149

5250
void log_phase_summary(WeakProcessorPhase phase, uint indent) const;

src/hotspot/share/gc/shared/weakProcessorPhases.hpp

Lines changed: 0 additions & 118 deletions
This file was deleted.

src/hotspot/share/utilities/enumIterator.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
//
4141
// case 2:
4242
// enum has sequential values, with U start and U end (exclusive).
43-
// WeakProcessorPhases is an example because of oopstorage.
4443
// This can be mapped onto case 1 by casting start/(end-1).
4544
//
4645
// case 3:

0 commit comments

Comments
 (0)