8287832: jdk/jfr/event/runtime/TestActiveSettingEvent.java failed with "Expected two batches of Active Setting events"

Reviewed-by: egahlin
This commit is contained in:
Markus Grönlund 2022-10-10 12:40:58 +00:00
parent 35d17a00ab
commit 4df4a1f8e2
4 changed files with 22 additions and 23 deletions

View File

@ -277,9 +277,7 @@ JVM_ENTRY_NO_ENV(void, jfr_set_method_sampling_period(JNIEnv* env, jobject jvm,
}
JfrEventId typed_event_id = (JfrEventId)type;
assert(EventExecutionSample::eventId == typed_event_id || EventNativeMethodSample::eventId == typed_event_id, "invariant");
if (periodMillis > 0) {
JfrEventSetting::set_enabled(typed_event_id, true); // ensure sampling event is enabled
}
JfrEventSetting::set_enabled(typed_event_id, periodMillis > 0);
if (EventExecutionSample::eventId == type) {
JfrThreadSampling::set_java_sample_period(periodMillis);
} else {

View File

@ -299,17 +299,21 @@ static const uint MAX_NR_OF_NATIVE_SAMPLES = 1;
void JfrThreadSampleClosure::commit_events(JfrSampleType type) {
if (JAVA_SAMPLE == type) {
assert(_added_java > 0 && _added_java <= MAX_NR_OF_JAVA_SAMPLES, "invariant");
if (EventExecutionSample::is_enabled()) {
for (uint i = 0; i < _added_java; ++i) {
_events[i].commit();
}
}
} else {
assert(NATIVE_SAMPLE == type, "invariant");
assert(_added_native > 0 && _added_native <= MAX_NR_OF_NATIVE_SAMPLES, "invariant");
if (EventNativeMethodSample::is_enabled()) {
for (uint i = 0; i < _added_native; ++i) {
_events_native[i].commit();
}
}
}
}
JfrThreadSampleClosure::JfrThreadSampleClosure(EventExecutionSample* events, EventNativeMethodSample* events_native) :
_events(events),

View File

@ -63,26 +63,22 @@ class JfrEvent {
private:
jlong _start_time;
jlong _end_time;
bool _started;
bool _untimed;
bool _should_commit;
bool _evaluated;
protected:
JfrEvent(EventStartTime timing=TIMED) : _start_time(0), _end_time(0),
_started(false), _untimed(timing == UNTIMED),
_untimed(timing == UNTIMED),
_should_commit(false), _evaluated(false)
#ifdef ASSERT
, _verifier()
#endif
{
if (T::is_enabled() && JfrThreadLocal::is_included(Thread::current())) {
_started = true;
if (TIMED == timing && !T::isInstant) {
if (!T::isInstant && !_untimed && is_enabled()) {
set_starttime(JfrTicks::now());
}
}
}
void commit() {
assert(!_verifier.committed(), "event already committed");
@ -146,20 +142,17 @@ class JfrEvent {
return T::hasStackTrace;
}
bool is_started() const {
return _started;
bool is_started() {
return is_instant() || _start_time != 0 || _untimed;
}
bool should_commit() {
if (!_started) {
if (!is_enabled()) {
return false;
}
if (_untimed) {
return true;
}
if (_evaluated) {
return _should_commit;
}
_should_commit = evaluate();
_evaluated = true;
return _should_commit;
@ -167,11 +160,16 @@ class JfrEvent {
private:
bool should_write() {
return _started && (_evaluated ? _should_commit : evaluate());
if (_evaluated) {
return _should_commit;
}
if (!is_enabled()) {
return false;
}
return evaluate() && JfrThreadLocal::is_included(Thread::current());
}
bool evaluate() {
assert(_started, "invariant");
if (_start_time == 0) {
set_starttime(JfrTicks::now());
} else if (_end_time == 0) {

View File

@ -749,7 +749,6 @@ jdk/jfr/startupargs/TestStartName.java 8214685 windows-
jdk/jfr/startupargs/TestStartDuration.java 8214685 windows-x64
jdk/jfr/jvm/TestWaste.java 8282427 generic-all
jdk/jfr/api/consumer/recordingstream/TestOnEvent.java 8255404 linux-x64
jdk/jfr/event/runtime/TestActiveSettingEvent.java 8287832 generic-all
jdk/jfr/api/consumer/TestRecordingFileWrite.java 8287699 linux-x64,macosx-x64
############################################################################