changeset 4981:1b8d02e10ee8

Remove the hacks around "is_Compiler_thread" assertions; Graal no longer uses the compiler thread mechanisms; don't create a C++ compilation queue or any compiler threads.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 27 Feb 2012 22:15:05 +0100
parents 1c7c5be93e84
children 38012b8c29b1
files src/share/vm/classfile/systemDictionary.cpp src/share/vm/code/compiledIC.cpp src/share/vm/compiler/compileBroker.cpp src/share/vm/runtime/javaCalls.cpp src/share/vm/runtime/thread.cpp src/share/vm/utilities/exceptions.cpp
diffstat 6 files changed, 20 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/systemDictionary.cpp	Mon Feb 27 21:49:51 2012 +0100
+++ b/src/share/vm/classfile/systemDictionary.cpp	Mon Feb 27 22:15:05 2012 +0100
@@ -193,8 +193,7 @@
 // Forwards to resolve_instance_class_or_null
 
 klassOop SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
-  // (tw) May we do this?
-  //assert(!THREAD->is_Compiler_thread(), "Can not load classes with the Compiler thread");
+  assert(!THREAD->is_Compiler_thread(), "Can not load classes with the Compiler thread");
   if (FieldType::is_array(class_name)) {
     return resolve_array_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL);
   } else if (FieldType::is_obj(class_name)) {
@@ -2370,9 +2369,8 @@
   if (spe == NULL || spe->property_oop() == NULL) {
     spe = NULL;
     // Must create lots of stuff here, but outside of the SystemDictionary lock.
-    // (tw) May we do this?
-	//if (THREAD->is_Compiler_thread())
-    //  return NULL;              // do not attempt from within compiler
+    if (THREAD->is_Compiler_thread())
+      return NULL;              // do not attempt from within compiler
     bool for_invokeGeneric = (name_id != vmSymbols::VM_SYMBOL_ENUM_NAME(invokeExact_name));
     bool found_on_bcp = false;
     Handle mt = find_method_handle_type(signature, accessing_klass,
--- a/src/share/vm/code/compiledIC.cpp	Mon Feb 27 21:49:51 2012 +0100
+++ b/src/share/vm/code/compiledIC.cpp	Mon Feb 27 22:15:05 2012 +0100
@@ -528,7 +528,7 @@
   NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
 
   assert(method_holder->data()    == 0           || method_holder->data()    == (intptr_t)callee(), "a) MT-unsafe modification of inline cache");
-// XXX GRAAL : ??
+// TODO(tw): Check what is the correct assert for Graal.
 #ifndef GRAAL
   assert(jump->jump_destination() == (address)-1 || jump->jump_destination() == entry, "b) MT-unsafe modification of inline cache");
 #endif
--- a/src/share/vm/compiler/compileBroker.cpp	Mon Feb 27 21:49:51 2012 +0100
+++ b/src/share/vm/compiler/compileBroker.cpp	Mon Feb 27 22:15:05 2012 +0100
@@ -729,6 +729,8 @@
   int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization);
 #if defined(GRAAL)
   _compilers[0] = new GraalCompiler();
+  c1_count = 0;
+  c2_count = 0;
 #elif defined(COMPILER1)
   if (c1_count > 0) {
     _compilers[0] = new Compiler();
@@ -943,7 +945,7 @@
 // Initialize the compilation queue
 void CompileBroker::init_compiler_threads(int c1_compiler_count, int c2_compiler_count) {
   EXCEPTION_MARK;
-#if !defined(ZERO) && !defined(SHARK)
+#if !defined(ZERO) && !defined(SHARK) && !defined(GRAAL)
   assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?");
 #endif // !ZERO && !SHARK
   if (c2_compiler_count > 0) {
@@ -1081,6 +1083,14 @@
   if (instanceRefKlass::owns_pending_list_lock(JavaThread::current())) {
     return;
   }
+#ifdef GRAAL
+  if (!JavaThread::current()->is_compiling()) {
+    method->set_queued_for_compilation();
+    GraalCompiler::instance()->compile_method(method, osr_bci, is_compile_blocking(method, osr_bci));
+  } else {
+    // Recursive compile request => ignore.
+  }
+#else
 
   // Outputs from the following MutexLocker block:
   CompileTask* task     = NULL;
@@ -1091,14 +1101,6 @@
   {
     MutexLocker locker(queue->lock(), thread);
 
-#ifdef GRAAL
-    if (JavaThread::current()->is_compiling() && !BackgroundCompilation) {
-      TRACE_graal_1("Recursive compile %s!", method->name_and_sig_as_C_string());
-      method->set_not_compilable();
-      return;
-    }
-#endif
-
     // Make sure the method has not slipped into the queues since
     // last we checked; note that those checks were "fast bail-outs".
     // Here we need to be more careful, see 14012000 below.
@@ -1163,23 +1165,13 @@
     // and in that case it's best to protect both the testing (here) of
     // these bits, and their updating (here and elsewhere) under a
     // common lock.
-#ifndef GRAAL
     task = create_compile_task(queue,
                                compile_id, method,
                                osr_bci, comp_level,
                                hot_method, hot_count, comment,
                                blocking);
-#endif
   }
 
-#ifdef GRAAL
-  if (!JavaThread::current()->is_compiling()) {
-    method->set_queued_for_compilation();
-    GraalCompiler::instance()->compile_method(method, osr_bci, blocking);
-  } else {
-    // Recursive compile request => ignore.
-  }
-#else
   if (blocking) {
     wait_for_completion(task);
   }
--- a/src/share/vm/runtime/javaCalls.cpp	Mon Feb 27 21:49:51 2012 +0100
+++ b/src/share/vm/runtime/javaCalls.cpp	Mon Feb 27 22:15:05 2012 +0100
@@ -61,8 +61,7 @@
 
   guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code");
   assert(!thread->owns_locks(), "must release all locks when leaving VM");
-  // (tw) may we do this?
-  // guarantee(!thread->is_Compiler_thread(), "cannot make java calls from the compiler");
+  guarantee(!thread->is_Compiler_thread(), "cannot make java calls from the compiler");
   _result   = result;
 
   // Allocate handle block for Java code. This must be done before we change thread_state to _thread_in_Java_or_stub,
@@ -373,8 +372,7 @@
 #endif
 
 
-  // (tw) may we do this?
-  //assert(!thread->is_Compiler_thread(), "cannot compile from the compiler");
+  assert(!thread->is_Compiler_thread(), "cannot compile from the compiler");
   if (CompilationPolicy::must_be_compiled(method)) {
     CompileBroker::compile_method(method, InvocationEntryBci,
                                   CompilationPolicy::policy()->initial_compile_level(),
--- a/src/share/vm/runtime/thread.cpp	Mon Feb 27 21:49:51 2012 +0100
+++ b/src/share/vm/runtime/thread.cpp	Mon Feb 27 22:15:05 2012 +0100
@@ -4067,9 +4067,7 @@
   {
     MutexLockerEx ml(doLock ? Threads_lock : NULL);
     ALL_JAVA_THREADS(p) {
-      
-      // (tw) May we do this?
-      //if (p->is_Compiler_thread()) continue;
+      if (p->is_Compiler_thread()) continue;
 
       address pending = (address)p->current_pending_monitor();
       if (pending == monitor) {             // found a match
--- a/src/share/vm/utilities/exceptions.cpp	Mon Feb 27 21:49:51 2012 +0100
+++ b/src/share/vm/utilities/exceptions.cpp	Mon Feb 27 22:15:05 2012 +0100
@@ -95,10 +95,7 @@
 #endif // ASSERT
 
   if (thread->is_VM_thread()
-#ifndef GRAAL
-      || thread->is_Compiler_thread()
-#endif
-    ) {
+      || thread->is_Compiler_thread() ) {
     // We do not care what kind of exception we get for the vm-thread or a thread which
     // is compiling.  We just install a dummy exception object
     thread->set_pending_exception(Universe::vm_exception(), file, line);
@@ -121,10 +118,7 @@
   }
 
   if (thread->is_VM_thread()
-#ifndef GRAAL
-      || thread->is_Compiler_thread()
-#endif
-    ) {
+      || thread->is_Compiler_thread() ) {
     // We do not care what kind of exception we get for the vm-thread or a thread which
     // is compiling.  We just install a dummy exception object
     thread->set_pending_exception(Universe::vm_exception(), file, line);