Skip to content

Commit be08305

Browse files
committedJan 11, 2020
JVMTI update for virtual threads
1 parent 3ea4531 commit be08305

File tree

7 files changed

+430
-134
lines changed

7 files changed

+430
-134
lines changed
 

‎src/hotspot/share/classfile/javaClasses.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -2040,11 +2040,13 @@ void java_lang_ThreadGroup::serialize_offsets(SerializeClosure* f) {
20402040
int java_lang_Fiber::static_notify_jvmti_events_offset = 0;
20412041
int java_lang_Fiber::_carrierThread_offset = 0;
20422042
int java_lang_Fiber::_continuation_offset = 0;
2043+
int java_lang_Fiber::_state_offset = 0;
20432044

20442045
#define FIBER_FIELDS_DO(macro) \
20452046
macro(static_notify_jvmti_events_offset, k, "notifyJvmtiEvents", bool_signature, true); \
20462047
macro(_carrierThread_offset, k, "carrierThread", thread_signature, false); \
2047-
macro(_continuation_offset, k, "cont", continuation_signature, false)
2048+
macro(_continuation_offset, k, "cont", continuation_signature, false); \
2049+
macro(_state_offset, k, "state", short_signature, false)
20482050

20492051
static jboolean fiber_notify_jvmti_events = JNI_FALSE;
20502052

@@ -2075,6 +2077,16 @@ oop java_lang_Fiber::continuation(oop fiber) {
20752077
return cont;
20762078
}
20772079

2080+
// Read thread status value from state field in java.lang.Fiber java class.
2081+
java_lang_Thread::ThreadStatus java_lang_Fiber::get_thread_status(oop fiber) {
2082+
// Make sure the caller is operating on behalf of the VM or is
2083+
// running VM code (state == _thread_in_vm).
2084+
assert(Threads_lock->owned_by_self() || Thread::current()->is_VM_thread() ||
2085+
JavaThread::current()->thread_state() == _thread_in_vm,
2086+
"Java Thread is not running in vm");
2087+
return (java_lang_Thread::ThreadStatus)fiber->short_field(_state_offset);
2088+
}
2089+
20782090
#if INCLUDE_CDS
20792091
void java_lang_Fiber::serialize_offsets(SerializeClosure* f) {
20802092
FIBER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);

‎src/hotspot/share/classfile/javaClasses.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ class java_lang_Fiber : AllStatic {
581581
static int static_notify_jvmti_events_offset;
582582
static int _carrierThread_offset;
583583
static int _continuation_offset;
584+
static int _state_offset;
584585
public:
585586
static void compute_offsets();
586587
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
@@ -592,6 +593,7 @@ class java_lang_Fiber : AllStatic {
592593
static bool is_instance(oop obj);
593594
static oop carrier_thread(oop fiber);
594595
static oop continuation(oop fiber);
596+
static java_lang_Thread::ThreadStatus get_thread_status(oop fiber);
595597
static void set_notify_jvmti_events(jboolean enable);
596598
static void init_static_notify_jvmti_events();
597599
};

‎src/hotspot/share/prims/jvmti.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ jvmtiEnv *jvmti;
19211921
</capabilities>
19221922
<parameters>
19231923
<param id="thread">
1924-
<jthread null="current"/>
1924+
<jthread null="current" impl="noconvert"/>
19251925
<description>
19261926
The thread to query.
19271927
</description>
@@ -1975,7 +1975,7 @@ jvmtiEnv *jvmti;
19751975
</capabilities>
19761976
<parameters>
19771977
<param id="thread">
1978-
<jthread null="current"/>
1978+
<jthread null="current" impl="noconvert"/>
19791979
<description>
19801980
The thread to query.
19811981
</description>
@@ -2011,7 +2011,7 @@ jvmtiEnv *jvmti;
20112011
</capabilities>
20122012
<parameters>
20132013
<param id="thread">
2014-
<jthread null="current"/>
2014+
<jthread null="current" impl="noconvert"/>
20152015
<description>
20162016
The thread to query.
20172017
</description>

0 commit comments

Comments
 (0)