775 |
775 |
776 // ------------------------------------------------------------------ |
776 // ------------------------------------------------------------------ |
777 // CompileBroker::compile_method |
777 // CompileBroker::compile_method |
778 // |
778 // |
779 // Request compilation of a method. |
779 // Request compilation of a method. |
780 void CompileBroker::compile_method_base(methodHandle method, |
780 void CompileBroker::compile_method_base(const methodHandle& method, |
781 int osr_bci, |
781 int osr_bci, |
782 int comp_level, |
782 int comp_level, |
783 methodHandle hot_method, |
783 const methodHandle& hot_method, |
784 int hot_count, |
784 int hot_count, |
785 const char* comment, |
785 const char* comment, |
786 Thread* thread) { |
786 Thread* thread) { |
787 // do nothing if compiler thread(s) is not available |
787 // do nothing if compiler thread(s) is not available |
788 if (!_initialized) { |
788 if (!_initialized) { |
978 wait_for_completion(task); |
978 wait_for_completion(task); |
979 } |
979 } |
980 } |
980 } |
981 |
981 |
982 |
982 |
983 nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, |
983 nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, |
984 int comp_level, |
984 int comp_level, |
985 methodHandle hot_method, int hot_count, |
985 const methodHandle& hot_method, int hot_count, |
986 const char* comment, Thread* THREAD) { |
986 const char* comment, Thread* THREAD) { |
987 // make sure arguments make sense |
987 // make sure arguments make sense |
988 assert(method->method_holder()->oop_is_instance(), "not an instance method"); |
988 assert(method->method_holder()->oop_is_instance(), "not an instance method"); |
989 assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range"); |
989 assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range"); |
990 assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods"); |
990 assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods"); |
1119 |
1119 |
1120 // ------------------------------------------------------------------ |
1120 // ------------------------------------------------------------------ |
1121 // CompileBroker::compilation_is_complete |
1121 // CompileBroker::compilation_is_complete |
1122 // |
1122 // |
1123 // See if compilation of this method is already complete. |
1123 // See if compilation of this method is already complete. |
1124 bool CompileBroker::compilation_is_complete(methodHandle method, |
1124 bool CompileBroker::compilation_is_complete(const methodHandle& method, |
1125 int osr_bci, |
1125 int osr_bci, |
1126 int comp_level) { |
1126 int comp_level) { |
1127 bool is_osr = (osr_bci != standard_entry_bci); |
1127 bool is_osr = (osr_bci != standard_entry_bci); |
1128 if (is_osr) { |
1128 if (is_osr) { |
1129 if (method->is_not_osr_compilable(comp_level)) { |
1129 if (method->is_not_osr_compilable(comp_level)) { |
1152 * conservative in the sense that an osr compilation in the queue |
1152 * conservative in the sense that an osr compilation in the queue |
1153 * will block a normal compilation from entering the queue (and vice |
1153 * will block a normal compilation from entering the queue (and vice |
1154 * versa). This can be remedied by a full queue search to disambiguate |
1154 * versa). This can be remedied by a full queue search to disambiguate |
1155 * cases. If it is deemed profitable, this may be done. |
1155 * cases. If it is deemed profitable, this may be done. |
1156 */ |
1156 */ |
1157 bool CompileBroker::compilation_is_in_queue(methodHandle method) { |
1157 bool CompileBroker::compilation_is_in_queue(const methodHandle& method) { |
1158 return method->queued_for_compilation(); |
1158 return method->queued_for_compilation(); |
1159 } |
1159 } |
1160 |
1160 |
1161 // ------------------------------------------------------------------ |
1161 // ------------------------------------------------------------------ |
1162 // CompileBroker::compilation_is_prohibited |
1162 // CompileBroker::compilation_is_prohibited |
1163 // |
1163 // |
1164 // See if this compilation is not allowed. |
1164 // See if this compilation is not allowed. |
1165 bool CompileBroker::compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level) { |
1165 bool CompileBroker::compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level) { |
1166 bool is_native = method->is_native(); |
1166 bool is_native = method->is_native(); |
1167 // Some compilers may not support the compilation of natives. |
1167 // Some compilers may not support the compilation of natives. |
1168 AbstractCompiler *comp = compiler(comp_level); |
1168 AbstractCompiler *comp = compiler(comp_level); |
1169 if (is_native && |
1169 if (is_native && |
1170 (!CICompileNatives || comp == NULL || !comp->supports_native())) { |
1170 (!CICompileNatives || comp == NULL || !comp->supports_native())) { |
1203 /** |
1203 /** |
1204 * Generate serialized IDs for compilation requests. If certain debugging flags are used |
1204 * Generate serialized IDs for compilation requests. If certain debugging flags are used |
1205 * and the ID is not within the specified range, the method is not compiled and 0 is returned. |
1205 * and the ID is not within the specified range, the method is not compiled and 0 is returned. |
1206 * The function also allows to generate separate compilation IDs for OSR compilations. |
1206 * The function also allows to generate separate compilation IDs for OSR compilations. |
1207 */ |
1207 */ |
1208 int CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { |
1208 int CompileBroker::assign_compile_id(const methodHandle& method, int osr_bci) { |
1209 #ifdef ASSERT |
1209 #ifdef ASSERT |
1210 bool is_osr = (osr_bci != standard_entry_bci); |
1210 bool is_osr = (osr_bci != standard_entry_bci); |
1211 int id; |
1211 int id; |
1212 if (method->is_native()) { |
1212 if (method->is_native()) { |
1213 assert(!is_osr, "can't be osr"); |
1213 assert(!is_osr, "can't be osr"); |
1238 |
1238 |
1239 // ------------------------------------------------------------------ |
1239 // ------------------------------------------------------------------ |
1240 // CompileBroker::assign_compile_id_unlocked |
1240 // CompileBroker::assign_compile_id_unlocked |
1241 // |
1241 // |
1242 // Public wrapper for assign_compile_id that acquires the needed locks |
1242 // Public wrapper for assign_compile_id that acquires the needed locks |
1243 uint CompileBroker::assign_compile_id_unlocked(Thread* thread, methodHandle method, int osr_bci) { |
1243 uint CompileBroker::assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci) { |
1244 MutexLocker locker(MethodCompileQueue_lock, thread); |
1244 MutexLocker locker(MethodCompileQueue_lock, thread); |
1245 return assign_compile_id(method, osr_bci); |
1245 return assign_compile_id(method, osr_bci); |
1246 } |
1246 } |
1247 |
1247 |
1248 /** |
1248 /** |
1255 } |
1255 } |
1256 |
1256 |
1257 |
1257 |
1258 // ------------------------------------------------------------------ |
1258 // ------------------------------------------------------------------ |
1259 // CompileBroker::preload_classes |
1259 // CompileBroker::preload_classes |
1260 void CompileBroker::preload_classes(methodHandle method, TRAPS) { |
1260 void CompileBroker::preload_classes(const methodHandle& method, TRAPS) { |
1261 // Move this code over from c1_Compiler.cpp |
1261 // Move this code over from c1_Compiler.cpp |
1262 ShouldNotReachHere(); |
1262 ShouldNotReachHere(); |
1263 } |
1263 } |
1264 |
1264 |
1265 |
1265 |
1268 // |
1268 // |
1269 // Create a CompileTask object representing the current request for |
1269 // Create a CompileTask object representing the current request for |
1270 // compilation. Add this task to the queue. |
1270 // compilation. Add this task to the queue. |
1271 CompileTask* CompileBroker::create_compile_task(CompileQueue* queue, |
1271 CompileTask* CompileBroker::create_compile_task(CompileQueue* queue, |
1272 int compile_id, |
1272 int compile_id, |
1273 methodHandle method, |
1273 const methodHandle& method, |
1274 int osr_bci, |
1274 int osr_bci, |
1275 int comp_level, |
1275 int comp_level, |
1276 methodHandle hot_method, |
1276 const methodHandle& hot_method, |
1277 int hot_count, |
1277 int hot_count, |
1278 const char* comment, |
1278 const char* comment, |
1279 bool blocking) { |
1279 bool blocking) { |
1280 CompileTask* new_task = CompileTask::allocate(); |
1280 CompileTask* new_task = CompileTask::allocate(); |
1281 new_task->initialize(compile_id, method, osr_bci, comp_level, |
1281 new_task->initialize(compile_id, method, osr_bci, comp_level, |
1864 |
1864 |
1865 // ------------------------------------------------------------------ |
1865 // ------------------------------------------------------------------ |
1866 // CompileBroker::set_last_compile |
1866 // CompileBroker::set_last_compile |
1867 // |
1867 // |
1868 // Record this compilation for debugging purposes. |
1868 // Record this compilation for debugging purposes. |
1869 void CompileBroker::set_last_compile(CompilerThread* thread, methodHandle method, bool is_osr, int comp_level) { |
1869 void CompileBroker::set_last_compile(CompilerThread* thread, const methodHandle& method, bool is_osr, int comp_level) { |
1870 ResourceMark rm; |
1870 ResourceMark rm; |
1871 char* method_name = method->name()->as_C_string(); |
1871 char* method_name = method->name()->as_C_string(); |
1872 strncpy(_last_method_compiled, method_name, CompileBroker::name_buffer_length); |
1872 strncpy(_last_method_compiled, method_name, CompileBroker::name_buffer_length); |
1873 _last_method_compiled[CompileBroker::name_buffer_length - 1] = '\0'; // ensure null terminated |
1873 _last_method_compiled[CompileBroker::name_buffer_length - 1] = '\0'; // ensure null terminated |
1874 char current_method[CompilerCounters::cmname_buffer_length]; |
1874 char current_method[CompilerCounters::cmname_buffer_length]; |
1950 |
1950 |
1951 // ------------------------------------------------------------------ |
1951 // ------------------------------------------------------------------ |
1952 // CompileBroker::check_break_at |
1952 // CompileBroker::check_break_at |
1953 // |
1953 // |
1954 // Should the compilation break at the current compilation. |
1954 // Should the compilation break at the current compilation. |
1955 bool CompileBroker::check_break_at(methodHandle method, int compile_id, bool is_osr) { |
1955 bool CompileBroker::check_break_at(const methodHandle& method, int compile_id, bool is_osr) { |
1956 if (CICountOSR && is_osr && (compile_id == CIBreakAtOSR)) { |
1956 if (CICountOSR && is_osr && (compile_id == CIBreakAtOSR)) { |
1957 return true; |
1957 return true; |
1958 } else if( CompilerOracle::should_break_at(method) ) { // break when compiling |
1958 } else if( CompilerOracle::should_break_at(method) ) { // break when compiling |
1959 return true; |
1959 return true; |
1960 } else { |
1960 } else { |