(original) (raw)

src/share/vm/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File

*** old/src/share/vm/runtime/thread.cpp Wed Sep 16 15:19:09 2015** --- new/src/share/vm/runtime/thread.cpp Wed Sep 16 15:19:08 2015


*** 97,106 **** --- 97,110 ---- #if INCLUDE_ALL_GCS #include "gc/cms/concurrentMarkSweepThread.hpp" #include "gc/g1/concurrentMarkThread.inline.hpp" #include "gc/parallel/pcTasks.hpp" #endif // INCLUDE_ALL_GCS + #if INCLUDE_JVMCI + #include "jvmci/jvmciCompiler.hpp" + #include "jvmci/jvmciRuntime.hpp" + #endif #ifdef COMPILER1 #include "c1/c1_Compiler.hpp" #endif #ifdef COMPILER2 #include "opto/c2compiler.hpp"


*** 1384,1393 **** --- 1388,1424 ---- st->cr(); }
// ======= JavaThread ========
+ #if INCLUDE_JVMCI + + jlong JavaThread::_jvmci_old_thread_counters;* + + bool jvmci_counters_include(JavaThread thread) {* + oop threadObj = thread->threadObj(); + return !JVMCICountersExcludeCompiler || !thread->is_Compiler_thread(); + } + + void JavaThread::collect_counters(typeArrayOop array) { + if (JVMCICounterSize > 0) { + MutexLocker tl(Threads_lock); + for (int i = 0; i < array->length(); i++) { + array->long_at_put(i, _jvmci_old_thread_counters[i]); + } + for (JavaThread tp = Threads::first(); tp != NULL; tp = tp->next()) {* + if (jvmci_counters_include(tp)) { + for (int i = 0; i < array->length(); i++) { + array->long_at_put(i, array->long_at(i) + tp->_jvmci_counters[i]); + } + } + } + } + } + + #endif + // A JavaThread is a normal Java thread
void JavaThread::initialize() { // Initialize fields

*** 1416,1425 **** --- 1447,1470 ---- _array_for_gc = NULL; _suspend_equivalent = false; _in_deopt_handler = 0; _doing_unsafe_access = false; _stack_guard_state = stack_guard_unused; + #if INCLUDE_JVMCI + _pending_monitorenter = false; + _pending_deoptimization = -1; + _pending_failed_speculation = NULL; + _pending_transfer_to_interpreter = false; + _jvmci._alternate_call_target = NULL; + assert(_jvmci._implicit_exception_pc == NULL, "must be"); + if (JVMCICounterSize > 0) { + _jvmci_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal); + memset(_jvmci_counters, 0, sizeof(jlong) * JVMCICounterSize); + } else { + _jvmci_counters = NULL; + } + #endif (void)const_cast<oop&>(_exception_oop = oop(NULL)); _exception_pc = 0; _exception_handler_pc = 0; _is_method_handle_return = 0; _jvmti_thread_state= NULL;


*** 1590,1599 **** --- 1635,1655 ----

// All Java related clean up happens in exit
ThreadSafepointState::destroy(this);
if (_thread_profiler != NULL) delete _thread_profiler;
if (_thread_stat != NULL) delete _thread_stat;

+ + #if INCLUDE_JVMCI + if (JVMCICounterSize > 0) { + if (jvmci_counters_include(this)) { + for (int i = 0; i < JVMCICounterSize; i++) { + _jvmci_old_thread_counters[i] += _jvmci_counters[i]; + } + } + FREE_C_HEAP_ARRAY(jlong, _jvmci_counters); + } + #endif }

// The first routine called by a new Java thread void JavaThread::run() {


*** 2133,2143 **** --- 2189,2199 ---- assert(Threads_lock->is_locked(), "Threads_lock should be locked by safepoint code"); assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped");

// Do not throw asynchronous exceptions against the compiler thread
// (the compiler thread should not be a Java thread -- fix in 1.4.2)

! if (is_Compiler_thread()) return; ! if (!can_call_java()) return;

{
  // Actually throw the Throwable against the target Thread - however
  // only if there is no thread death exception installed already.
  if (_pending_async_exception == NULL || !_pending_async_exception->is_a(SystemDictionary::ThreadDeath_klass())) {

*** 2612,2627 **** --- 2668,2677 ---- if (!has_last_Java_frame()) return; // BiasedLocking needs an updated RegisterMap for the revoke monitors pass StackFrameStream fst(this, UseBiasedLocking); for (; !fst.is_done(); fst.next()) { if (fst.current()->should_be_deoptimized()) { if (LogCompilation && xtty != NULL) { nmethod nm = fst.current()->cb()->as_nmethod_or_null();* xtty->elem("deoptimized thread='" UINTX_FORMAT "' compile_id='%d'", this->name(), nm != NULL ? nm->compile_id() : -1); }

    Deoptimization::deoptimize(this, *fst.current(), fst.register_map());
  }
}

}

*** 2656,2665 **** --- 2706,2717 ---- // since there may be more than one thread using each ThreadProfiler.

// Traverse the GCHandles
Thread::oops_do(f, cld_f, cf);

+ JVMCI_ONLY(f->do_oop((oop)&_pending_failed_speculation);)* + assert((!has_last_Java_frame() && java_call_counter() == 0) || (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!");

if (has_last_Java_frame()) {
  // Record JavaThread to GC thread

*** 3173,3182 **** --- 3225,3238 ---- #ifndef PRODUCT _ideal_graph_printer = NULL; #endif }

+ bool CompilerThread::can_call_java() const { + return _compiler != NULL && _compiler->is_jvmci(); + } + // Create sweeper thread CodeCacheSweeperThread::CodeCacheSweeperThread() : JavaThread(&sweeper_thread_entry) { _scanned_nmethod = NULL; }


*** 3378,3387 **** --- 3434,3452 ---- _number_of_non_daemon_threads = 0;

// Initialize global data structures and create system classes in heap
vm_init_globals();

+ #if INCLUDE_JVMCI + if (JVMCICounterSize > 0) { + JavaThread::_jvmci_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal); + memset(JavaThread::_jvmci_old_thread_counters, 0, sizeof(jlong) * JVMCICounterSize); + } else { + JavaThread::_jvmci_old_thread_counters = NULL; + } + #endif + // Attach the main thread to this os thread JavaThread* main_thread = new JavaThread(); main_thread->set_thread_state(_thread_in_vm); // must do this before set_active_handles and initialize_thread_local_storage // Note: on solaris initialize_thread_local_storage() will (indirectly)


*** 3504,3514 **** --- 3569,3579 ---- // Compute system loader. Note that this has to occur after set_init_completed, since // valid exceptions may be thrown in the process. // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and // set_init_completed has just been called, causing exceptions not to be shortcut // anymore. We call vm_exit_during_initialization directly instead. ! SystemDictionary::compute_java_system_loader(CHECK_(JNI_ERR));

#if INCLUDE_ALL_GCS // Support for ConcurrentMarkSweep. This should be cleaned up // and better encapsulated. The ugly nested if test would go away // once things are properly refactored. XXX YSR


*** 3552,3563 **** --- 3617,3641 ----

if (CleanChunkPoolAsync) {
  Chunk::start_chunk_pool_cleaner_task();
}

+ #if INCLUDE_JVMCI + if (EnableJVMCI) { + const char jvmciCompiler = Arguments::PropertyList_get_value(Arguments::system_properties(), "jvmci.compiler");* + if (jvmciCompiler != NULL) { + JVMCIRuntime::save_compiler(jvmciCompiler); + } + const char jvmciOptions = Arguments::PropertyList_get_value(Arguments::system_properties(), "jvmci.options");* + if (jvmciOptions != NULL) { + JVMCIRuntime::save_options(jvmciOptions); + } + } + #endif + // initialize compiler(s) ! #if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || INCLUDE_JVMCI CompileBroker::compilation_init(); #endif

// Pre-initialize some JSR292 core classes to avoid deadlock during class loading.
// It is done after compilers are initialized, because otherwise compilations of

*** 3961,3970 **** --- 4039,4054 ----

notify_vm_shutdown();

delete thread;

+ #if INCLUDE_JVMCI + if (JVMCICounterSize > 0) { + FREE_C_HEAP_ARRAY(jlong, JavaThread::_jvmci_old_thread_counters); + } + #endif + // exit_globals() will delete tty exit_globals();

return true;

}


*** 4177,4187 **** --- 4261,4271 ----

int i = 0;
{
  MutexLockerEx ml(doLock ? Threads_lock : NULL);
  ALL_JAVA_THREADS(p) {

! if (p->is_Compiler_thread()) continue; ! if (!p->can_call_java()) continue;

    address pending = (address)p->current_pending_monitor();
    if (pending == monitor) {             // found a match
      if (i < count) result->append(p);   // save the first count matches
      i++;

*** 4234,4244 **** --- 4318,4328 ----

// Threads::print_on() is called at safepoint by VM_PrintThreads operation. void Threads::print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks) { char buf[32]; ! st->print_cr("%s", os::local_time_string(buf, sizeof(buf))); ! st->print_raw_cr(os::local_time_string(buf, sizeof(buf)));

st->print_cr("Full thread dump %s (%s %s):",
             Abstract_VM_Version::vm_name(),
             Abstract_VM_Version::vm_release(),
             Abstract_VM_Version::vm_info_string());

src/share/vm/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File