< prev index next >

src/share/vm/jvmci/jvmciCompiler.cpp

Print this page




  40   _bootstrapping = false;
  41   _methodsCompiled = 0;
  42   assert(_instance == NULL, "only one instance allowed");
  43   _instance = this;
  44 }
  45 
  46 // Initialization
  47 void JVMCICompiler::initialize() {
  48   if (!UseCompiler || !EnableJVMCI || !UseJVMCICompiler || !should_perform_init()) {
  49     return;
  50   }
  51 
  52   set_state(initialized);
  53 
  54   // JVMCI is considered as application code so we need to
  55   // stop the VM deferring compilation now.
  56   CompilationPolicy::completed_vm_startup();
  57 }
  58 
  59 void JVMCICompiler::bootstrap() {




  60 #ifndef PRODUCT
  61   // We turn off CompileTheWorld so that compilation requests are not
  62   // ignored during bootstrap or that JVMCI can be compiled by C1/C2.
  63   FlagSetting ctwOff(CompileTheWorld, false);
  64 #endif
  65 
  66   JavaThread* THREAD = JavaThread::current();
  67   _bootstrapping = true;
  68   ResourceMark rm;
  69   HandleMark hm;
  70   if (PrintBootstrap) {
  71     tty->print("Bootstrapping JVMCI");
  72   }
  73   jlong start = os::javaTimeMillis();
  74 
  75   Array<Method*>* objectMethods = InstanceKlass::cast(SystemDictionary::Object_klass())->methods();
  76   // Initialize compile queue with a selected set of methods.
  77   int len = objectMethods->length();
  78   for (int i = 0; i < len; i++) {
  79     methodHandle mh = objectMethods->at(i);


 108   _bootstrapping = false;
 109 }
 110 
 111 void JVMCICompiler::compile_method(methodHandle method, int entry_bci, JVMCIEnv* env) {
 112   JVMCI_EXCEPTION_CONTEXT
 113 
 114   bool is_osr = entry_bci != InvocationEntryBci;
 115   if (_bootstrapping && is_osr) {
 116       // no OSR compilations during bootstrap - the compiler is just too slow at this point,
 117       // and we know that there are no endless loops
 118       return;
 119   }
 120 
 121   JVMCIRuntime::initialize_well_known_classes(CHECK_ABORT);
 122 
 123   HandleMark hm;
 124   ResourceMark rm;
 125   Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT);
 126 
 127   JavaValue method_result(T_OBJECT);
 128   {
 129     JavaCallArguments args;
 130     args.push_long((jlong) (address) method());
 131     JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, CHECK_ABORT);
 132   }
 133 

 134   JavaValue result(T_VOID);
 135   JavaCallArguments args;
 136   args.push_oop(receiver);
 137   args.push_oop((oop)method_result.get_jobject());
 138   args.push_int(entry_bci);
 139   args.push_long((jlong) (address) env);
 140   args.push_int(env->task()->compile_id());
 141   JavaCalls::call_special(&result, receiver->klass(), vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, CHECK_ABORT);









 142 








 143   _methodsCompiled++;

 144 }
 145 
 146 
 147 // Compilation entry point for methods
 148 void JVMCICompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, DirectiveSet* directive) {
 149   ShouldNotReachHere();
 150 }
 151 







 152 // Print compilation timers and statistics
 153 void JVMCICompiler::print_timers() {
 154   print_compilation_timers();
 155 }
 156 
 157 // Print compilation timers and statistics
 158 void JVMCICompiler::print_compilation_timers() {
 159   TRACE_jvmci_1("JVMCICompiler::print_timers");
 160   tty->print_cr("       JVMCI code install time:        %6.3f s",    _codeInstallTimer.seconds());
 161 }


  40   _bootstrapping = false;
  41   _methodsCompiled = 0;
  42   assert(_instance == NULL, "only one instance allowed");
  43   _instance = this;
  44 }
  45 
  46 // Initialization
  47 void JVMCICompiler::initialize() {
  48   if (!UseCompiler || !EnableJVMCI || !UseJVMCICompiler || !should_perform_init()) {
  49     return;
  50   }
  51 
  52   set_state(initialized);
  53 
  54   // JVMCI is considered as application code so we need to
  55   // stop the VM deferring compilation now.
  56   CompilationPolicy::completed_vm_startup();
  57 }
  58 
  59 void JVMCICompiler::bootstrap() {
  60   if (Arguments::mode() == Arguments::_int) {
  61     // Nothing to do in -Xint mode
  62     return;
  63   }
  64 #ifndef PRODUCT
  65   // We turn off CompileTheWorld so that compilation requests are not
  66   // ignored during bootstrap or that JVMCI can be compiled by C1/C2.
  67   FlagSetting ctwOff(CompileTheWorld, false);
  68 #endif
  69 
  70   JavaThread* THREAD = JavaThread::current();
  71   _bootstrapping = true;
  72   ResourceMark rm;
  73   HandleMark hm;
  74   if (PrintBootstrap) {
  75     tty->print("Bootstrapping JVMCI");
  76   }
  77   jlong start = os::javaTimeMillis();
  78 
  79   Array<Method*>* objectMethods = InstanceKlass::cast(SystemDictionary::Object_klass())->methods();
  80   // Initialize compile queue with a selected set of methods.
  81   int len = objectMethods->length();
  82   for (int i = 0; i < len; i++) {
  83     methodHandle mh = objectMethods->at(i);


 112   _bootstrapping = false;
 113 }
 114 
 115 void JVMCICompiler::compile_method(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() {
 188   TRACE_jvmci_1("JVMCICompiler::print_timers");
 189   tty->print_cr("       JVMCI code install time:        %6.3f s",    _codeInstallTimer.seconds());
 190 }
< prev index next >