hotspot/src/share/vm/runtime/thread.cpp
changeset 27420 04e6f914cce1
parent 27164 6523fa019ffa
child 27429 4ccd0992d680
equal deleted inserted replaced
27419:a934f24b4dcf 27420:04e6f914cce1
    64 #include "runtime/osThread.hpp"
    64 #include "runtime/osThread.hpp"
    65 #include "runtime/safepoint.hpp"
    65 #include "runtime/safepoint.hpp"
    66 #include "runtime/sharedRuntime.hpp"
    66 #include "runtime/sharedRuntime.hpp"
    67 #include "runtime/statSampler.hpp"
    67 #include "runtime/statSampler.hpp"
    68 #include "runtime/stubRoutines.hpp"
    68 #include "runtime/stubRoutines.hpp"
       
    69 #include "runtime/sweeper.hpp"
    69 #include "runtime/task.hpp"
    70 #include "runtime/task.hpp"
    70 #include "runtime/thread.inline.hpp"
    71 #include "runtime/thread.inline.hpp"
    71 #include "runtime/threadCritical.hpp"
    72 #include "runtime/threadCritical.hpp"
    72 #include "runtime/threadLocalStorage.hpp"
    73 #include "runtime/threadLocalStorage.hpp"
    73 #include "runtime/vframe.hpp"
    74 #include "runtime/vframe.hpp"
  1549 }
  1550 }
  1550 
  1551 
  1551 
  1552 
  1552 // Remove this ifdef when C1 is ported to the compiler interface.
  1553 // Remove this ifdef when C1 is ported to the compiler interface.
  1553 static void compiler_thread_entry(JavaThread* thread, TRAPS);
  1554 static void compiler_thread_entry(JavaThread* thread, TRAPS);
       
  1555 static void sweeper_thread_entry(JavaThread* thread, TRAPS);
  1554 
  1556 
  1555 JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) :
  1557 JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) :
  1556                        Thread()
  1558                        Thread()
  1557 #if INCLUDE_ALL_GCS
  1559 #if INCLUDE_ALL_GCS
  1558                        , _satb_mark_queue(&_satb_mark_queue_set),
  1560                        , _satb_mark_queue(&_satb_mark_queue_set),
  3168 static void compiler_thread_entry(JavaThread* thread, TRAPS) {
  3170 static void compiler_thread_entry(JavaThread* thread, TRAPS) {
  3169   assert(thread->is_Compiler_thread(), "must be compiler thread");
  3171   assert(thread->is_Compiler_thread(), "must be compiler thread");
  3170   CompileBroker::compiler_thread_loop();
  3172   CompileBroker::compiler_thread_loop();
  3171 }
  3173 }
  3172 
  3174 
       
  3175 static void sweeper_thread_entry(JavaThread* thread, TRAPS) {
       
  3176   NMethodSweeper::sweeper_loop();
       
  3177 }
       
  3178 
  3173 // Create a CompilerThread
  3179 // Create a CompilerThread
  3174 CompilerThread::CompilerThread(CompileQueue* queue,
  3180 CompilerThread::CompilerThread(CompileQueue* queue,
  3175                                CompilerCounters* counters)
  3181                                CompilerCounters* counters)
  3176                                : JavaThread(&compiler_thread_entry) {
  3182                                : JavaThread(&compiler_thread_entry) {
  3177   _env   = NULL;
  3183   _env   = NULL;
  3178   _log   = NULL;
  3184   _log   = NULL;
  3179   _task  = NULL;
  3185   _task  = NULL;
  3180   _queue = queue;
  3186   _queue = queue;
  3181   _counters = counters;
  3187   _counters = counters;
  3182   _buffer_blob = NULL;
  3188   _buffer_blob = NULL;
  3183   _scanned_nmethod = NULL;
       
  3184   _compiler = NULL;
  3189   _compiler = NULL;
  3185 
  3190 
  3186 #ifndef PRODUCT
  3191 #ifndef PRODUCT
  3187   _ideal_graph_printer = NULL;
  3192   _ideal_graph_printer = NULL;
  3188 #endif
  3193 #endif
  3189 }
  3194 }
  3190 
  3195 
  3191 void CompilerThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
  3196 // Create sweeper thread
       
  3197 CodeCacheSweeperThread::CodeCacheSweeperThread()
       
  3198 : JavaThread(&sweeper_thread_entry) {
       
  3199   _scanned_nmethod = NULL;
       
  3200 }
       
  3201 void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
  3192   JavaThread::oops_do(f, cld_f, cf);
  3202   JavaThread::oops_do(f, cld_f, cf);
  3193   if (_scanned_nmethod != NULL && cf != NULL) {
  3203   if (_scanned_nmethod != NULL && cf != NULL) {
  3194     // Safepoints can occur when the sweeper is scanning an nmethod so
  3204     // Safepoints can occur when the sweeper is scanning an nmethod so
  3195     // process it here to make sure it isn't unloaded in the middle of
  3205     // process it here to make sure it isn't unloaded in the middle of
  3196     // a scan.
  3206     // a scan.