8145038: Simplify mut_process_buffer worker id management
authoraharlap
Mon, 11 Jan 2016 14:26:00 -0500
changeset 35481 53825bdb41a0
parent 35478 017a7cab2a55
child 35482 cedc2e709ac8
8145038: Simplify mut_process_buffer worker id management Summary: Remove some wasted code Reviewed-by: kbarrett, tschatzl
hotspot/src/share/vm/gc/g1/dirtyCardQueue.cpp
hotspot/src/share/vm/runtime/thread.cpp
hotspot/src/share/vm/runtime/thread.hpp
--- a/hotspot/src/share/vm/gc/g1/dirtyCardQueue.cpp	Tue Jan 12 19:11:39 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/dirtyCardQueue.cpp	Mon Jan 11 14:26:00 2016 -0500
@@ -190,47 +190,19 @@
 
 bool DirtyCardQueueSet::mut_process_buffer(void** buf) {
   guarantee(_free_ids != NULL, "must be");
-  // Used to determine if we had already claimed a par_id
-  // before entering this method.
-  bool already_claimed = false;
 
-  // We grab the current JavaThread.
-  JavaThread* thread = JavaThread::current();
-
-  // We get the the number of any par_id that this thread
-  // might have already claimed.
-  uint worker_i = thread->get_claimed_par_id();
+  // claim a par id
+  uint worker_i = _free_ids->claim_par_id();
 
-  // If worker_i is not UINT_MAX then the thread has already claimed
-  // a par_id. We make note of it using the already_claimed value
-  if (worker_i != UINT_MAX) {
-    already_claimed = true;
-  } else {
-
-    // Otherwise we need to claim a par id
-    worker_i = _free_ids->claim_par_id();
-
-    // And store the par_id value in the thread
-    thread->set_claimed_par_id(worker_i);
+  bool b = DirtyCardQueue::apply_closure_to_buffer(_mut_process_closure, buf, 0,
+                                                   _sz, true, worker_i);
+  if (b) {
+    Atomic::inc(&_processed_buffers_mut);
   }
 
-  bool b = false;
-  if (worker_i != UINT_MAX) {
-    b = DirtyCardQueue::apply_closure_to_buffer(_mut_process_closure, buf, 0,
-                                                _sz, true, worker_i);
-    if (b) Atomic::inc(&_processed_buffers_mut);
+  // release the id
+  _free_ids->release_par_id(worker_i);
 
-    // If we had not claimed an id before entering the method
-    // then we must release the id.
-    if (!already_claimed) {
-
-      // we release the id
-      _free_ids->release_par_id(worker_i);
-
-      // and set the claimed_id in the thread to UINT_MAX
-      thread->set_claimed_par_id(UINT_MAX);
-    }
-  }
   return b;
 }
 
--- a/hotspot/src/share/vm/runtime/thread.cpp	Tue Jan 12 19:11:39 2016 +0000
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Mon Jan 11 14:26:00 2016 -0500
@@ -1419,9 +1419,6 @@
 void JavaThread::initialize() {
   // Initialize fields
 
-  // Set the claimed par_id to UINT_MAX (ie not claiming any par_ids)
-  set_claimed_par_id(UINT_MAX);
-
   set_saved_exception_pc(NULL);
   set_threadObj(NULL);
   _anchor.clear();
--- a/hotspot/src/share/vm/runtime/thread.hpp	Tue Jan 12 19:11:39 2016 +0000
+++ b/hotspot/src/share/vm/runtime/thread.hpp	Mon Jan 11 14:26:00 2016 -0500
@@ -1964,14 +1964,6 @@
   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
   inline void set_done_attaching_via_jni();
- private:
-  // This field is used to determine if a thread has claimed
-  // a par_id: it is UINT_MAX if the thread has not claimed a par_id;
-  // otherwise its value is the par_id that has been claimed.
-  uint _claimed_par_id;
- public:
-  uint get_claimed_par_id() { return _claimed_par_id; }
-  void set_claimed_par_id(uint id) { _claimed_par_id = id; }
 };
 
 // Inline implementation of JavaThread::current