< prev index next >

src/hotspot/share/compiler/compileBroker.cpp

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

@@ -733,22 +733,27 @@
                        string,
                        CHECK_NH);
 }
 
 
-JavaThread* CompileBroker::make_thread(jobject thread_handle, CompileQueue* queue, AbstractCompiler* comp, TRAPS) {
+JavaThread* CompileBroker::make_thread(ThreadType type, jobject thread_handle, CompileQueue* queue, AbstractCompiler* comp, TRAPS) {
   JavaThread* thread = NULL;
   {
     MutexLocker mu(Threads_lock, THREAD);
-    if (comp != NULL) {
+    if (type == compiler_t) {
       if (!InjectCompilerCreationFailure || comp->num_compiler_threads() == 0) {
         CompilerCounters* counters = new CompilerCounters();
         thread = new CompilerThread(queue, counters);
       }
-    } else {
+    } else if (type == sweeper_t) {
       thread = new CodeCacheSweeperThread();
     }
+#if defined(ASSERT) && COMPILER2_OR_JVMCI
+    else {
+      thread = new DeoptimizeObjectsALotThread();
+    }
+#endif // ASSERT
     // At this point the new CompilerThread data-races with this startup
     // thread (which I believe is the primoridal thread and NOT the VM
     // thread).  This means Java bytecodes being executed at startup can
     // queue compile jobs which will run at whatever default priority the
     // newly created CompilerThread runs at.

@@ -786,21 +791,21 @@
       os::set_native_priority(thread, native_prio);
 
       java_lang_Thread::set_daemon(JNIHandles::resolve_non_null(thread_handle));
 
       thread->set_threadObj(JNIHandles::resolve_non_null(thread_handle));
-      if (comp != NULL) {
+      if (type == compiler_t) {
         thread->as_CompilerThread()->set_compiler(comp);
       }
       Threads::add(thread);
       Thread::start(thread);
     }
   }
 
   // First release lock before aborting VM.
   if (thread == NULL || thread->osthread() == NULL) {
-    if (UseDynamicNumberOfCompilerThreads && comp != NULL && comp->num_compiler_threads() > 0) {
+    if (UseDynamicNumberOfCompilerThreads && type == compiler_t && comp->num_compiler_threads() > 0) {
       if (thread != NULL) {
         thread->smr_delete();
       }
       return NULL;
     }

@@ -842,11 +847,11 @@
     jobject thread_handle = JNIHandles::make_global(thread_oop);
     _compiler2_objects[i] = thread_handle;
     _compiler2_logs[i] = NULL;
 
     if (!UseDynamicNumberOfCompilerThreads || i == 0) {
-      JavaThread *ct = make_thread(thread_handle, _c2_compile_queue, _compilers[1], CHECK);
+      JavaThread *ct = make_thread(compiler_t, thread_handle, _c2_compile_queue, _compilers[1], CHECK);
       assert(ct != NULL, "should have been handled for initial thread");
       _compilers[1]->set_num_compiler_threads(i + 1);
       if (TraceCompilerThreads) {
         ResourceMark rm;
         MutexLocker mu(Threads_lock);

@@ -862,11 +867,11 @@
     jobject thread_handle = JNIHandles::make_global(thread_oop);
     _compiler1_objects[i] = thread_handle;
     _compiler1_logs[i] = NULL;
 
     if (!UseDynamicNumberOfCompilerThreads || i == 0) {
-      JavaThread *ct = make_thread(thread_handle, _c1_compile_queue, _compilers[0], CHECK);
+      JavaThread *ct = make_thread(compiler_t, thread_handle, _c1_compile_queue, _compilers[0], CHECK);
       assert(ct != NULL, "should have been handled for initial thread");
       _compilers[0]->set_num_compiler_threads(i + 1);
       if (TraceCompilerThreads) {
         ResourceMark rm;
         MutexLocker mu(Threads_lock);

@@ -881,12 +886,21 @@
 
   if (MethodFlushing) {
     // Initialize the sweeper thread
     Handle thread_oop = create_thread_oop("Sweeper thread", CHECK);
     jobject thread_handle = JNIHandles::make_local(THREAD, thread_oop());
-    make_thread(thread_handle, NULL, NULL, CHECK);
+    make_thread(sweeper_t, thread_handle, NULL, NULL, CHECK);
+  }
+
+#if defined(ASSERT) && COMPILER2_OR_JVMCI
+  if (DeoptimizeObjectsALot == 2) {
+    // Initialize and start the object deoptimizer thread
+    Handle thread_oop = create_thread_oop("Deoptimize objects a lot thread", CHECK);
+    jobject thread_handle = JNIHandles::make_local(THREAD, thread_oop());
+    make_thread(deoptimizer_t, thread_handle, NULL, NULL, CHECK);
   }
+#endif // defined(ASSERT) && COMPILER2_OR_JVMCI
 }
 
 void CompileBroker::possibly_add_compiler_threads() {
   EXCEPTION_MARK;
 

@@ -904,11 +918,11 @@
         _c2_compile_queue->size() / 2,
         (int)(available_memory / (200*M)),
         (int)(available_cc_np / (128*K)));
 
     for (int i = old_c2_count; i < new_c2_count; i++) {
-      JavaThread *ct = make_thread(compiler2_object(i), _c2_compile_queue, _compilers[1], CHECK);
+      JavaThread *ct = make_thread(compiler_t, compiler2_object(i), _c2_compile_queue, _compilers[1], CHECK);
       if (ct == NULL) break;
       _compilers[1]->set_num_compiler_threads(i + 1);
       if (TraceCompilerThreads) {
         ResourceMark rm;
         MutexLocker mu(Threads_lock);

@@ -924,11 +938,11 @@
         _c1_compile_queue->size() / 4,
         (int)(available_memory / (100*M)),
         (int)(available_cc_p / (128*K)));
 
     for (int i = old_c1_count; i < new_c1_count; i++) {
-      JavaThread *ct = make_thread(compiler1_object(i), _c1_compile_queue, _compilers[0], CHECK);
+      JavaThread *ct = make_thread(compiler_t, compiler1_object(i), _c1_compile_queue, _compilers[0], CHECK);
       if (ct == NULL) break;
       _compilers[0]->set_num_compiler_threads(i + 1);
       if (TraceCompilerThreads) {
         ResourceMark rm;
         MutexLocker mu(Threads_lock);
< prev index next >