8315364: Assert thread state invariant for JFR stack trace capture

Reviewed-by: egahlin
This commit is contained in:
Markus Grönlund 2023-11-02 19:34:51 +00:00
parent 3b65b8797a
commit ffaecd4aa2
2 changed files with 10 additions and 8 deletions
src/hotspot/share/jfr/recorder

@ -114,14 +114,6 @@ class JfrEvent {
return JfrEventSetting::has_stacktrace(T::eventId);
}
static bool is_large() {
return JfrEventSetting::is_large(T::eventId);
}
static void set_large() {
JfrEventSetting::set_large(T::eventId);
}
static JfrEventId id() {
return T::eventId;
}
@ -248,6 +240,14 @@ class JfrEvent {
return writer.end_event_write(large_size) > 0;
}
static bool is_large() {
return JfrEventSetting::is_large(T::eventId);
}
static void set_large() {
JfrEventSetting::set_large(T::eventId);
}
#ifdef ASSERT
private:
// Verification of fields.

@ -234,6 +234,7 @@ bool JfrStackTrace::record_async(JavaThread* jt, const frame& frame) {
assert(jt != nullptr, "invariant");
assert(!_lineno, "invariant");
Thread* current_thread = Thread::current();
assert(current_thread->is_JfrSampler_thread(), "invariant");
assert(jt != current_thread, "invariant");
// Explicitly monitor the available space of the thread-local buffer used for enqueuing klasses as part of tagging methods.
// We do this because if space becomes sparse, we cannot rely on the implicit allocation of a new buffer as part of the
@ -286,6 +287,7 @@ bool JfrStackTrace::record_async(JavaThread* jt, const frame& frame) {
bool JfrStackTrace::record(JavaThread* jt, const frame& frame, int skip) {
assert(jt != nullptr, "invariant");
assert(jt == Thread::current(), "invariant");
assert(jt->thread_state() != _thread_in_native, "invariant");
assert(!_lineno, "invariant");
// Must use ResetNoHandleMark here to bypass if any NoHandleMark exist on stack.
// This is because RegisterMap uses Handles to support continuations.