@@ -119,6 +119,7 @@ class OSThreadSampler : public os::SuspendedThreadTask {
119
119
JfrStackFrame *frames,
120
120
u4 max_frames) : os::SuspendedThreadTask((Thread*)thread),
121
121
_success (false ),
122
+ _thread_oop(thread->threadObj ()),
122
123
_stacktrace(frames, max_frames),
123
124
_closure(closure),
124
125
_suspend_time() {}
@@ -131,6 +132,7 @@ class OSThreadSampler : public os::SuspendedThreadTask {
131
132
132
133
private:
133
134
bool _success;
135
+ oop _thread_oop;
134
136
JfrStackTrace _stacktrace;
135
137
JfrThreadSampleClosure& _closure;
136
138
JfrTicks _suspend_time;
@@ -190,7 +192,7 @@ void OSThreadSampler::protected_task(const os::SuspendedThreadTaskContext& conte
190
192
ev->set_starttime (_suspend_time);
191
193
ev->set_endtime (_suspend_time); // fake to not take an end time
192
194
ev->set_sampledThread (JFR_THREAD_ID (jth));
193
- ev->set_state (java_lang_Thread::get_thread_status (jth-> threadObj () ));
195
+ ev->set_state (java_lang_Thread::get_thread_status (_thread_oop ));
194
196
}
195
197
}
196
198
}
@@ -202,7 +204,7 @@ void OSThreadSampler::take_sample() {
202
204
class JfrNativeSamplerCallback : public os ::CrashProtectionCallback {
203
205
public:
204
206
JfrNativeSamplerCallback (JfrThreadSampleClosure& closure, JavaThread* jt, JfrStackFrame* frames, u4 max_frames) :
205
- _closure (closure), _jt(jt), _stacktrace(frames, max_frames), _success(false ) {
207
+ _closure (closure), _jt(jt), _thread_oop(jt-> threadObj ()), _stacktrace(frames, max_frames), _success(false ) {
206
208
}
207
209
virtual void call ();
208
210
bool success () { return _success; }
@@ -211,15 +213,16 @@ class JfrNativeSamplerCallback : public os::CrashProtectionCallback {
211
213
private:
212
214
JfrThreadSampleClosure& _closure;
213
215
JavaThread* _jt;
216
+ oop _thread_oop;
214
217
JfrStackTrace _stacktrace;
215
218
bool _success;
216
219
};
217
220
218
- static void write_native_event (JfrThreadSampleClosure& closure, JavaThread* jt) {
221
+ static void write_native_event (JfrThreadSampleClosure& closure, JavaThread* jt, oop thread_oop ) {
219
222
EventNativeMethodSample *ev = closure.next_event_native ();
220
223
ev->set_starttime (JfrTicks::now ());
221
224
ev->set_sampledThread (JFR_THREAD_ID (jt));
222
- ev->set_state (java_lang_Thread::get_thread_status (jt-> threadObj () ));
225
+ ev->set_state (java_lang_Thread::get_thread_status (thread_oop ));
223
226
}
224
227
225
228
void JfrNativeSamplerCallback::call () {
@@ -241,7 +244,7 @@ void JfrNativeSamplerCallback::call() {
241
244
topframe = first_java_frame;
242
245
_success = _stacktrace.record_thread (*_jt, topframe);
243
246
if (_success) {
244
- write_native_event (_closure, _jt);
247
+ write_native_event (_closure, _jt, _thread_oop );
245
248
}
246
249
}
247
250
0 commit comments