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