diff src/share/vm/runtime/thread.cpp @ 16795:a29e6e7b7a86

Replace hsail donor threads with hsail tlabs
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 12 Aug 2014 16:30:17 -0700
parents ce6696559683
children 52b4284cb496
line wrap: on
line diff
--- a/src/share/vm/runtime/thread.cpp	Tue Aug 12 16:12:49 2014 -0700
+++ b/src/share/vm/runtime/thread.cpp	Tue Aug 12 16:30:17 2014 -0700
@@ -1474,7 +1474,9 @@
 #ifdef GRAAL
   set_gpu_exception_bci(0);
   set_gpu_exception_method(NULL);  
-  set_gpu_hsail_deopt_info(NULL);  
+  set_gpu_hsail_deopt_info(NULL);
+  _gpu_hsail_tlabs_count = 0;
+  _gpu_hsail_tlabs = NULL;
 #endif
   set_thread_state(_thread_new);
 #if INCLUDE_NMT
@@ -1694,6 +1696,8 @@
     }
     FREE_C_HEAP_ARRAY(jlong, _graal_counters, mtInternal);
   }
+
+  delete_gpu_hsail_tlabs();
 #endif // GRAAL
 }
 
@@ -1968,7 +1972,7 @@
   remove_stack_guard_pages();
 
   if (UseTLAB) {
-    tlab().make_parsable(true);  // retire TLAB
+    tlabs_make_parsable(true);   // retire TLABs, if any
   }
 
   if (JvmtiEnv::environments_might_exist()) {
@@ -2047,7 +2051,7 @@
   remove_stack_guard_pages();
 
   if (UseTLAB) {
-    tlab().make_parsable(true);  // retire TLAB, if any
+    tlabs_make_parsable(true);   // retire TLABs, if any
   }
 
 #if INCLUDE_ALL_GCS
@@ -4792,3 +4796,54 @@
   VMThread* thread = VMThread::vm_thread();
   if (thread != NULL) thread->verify();
 }
+
+void JavaThread::tlabs_make_parsable(bool retire) {
+  // do the primary tlab for this thread
+  tlab().make_parsable(retire);
+#ifdef GRAAL
+  // do the gpu_hsail tlabs if any
+  gpu_hsail_tlabs_make_parsable(retire);
+#endif
+}
+
+
+#ifdef GRAAL
+void JavaThread::initialize_gpu_hsail_tlabs(jint count) {
+  if (!UseTLAB) return;
+  // create tlabs
+  _gpu_hsail_tlabs = NEW_C_HEAP_ARRAY(ThreadLocalAllocBuffer*, count, mtInternal);
+  // initialize
+  for (jint i = 0; i < count; i++) {
+    _gpu_hsail_tlabs[i] = new ThreadLocalAllocBuffer();
+    _gpu_hsail_tlabs[i]->initialize(Thread::current());
+  }
+  _gpu_hsail_tlabs_count = count;
+}
+
+ThreadLocalAllocBuffer* JavaThread::get_gpu_hsail_tlab_at(jint idx) {
+  assert(idx >= 0 && idx < get_gpu_hsail_tlabs_count(), "illegal gpu tlab index");
+  return _gpu_hsail_tlabs[idx];
+}
+
+void JavaThread::gpu_hsail_tlabs_make_parsable(bool retire) {
+  for (jint i = 0; i < get_gpu_hsail_tlabs_count(); i++) {
+    get_gpu_hsail_tlab_at(i)->make_parsable(retire);
+  }
+}
+
+void JavaThread::delete_gpu_hsail_tlabs() {
+  if (!UseTLAB) return;
+  if (_gpu_hsail_tlabs_count == 0) return;
+
+  gpu_hsail_tlabs_make_parsable(true);
+  for (jint i = 0; i < get_gpu_hsail_tlabs_count(); i++) {
+    delete get_gpu_hsail_tlab_at(i);
+  }
+  FREE_C_HEAP_ARRAY(ThreadLocalAllocBuffer*, _gpu_hsail_tlabs, mtInternal);
+  _gpu_hsail_tlabs = NULL;
+  _gpu_hsail_tlabs_count = 0;
+}
+
+
+#endif
+