changeset 27290:ccd373eddb9f

8145038: Simplify mut_process_buffer worker id management Summary: Remove some wasted code Reviewed-by: kbarrett, tschatzl
author aharlap
date Mon, 11 Jan 2016 14:26:00 -0500
parents 5eea918d4321
children 7897f368ccbf
files src/share/vm/gc/g1/dirtyCardQueue.cpp src/share/vm/runtime/thread.cpp src/share/vm/runtime/thread.hpp
diffstat 3 files changed, 8 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/g1/dirtyCardQueue.cpp	Tue Jan 12 19:11:39 2016 +0000
+++ b/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();
+  // claim a par id
+  uint worker_i = _free_ids->claim_par_id();
 
-  // We get the the number of any par_id that this thread
-  // might have already claimed.
-  uint worker_i = thread->get_claimed_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/src/share/vm/runtime/thread.cpp	Tue Jan 12 19:11:39 2016 +0000
+++ b/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/src/share/vm/runtime/thread.hpp	Tue Jan 12 19:11:39 2016 +0000
+++ b/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