Mercurial > hg > graal-jvmci-8
comparison src/share/vm/compiler/compileBroker.cpp @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | 10c4df6767c4 |
children | 4062efea018b |
comparison
equal
deleted
inserted
replaced
14908:8db6e76cb658 | 14909:4ca6dc0799b6 |
---|---|
61 | 61 |
62 #ifdef DTRACE_ENABLED | 62 #ifdef DTRACE_ENABLED |
63 | 63 |
64 // Only bother with this argument setup if dtrace is available | 64 // Only bother with this argument setup if dtrace is available |
65 | 65 |
66 #ifndef USDT2 | |
67 HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin, | |
68 char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t); | |
69 HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end, | |
70 char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t, bool); | |
71 | |
72 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) \ | |
73 { \ | |
74 Symbol* klass_name = (method)->klass_name(); \ | |
75 Symbol* name = (method)->name(); \ | |
76 Symbol* signature = (method)->signature(); \ | |
77 HS_DTRACE_PROBE8(hotspot, method__compile__begin, \ | |
78 comp_name, strlen(comp_name), \ | |
79 klass_name->bytes(), klass_name->utf8_length(), \ | |
80 name->bytes(), name->utf8_length(), \ | |
81 signature->bytes(), signature->utf8_length()); \ | |
82 } | |
83 | |
84 #define DTRACE_METHOD_COMPILE_END_PROBE(method, comp_name, success) \ | |
85 { \ | |
86 Symbol* klass_name = (method)->klass_name(); \ | |
87 Symbol* name = (method)->name(); \ | |
88 Symbol* signature = (method)->signature(); \ | |
89 HS_DTRACE_PROBE9(hotspot, method__compile__end, \ | |
90 comp_name, strlen(comp_name), \ | |
91 klass_name->bytes(), klass_name->utf8_length(), \ | |
92 name->bytes(), name->utf8_length(), \ | |
93 signature->bytes(), signature->utf8_length(), (success)); \ | |
94 } | |
95 | |
96 #else /* USDT2 */ | |
97 | |
66 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) \ | 98 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) \ |
67 { \ | 99 { \ |
68 Symbol* klass_name = (method)->klass_name(); \ | 100 Symbol* klass_name = (method)->klass_name(); \ |
69 Symbol* name = (method)->name(); \ | 101 Symbol* name = (method)->name(); \ |
70 Symbol* signature = (method)->signature(); \ | 102 Symbol* signature = (method)->signature(); \ |
71 HOTSPOT_METHOD_COMPILE_BEGIN( \ | 103 HOTSPOT_METHOD_COMPILE_BEGIN( \ |
72 (char *) comp_name, strlen(comp_name), \ | 104 comp_name, strlen(comp_name), \ |
73 (char *) klass_name->bytes(), klass_name->utf8_length(), \ | 105 (char *) klass_name->bytes(), klass_name->utf8_length(), \ |
74 (char *) name->bytes(), name->utf8_length(), \ | 106 (char *) name->bytes(), name->utf8_length(), \ |
75 (char *) signature->bytes(), signature->utf8_length()); \ | 107 (char *) signature->bytes(), signature->utf8_length()); \ |
76 } | 108 } |
77 | 109 |
79 { \ | 111 { \ |
80 Symbol* klass_name = (method)->klass_name(); \ | 112 Symbol* klass_name = (method)->klass_name(); \ |
81 Symbol* name = (method)->name(); \ | 113 Symbol* name = (method)->name(); \ |
82 Symbol* signature = (method)->signature(); \ | 114 Symbol* signature = (method)->signature(); \ |
83 HOTSPOT_METHOD_COMPILE_END( \ | 115 HOTSPOT_METHOD_COMPILE_END( \ |
84 (char *) comp_name, strlen(comp_name), \ | 116 comp_name, strlen(comp_name), \ |
85 (char *) klass_name->bytes(), klass_name->utf8_length(), \ | 117 (char *) klass_name->bytes(), klass_name->utf8_length(), \ |
86 (char *) name->bytes(), name->utf8_length(), \ | 118 (char *) name->bytes(), name->utf8_length(), \ |
87 (char *) signature->bytes(), signature->utf8_length(), (success)); \ | 119 (char *) signature->bytes(), signature->utf8_length(), (success)); \ |
88 } | 120 } |
121 #endif /* USDT2 */ | |
89 | 122 |
90 #else // ndef DTRACE_ENABLED | 123 #else // ndef DTRACE_ENABLED |
91 | 124 |
92 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) | 125 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) |
93 #define DTRACE_METHOD_COMPILE_END_PROBE(method, comp_name, success) | 126 #define DTRACE_METHOD_COMPILE_END_PROBE(method, comp_name, success) |
100 volatile jint CompileBroker::_should_compile_new_jobs = run_compilation; | 133 volatile jint CompileBroker::_should_compile_new_jobs = run_compilation; |
101 | 134 |
102 // The installed compiler(s) | 135 // The installed compiler(s) |
103 AbstractCompiler* CompileBroker::_compilers[2]; | 136 AbstractCompiler* CompileBroker::_compilers[2]; |
104 | 137 |
105 // These counters are used to assign an unique ID to each compilation. | 138 // These counters are used for assigning id's to each compilation |
106 volatile jint CompileBroker::_compilation_id = 0; | 139 uint CompileBroker::_compilation_id = 0; |
107 volatile jint CompileBroker::_osr_compilation_id = 0; | 140 uint CompileBroker::_osr_compilation_id = 0; |
108 | 141 |
109 // Debugging information | 142 // Debugging information |
110 int CompileBroker::_last_compile_type = no_compile; | 143 int CompileBroker::_last_compile_type = no_compile; |
111 int CompileBroker::_last_compile_level = CompLevel_none; | 144 int CompileBroker::_last_compile_level = CompLevel_none; |
112 char CompileBroker::_last_method_compiled[CompileBroker::name_buffer_length]; | 145 char CompileBroker::_last_method_compiled[CompileBroker::name_buffer_length]; |
931 // in that case. However, since this must work and we do not allow | 964 // in that case. However, since this must work and we do not allow |
932 // exceptions anyway, check and abort if this fails. | 965 // exceptions anyway, check and abort if this fails. |
933 | 966 |
934 if (compiler_thread == NULL || compiler_thread->osthread() == NULL){ | 967 if (compiler_thread == NULL || compiler_thread->osthread() == NULL){ |
935 vm_exit_during_initialization("java.lang.OutOfMemoryError", | 968 vm_exit_during_initialization("java.lang.OutOfMemoryError", |
936 os::native_thread_creation_failed_msg()); | 969 "unable to create new native thread"); |
937 } | 970 } |
938 | 971 |
939 java_lang_Thread::set_thread(thread_oop(), compiler_thread); | 972 java_lang_Thread::set_thread(thread_oop(), compiler_thread); |
940 | 973 |
941 // Note that this only sets the JavaThread _priority field, which by | 974 // Note that this only sets the JavaThread _priority field, which by |
1152 } | 1185 } |
1153 | 1186 |
1154 // We now know that this compilation is not pending, complete, | 1187 // We now know that this compilation is not pending, complete, |
1155 // or prohibited. Assign a compile_id to this compilation | 1188 // or prohibited. Assign a compile_id to this compilation |
1156 // and check to see if it is in our [Start..Stop) range. | 1189 // and check to see if it is in our [Start..Stop) range. |
1157 int compile_id = assign_compile_id(method, osr_bci); | 1190 uint compile_id = assign_compile_id(method, osr_bci); |
1158 if (compile_id == 0) { | 1191 if (compile_id == 0) { |
1159 // The compilation falls outside the allowed range. | 1192 // The compilation falls outside the allowed range. |
1160 return; | 1193 return; |
1161 } | 1194 } |
1162 | 1195 |
1299 } | 1332 } |
1300 | 1333 |
1301 // do the compilation | 1334 // do the compilation |
1302 if (method->is_native()) { | 1335 if (method->is_native()) { |
1303 if (!PreferInterpreterNativeStubs || method->is_method_handle_intrinsic()) { | 1336 if (!PreferInterpreterNativeStubs || method->is_method_handle_intrinsic()) { |
1337 // Acquire our lock. | |
1338 int compile_id; | |
1339 { | |
1340 MutexLocker locker(MethodCompileQueue_lock, THREAD); | |
1341 compile_id = assign_compile_id(method, standard_entry_bci); | |
1342 } | |
1304 // To properly handle the appendix argument for out-of-line calls we are using a small trampoline that | 1343 // To properly handle the appendix argument for out-of-line calls we are using a small trampoline that |
1305 // pops off the appendix argument and jumps to the target (see gen_special_dispatch in SharedRuntime). | 1344 // pops off the appendix argument and jumps to the target (see gen_special_dispatch in SharedRuntime). |
1306 // | 1345 // |
1307 // Since normal compiled-to-compiled calls are not able to handle such a thing we MUST generate an adapter | 1346 // Since normal compiled-to-compiled calls are not able to handle such a thing we MUST generate an adapter |
1308 // in this case. If we can't generate one and use it we can not execute the out-of-line method handle calls. | 1347 // in this case. If we can't generate one and use it we can not execute the out-of-line method handle calls. |
1309 AdapterHandlerLibrary::create_native_wrapper(method); | 1348 (void) AdapterHandlerLibrary::create_native_wrapper(method, compile_id); |
1310 } else { | 1349 } else { |
1311 return NULL; | 1350 return NULL; |
1312 } | 1351 } |
1313 } else { | 1352 } else { |
1314 // If the compiler is shut off due to code cache getting full | 1353 // If the compiler is shut off due to code cache getting full |
1407 } | 1446 } |
1408 | 1447 |
1409 return false; | 1448 return false; |
1410 } | 1449 } |
1411 | 1450 |
1412 /** | 1451 |
1413 * Generate serialized IDs for compilation requests. If certain debugging flags are used | 1452 // ------------------------------------------------------------------ |
1414 * and the ID is not within the specified range, the method is not compiled and 0 is returned. | 1453 // CompileBroker::assign_compile_id |
1415 * The function also allows to generate separate compilation IDs for OSR compilations. | 1454 // |
1416 */ | 1455 // Assign a serialized id number to this compilation request. If the |
1417 int CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { | 1456 // number falls out of the allowed range, return a 0. OSR |
1418 #ifdef ASSERT | 1457 // compilations may be numbered separately from regular compilations |
1458 // if certain debugging flags are used. | |
1459 uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { | |
1460 assert(MethodCompileQueue_lock->owner() == Thread::current(), | |
1461 "must hold the compilation queue lock"); | |
1419 bool is_osr = (osr_bci != standard_entry_bci); | 1462 bool is_osr = (osr_bci != standard_entry_bci); |
1420 int id; | 1463 uint id; |
1421 if (method->is_native()) { | 1464 if (CICountOSR && is_osr) { |
1422 assert(!is_osr, "can't be osr"); | 1465 id = ++_osr_compilation_id; |
1423 // Adapters, native wrappers and method handle intrinsics | 1466 if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) { |
1424 // should be generated always. | |
1425 return Atomic::add(1, &_compilation_id); | |
1426 } else if (CICountOSR && is_osr) { | |
1427 id = Atomic::add(1, &_osr_compilation_id); | |
1428 if (CIStartOSR <= id && id < CIStopOSR) { | |
1429 return id; | 1467 return id; |
1430 } | 1468 } |
1431 } else { | 1469 } else { |
1432 id = Atomic::add(1, &_compilation_id); | 1470 id = ++_compilation_id; |
1433 if (CIStart <= id && id < CIStop) { | 1471 if ((uint)CIStart <= id && id < (uint)CIStop) { |
1434 return id; | 1472 return id; |
1435 } | 1473 } |
1436 } | 1474 } |
1437 | 1475 |
1438 // Method was not in the appropriate compilation range. | 1476 // Method was not in the appropriate compilation range. |
1439 method->set_not_compilable_quietly(); | 1477 method->set_not_compilable_quietly(); |
1440 return 0; | 1478 return 0; |
1441 #else | |
1442 // CICountOSR is a develop flag and set to 'false' by default. In a product built, | |
1443 // only _compilation_id is incremented. | |
1444 return Atomic::add(1, &_compilation_id); | |
1445 #endif | |
1446 } | 1479 } |
1447 | 1480 |
1448 | 1481 |
1449 // ------------------------------------------------------------------ | 1482 // ------------------------------------------------------------------ |
1450 // CompileBroker::assign_compile_id_unlocked | 1483 // CompileBroker::assign_compile_id_unlocked |