< prev index next >

src/hotspot/share/runtime/javaThread.cpp

Print this page
@@ -486,10 +486,12 @@
    _cont_fastpath(0),
    _cont_fastpath_thread_state(1),
    _held_monitor_count(0),
    _jni_monitor_count(0),
  
+   _can_call_java(true),
+ 
    _handshake(this),
  
    _popframe_preserved_args(nullptr),
    _popframe_preserved_args_size(0),
  

@@ -499,10 +501,11 @@
    _thread_stat(new ThreadStatistics()),
  
    _parker(),
  
    _class_to_be_initialized(nullptr),
+   _class_being_initialized(nullptr),
  
    _SleepEvent(ParkEvent::Allocate(this)),
  
    _lock_stack(this) {
    set_jni_functions(jni_functions());

@@ -961,11 +964,11 @@
    }
  
    // We need to cache the thread name for logging purposes below as once
    // we have called on_thread_detach this thread must not access any oops.
    char* thread_name = nullptr;
-   if (log_is_enabled(Debug, os, thread, timer)) {
+   if (log_is_enabled(Debug, os, thread, timer) || (CountBytecodesPerThread && log_is_enabled(Info, init))) {
      ResourceMark rm(this);
      thread_name = os::strdup(name());
    }
  
    if (log_is_enabled(Info, os, thread)) {

@@ -988,10 +991,15 @@
        }
      }
    }
  #endif // INCLUDE_JVMCI
  
+   if (bc_counter_value() > 0) {
+     log_info(init)("Thread '%s': " JLONG_FORMAT " bytecodes executed (during clinit: " JLONG_FORMAT ")",
+                    thread_name, bc_counter_value(), clinit_bc_counter_value());
+   }
+ 
    // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread.
    // We call BarrierSet::barrier_set()->on_thread_detach() here so no touching of oops after this point.
    Threads::remove(this, daemon);
  
    if (log_is_enabled(Debug, os, thread, timer)) {

@@ -1745,30 +1753,35 @@
  // This is the external format, selecting the platform or vthread
  // as applicable, and allowing for a native-only stack.
  void JavaThread::print_jni_stack() {
    assert(this == JavaThread::current(), "Can't print stack of other threads");
    if (!has_last_Java_frame()) {
-     ResourceMark rm(this);
-     char* buf = NEW_RESOURCE_ARRAY_RETURN_NULL(char, O_BUFLEN);
-     if (buf == nullptr) {
-       tty->print_cr("Unable to print native stack - out of memory");
-       return;
-     }
-     address lastpc = nullptr;
-     if (os::platform_print_native_stack(tty, nullptr, buf, O_BUFLEN, lastpc)) {
-       // We have printed the native stack in platform-specific code,
-       // so nothing else to do in this case.
-     } else {
-       frame f = os::current_frame();
-       VMError::print_native_stack(tty, f, this, true /*print_source_info */,
-                                   -1 /* max stack */, buf, O_BUFLEN);
-     }
+     print_native_stack_on(tty);
    } else {
      print_active_stack_on(tty);
    }
  }
  
+ void JavaThread::print_native_stack_on(outputStream *st) {
+   assert(this == JavaThread::current(), "Can't print stack of other threads");
+   ResourceMark rm;
+   char* buf = NEW_RESOURCE_ARRAY_RETURN_NULL(char, O_BUFLEN);
+   if (buf == nullptr) {
+     st->print_cr("Unable to print native stack - out of memory");
+     return;
+   }
+   address lastpc = nullptr;
+   if (os::platform_print_native_stack(st, nullptr, buf, O_BUFLEN, lastpc)) {
+     // We have printed the native stack in platform-specific code,
+     // so nothing else to do in this case.
+   } else {
+     frame f = os::current_frame();
+     VMError::print_native_stack(st, f, this, true /*print_source_info */,
+                                 -1 /* max stack */, buf, O_BUFLEN);
+   }
+ }
+ 
  void JavaThread::print_stack_on(outputStream* st) {
    if (!has_last_Java_frame()) return;
  
    Thread* current_thread = Thread::current();
    ResourceMark rm(current_thread);
< prev index next >