Mercurial > hg > truffle
diff 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 |
line wrap: on
line diff
--- a/src/share/vm/compiler/compileBroker.cpp Tue Apr 01 14:09:03 2014 +0200 +++ b/src/share/vm/compiler/compileBroker.cpp Tue Apr 01 13:57:07 2014 +0200 @@ -63,13 +63,45 @@ // Only bother with this argument setup if dtrace is available +#ifndef USDT2 +HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin, + char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t); +HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end, + char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t, bool); + +#define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) \ + { \ + Symbol* klass_name = (method)->klass_name(); \ + Symbol* name = (method)->name(); \ + Symbol* signature = (method)->signature(); \ + HS_DTRACE_PROBE8(hotspot, method__compile__begin, \ + comp_name, strlen(comp_name), \ + klass_name->bytes(), klass_name->utf8_length(), \ + name->bytes(), name->utf8_length(), \ + signature->bytes(), signature->utf8_length()); \ + } + +#define DTRACE_METHOD_COMPILE_END_PROBE(method, comp_name, success) \ + { \ + Symbol* klass_name = (method)->klass_name(); \ + Symbol* name = (method)->name(); \ + Symbol* signature = (method)->signature(); \ + HS_DTRACE_PROBE9(hotspot, method__compile__end, \ + comp_name, strlen(comp_name), \ + klass_name->bytes(), klass_name->utf8_length(), \ + name->bytes(), name->utf8_length(), \ + signature->bytes(), signature->utf8_length(), (success)); \ + } + +#else /* USDT2 */ + #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) \ { \ Symbol* klass_name = (method)->klass_name(); \ Symbol* name = (method)->name(); \ Symbol* signature = (method)->signature(); \ HOTSPOT_METHOD_COMPILE_BEGIN( \ - (char *) comp_name, strlen(comp_name), \ + comp_name, strlen(comp_name), \ (char *) klass_name->bytes(), klass_name->utf8_length(), \ (char *) name->bytes(), name->utf8_length(), \ (char *) signature->bytes(), signature->utf8_length()); \ @@ -81,11 +113,12 @@ Symbol* name = (method)->name(); \ Symbol* signature = (method)->signature(); \ HOTSPOT_METHOD_COMPILE_END( \ - (char *) comp_name, strlen(comp_name), \ + comp_name, strlen(comp_name), \ (char *) klass_name->bytes(), klass_name->utf8_length(), \ (char *) name->bytes(), name->utf8_length(), \ (char *) signature->bytes(), signature->utf8_length(), (success)); \ } +#endif /* USDT2 */ #else // ndef DTRACE_ENABLED @@ -102,9 +135,9 @@ // The installed compiler(s) AbstractCompiler* CompileBroker::_compilers[2]; -// These counters are used to assign an unique ID to each compilation. -volatile jint CompileBroker::_compilation_id = 0; -volatile jint CompileBroker::_osr_compilation_id = 0; +// These counters are used for assigning id's to each compilation +uint CompileBroker::_compilation_id = 0; +uint CompileBroker::_osr_compilation_id = 0; // Debugging information int CompileBroker::_last_compile_type = no_compile; @@ -933,7 +966,7 @@ if (compiler_thread == NULL || compiler_thread->osthread() == NULL){ vm_exit_during_initialization("java.lang.OutOfMemoryError", - os::native_thread_creation_failed_msg()); + "unable to create new native thread"); } java_lang_Thread::set_thread(thread_oop(), compiler_thread); @@ -1154,7 +1187,7 @@ // We now know that this compilation is not pending, complete, // or prohibited. Assign a compile_id to this compilation // and check to see if it is in our [Start..Stop) range. - int compile_id = assign_compile_id(method, osr_bci); + uint compile_id = assign_compile_id(method, osr_bci); if (compile_id == 0) { // The compilation falls outside the allowed range. return; @@ -1301,12 +1334,18 @@ // do the compilation if (method->is_native()) { if (!PreferInterpreterNativeStubs || method->is_method_handle_intrinsic()) { + // Acquire our lock. + int compile_id; + { + MutexLocker locker(MethodCompileQueue_lock, THREAD); + compile_id = assign_compile_id(method, standard_entry_bci); + } // To properly handle the appendix argument for out-of-line calls we are using a small trampoline that // pops off the appendix argument and jumps to the target (see gen_special_dispatch in SharedRuntime). // // Since normal compiled-to-compiled calls are not able to handle such a thing we MUST generate an adapter // in this case. If we can't generate one and use it we can not execute the out-of-line method handle calls. - AdapterHandlerLibrary::create_native_wrapper(method); + (void) AdapterHandlerLibrary::create_native_wrapper(method, compile_id); } else { return NULL; } @@ -1409,28 +1448,27 @@ return false; } -/** - * Generate serialized IDs for compilation requests. If certain debugging flags are used - * and the ID is not within the specified range, the method is not compiled and 0 is returned. - * The function also allows to generate separate compilation IDs for OSR compilations. - */ -int CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { -#ifdef ASSERT + +// ------------------------------------------------------------------ +// CompileBroker::assign_compile_id +// +// Assign a serialized id number to this compilation request. If the +// number falls out of the allowed range, return a 0. OSR +// compilations may be numbered separately from regular compilations +// if certain debugging flags are used. +uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { + assert(MethodCompileQueue_lock->owner() == Thread::current(), + "must hold the compilation queue lock"); bool is_osr = (osr_bci != standard_entry_bci); - int id; - if (method->is_native()) { - assert(!is_osr, "can't be osr"); - // Adapters, native wrappers and method handle intrinsics - // should be generated always. - return Atomic::add(1, &_compilation_id); - } else if (CICountOSR && is_osr) { - id = Atomic::add(1, &_osr_compilation_id); - if (CIStartOSR <= id && id < CIStopOSR) { + uint id; + if (CICountOSR && is_osr) { + id = ++_osr_compilation_id; + if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) { return id; } } else { - id = Atomic::add(1, &_compilation_id); - if (CIStart <= id && id < CIStop) { + id = ++_compilation_id; + if ((uint)CIStart <= id && id < (uint)CIStop) { return id; } } @@ -1438,11 +1476,6 @@ // Method was not in the appropriate compilation range. method->set_not_compilable_quietly(); return 0; -#else - // CICountOSR is a develop flag and set to 'false' by default. In a product built, - // only _compilation_id is incremented. - return Atomic::add(1, &_compilation_id); -#endif }