< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
rev 56101 : 8227745: Enable Escape Analysis for better performance when debugging
Reviewed-by: ???

@@ -1656,11 +1656,11 @@
   set_callee_target(NULL);
   set_vm_result(NULL);
   set_vm_result_2(NULL);
   set_vframe_array_head(NULL);
   set_vframe_array_last(NULL);
-  set_deferred_locals(NULL);
+  reset_deferred_updates();
   set_deopt_mark(NULL);
   set_deopt_compiled_method(NULL);
   set_monitor_chunks(NULL);
   _on_thread_list = false;
   set_thread_state(_thread_new);

@@ -1830,11 +1830,11 @@
       jvmtiDeferredLocalVariableSet* dlv = deferred->at(0);
       deferred->remove_at(0);
       // individual jvmtiDeferredLocalVariableSet are CHeapObj's
       delete dlv;
     } while (deferred->length() != 0);
-    delete deferred;
+    delete deferred_updates();
   }
 
   // All Java related clean up happens in exit
   ThreadSafepointState::destroy(this);
   if (_thread_stat != NULL) delete _thread_stat;

@@ -2324,10 +2324,15 @@
   // so check for other async requests.
   if (check_asyncs) {
     check_and_handle_async_exceptions();
   }
 
+  if (is_ea_obj_deopt_suspend()) {
+    frame_anchor()->make_walkable(this);
+    wait_for_object_deoptimization();
+  }
+
   JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(this);)
 }
 
 void JavaThread::send_thread_stop(oop java_throwable)  {
   assert(Thread::current()->is_VM_thread(), "should be in the vm thread");

@@ -2517,10 +2522,37 @@
   if (state != _thread_in_native) {
     SafepointMechanism::block_if_requested(this);
   }
 }
 
+void JavaThread::wait_for_object_deoptimization() {
+  assert(!has_last_Java_frame() || frame_anchor()->walkable(), "should have walkable stack");
+  assert(this == Thread::current(), "invariant");
+  JavaThreadState state = thread_state();
+
+  do {
+    set_thread_state(_thread_blocked);
+    set_suspend_equivalent();
+    MonitorLocker ml(JvmtiObjReallocRelock_lock, Monitor::_no_safepoint_check_flag);
+    if (is_ea_obj_deopt_suspend()) {
+      ml.wait();
+    }
+    if (handle_special_suspend_equivalent_condition()) {
+      MutexUnlocker mu(JvmtiObjReallocRelock_lock, Monitor::_no_safepoint_check_flag);
+      java_suspend_self();
+    }
+    set_thread_state_fence(state);
+  } while (is_ea_obj_deopt_suspend());
+
+  // Since we are not using a regular thread-state transition helper here,
+  // we must manually emit the instruction barrier after leaving a safe state.
+  OrderAccess::cross_modify_fence();
+  if (state != _thread_in_native) {
+    SafepointMechanism::block_if_requested(this);
+  }
+}
+
 #ifdef ASSERT
 // Verify the JavaThread has not yet been published in the Threads::list, and
 // hence doesn't need protection from concurrent access at this stage.
 void JavaThread::verify_not_published() {
   // Cannot create a ThreadsListHandle here and check !tlh.includes(this)

@@ -2546,10 +2578,14 @@
     thread->java_suspend_self_with_safepoint_check();
   } else {
     SafepointMechanism::block_if_requested(thread);
   }
 
+  if (thread->is_ea_obj_deopt_suspend()) {
+    thread->wait_for_object_deoptimization();
+  }
+
   JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);)
 }
 
 // Slow path when the native==>VM/Java barriers detect a safepoint is in
 // progress or when _suspend_flags is non-zero.

@@ -3405,10 +3441,19 @@
     // a scan.
     cf->do_code_blob(_scanned_compiled_method);
   }
 }
 
+#if defined(ASSERT) && COMPILER2_OR_JVMCI
+static void deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS) {
+  Deoptimization::deoptimize_objects_alot_loop();
+}
+
+DeoptimizeObjectsALotThread::DeoptimizeObjectsALotThread()
+: JavaThread(&deopt_objs_alot_thread_entry) {
+}
+#endif // defined(ASSERT) && COMPILER2_OR_JVMCI
 
 // ======= Threads ========
 
 // The Threads class links together all active threads, and provides
 // operations over all threads. It is protected by the Threads_lock,
< prev index next >