8225788: Dead code in thread and safepoint
authorrehn
Thu, 15 Aug 2019 09:06:42 +0200
changeset 57758 91a758925be7
parent 57757 902cef494e66
child 57759 22fa46d5dc2e
8225788: Dead code in thread and safepoint Reviewed-by: dholmes, dcubed, coleenp
src/hotspot/share/compiler/compileBroker.cpp
src/hotspot/share/runtime/safepoint.cpp
src/hotspot/share/runtime/safepoint.hpp
src/hotspot/share/runtime/thread.cpp
src/hotspot/share/runtime/thread.hpp
src/hotspot/share/runtime/vframe_hp.cpp
src/hotspot/share/runtime/vmOperations.cpp
src/hotspot/share/runtime/vmOperations.hpp
src/hotspot/share/runtime/vmThread.cpp
--- a/src/hotspot/share/compiler/compileBroker.cpp	Thu Aug 15 14:00:36 2019 +0800
+++ b/src/hotspot/share/compiler/compileBroker.cpp	Thu Aug 15 09:06:42 2019 +0200
@@ -1546,7 +1546,6 @@
   assert(task->is_blocking(), "can only wait on blocking task");
 
   JavaThread* thread = JavaThread::current();
-  thread->set_blocked_on_compilation(true);
 
   methodHandle method(thread, task->method());
   bool free_task;
@@ -1564,7 +1563,6 @@
     }
   }
 
-  thread->set_blocked_on_compilation(false);
   if (free_task) {
     if (is_compilation_disabled_forever()) {
       CompileTask::free(task);
--- a/src/hotspot/share/runtime/safepoint.cpp	Thu Aug 15 14:00:36 2019 +0800
+++ b/src/hotspot/share/runtime/safepoint.cpp	Thu Aug 15 09:06:42 2019 +0200
@@ -952,8 +952,7 @@
 
 ThreadSafepointState::ThreadSafepointState(JavaThread *thread)
   : _at_poll_safepoint(false), _thread(thread), _safepoint_safe(false),
-    _safepoint_id(SafepointSynchronize::InactiveSafepointCounter),
-    _orig_thread_state(_thread_uninitialized), _next(NULL) {
+    _safepoint_id(SafepointSynchronize::InactiveSafepointCounter), _next(NULL) {
 }
 
 void ThreadSafepointState::create(JavaThread *thread) {
@@ -990,9 +989,6 @@
     return;
   }
 
-  // Save the state at the start of safepoint processing.
-  _orig_thread_state = stable_state;
-
   // Check for a thread that is suspended. Note that thread resume tries
   // to grab the Threads_lock which we own here, so a thread cannot be
   // resumed during safepoint synchronization.
@@ -1060,8 +1056,6 @@
   _thread->print_thread_state_on(st);
 }
 
-void ThreadSafepointState::print() const { print_on(tty); }
-
 // ---------------------------------------------------------------------------------------------------------------------
 
 // Block the thread at poll or poll return for safepoint/handshake.
--- a/src/hotspot/share/runtime/safepoint.hpp	Thu Aug 15 14:00:36 2019 +0800
+++ b/src/hotspot/share/runtime/safepoint.hpp	Thu Aug 15 09:06:42 2019 +0200
@@ -112,14 +112,6 @@
   static long         _end_of_last_safepoint;     // Time of last safepoint in milliseconds
   static julong       _coalesced_vmop_count;     // coalesced vmop count
 
-  // Statistics
-  static void begin_statistics(int nof_threads, int nof_running);
-  static void update_statistics_on_spin_end();
-  static void update_statistics_on_sync_end(jlong end_time);
-  static void update_statistics_on_cleanup_end(jlong end_time);
-  static void end_statistics(jlong end_time);
-  static void print_statistics();
-
   // For debug long safepoint
   static void print_safepoint_timeout();
 
@@ -215,7 +207,6 @@
   JavaThread*                     _thread;
   bool                            _safepoint_safe;
   volatile uint64_t               _safepoint_id;
-  JavaThreadState                 _orig_thread_state;
 
   ThreadSafepointState*           _next;
 
@@ -241,8 +232,6 @@
   void     reset_safepoint_id();
   void     set_safepoint_id(uint64_t sid);
 
-  JavaThreadState orig_thread_state() const { return _orig_thread_state; }
-
   // Support for safepoint timeout (debugging)
   bool is_at_poll_safepoint()           { return _at_poll_safepoint; }
   void set_at_poll_safepoint(bool val)  { _at_poll_safepoint = val; }
@@ -251,7 +240,6 @@
 
   // debugging
   void print_on(outputStream* st) const;
-  void print() const;
 
   // Initialize
   static void create(JavaThread *thread);
--- a/src/hotspot/share/runtime/thread.cpp	Thu Aug 15 14:00:36 2019 +0800
+++ b/src/hotspot/share/runtime/thread.cpp	Thu Aug 15 09:06:42 2019 +0200
@@ -223,7 +223,6 @@
   // stack and get_thread
   set_stack_base(NULL);
   set_stack_size(0);
-  set_self_raw_id(0);
   set_lgrp_id(-1);
   DEBUG_ONLY(clear_suspendible_thread();)
 
@@ -859,23 +858,6 @@
   return true;
 }
 
-#ifndef PRODUCT
-void JavaThread::record_jump(address target, address instr, const char* file,
-                             int line) {
-
-  // This should not need to be atomic as the only way for simultaneous
-  // updates is via interrupts. Even then this should be rare or non-existent
-  // and we don't care that much anyway.
-
-  int index = _jmp_ring_index;
-  _jmp_ring_index = (index + 1) & (jump_ring_buffer_size - 1);
-  _jmp_ring[index]._target = (intptr_t) target;
-  _jmp_ring[index]._instruction = (intptr_t) instr;
-  _jmp_ring[index]._file = file;
-  _jmp_ring[index]._line = line;
-}
-#endif // PRODUCT
-
 void Thread::interrupt(Thread* thread) {
   debug_only(check_for_dangling_thread_pointer(thread);)
   os::interrupt(thread);
@@ -1001,15 +983,6 @@
   }
 }
 
-static int ref_use_count  = 0;
-
-bool Thread::owns_locks_but_compiled_lock() const {
-  for (Monitor *cur = _owned_locks; cur; cur = cur->next()) {
-    if (cur != Compile_lock) return true;
-  }
-  return false;
-}
-
 // Checks safepoint allowed and clears unhandled oops at potential safepoints.
 void Thread::check_possible_safepoint() {
   if (!is_Java_thread()) return;
@@ -1688,7 +1661,6 @@
   set_deferred_locals(NULL);
   set_deopt_mark(NULL);
   set_deopt_compiled_method(NULL);
-  clear_must_deopt_id();
   set_monitor_chunks(NULL);
   _on_thread_list = false;
   set_thread_state(_thread_new);
@@ -1723,20 +1695,12 @@
   _pending_async_exception = NULL;
   _thread_stat = NULL;
   _thread_stat = new ThreadStatistics();
-  _blocked_on_compilation = false;
   _jni_active_critical = 0;
   _pending_jni_exception_check_fn = NULL;
   _do_not_unlock_if_synchronized = false;
   _cached_monitor_info = NULL;
   _parker = Parker::Allocate(this);
 
-#ifndef PRODUCT
-  _jmp_ring_index = 0;
-  for (int ji = 0; ji < jump_ring_buffer_size; ji++) {
-    record_jump(NULL, NULL, NULL, 0);
-  }
-#endif // PRODUCT
-
   // Setup safepoint state info for this thread
   ThreadSafepointState::create(this);
 
@@ -3048,9 +3012,6 @@
 void JavaThread::print_thread_state_on(outputStream *st) const {
   st->print_cr("   JavaThread state: %s", _get_thread_state_name(_thread_state));
 };
-void JavaThread::print_thread_state() const {
-  print_thread_state_on(tty);
-}
 #endif // PRODUCT
 
 // Called by Threads::print() for VM_PrintThreads operation
@@ -3171,47 +3132,10 @@
   return name_str;
 }
 
-
-const char* JavaThread::get_threadgroup_name() const {
-  debug_only(if (JavaThread::current() != this) assert_locked_or_safepoint(Threads_lock);)
-  oop thread_obj = threadObj();
-  if (thread_obj != NULL) {
-    oop thread_group = java_lang_Thread::threadGroup(thread_obj);
-    if (thread_group != NULL) {
-      // ThreadGroup.name can be null
-      return java_lang_ThreadGroup::name(thread_group);
-    }
-  }
-  return NULL;
-}
-
-const char* JavaThread::get_parent_name() const {
-  debug_only(if (JavaThread::current() != this) assert_locked_or_safepoint(Threads_lock);)
-  oop thread_obj = threadObj();
-  if (thread_obj != NULL) {
-    oop thread_group = java_lang_Thread::threadGroup(thread_obj);
-    if (thread_group != NULL) {
-      oop parent = java_lang_ThreadGroup::parent(thread_group);
-      if (parent != NULL) {
-        // ThreadGroup.name can be null
-        return java_lang_ThreadGroup::name(parent);
-      }
-    }
-  }
-  return NULL;
-}
-
-ThreadPriority JavaThread::java_priority() const {
-  oop thr_oop = threadObj();
-  if (thr_oop == NULL) return NormPriority; // Bootstrapping
-  ThreadPriority priority = java_lang_Thread::priority(thr_oop);
-  assert(MinPriority <= priority && priority <= MaxPriority, "sanity check");
-  return priority;
-}
-
 void JavaThread::prepare(jobject jni_thread, ThreadPriority prio) {
 
   assert(Threads_lock->owner() == Thread::current(), "must have threads lock");
+  assert(NoPriority <= prio && prio <= MaxPriority, "sanity check");
   // Link Java Thread object <-> C++ Thread
 
   // Get the C++ thread object (an oop) from the JNI handle (a jthread)
@@ -3351,23 +3275,6 @@
   virtual void do_oop(narrowOop* p)  { do_oop_work(p); }
 };
 
-
-static void oops_print(frame* f, const RegisterMap *map) {
-  PrintAndVerifyOopClosure print;
-  f->print_value();
-  f->oops_do(&print, NULL, (RegisterMap*)map);
-}
-
-// Print our all the locations that contain oops and whether they are
-// valid or not.  This useful when trying to find the oldest frame
-// where an oop has gone bad since the frame walk is from youngest to
-// oldest.
-void JavaThread::trace_oops() {
-  tty->print_cr("[Trace oops]");
-  frames_do(oops_print);
-}
-
-
 #ifdef ASSERT
 // Print or validate the layout of stack frames
 void JavaThread::print_frame_layout(int depth, bool validate_only) {
--- a/src/hotspot/share/runtime/thread.hpp	Thu Aug 15 14:00:36 2019 +0800
+++ b/src/hotspot/share/runtime/thread.hpp	Thu Aug 15 09:06:42 2019 +0200
@@ -705,7 +705,6 @@
   // Support for stack overflow handling, get_thread, etc.
   address          _stack_base;
   size_t           _stack_size;
-  uintptr_t        _self_raw_id;      // used by get_thread (mutable)
   int              _lgrp_id;
 
   volatile void** polling_page_addr() { return &_polling_page; }
@@ -725,9 +724,6 @@
     return (_stack_base >= adr && adr >= stack_end());
   }
 
-  uintptr_t self_raw_id()                    { return _self_raw_id; }
-  void      set_self_raw_id(uintptr_t value) { _self_raw_id = value; }
-
   int     lgrp_id() const        { return _lgrp_id; }
   void    set_lgrp_id(int value) { _lgrp_id = value; }
 
@@ -753,7 +749,6 @@
   void print_owned_locks() const                 { print_owned_locks_on(tty);    }
   Monitor* owned_locks() const                   { return _owned_locks;          }
   bool owns_locks() const                        { return owned_locks() != NULL; }
-  bool owns_locks_but_compiled_lock() const;
 
   // Deadlock detection
   ResourceMark* current_resource_mark()          { return _current_resource_mark; }
@@ -1021,8 +1016,6 @@
   // Deopt support
   DeoptResourceMark*  _deopt_mark;               // Holds special ResourceMark for deoptimization
 
-  intptr_t*      _must_deopt_id;                 // id of frame that needs to be deopted once we
-                                                 // transition out of native
   CompiledMethod*       _deopt_nmethod;         // CompiledMethod that is currently being deoptimized
   vframeArray*  _vframe_array_head;              // Holds the heap of the active vframeArrays
   vframeArray*  _vframe_array_last;              // Holds last vFrameArray we popped
@@ -1199,17 +1192,6 @@
   // failed reallocations.
   int _frames_to_pop_failed_realloc;
 
-#ifndef PRODUCT
-  int _jmp_ring_index;
-  struct {
-    // We use intptr_t instead of address so debugger doesn't try and display strings
-    intptr_t _target;
-    intptr_t _instruction;
-    const char*  _file;
-    int _line;
-  }   _jmp_ring[jump_ring_buffer_size];
-#endif // PRODUCT
-
   friend class VMThread;
   friend class ThreadWaitTransition;
   friend class VM_Exit;
@@ -1264,8 +1246,6 @@
   oop threadObj() const                          { return _threadObj; }
   void set_threadObj(oop p)                      { _threadObj = p; }
 
-  ThreadPriority java_priority() const;          // Read from threadObj()
-
   // Prepare thread and add to priority queue.  If a priority is
   // not specified, use the priority of the thread object. Threads_lock
   // must be held while this function is called.
@@ -1521,10 +1501,6 @@
   void set_deopt_mark(DeoptResourceMark* value)  { _deopt_mark = value; }
   DeoptResourceMark* deopt_mark(void)            { return _deopt_mark; }
 
-  intptr_t* must_deopt_id()                      { return _must_deopt_id; }
-  void     set_must_deopt_id(intptr_t* id)       { _must_deopt_id = id; }
-  void     clear_must_deopt_id()                 { _must_deopt_id = NULL; }
-
   void set_deopt_compiled_method(CompiledMethod* nm)  { _deopt_nmethod = nm; }
   CompiledMethod* deopt_compiled_method()        { return _deopt_nmethod; }
 
@@ -1752,16 +1728,8 @@
   void clr_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = false; }
   bool do_not_unlock(void)                       { return _do_not_unlock_if_synchronized; }
 
-#ifndef PRODUCT
-  void record_jump(address target, address instr, const char* file, int line);
-#endif // PRODUCT
-
   // For assembly stub generation
   static ByteSize threadObj_offset()             { return byte_offset_of(JavaThread, _threadObj); }
-#ifndef PRODUCT
-  static ByteSize jmp_ring_index_offset()        { return byte_offset_of(JavaThread, _jmp_ring_index); }
-  static ByteSize jmp_ring_offset()              { return byte_offset_of(JavaThread, _jmp_ring); }
-#endif // PRODUCT
   static ByteSize jni_environment_offset()       { return byte_offset_of(JavaThread, _jni_environment); }
   static ByteSize pending_jni_exception_check_fn_offset() {
     return byte_offset_of(JavaThread, _pending_jni_exception_check_fn);
@@ -1884,9 +1852,7 @@
   void print_on(outputStream* st, bool print_extended_info) const;
   void print_on(outputStream* st) const { print_on(st, false); }
   void print() const;
-  void print_value();
   void print_thread_state_on(outputStream*) const      PRODUCT_RETURN;
-  void print_thread_state() const                      PRODUCT_RETURN;
   void print_on_error(outputStream* st, char* buf, int buflen) const;
   void print_name_on_error(outputStream* st, char* buf, int buflen) const;
   void verify();
@@ -1895,9 +1861,6 @@
   // factor out low-level mechanics for use in both normal and error cases
   virtual const char* get_thread_name_string(char* buf = NULL, int buflen = 0) const;
  public:
-  const char* get_threadgroup_name() const;
-  const char* get_parent_name() const;
-
   // Accessing frames
   frame last_frame() {
     _anchor.make_walkable(this);
@@ -1917,7 +1880,6 @@
   void trace_stack()                             PRODUCT_RETURN;
   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
   void trace_frames()                            PRODUCT_RETURN;
-  void trace_oops()                              PRODUCT_RETURN;
 
   // Print an annotated view of the stack frames
   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
@@ -1925,9 +1887,6 @@
     print_frame_layout(0, true);
   }
 
-  // Returns the number of stack frames on the stack
-  int depth() const;
-
   // Function for testing deoptimization
   void deoptimize();
   void make_zombies();
@@ -2071,18 +2030,6 @@
   // Machine dependent stuff
 #include OS_CPU_HEADER(thread)
 
- public:
-  void set_blocked_on_compilation(bool value) {
-    _blocked_on_compilation = value;
-  }
-
-  bool blocked_on_compilation() {
-    return _blocked_on_compilation;
-  }
- protected:
-  bool         _blocked_on_compilation;
-
-
   // JSR166 per-thread parker
  private:
   Parker*    _parker;
@@ -2283,13 +2230,6 @@
   // This version may be called by sequential or parallel code.
   static void possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf);
 
-  // Apply "f->do_oop" to roots in all threads that
-  // are part of compiled frames
-  static void compiled_frame_oops_do(OopClosure* f, CodeBlobClosure* cf);
-
-  static void convert_hcode_pointers();
-  static void restore_hcode_pointers();
-
   // Sweeper
   static void nmethods_do(CodeBlobClosure* cf);
 
--- a/src/hotspot/share/runtime/vframe_hp.cpp	Thu Aug 15 14:00:36 2019 +0800
+++ b/src/hotspot/share/runtime/vframe_hp.cpp	Thu Aug 15 09:06:42 2019 +0200
@@ -102,8 +102,7 @@
 }
 
 void compiledVFrame::update_deferred_value(BasicType type, int index, jvalue value) {
-  assert(fr().is_deoptimized_frame() || thread()->must_deopt_id() == fr().id(),
-         "frame must be scheduled for deoptimization");
+  assert(fr().is_deoptimized_frame(), "frame must be scheduled for deoptimization");
   GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred = thread()->deferred_locals();
   jvmtiDeferredLocalVariableSet* locals = NULL;
   if (deferred != NULL ) {
--- a/src/hotspot/share/runtime/vmOperations.cpp	Thu Aug 15 14:00:36 2019 +0800
+++ b/src/hotspot/share/runtime/vmOperations.cpp	Thu Aug 15 09:06:42 2019 +0200
@@ -51,13 +51,10 @@
 const char* VM_Operation::_names[VM_Operation::VMOp_Terminating] = \
   { VM_OPS_DO(VM_OP_NAME_INITIALIZE) };
 
-void VM_Operation::set_calling_thread(Thread* thread, ThreadPriority priority) {
+void VM_Operation::set_calling_thread(Thread* thread) {
   _calling_thread = thread;
-  assert(MinPriority <= priority && priority <= MaxPriority, "sanity check");
-  _priority = priority;
 }
 
-
 void VM_Operation::evaluate() {
   ResourceMark rm;
   LogTarget(Debug, vmoperation) lt;
--- a/src/hotspot/share/runtime/vmOperations.hpp	Thu Aug 15 14:00:36 2019 +0800
+++ b/src/hotspot/share/runtime/vmOperations.hpp	Thu Aug 15 09:06:42 2019 +0200
@@ -146,7 +146,6 @@
 
  private:
   Thread*         _calling_thread;
-  ThreadPriority  _priority;
   long            _timestamp;
   VM_Operation*   _next;
   VM_Operation*   _prev;
@@ -160,8 +159,7 @@
 
   // VM operation support (used by VM thread)
   Thread* calling_thread() const                 { return _calling_thread; }
-  ThreadPriority priority()                      { return _priority; }
-  void set_calling_thread(Thread* thread, ThreadPriority priority);
+  void set_calling_thread(Thread* thread);
 
   long timestamp() const              { return _timestamp; }
   void set_timestamp(long timestamp)  { _timestamp = timestamp; }
--- a/src/hotspot/share/runtime/vmThread.cpp	Thu Aug 15 14:00:36 2019 +0800
+++ b/src/hotspot/share/runtime/vmThread.cpp	Thu Aug 15 09:06:42 2019 +0200
@@ -677,7 +677,7 @@
     }
 
     // Setup VM_operations for execution
-    op->set_calling_thread(t, Thread::get_priority(t));
+    op->set_calling_thread(t);
 
     // It does not make sense to execute the epilogue, if the VM operation object is getting
     // deallocated by the VM thread.
@@ -726,7 +726,7 @@
         fatal("Nested VM operation %s requested by operation %s",
               op->name(), vm_operation()->name());
       }
-      op->set_calling_thread(prev_vm_operation->calling_thread(), prev_vm_operation->priority());
+      op->set_calling_thread(prev_vm_operation->calling_thread());
     }
 
     EventMark em("Executing %s VM operation: %s", prev_vm_operation ? "nested" : "", op->name());