Skip to content
Permalink
Browse files
remove continuations support from JVMTI
  • Loading branch information
sspitsyn committed Mar 11, 2021
1 parent 6f9eb04 commit 41b1ed08aac8769e756599bf66b74ca85ddebe0c
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 478 deletions.
@@ -7182,11 +7182,7 @@ RuntimeStub* generate_cont_doYield() {

__ movl(c_rarg1, (return_barrier ? 1 : 0) + (exception ? 1 : 0));
if (ContPerfTest > 112) {
if (!return_barrier && JvmtiExport::can_support_continuations()) {
__ call_VM(noreg, CAST_FROM_FN_PTR(address, Continuation::thaw), c_rarg1);
} else {
__ call_VM_leaf(CAST_FROM_FN_PTR(address, Continuation::thaw_leaf), r15_thread, c_rarg1);
}
__ call_VM_leaf(CAST_FROM_FN_PTR(address, Continuation::thaw_leaf), r15_thread, c_rarg1);
}
__ movptr(rbx, rax); // rbx is now the sp of the yielding frame

@@ -10609,14 +10609,6 @@ myInit() {
<eventlink id="VirtualThreadUnmounted"></eventlink>.
</description>
</capabilityfield>
<capabilityfield id="can_support_continuations" since="14">
<description>
Can support continuations. If this capability is enabled then
the following events can be enabled:
<eventlink id="ContinuationRun"></eventlink> and
<eventlink id="ContinuationYield"></eventlink>.
</description>
</capabilityfield>
</capabilitiestypedef>

<function id="GetPotentialCapabilities" jkernel="yes" phase="onload" num="140">
@@ -13064,77 +13056,6 @@ myInit() {
</parameters>
</event>

<event label="Continuation Run"
id="ContinuationRun" const="JVMTI_EVENT_CONTINUATION_RUN" filtered="thread" num="91" phase="start" since="14">
<description>
Continuation run events are generated before the continuation is continued execution on current thread.
<p/>
The event is sent on the <paramlink id="thread"></paramlink> the continuation is about to leave.
</description>
<origin>new</origin>
<capabilities>
<required id="can_support_continuations">Can support continuations</required>
</capabilities>
<parameters>
<param id="jni_env">
<outptr>
<struct>JNIEnv</struct>
</outptr>
<description>
The JNI environment of the event (current) thread.
</description>
</param>
<param id="thread">
<jthread/>
<description>
Thread the continuation is executed on.
</description>
</param>
<param id="continuation_frame_count">
<jint min="1"/>
<description>
Number of frames the continuation is executing.
</description>
</param>
</parameters>
</event>

<event label="Continuation Yield"
id="ContinuationYield" const="JVMTI_EVENT_CONTINUATION_YIELD" filtered="thread" num="92" phase="start" since="14">
<description>
Continuation yield events are generated before the continuation actually yields on current thread.
<p/>
The event is sent on the <paramlink id="thread"></paramlink> the continuation is about to leave.
</description>
<origin>new</origin>
<capabilities>
<required id="can_support_continuations">Can support continuations</required>
</capabilities>
<parameters>
<param id="jni_env">
<outptr>
<struct>JNIEnv</struct>
</outptr>
<description>
The JNI environment of the event (current) thread.
</description>
</param>
<param id="thread">
<jthread/>
<description>
Thread the continuation is executed on.
</description>
</param>
<param id="continuation_frame_count">
<jint min="1"/>
<description>
Number of frames the continuation is executing.
</description>
</param>
</parameters>
</event>


<event label="Class Load"
id="ClassLoad" const="JVMTI_EVENT_CLASS_LOAD" filtered="thread" phase="start" num="55">
<description>
@@ -92,21 +92,18 @@ static const jlong VTHREAD_SCHEDULED_BIT = (((jlong)1) << (JVMTI_EVENT_VIRTUAL_
static const jlong VTHREAD_TERMINATED_BIT = (((jlong)1) << (JVMTI_EVENT_VIRTUAL_THREAD_TERMINATED - TOTAL_MIN_EVENT_TYPE_VAL));
static const jlong VTHREAD_MOUNTED_BIT = (((jlong)1) << (JVMTI_EVENT_VIRTUAL_THREAD_MOUNTED - TOTAL_MIN_EVENT_TYPE_VAL));
static const jlong VTHREAD_UNMOUNTED_BIT = (((jlong)1) << (JVMTI_EVENT_VIRTUAL_THREAD_UNMOUNTED - TOTAL_MIN_EVENT_TYPE_VAL));
static const jlong CONTINUATION_RUN_BIT = (((jlong)1) << (JVMTI_EVENT_CONTINUATION_RUN - TOTAL_MIN_EVENT_TYPE_VAL));
static const jlong CONTINUATION_YIELD_BIT = (((jlong)1) << (JVMTI_EVENT_CONTINUATION_YIELD - TOTAL_MIN_EVENT_TYPE_VAL));

// bits for extension events
static const jlong CLASS_UNLOAD_BIT = (((jlong)1) << (EXT_EVENT_CLASS_UNLOAD - TOTAL_MIN_EVENT_TYPE_VAL));


static const jlong VTHREAD_BITS = VTHREAD_SCHEDULED_BIT | VTHREAD_TERMINATED_BIT | VTHREAD_MOUNTED_BIT | VTHREAD_UNMOUNTED_BIT;
static const jlong CONTINUATION_BITS = CONTINUATION_RUN_BIT | CONTINUATION_YIELD_BIT;
static const jlong MONITOR_BITS = MONITOR_CONTENDED_ENTER_BIT | MONITOR_CONTENDED_ENTERED_BIT |
MONITOR_WAIT_BIT | MONITOR_WAITED_BIT;
static const jlong EXCEPTION_BITS = EXCEPTION_THROW_BIT | EXCEPTION_CATCH_BIT;
static const jlong INTERP_EVENT_BITS = SINGLE_STEP_BIT | METHOD_ENTRY_BIT | METHOD_EXIT_BIT |
FRAME_POP_BIT | FIELD_ACCESS_BIT | FIELD_MODIFICATION_BIT;
static const jlong THREAD_FILTERED_EVENT_BITS = INTERP_EVENT_BITS | EXCEPTION_BITS | MONITOR_BITS | VTHREAD_BITS | CONTINUATION_BITS |
static const jlong THREAD_FILTERED_EVENT_BITS = INTERP_EVENT_BITS | EXCEPTION_BITS | MONITOR_BITS | VTHREAD_BITS |
BREAKPOINT_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT | THREAD_END_BIT |
SAMPLED_OBJECT_ALLOC_BIT;
static const jlong NEED_THREAD_LIFE_EVENTS = THREAD_FILTERED_EVENT_BITS | THREAD_START_BIT;
@@ -682,8 +679,6 @@ JvmtiEventControllerPrivate::recompute_enabled() {
JvmtiExport::set_should_post_vthread_terminated((any_env_thread_enabled & VTHREAD_TERMINATED_BIT) != 0);
JvmtiExport::set_should_post_vthread_mounted((any_env_thread_enabled & VTHREAD_MOUNTED_BIT) != 0);
JvmtiExport::set_should_post_vthread_unmounted((any_env_thread_enabled & VTHREAD_UNMOUNTED_BIT) != 0);
JvmtiExport::set_should_post_continuation_run((any_env_thread_enabled & CONTINUATION_RUN_BIT) != 0);
JvmtiExport::set_should_post_continuation_yield((any_env_thread_enabled & CONTINUATION_YIELD_BIT) != 0);

// need this if we want thread events or we need them to init data
JvmtiExport::set_should_post_thread_life((any_env_thread_enabled & NEED_THREAD_LIFE_EVENTS) != 0);
@@ -1256,7 +1256,6 @@ bool JvmtiExport::_can_post_frame_pop = fals
bool JvmtiExport::_can_pop_frame = false;
bool JvmtiExport::_can_force_early_return = false;
bool JvmtiExport::_can_support_virtual_threads = false;
bool JvmtiExport::_can_support_continuations = false;
bool JvmtiExport::_can_get_owned_monitor_info = false;

bool JvmtiExport::_early_vmstart_recorded = false;
@@ -1285,8 +1284,6 @@ bool JvmtiExport::_should_post_resource_exhausted = fals
bool JvmtiExport::_should_post_vm_object_alloc = false;
bool JvmtiExport::_should_post_sampled_object_alloc = false;
bool JvmtiExport::_should_post_on_exceptions = false;
bool JvmtiExport::_should_post_continuation_run = false;
bool JvmtiExport::_should_post_continuation_yield = false;
bool JvmtiExport::_should_post_vthread_scheduled = false;
bool JvmtiExport::_should_post_vthread_terminated = false;
bool JvmtiExport::_should_post_vthread_mounted = false;
@@ -1661,11 +1658,10 @@ void JvmtiExport::post_vthread_unmounted(jobject vthread) {
}
}

void JvmtiExport::post_continuation_run(JavaThread* thread, jint continuation_frame_count) {
void JvmtiExport::continuation_yield_cleanup(JavaThread* thread, jint continuation_frame_count) {
if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
return;
}
EVT_TRIG_TRACE(JVMTI_EVENT_CONTINUATION_RUN, ("Trg Continuation Run event triggered"));

assert (thread == JavaThread::current(), "must be");
JvmtiThreadState *state = thread->jvmti_thread_state();
@@ -1674,62 +1670,6 @@ void JvmtiExport::post_continuation_run(JavaThread* thread, jint continuation_fr
}
state->invalidate_cur_stack_depth();

if (state->is_enabled(JVMTI_EVENT_CONTINUATION_RUN)) {
JvmtiEnvThreadStateIterator it(state);

for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
JvmtiEnv *env = ets->get_env();
if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
continue;
}
if (ets->is_enabled(JVMTI_EVENT_CONTINUATION_RUN)) {
EVT_TRACE(JVMTI_EVENT_CONTINUATION_RUN, ("Evt Continuation Run event sent"));

JvmtiVirtualThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
jvmtiEventContinuationRun callback = env->callbacks()->ContinuationRun;
if (callback != NULL) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), continuation_frame_count);
}
}
}
}
}

void JvmtiExport::post_continuation_yield(JavaThread* thread, jint continuation_frame_count) {
if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
return;
}
EVT_TRIG_TRACE(JVMTI_EVENT_CONTINUATION_YIELD, ("Trg Continuation Yield event triggered"));

assert (thread == JavaThread::current(), "must be");
JvmtiThreadState *state = thread->jvmti_thread_state();
if (state == NULL) {
return;
}
state->invalidate_cur_stack_depth();

if (state->is_enabled(JVMTI_EVENT_CONTINUATION_YIELD)) {
JvmtiEnvThreadStateIterator it(state);

for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
JvmtiEnv *env = ets->get_env();
if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
continue;
}
if (ets->is_enabled(JVMTI_EVENT_CONTINUATION_YIELD)) {
EVT_TRACE(JVMTI_EVENT_CONTINUATION_YIELD, ("Evt Continuation Yield event sent"));

JvmtiVirtualThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
jvmtiEventContinuationYield callback = env->callbacks()->ContinuationYield;
if (callback != NULL) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), continuation_frame_count);
}
}
}
}

// Clear frame_pop requests in frames popped by yield
if (can_post_frame_pop()) {
JvmtiEnvThreadStateIterator it(state);
@@ -95,7 +95,6 @@ class JvmtiExport : public AllStatic {
JVMTI_SUPPORT_FLAG(can_pop_frame)
JVMTI_SUPPORT_FLAG(can_force_early_return)
JVMTI_SUPPORT_FLAG(can_support_virtual_threads)
JVMTI_SUPPORT_FLAG(can_support_continuations)

JVMTI_SUPPORT_FLAG(early_vmstart_recorded)
JVMTI_SUPPORT_FLAG(can_get_owned_monitor_info) // includes can_get_owned_monitor_stack_depth_info
@@ -133,9 +132,6 @@ class JvmtiExport : public AllStatic {
JVMTI_SUPPORT_FLAG(should_post_vm_object_alloc)
JVMTI_SUPPORT_FLAG(should_post_sampled_object_alloc)

JVMTI_SUPPORT_FLAG(should_post_continuation_run)
JVMTI_SUPPORT_FLAG(should_post_continuation_yield)

JVMTI_SUPPORT_FLAG(should_post_vthread_scheduled)
JVMTI_SUPPORT_FLAG(should_post_vthread_terminated)
JVMTI_SUPPORT_FLAG(should_post_vthread_mounted)
@@ -350,9 +346,8 @@ class JvmtiExport : public AllStatic {
static void post_vthread_terminated (jthread vthread) NOT_JVMTI_RETURN;
static void post_vthread_mounted (jthread vthread) NOT_JVMTI_RETURN;
static void post_vthread_unmounted (jthread vthread) NOT_JVMTI_RETURN;

static void post_continuation_run (JavaThread* thread, jint continuation_frame_count) NOT_JVMTI_RETURN;
static void post_continuation_yield (JavaThread* thread, jint continuation_frame_count) NOT_JVMTI_RETURN;

static void continuation_yield_cleanup (JavaThread* thread, jint continuation_frame_count) NOT_JVMTI_RETURN;

// Support for java.lang.instrument agent loading.
static bool _should_post_class_file_load_hook;
@@ -131,7 +131,6 @@ jvmtiCapabilities JvmtiManageCapabilities::init_onload_capabilities() {
jc.can_generate_early_vmstart = 1;
jc.can_generate_early_class_hook_events = 1;
jc.can_support_virtual_threads = 1;
jc.can_support_continuations = 1;
return jc;
}

@@ -376,7 +375,6 @@ void JvmtiManageCapabilities::update() {
JvmtiExport::set_can_pop_frame(avail.can_pop_frame);
JvmtiExport::set_can_force_early_return(avail.can_force_early_return);
JvmtiExport::set_can_support_virtual_threads(avail.can_support_virtual_threads);
JvmtiExport::set_can_support_continuations(avail.can_support_continuations);
JvmtiExport::set_should_clean_up_heap_objects(avail.can_generate_breakpoint_events);
JvmtiExport::set_can_get_owned_monitor_info(avail.can_get_owned_monitor_info ||
avail.can_get_owned_monitor_stack_depth_info);
@@ -472,8 +470,6 @@ void JvmtiManageCapabilities:: print(const jvmtiCapabilities* cap) {
log_trace(jvmti)("can_generate_early_class_hook_events");
if (cap->can_support_virtual_threads)
log_trace(jvmti)("can_support_virtual_threads");
if (cap->can_support_continuations)
log_trace(jvmti)("can_support_continuations");
}

#endif

0 comments on commit 41b1ed0

Please sign in to comment.