--- old/src/share/vm/runtime/thread.cpp 2014-10-13 17:32:20.804926189 +0200 +++ new/src/share/vm/runtime/thread.cpp 2014-10-13 17:32:19.664926232 +0200 @@ -66,6 +66,7 @@ #include "runtime/sharedRuntime.hpp" #include "runtime/statSampler.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/sweeper.hpp" #include "runtime/task.hpp" #include "runtime/thread.inline.hpp" #include "runtime/threadCritical.hpp" @@ -1550,6 +1551,7 @@ // Remove this ifdef when C1 is ported to the compiler interface. static void compiler_thread_entry(JavaThread* thread, TRAPS); +static void sweeper_thread_entry(JavaThread* thread, TRAPS); JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) : Thread() @@ -3169,6 +3171,10 @@ CompileBroker::compiler_thread_loop(); } +static void sweeper_thread_entry(JavaThread* thread, TRAPS) { + NMethodSweeper::sweeper_loop(); +} + // Create a CompilerThread CompilerThread::CompilerThread(CompileQueue* queue, CompilerCounters* counters) @@ -3179,7 +3185,6 @@ _queue = queue; _counters = counters; _buffer_blob = NULL; - _scanned_nmethod = NULL; _compiler = NULL; #ifndef PRODUCT @@ -3187,7 +3192,12 @@ #endif } -void CompilerThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { +// Create sweeper thread +CodeCacheSweeperThread::CodeCacheSweeperThread() +: JavaThread(&sweeper_thread_entry) { + _scanned_nmethod = NULL; +} +void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { JavaThread::oops_do(f, cld_f, cf); if (_scanned_nmethod != NULL && cf != NULL) { // Safepoints can occur when the sweeper is scanning an nmethod so