< prev index next >

src/share/vm/jvmci/jvmciCompiler.cpp

Print this page




  95     // Loop until there is something in the queue.
  96     do {
  97       os::sleep(THREAD, 100, true);
  98       qsize = CompileBroker::queue_size(CompLevel_full_optimization);
  99     } while (first_round && qsize == 0);
 100     first_round = false;
 101     if (PrintBootstrap) {
 102       while (z < (_methodsCompiled / 100)) {
 103         ++z;
 104         tty->print_raw(".");
 105       }
 106     }
 107   } while (qsize != 0);
 108 
 109   if (PrintBootstrap) {
 110     tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled);
 111   }
 112   _bootstrapping = false;
 113 }
 114 









 115 void JVMCICompiler::compile_method(const methodHandle& method, int entry_bci, JVMCIEnv* env) {
 116   JVMCI_EXCEPTION_CONTEXT
 117 
 118   bool is_osr = entry_bci != InvocationEntryBci;
 119   if (_bootstrapping && is_osr) {
 120       // no OSR compilations during bootstrap - the compiler is just too slow at this point,
 121       // and we know that there are no endless loops
 122       return;
 123   }
 124 
 125   JVMCIRuntime::initialize_well_known_classes(CHECK_ABORT);
 126 
 127   HandleMark hm;
 128   ResourceMark rm;
 129   Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT);
 130 
 131   JavaValue method_result(T_OBJECT);
 132   JavaCallArguments args;
 133   args.push_long((jlong) (address) method());
 134   JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(),
 135                          vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD);
 136 
 137   if (!HAS_PENDING_EXCEPTION) {
 138     JavaValue result(T_VOID);
 139     JavaCallArguments args;
 140     args.push_oop(receiver);
 141     args.push_oop((oop)method_result.get_jobject());
 142     args.push_int(entry_bci);
 143     args.push_long((jlong) (address) env);
 144     args.push_int(env->task()->compile_id());
 145     JavaCalls::call_special(&result, receiver->klass(),
 146                             vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
 147   }
 148 
 149   // An uncaught exception was thrown during compilation.  Generally these
 150   // should be handled by the Java code in some useful way but if they leak
 151   // through to here report them instead of dying or silently ignoring them.
 152   if (HAS_PENDING_EXCEPTION) {
 153     Handle throwable = PENDING_EXCEPTION;
 154     CLEAR_PENDING_EXCEPTION;
 155 
 156     JVMCIRuntime::call_printStackTrace(throwable, THREAD);
 157     if (HAS_PENDING_EXCEPTION) {
 158       CLEAR_PENDING_EXCEPTION;
 159     }
 160 
 161     // Something went wrong so disable compilation at this level
 162     method->set_not_compilable(CompLevel_full_optimization);
 163   } else {
 164     _methodsCompiled++;
 165   }
 166 }
 167 






















 168 
 169 // Compilation entry point for methods
 170 void JVMCICompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, DirectiveSet* directive) {
 171   ShouldNotReachHere();
 172 }
 173 
 174 bool JVMCICompiler::is_trivial(Method* method) {
 175   if (_bootstrapping) {
 176     return false;
 177   }
 178   return JVMCIRuntime::treat_as_trivial(method);
 179 }
 180 
 181 // Print compilation timers and statistics
 182 void JVMCICompiler::print_timers() {
 183   print_compilation_timers();
 184 }
 185 
 186 // Print compilation timers and statistics
 187 void JVMCICompiler::print_compilation_timers() {


  95     // Loop until there is something in the queue.
  96     do {
  97       os::sleep(THREAD, 100, true);
  98       qsize = CompileBroker::queue_size(CompLevel_full_optimization);
  99     } while (first_round && qsize == 0);
 100     first_round = false;
 101     if (PrintBootstrap) {
 102       while (z < (_methodsCompiled / 100)) {
 103         ++z;
 104         tty->print_raw(".");
 105       }
 106     }
 107   } while (qsize != 0);
 108 
 109   if (PrintBootstrap) {
 110     tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled);
 111   }
 112   _bootstrapping = false;
 113 }
 114 
 115 #define CHECK_ABORT THREAD); \
 116 if (HAS_PENDING_EXCEPTION) { \
 117   char buf[256]; \
 118   jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
 119   JVMCICompiler::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
 120   return; \
 121 } \
 122 (void)(0
 123 
 124 void JVMCICompiler::compile_method(const methodHandle& method, int entry_bci, JVMCIEnv* env) {
 125   JVMCI_EXCEPTION_CONTEXT
 126 
 127   bool is_osr = entry_bci != InvocationEntryBci;
 128   if (_bootstrapping && is_osr) {
 129       // no OSR compilations during bootstrap - the compiler is just too slow at this point,
 130       // and we know that there are no endless loops
 131       return;
 132   }
 133 
 134   JVMCIRuntime::initialize_well_known_classes(CHECK_ABORT);
 135 
 136   HandleMark hm;
 137   ResourceMark rm;
 138   Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT);
 139 
 140   JavaValue method_result(T_OBJECT);
 141   JavaCallArguments args;
 142   args.push_long((jlong) (address) method());
 143   JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(),
 144                          vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD);
 145 
 146   if (!HAS_PENDING_EXCEPTION) {
 147     JavaValue result(T_VOID);
 148     JavaCallArguments args;
 149     args.push_oop(receiver);
 150     args.push_oop((oop)method_result.get_jobject());
 151     args.push_int(entry_bci);
 152     args.push_long((jlong) (address) env);
 153     args.push_int(env->task()->compile_id());
 154     JavaCalls::call_special(&result, receiver->klass(),
 155                             vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
 156   }
 157 
 158   // An uncaught exception was thrown during compilation.  Generally these
 159   // should be handled by the Java code in some useful way but if they leak
 160   // through to here report them instead of dying or silently ignoring them.
 161   if (HAS_PENDING_EXCEPTION) {
 162     Handle exception(THREAD, PENDING_EXCEPTION);
 163     CLEAR_PENDING_EXCEPTION;
 164 
 165     {
 166       ttyLocker ttyl;
 167       java_lang_Throwable::print_stack_trace(exception, tty);
 168     }
 169 
 170     // Something went wrong so disable compilation at this level
 171     method->set_not_compilable(CompLevel_full_optimization);
 172   } else {
 173     _methodsCompiled++;
 174   }
 175 }
 176 
 177 /**
 178  * Aborts the VM due to an unexpected exception.
 179  */
 180 void JVMCICompiler::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
 181   Thread* THREAD = Thread::current();
 182   CLEAR_PENDING_EXCEPTION;
 183 
 184   {
 185     ttyLocker ttyl;
 186     tty->print_raw_cr(message);
 187     java_lang_Throwable::print_stack_trace(exception, tty);
 188   }
 189 
 190   // Give other aborting threads to also print their stack traces.
 191   // This can be very useful when debugging class initialization
 192   // failures.
 193   assert(THREAD->is_Java_thread(), "compiler threads should be Java threads");
 194   const bool interruptible = true;
 195   os::sleep(THREAD, 200, interruptible);
 196 
 197   vm_abort(dump_core);
 198 }
 199 
 200 // Compilation entry point for methods
 201 void JVMCICompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, DirectiveSet* directive) {
 202   ShouldNotReachHere();
 203 }
 204 
 205 bool JVMCICompiler::is_trivial(Method* method) {
 206   if (_bootstrapping) {
 207     return false;
 208   }
 209   return JVMCIRuntime::treat_as_trivial(method);
 210 }
 211 
 212 // Print compilation timers and statistics
 213 void JVMCICompiler::print_timers() {
 214   print_compilation_timers();
 215 }
 216 
 217 // Print compilation timers and statistics
 218 void JVMCICompiler::print_compilation_timers() {
< prev index next >