src/hotspot/share/prims/jvm.cpp
changeset 50113 caf115bb98ad
parent 50063 50c0d24d3971
child 50217 843fc56f4686
equal deleted inserted replaced
50112:7a2a740815b7 50113:caf115bb98ad
    35 #include "classfile/stringTable.hpp"
    35 #include "classfile/stringTable.hpp"
    36 #include "classfile/systemDictionary.hpp"
    36 #include "classfile/systemDictionary.hpp"
    37 #include "classfile/vmSymbols.hpp"
    37 #include "classfile/vmSymbols.hpp"
    38 #include "gc/shared/collectedHeap.inline.hpp"
    38 #include "gc/shared/collectedHeap.inline.hpp"
    39 #include "interpreter/bytecode.hpp"
    39 #include "interpreter/bytecode.hpp"
       
    40 #include "jfr/jfrEvents.hpp"
    40 #include "memory/oopFactory.hpp"
    41 #include "memory/oopFactory.hpp"
    41 #include "memory/referenceType.hpp"
    42 #include "memory/referenceType.hpp"
    42 #include "memory/resourceArea.hpp"
    43 #include "memory/resourceArea.hpp"
    43 #include "memory/universe.hpp"
    44 #include "memory/universe.hpp"
    44 #include "oops/access.inline.hpp"
    45 #include "oops/access.inline.hpp"
    73 #include "runtime/vm_operations.hpp"
    74 #include "runtime/vm_operations.hpp"
    74 #include "runtime/vm_version.hpp"
    75 #include "runtime/vm_version.hpp"
    75 #include "services/attachListener.hpp"
    76 #include "services/attachListener.hpp"
    76 #include "services/management.hpp"
    77 #include "services/management.hpp"
    77 #include "services/threadService.hpp"
    78 #include "services/threadService.hpp"
    78 #include "trace/tracing.hpp"
       
    79 #include "utilities/copy.hpp"
    79 #include "utilities/copy.hpp"
    80 #include "utilities/defaultStream.hpp"
    80 #include "utilities/defaultStream.hpp"
    81 #include "utilities/dtrace.hpp"
    81 #include "utilities/dtrace.hpp"
    82 #include "utilities/events.hpp"
    82 #include "utilities/events.hpp"
    83 #include "utilities/histogram.hpp"
    83 #include "utilities/histogram.hpp"
  2981   if (os::dont_yield()) return;
  2981   if (os::dont_yield()) return;
  2982   HOTSPOT_THREAD_YIELD();
  2982   HOTSPOT_THREAD_YIELD();
  2983   os::naked_yield();
  2983   os::naked_yield();
  2984 JVM_END
  2984 JVM_END
  2985 
  2985 
       
  2986 static void post_thread_sleep_event(EventThreadSleep* event, jlong millis) {
       
  2987   assert(event != NULL, "invariant");
       
  2988   assert(event->should_commit(), "invariant");
       
  2989   event->set_time(millis);
       
  2990   event->commit();
       
  2991 }
  2986 
  2992 
  2987 JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis))
  2993 JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis))
  2988   JVMWrapper("JVM_Sleep");
  2994   JVMWrapper("JVM_Sleep");
  2989 
  2995 
  2990   if (millis < 0) {
  2996   if (millis < 0) {
  2998   // Save current thread state and restore it at the end of this block.
  3004   // Save current thread state and restore it at the end of this block.
  2999   // And set new thread state to SLEEPING.
  3005   // And set new thread state to SLEEPING.
  3000   JavaThreadSleepState jtss(thread);
  3006   JavaThreadSleepState jtss(thread);
  3001 
  3007 
  3002   HOTSPOT_THREAD_SLEEP_BEGIN(millis);
  3008   HOTSPOT_THREAD_SLEEP_BEGIN(millis);
  3003 
       
  3004   EventThreadSleep event;
  3009   EventThreadSleep event;
  3005 
  3010 
  3006   if (millis == 0) {
  3011   if (millis == 0) {
  3007     os::naked_yield();
  3012     os::naked_yield();
  3008   } else {
  3013   } else {
  3011     if (os::sleep(thread, millis, true) == OS_INTRPT) {
  3016     if (os::sleep(thread, millis, true) == OS_INTRPT) {
  3012       // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on
  3017       // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on
  3013       // us while we were sleeping. We do not overwrite those.
  3018       // us while we were sleeping. We do not overwrite those.
  3014       if (!HAS_PENDING_EXCEPTION) {
  3019       if (!HAS_PENDING_EXCEPTION) {
  3015         if (event.should_commit()) {
  3020         if (event.should_commit()) {
  3016           event.set_time(millis);
  3021           post_thread_sleep_event(&event, millis);
  3017           event.commit();
       
  3018         }
  3022         }
  3019         HOTSPOT_THREAD_SLEEP_END(1);
  3023         HOTSPOT_THREAD_SLEEP_END(1);
  3020 
  3024 
  3021         // TODO-FIXME: THROW_MSG returns which means we will not call set_state()
  3025         // TODO-FIXME: THROW_MSG returns which means we will not call set_state()
  3022         // to properly restore the thread state.  That's likely wrong.
  3026         // to properly restore the thread state.  That's likely wrong.
  3024       }
  3028       }
  3025     }
  3029     }
  3026     thread->osthread()->set_state(old_state);
  3030     thread->osthread()->set_state(old_state);
  3027   }
  3031   }
  3028   if (event.should_commit()) {
  3032   if (event.should_commit()) {
  3029     event.set_time(millis);
  3033     post_thread_sleep_event(&event, millis);
  3030     event.commit();
       
  3031   }
  3034   }
  3032   HOTSPOT_THREAD_SLEEP_END(0);
  3035   HOTSPOT_THREAD_SLEEP_END(0);
  3033 JVM_END
  3036 JVM_END
  3034 
  3037 
  3035 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass))
  3038 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass))