Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit ba721f5

Browse files
coleenpKim Barrett
andcommitted
8212879: Make JVMTI TagMap table concurrent
Co-authored-by: Kim Barrett <kbarrett@openjdk.org> Co-authored-by: Coleen Phillimore <coleenp@openjdk.org> Reviewed-by: stefank, ihse, zgu, eosterlund, sspitsyn, kbarrett
1 parent 3a4b90f commit ba721f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+899
-1122
lines changed

make/hotspot/lib/JvmFeatures.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ifneq ($(call check-jvm-feature, jvmti), true)
8484
jvmtiImpl.cpp jvmtiManageCapabilities.cpp jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp \
8585
jvmtiCodeBlobEvents.cpp jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp jvmtiEnvThreadState.cpp \
8686
jvmtiTagMap.cpp jvmtiEventController.cpp evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \
87-
jvmtiClassFileReconstituter.cpp
87+
jvmtiClassFileReconstituter.cpp jvmtiTagMapTable.cpp
8888
endif
8989

9090
ifneq ($(call check-jvm-feature, jvmci), true)

src/hotspot/share/classfile/dictionary.cpp

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,6 @@ void Dictionary::free_entry(DictionaryEntry* entry) {
9696
}
9797

9898
const int _resize_load_trigger = 5; // load factor that will trigger the resize
99-
const double _resize_factor = 2.0; // by how much we will resize using current number of entries
100-
const int _resize_max_size = 40423; // the max dictionary size allowed
101-
const int _primelist[] = {107, 1009, 2017, 4049, 5051, 10103, 20201, _resize_max_size};
102-
const int _prime_array_size = sizeof(_primelist)/sizeof(int);
103-
104-
// Calculate next "good" dictionary size based on requested count
105-
static int calculate_dictionary_size(int requested) {
106-
int newsize = _primelist[0];
107-
int index = 0;
108-
for (newsize = _primelist[index]; index < (_prime_array_size - 1);
109-
newsize = _primelist[++index]) {
110-
if (requested <= newsize) {
111-
break;
112-
}
113-
}
114-
return newsize;
115-
}
11699

117100
bool Dictionary::does_any_dictionary_needs_resizing() {
118101
return Dictionary::_some_dictionary_needs_resizing;
@@ -128,15 +111,14 @@ void Dictionary::check_if_needs_resize() {
128111
}
129112

130113
bool Dictionary::resize_if_needed() {
114+
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
131115
int desired_size = 0;
132116
if (_needs_resizing == true) {
133-
desired_size = calculate_dictionary_size((int)(_resize_factor*number_of_entries()));
134-
if (desired_size >= _resize_max_size) {
135-
desired_size = _resize_max_size;
136-
// We have reached the limit, turn resizing off
137-
_resizable = false;
138-
}
139-
if ((desired_size != 0) && (desired_size != table_size())) {
117+
desired_size = calculate_resize(false);
118+
assert(desired_size != 0, "bug in calculate_resize");
119+
if (desired_size == table_size()) {
120+
_resizable = false; // hit max
121+
} else {
140122
if (!resize(desired_size)) {
141123
// Something went wrong, turn resizing off
142124
_resizable = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class OopStorageSet : public AllStatic {
3838
public:
3939
// Must be updated when new OopStorages are introduced
4040
static const uint strong_count = 4 JVMTI_ONLY(+ 1);
41-
static const uint weak_count = 5 JFR_ONLY(+ 1);
41+
static const uint weak_count = 5 JVMTI_ONLY(+ 1) JFR_ONLY(+ 1);
4242
static const uint all_count = strong_count + weak_count;
4343

4444
private:

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

Lines changed: 23 additions & 12 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, 2020, 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
@@ -37,16 +37,30 @@
3737
#include "runtime/globals.hpp"
3838
#include "utilities/macros.hpp"
3939

40-
void WeakProcessor::do_serial_parts(BoolObjectClosure* is_alive,
41-
OopClosure* keep_alive) {
42-
WeakProcessorPhases::Iterator it = WeakProcessorPhases::serial_iterator();
43-
for ( ; !it.is_end(); ++it) {
44-
WeakProcessorPhases::processor(*it)(is_alive, keep_alive);
45-
}
40+
#if INCLUDE_JVMTI
41+
#include "prims/jvmtiTagMap.hpp"
42+
#endif // INCLUDE_JVMTI
43+
44+
void notify_jvmti_tagmaps() {
45+
#if INCLUDE_JVMTI
46+
// Notify JVMTI tagmaps that a STW weak reference processing might be
47+
// clearing entries, so the tagmaps need cleaning. Doing this here allows
48+
// the tagmap's oopstorage notification handler to not care whether it's
49+
// invoked by STW or concurrent reference processing.
50+
JvmtiTagMap::set_needs_cleaning();
51+
52+
// Notify JVMTI tagmaps that a STW collection may have moved objects, so
53+
// the tagmaps need rehashing. This isn't the right place for this, but
54+
// is convenient because all the STW collectors use WeakProcessor. One
55+
// problem is that the end of a G1 concurrent collection also comes here,
56+
// possibly triggering unnecessary rehashes.
57+
JvmtiTagMap::set_needs_rehashing();
58+
#endif // INCLUDE_JVMTI
4659
}
4760

4861
void WeakProcessor::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive) {
49-
do_serial_parts(is_alive, keep_alive);
62+
63+
notify_jvmti_tagmaps();
5064

5165
OopStorageSet::Iterator it = OopStorageSet::weak_iterator();
5266
for ( ; !it.is_end(); ++it) {
@@ -61,8 +75,6 @@ void WeakProcessor::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_a
6175
}
6276

6377
void WeakProcessor::oops_do(OopClosure* closure) {
64-
AlwaysTrueClosure always_true;
65-
do_serial_parts(&always_true, closure);
6678

6779
OopStorageSet::Iterator it = OopStorageSet::weak_iterator();
6880
for ( ; !it.is_end(); ++it) {
@@ -106,12 +118,12 @@ void WeakProcessor::Task::initialize() {
106118
if (_phase_times) {
107119
_phase_times->set_active_workers(_nworkers);
108120
}
121+
notify_jvmti_tagmaps();
109122
}
110123

111124
WeakProcessor::Task::Task(uint nworkers) :
112125
_phase_times(NULL),
113126
_nworkers(nworkers),
114-
_serial_phases_done(WeakProcessorPhases::serial_phase_count),
115127
_storage_states()
116128
{
117129
initialize();
@@ -120,7 +132,6 @@ WeakProcessor::Task::Task(uint nworkers) :
120132
WeakProcessor::Task::Task(WeakProcessorPhaseTimes* phase_times, uint nworkers) :
121133
_phase_times(phase_times),
122134
_nworkers(nworkers),
123-
_serial_phases_done(WeakProcessorPhases::serial_phase_count),
124135
_storage_states()
125136
{
126137
initialize();

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

Lines changed: 1 addition & 4 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, 2020, 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
@@ -72,16 +72,13 @@ class WeakProcessor : AllStatic {
7272

7373
private:
7474
class GangTask;
75-
76-
static void do_serial_parts(BoolObjectClosure* is_alive, OopClosure* keep_alive);
7775
};
7876

7977
class WeakProcessor::Task {
8078
typedef OopStorage::ParState<false, false> StorageState;
8179

8280
WeakProcessorPhaseTimes* _phase_times;
8381
uint _nworkers;
84-
SubTasksDone _serial_phases_done;
8582
OopStorageSetWeakParState<false, false> _storage_states;
8683

8784
void initialize();

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,33 +96,17 @@ void WeakProcessor::Task::work(uint worker_id,
9696

9797
typedef WeakProcessorPhases::Iterator Iterator;
9898

99-
for (Iterator it = WeakProcessorPhases::serial_iterator(); !it.is_end(); ++it) {
100-
WeakProcessorPhase phase = *it;
101-
CountingIsAliveClosure<IsAlive> cl(is_alive);
102-
uint serial_index = WeakProcessorPhases::serial_index(phase);
103-
if (_serial_phases_done.try_claim_task(serial_index)) {
104-
WeakProcessorPhaseTimeTracker pt(_phase_times, phase);
105-
WeakProcessorPhases::processor(phase)(&cl, keep_alive);
106-
if (_phase_times != NULL) {
107-
_phase_times->record_phase_items(phase, cl.num_dead(), cl.num_total());
108-
}
109-
}
110-
}
111-
11299
for (Iterator it = WeakProcessorPhases::oopstorage_iterator(); !it.is_end(); ++it) {
113100
WeakProcessorPhase phase = *it;
114101
CountingSkippedIsAliveClosure<IsAlive, KeepAlive> cl(is_alive, keep_alive);
115102
WeakProcessorPhaseTimeTracker pt(_phase_times, phase, worker_id);
116-
uint oopstorage_index = WeakProcessorPhases::oopstorage_index(phase);
117-
StorageState* cur_state = _storage_states.par_state(oopstorage_index);
103+
StorageState* cur_state = _storage_states.par_state(phase);
118104
cur_state->oops_do(&cl);
119105
cur_state->increment_num_dead(cl.num_skipped() + cl.num_dead());
120106
if (_phase_times != NULL) {
121107
_phase_times->record_worker_items(worker_id, phase, cl.num_dead(), cl.num_total());
122108
}
123109
}
124-
125-
_serial_phases_done.all_tasks_completed(_nworkers);
126110
}
127111

128112
class WeakProcessor::GangTask : public AbstractGangTask {

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

Lines changed: 3 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2020, 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
@@ -33,48 +33,12 @@
3333
#include "utilities/globalDefinitions.hpp"
3434
#include "utilities/ticks.hpp"
3535

36-
static uint serial_phase_index(WeakProcessorPhase phase) {
37-
return WeakProcessorPhases::serial_index(phase);
38-
}
39-
40-
static bool is_serial_phase(WeakProcessorPhase phase) {
41-
return WeakProcessorPhases::is_serial(phase);
42-
}
43-
44-
static void assert_serial_phase(WeakProcessorPhase phase) {
45-
assert(is_serial_phase(phase),
46-
"Not a serial phase %u", static_cast<uint>(phase));
47-
}
48-
49-
static void assert_oopstorage_phase(WeakProcessorPhase phase) {
50-
assert(WeakProcessorPhases::is_oopstorage(phase),
51-
"Not an oopstorage phase %u", static_cast<uint>(phase));
52-
}
53-
5436
const double uninitialized_time = -1.0;
5537

5638
#ifdef ASSERT
5739
static bool is_initialized_time(double t) { return t >= 0.0; }
58-
static bool is_initialized_items(size_t i) { return i != 0; }
5940
#endif // ASSERT
6041

61-
static void reset_times(double* times, size_t ntimes) {
62-
for (size_t i = 0; i < ntimes; ++i) {
63-
times[i] = uninitialized_time;
64-
}
65-
}
66-
67-
static void reset_items(size_t* items, size_t nitems) {
68-
for (size_t i = 0; i < nitems; ++i) {
69-
items[i] = 0;
70-
}
71-
}
72-
73-
void WeakProcessorPhaseTimes::reset_phase_data() {
74-
reset_times(_phase_times_sec, ARRAY_SIZE(_phase_times_sec));
75-
reset_items(_phase_dead_items, ARRAY_SIZE(_phase_dead_items));
76-
reset_items(_phase_total_items, ARRAY_SIZE(_phase_total_items));
77-
}
7842

7943
WeakProcessorPhaseTimes::WeakProcessorPhaseTimes(uint max_threads) :
8044
_max_threads(max_threads),
@@ -84,8 +48,6 @@ WeakProcessorPhaseTimes::WeakProcessorPhaseTimes(uint max_threads) :
8448
{
8549
assert(_max_threads > 0, "max_threads must not be zero");
8650

87-
reset_phase_data();
88-
8951
WorkerDataArray<double>** wpt = _worker_data;
9052
OopStorageSet::Iterator it = OopStorageSet::weak_iterator();
9153
for ( ; !it.is_end(); ++it) {
@@ -122,7 +84,6 @@ void WeakProcessorPhaseTimes::set_active_workers(uint n) {
12284
void WeakProcessorPhaseTimes::reset() {
12385
_active_workers = 0;
12486
_total_time_sec = uninitialized_time;
125-
reset_phase_data();
12687
for (size_t i = 0; i < ARRAY_SIZE(_worker_data); ++i) {
12788
_worker_data[i]->reset();
12889
}
@@ -138,34 +99,8 @@ void WeakProcessorPhaseTimes::record_total_time_sec(double time_sec) {
13899
_total_time_sec = time_sec;
139100
}
140101

141-
double WeakProcessorPhaseTimes::phase_time_sec(WeakProcessorPhase phase) const {
142-
assert_serial_phase(phase);
143-
assert(is_initialized_time(_phase_times_sec[serial_phase_index(phase)]),
144-
"phase time not set %u", serial_phase_index(phase));
145-
return _phase_times_sec[serial_phase_index(phase)];
146-
}
147-
148-
void WeakProcessorPhaseTimes::record_phase_time_sec(WeakProcessorPhase phase, double time_sec) {
149-
assert_serial_phase(phase);
150-
assert(!is_initialized_time(_phase_times_sec[serial_phase_index(phase)]),
151-
"Already set time for phase %u", serial_phase_index(phase));
152-
_phase_times_sec[serial_phase_index(phase)] = time_sec;
153-
}
154-
155-
void WeakProcessorPhaseTimes::record_phase_items(WeakProcessorPhase phase, size_t num_dead, size_t num_total) {
156-
assert_serial_phase(phase);
157-
uint p = serial_phase_index(phase);
158-
assert(!is_initialized_items(_phase_dead_items[p]),
159-
"Already set dead items for phase %u", p);
160-
assert(!is_initialized_items(_phase_total_items[p]),
161-
"Already set total items for phase %u", p);
162-
_phase_dead_items[p] = num_dead;
163-
_phase_total_items[p] = num_total;
164-
}
165-
166102
WorkerDataArray<double>* WeakProcessorPhaseTimes::worker_data(WeakProcessorPhase phase) const {
167-
assert_oopstorage_phase(phase);
168-
return _worker_data[WeakProcessorPhases::oopstorage_index(phase)];
103+
return _worker_data[phase];
169104
}
170105

171106
double WeakProcessorPhaseTimes::worker_time_sec(uint worker_id, WeakProcessorPhase phase) const {
@@ -213,29 +148,15 @@ WeakProcessorPhaseTimeTracker::WeakProcessorPhaseTimeTracker(WeakProcessorPhaseT
213148
_worker_id(worker_id),
214149
_start_time(Ticks::now())
215150
{
216-
assert_oopstorage_phase(_phase);
217151
assert(_times == NULL || worker_id < _times->active_workers(),
218152
"Invalid worker_id %u", worker_id);
219153
}
220154

221-
WeakProcessorPhaseTimeTracker::WeakProcessorPhaseTimeTracker(WeakProcessorPhaseTimes* times,
222-
WeakProcessorPhase phase) :
223-
_times(times),
224-
_phase(phase),
225-
_worker_id(0),
226-
_start_time(Ticks::now())
227-
{
228-
assert_serial_phase(phase);
229-
}
230155

231156
WeakProcessorPhaseTimeTracker::~WeakProcessorPhaseTimeTracker() {
232157
if (_times != NULL) {
233158
double time_sec = elapsed_time_sec(_start_time, Ticks::now());
234-
if (is_serial_phase(_phase)) {
235-
_times->record_phase_time_sec(_phase, time_sec);
236-
} else {
237-
_times->record_worker_time_sec(_worker_id, _phase, time_sec);
238-
}
159+
_times->record_worker_time_sec(_worker_id, _phase, time_sec);
239160
}
240161
}
241162

@@ -251,25 +172,6 @@ static const char* indent_str(size_t i) {
251172

252173
#define TIME_FORMAT "%.1lfms"
253174

254-
void WeakProcessorPhaseTimes::log_st_phase(WeakProcessorPhase phase,
255-
uint indent) const {
256-
assert_serial_phase(phase);
257-
log_debug(gc, phases)("%s%s: " TIME_FORMAT,
258-
indent_str(indent),
259-
WeakProcessorPhases::description(phase),
260-
phase_time_sec(phase) * MILLIUNITS);
261-
262-
log_debug(gc, phases)("%s%s: " SIZE_FORMAT,
263-
indent_str(indent + 1),
264-
"Dead",
265-
_phase_dead_items[serial_phase_index(phase)]);
266-
267-
log_debug(gc, phases)("%s%s: " SIZE_FORMAT,
268-
indent_str(indent + 1),
269-
"Total",
270-
_phase_total_items[serial_phase_index(phase)]);
271-
}
272-
273175
void WeakProcessorPhaseTimes::log_mt_phase_summary(WeakProcessorPhase phase,
274176
uint indent) const {
275177
LogTarget(Debug, gc, phases) lt;
@@ -302,9 +204,6 @@ void WeakProcessorPhaseTimes::log_mt_phase_details(WorkerDataArray<T>* data,
302204
void WeakProcessorPhaseTimes::log_print_phases(uint indent) const {
303205
if (log_is_enabled(Debug, gc, phases)) {
304206
typedef WeakProcessorPhases::Iterator Iterator;
305-
for (Iterator it = WeakProcessorPhases::serial_iterator(); !it.is_end(); ++it) {
306-
log_st_phase(*it, indent);
307-
}
308207
for (Iterator it = WeakProcessorPhases::oopstorage_iterator(); !it.is_end(); ++it) {
309208
log_mt_phase_summary(*it, indent);
310209
}

0 commit comments

Comments
 (0)