< prev index next >

src/share/vm/compiler/compileBroker.cpp

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/symbolTable.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "code/codeCache.hpp"
  30 #include "code/dependencyContext.hpp"
  31 #include "compiler/compileBroker.hpp"
  32 #include "compiler/compileLog.hpp"
  33 #include "compiler/compilerOracle.hpp"
  34 #include "compiler/directivesParser.hpp"
  35 #include "gc/shared/referencePendingListLocker.hpp"
  36 #include "interpreter/linkResolver.hpp"
  37 #include "memory/allocation.inline.hpp"
  38 #include "oops/methodData.hpp"
  39 #include "oops/method.hpp"
  40 #include "oops/oop.inline.hpp"
  41 #include "prims/nativeLookup.hpp"
  42 #include "prims/whitebox.hpp"
  43 #include "runtime/arguments.hpp"
  44 #include "runtime/atomic.inline.hpp"
  45 #include "runtime/compilationPolicy.hpp"
  46 #include "runtime/init.hpp"
  47 #include "runtime/interfaceSupport.hpp"
  48 #include "runtime/javaCalls.hpp"
  49 #include "runtime/os.hpp"
  50 #include "runtime/sharedRuntime.hpp"
  51 #include "runtime/sweeper.hpp"
  52 #include "runtime/timerTrace.hpp"
  53 #include "trace/tracing.hpp"
  54 #include "utilities/dtrace.hpp"
  55 #include "utilities/events.hpp"


 884       // Positive OSROnlyBCI means only compile that bci.  Negative means don't compile that BCI.
 885       return;
 886     }
 887   }
 888 #endif
 889 
 890   // If this method is already in the compile queue, then
 891   // we do not block the current thread.
 892   if (compilation_is_in_queue(method)) {
 893     // We may want to decay our counter a bit here to prevent
 894     // multiple denied requests for compilation.  This is an
 895     // open compilation policy issue. Note: The other possibility,
 896     // in the case that this is a blocking compile request, is to have
 897     // all subsequent blocking requesters wait for completion of
 898     // ongoing compiles. Note that in this case we'll need a protocol
 899     // for freeing the associated compile tasks. [Or we could have
 900     // a single static monitor on which all these waiters sleep.]
 901     return;
 902   }
 903 
 904   // If the requesting thread is holding the pending list lock
 905   // then we just return. We can't risk blocking while holding
 906   // the pending list lock or a 3-way deadlock may occur
 907   // between the reference handler thread, a GC (instigated
 908   // by a compiler thread), and compiled method registration.
 909   if (ReferencePendingListLocker::is_locked_by_self()) {
 910     return;
 911   }
 912 
 913   if (TieredCompilation) {
 914     // Tiered policy requires MethodCounters to exist before adding a method to
 915     // the queue. Create if we don't have them yet.
 916     method->get_method_counters(thread);
 917   }
 918 
 919   // Outputs from the following MutexLocker block:
 920   CompileTask* task     = NULL;
 921   bool         blocking = false;
 922   CompileQueue* queue  = compile_queue(comp_level);
 923 
 924   // Acquire our lock.
 925   {
 926     MutexLocker locker(MethodCompileQueue_lock, thread);
 927 
 928     // Make sure the method has not slipped into the queues since
 929     // last we checked; note that those checks were "fast bail-outs".
 930     // Here we need to be more careful, see 14012000 below.
 931     if (compilation_is_in_queue(method)) {
 932       return;


1294   // CICountOSR is a develop flag and set to 'false' by default. In a product built,
1295   // only _compilation_id is incremented.
1296   return Atomic::add(1, &_compilation_id);
1297 #endif
1298 }
1299 
1300 // ------------------------------------------------------------------
1301 // CompileBroker::assign_compile_id_unlocked
1302 //
1303 // Public wrapper for assign_compile_id that acquires the needed locks
1304 uint CompileBroker::assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci) {
1305   MutexLocker locker(MethodCompileQueue_lock, thread);
1306   return assign_compile_id(method, osr_bci);
1307 }
1308 
1309 /**
1310  * Should the current thread block until this compilation request
1311  * has been fulfilled?
1312  */
1313 bool CompileBroker::is_compile_blocking() {
1314   assert(!ReferencePendingListLocker::is_locked_by_self(), "possible deadlock");
1315   return !BackgroundCompilation;
1316 }
1317 
1318 
1319 // ------------------------------------------------------------------
1320 // CompileBroker::preload_classes
1321 void CompileBroker::preload_classes(const methodHandle& method, TRAPS) {
1322   // Move this code over from c1_Compiler.cpp
1323   ShouldNotReachHere();
1324 }
1325 
1326 
1327 // ------------------------------------------------------------------
1328 // CompileBroker::create_compile_task
1329 //
1330 // Create a CompileTask object representing the current request for
1331 // compilation.  Add this task to the queue.
1332 CompileTask* CompileBroker::create_compile_task(CompileQueue*       queue,
1333                                                 int                 compile_id,
1334                                                 const methodHandle& method,




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/symbolTable.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "code/codeCache.hpp"
  30 #include "code/dependencyContext.hpp"
  31 #include "compiler/compileBroker.hpp"
  32 #include "compiler/compileLog.hpp"
  33 #include "compiler/compilerOracle.hpp"
  34 #include "compiler/directivesParser.hpp"

  35 #include "interpreter/linkResolver.hpp"
  36 #include "memory/allocation.inline.hpp"
  37 #include "oops/methodData.hpp"
  38 #include "oops/method.hpp"
  39 #include "oops/oop.inline.hpp"
  40 #include "prims/nativeLookup.hpp"
  41 #include "prims/whitebox.hpp"
  42 #include "runtime/arguments.hpp"
  43 #include "runtime/atomic.inline.hpp"
  44 #include "runtime/compilationPolicy.hpp"
  45 #include "runtime/init.hpp"
  46 #include "runtime/interfaceSupport.hpp"
  47 #include "runtime/javaCalls.hpp"
  48 #include "runtime/os.hpp"
  49 #include "runtime/sharedRuntime.hpp"
  50 #include "runtime/sweeper.hpp"
  51 #include "runtime/timerTrace.hpp"
  52 #include "trace/tracing.hpp"
  53 #include "utilities/dtrace.hpp"
  54 #include "utilities/events.hpp"


 883       // Positive OSROnlyBCI means only compile that bci.  Negative means don't compile that BCI.
 884       return;
 885     }
 886   }
 887 #endif
 888 
 889   // If this method is already in the compile queue, then
 890   // we do not block the current thread.
 891   if (compilation_is_in_queue(method)) {
 892     // We may want to decay our counter a bit here to prevent
 893     // multiple denied requests for compilation.  This is an
 894     // open compilation policy issue. Note: The other possibility,
 895     // in the case that this is a blocking compile request, is to have
 896     // all subsequent blocking requesters wait for completion of
 897     // ongoing compiles. Note that in this case we'll need a protocol
 898     // for freeing the associated compile tasks. [Or we could have
 899     // a single static monitor on which all these waiters sleep.]
 900     return;
 901   }
 902 









 903   if (TieredCompilation) {
 904     // Tiered policy requires MethodCounters to exist before adding a method to
 905     // the queue. Create if we don't have them yet.
 906     method->get_method_counters(thread);
 907   }
 908 
 909   // Outputs from the following MutexLocker block:
 910   CompileTask* task     = NULL;
 911   bool         blocking = false;
 912   CompileQueue* queue  = compile_queue(comp_level);
 913 
 914   // Acquire our lock.
 915   {
 916     MutexLocker locker(MethodCompileQueue_lock, thread);
 917 
 918     // Make sure the method has not slipped into the queues since
 919     // last we checked; note that those checks were "fast bail-outs".
 920     // Here we need to be more careful, see 14012000 below.
 921     if (compilation_is_in_queue(method)) {
 922       return;


1284   // CICountOSR is a develop flag and set to 'false' by default. In a product built,
1285   // only _compilation_id is incremented.
1286   return Atomic::add(1, &_compilation_id);
1287 #endif
1288 }
1289 
1290 // ------------------------------------------------------------------
1291 // CompileBroker::assign_compile_id_unlocked
1292 //
1293 // Public wrapper for assign_compile_id that acquires the needed locks
1294 uint CompileBroker::assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci) {
1295   MutexLocker locker(MethodCompileQueue_lock, thread);
1296   return assign_compile_id(method, osr_bci);
1297 }
1298 
1299 /**
1300  * Should the current thread block until this compilation request
1301  * has been fulfilled?
1302  */
1303 bool CompileBroker::is_compile_blocking() {

1304   return !BackgroundCompilation;
1305 }
1306 
1307 
1308 // ------------------------------------------------------------------
1309 // CompileBroker::preload_classes
1310 void CompileBroker::preload_classes(const methodHandle& method, TRAPS) {
1311   // Move this code over from c1_Compiler.cpp
1312   ShouldNotReachHere();
1313 }
1314 
1315 
1316 // ------------------------------------------------------------------
1317 // CompileBroker::create_compile_task
1318 //
1319 // Create a CompileTask object representing the current request for
1320 // compilation.  Add this task to the queue.
1321 CompileTask* CompileBroker::create_compile_task(CompileQueue*       queue,
1322                                                 int                 compile_id,
1323                                                 const methodHandle& method,


< prev index next >