1.1 --- a/src/share/vm/compiler/compileBroker.cpp Thu Jan 16 14:25:51 2014 +0100 1.2 +++ b/src/share/vm/compiler/compileBroker.cpp Wed Jan 22 17:42:23 2014 -0800 1.3 @@ -132,9 +132,9 @@ 1.4 // The installed compiler(s) 1.5 AbstractCompiler* CompileBroker::_compilers[2]; 1.6 1.7 -// These counters are used for assigning id's to each compilation 1.8 -uint CompileBroker::_compilation_id = 0; 1.9 -uint CompileBroker::_osr_compilation_id = 0; 1.10 +// These counters are used to assign an unique ID to each compilation. 1.11 +volatile jint CompileBroker::_compilation_id = 0; 1.12 +volatile jint CompileBroker::_osr_compilation_id = 0; 1.13 1.14 // Debugging information 1.15 int CompileBroker::_last_compile_type = no_compile; 1.16 @@ -1158,7 +1158,7 @@ 1.17 // We now know that this compilation is not pending, complete, 1.18 // or prohibited. Assign a compile_id to this compilation 1.19 // and check to see if it is in our [Start..Stop) range. 1.20 - uint compile_id = assign_compile_id(method, osr_bci); 1.21 + int compile_id = assign_compile_id(method, osr_bci); 1.22 if (compile_id == 0) { 1.23 // The compilation falls outside the allowed range. 1.24 return; 1.25 @@ -1305,18 +1305,12 @@ 1.26 // do the compilation 1.27 if (method->is_native()) { 1.28 if (!PreferInterpreterNativeStubs || method->is_method_handle_intrinsic()) { 1.29 - // Acquire our lock. 1.30 - int compile_id; 1.31 - { 1.32 - MutexLocker locker(MethodCompileQueue_lock, THREAD); 1.33 - compile_id = assign_compile_id(method, standard_entry_bci); 1.34 - } 1.35 // To properly handle the appendix argument for out-of-line calls we are using a small trampoline that 1.36 // pops off the appendix argument and jumps to the target (see gen_special_dispatch in SharedRuntime). 1.37 // 1.38 // Since normal compiled-to-compiled calls are not able to handle such a thing we MUST generate an adapter 1.39 // in this case. If we can't generate one and use it we can not execute the out-of-line method handle calls. 1.40 - (void) AdapterHandlerLibrary::create_native_wrapper(method, compile_id); 1.41 + AdapterHandlerLibrary::create_native_wrapper(method); 1.42 } else { 1.43 return NULL; 1.44 } 1.45 @@ -1419,27 +1413,28 @@ 1.46 return false; 1.47 } 1.48 1.49 - 1.50 -// ------------------------------------------------------------------ 1.51 -// CompileBroker::assign_compile_id 1.52 -// 1.53 -// Assign a serialized id number to this compilation request. If the 1.54 -// number falls out of the allowed range, return a 0. OSR 1.55 -// compilations may be numbered separately from regular compilations 1.56 -// if certain debugging flags are used. 1.57 -uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { 1.58 - assert(MethodCompileQueue_lock->owner() == Thread::current(), 1.59 - "must hold the compilation queue lock"); 1.60 +/** 1.61 + * Generate serialized IDs for compilation requests. If certain debugging flags are used 1.62 + * and the ID is not within the specified range, the method is not compiled and 0 is returned. 1.63 + * The function also allows to generate separate compilation IDs for OSR compilations. 1.64 + */ 1.65 +int CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { 1.66 +#ifdef ASSERT 1.67 bool is_osr = (osr_bci != standard_entry_bci); 1.68 - uint id; 1.69 - if (CICountOSR && is_osr) { 1.70 - id = ++_osr_compilation_id; 1.71 - if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) { 1.72 + int id; 1.73 + if (method->is_native()) { 1.74 + assert(!is_osr, "can't be osr"); 1.75 + // Adapters, native wrappers and method handle intrinsics 1.76 + // should be generated always. 1.77 + return Atomic::add(1, &_compilation_id); 1.78 + } else if (CICountOSR && is_osr) { 1.79 + id = Atomic::add(1, &_osr_compilation_id); 1.80 + if (CIStartOSR <= id && id < CIStopOSR) { 1.81 return id; 1.82 } 1.83 } else { 1.84 - id = ++_compilation_id; 1.85 - if ((uint)CIStart <= id && id < (uint)CIStop) { 1.86 + id = Atomic::add(1, &_compilation_id); 1.87 + if (CIStart <= id && id < CIStop) { 1.88 return id; 1.89 } 1.90 } 1.91 @@ -1447,6 +1442,11 @@ 1.92 // Method was not in the appropriate compilation range. 1.93 method->set_not_compilable_quietly(); 1.94 return 0; 1.95 +#else 1.96 + // CICountOSR is a develop flag and set to 'false' by default. In a product built, 1.97 + // only _compilation_id is incremented. 1.98 + return Atomic::add(1, &_compilation_id); 1.99 +#endif 1.100 } 1.101 1.102