JDK-8285739 : disable EscapeBarrier deopt for virtual threads
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 19,repo-loom
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-04-27
  • Updated: 2022-06-25
  • Resolved: 2022-05-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b24Fixed
Related Reports
Relates :  
Relates :  
Description
We need to find out how to disable escape analysis when both JVMTI and Preview are enabled.
There are several spots where EA is used.

src/hotspot/share/prims/jvmtiTagMap.cpp (Heap Walking API implementation):

// Deprecated function to iterate over all objects in the heap
void JvmtiTagMap::iterate_over_heap(jvmtiHeapObjectFilter object_filter,
                                    Klass* klass,
                                    jvmtiHeapObjectCallback heap_object_callback,
                                    const void* user_data)
{
  // EA based optimizations on tagged objects are already reverted.
  EscapeBarrier eb(object_filter == JVMTI_HEAP_OBJECT_UNTAGGED ||
                   object_filter == JVMTI_HEAP_OBJECT_EITHER,
                   JavaThread::current());
  eb.deoptimize_objects_all_threads();
  . . .

// Iterates over all objects in the heap
void JvmtiTagMap::iterate_through_heap(jint heap_filter,
                    Klass* klass,
                    const jvmtiHeapCallbacks* callbacks,
                    const void* user_data)
{
 // EA based optimizations on tagged objects are already reverted.
 EscapeBarrier eb(false, JavaThread::current()); // disable due to virtual threads
 eb.deoptimize_objects_all_threads();
 . . .

// iterate over all objects that are reachable from a set of roots
void JvmtiTagMap::iterate_over_reachable_objects(jvmtiHeapRootCallback heap_root_callback,
                         jvmtiStackReferenceCallback stack_ref_callback,
                         jvmtiObjectReferenceCallback object_ref_callback,
                         const void* user_data) {
 JavaThread* jt = JavaThread::current();
 EscapeBarrier eb(true, jt);
 . . .

void JvmtiTagMap::follow_references(jint heap_filter,
                                    Klass* klass,
                                    jobject object,
                                    const jvmtiHeapCallbacks* callbacks,
                                    const void* user_data)
{
  . . .
  // EA based optimizations that are tagged or reachable from initial_object are already reverted.
  EscapeBarrier eb(initial_object.is_null() &&

src/hotspot/share/prims/jvmtiImpl.hpp (implementation GetLocal/SetLocal):

class VM_GetOrSetLocal : public VM_BaseGetOrSetLocal {
 protected:
  JavaThread* _thread;
  EscapeBarrier _eb;
  . . .

src/hotspot/share/prims/jvmtiEnvBase.cpp (ForceEarlyReturn implementation):

jvmtiError
JvmtiEnvBase::force_early_return(jthread thread, jvalue value, TosState tos) {
  . . .
  // Eagerly reallocate scalar replaced objects.
  EscapeBarrier eb(true, current_thread, java_thread);
  . . .

src/hotspot/share/prims/jvmtiEnv.cpp (implementation of GetOwnedMonitorInfo, GetOwnedMonitorStackDepthInfo and PopFrame):

JvmtiEnv::GetOwnedMonitorInfo(jthread thread, jint* owned_monitor_count_ptr, jobject** owned_monitors_ptr) {
    . . .
    EscapeBarrier eb(true, calling_thread, java_thread);
  . . .

JvmtiEnv::GetOwnedMonitorStackDepthInfo(jthread thread, jint* monitor_info_count_ptr, jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
  . . .
    EscapeBarrier eb(true, calling_thread, java_thread);
  . . .

JvmtiEnv::PopFrame(jthread thread) {
  . . .
  // Eagerly reallocate scalar replaced objects.
  EscapeBarrier eb(true, current_thread, java_thread);
  . . .
Comments
Changeset: 940e94f1 Author: Leonid Mesnik <lmesnik@openjdk.org> Date: 2022-05-23 14:50:46 +0000 URL: https://git.openjdk.java.net/jdk/commit/940e94f194e2abab8006e67dbb82cab5f16e3a17
23-05-2022

Disabling EscapeAnalysis is not sufficient to avoid all issues fixed by JDK-8227745. JDK-8233915 is an issue that can only be fixed with EscapeBarriers, i.e. JDK-8227745.
21-05-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8589 Date: 2022-05-09 01:36:39 +0000
09-05-2022