changeset 25477:7dad9f95fd31

8047714: Fix for JDK-6546236 made Solaris os::yield() a no-op Reviewed-by: hseigel, lfoltan
author fparain
date Tue, 08 Jul 2014 08:04:06 -0700
parents b97716c4b5c9
children 7e6c884aa31f
files hotspot/src/os/aix/vm/os_aix.cpp hotspot/src/os/bsd/vm/os_bsd.cpp hotspot/src/os/linux/vm/os_linux.cpp hotspot/src/os/solaris/vm/os_solaris.cpp hotspot/src/os/windows/vm/os_windows.cpp hotspot/src/share/vm/compiler/compileBroker.cpp hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp hotspot/src/share/vm/prims/jni.cpp hotspot/src/share/vm/prims/jvm.cpp hotspot/src/share/vm/runtime/os.hpp hotspot/src/share/vm/runtime/safepoint.cpp hotspot/src/share/vm/runtime/synchronizer.cpp hotspot/src/share/vm/runtime/thread.cpp hotspot/src/share/vm/services/memTracker.hpp hotspot/src/share/vm/utilities/taskqueue.cpp
diffstat 15 files changed, 24 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/os/aix/vm/os_aix.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/os/aix/vm/os_aix.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -2808,12 +2808,10 @@
   return DontYieldALot;
 }
 
-void os::yield() {
+void os::naked_yield() {
   sched_yield();
 }
 
-os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
-
 ////////////////////////////////////////////////////////////////////////////////
 // thread priority support
 
@@ -3070,7 +3068,7 @@
 
   for (int n = 0; !osthread->sr.is_suspended(); n++) {
     for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) {
-      os::yield();
+      os::naked_yield();
     }
 
     // timeout, try to cancel the request
@@ -3104,7 +3102,7 @@
     if (sr_notify(osthread) == 0) {
       for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) {
         for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) {
-          os::yield();
+          os::naked_yield();
         }
       }
     } else {
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -2596,12 +2596,10 @@
   return DontYieldALot;
 }
 
-void os::yield() {
+void os::naked_yield() {
   sched_yield();
 }
 
-os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
-
 ////////////////////////////////////////////////////////////////////////////////
 // thread priority support
 
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -3791,12 +3791,10 @@
   return DontYieldALot;
 }
 
-void os::yield() {
+void os::naked_yield() {
   sched_yield();
 }
 
-os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
-
 ////////////////////////////////////////////////////////////////////////////////
 // thread priority support
 
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -3173,20 +3173,14 @@
   }
 }
 
-// Caveat: Solaris os::yield() causes a thread-state transition whereas
-// the linux and win32 implementations do not.  This should be checked.
-
-void os::yield() {
-  // Yields to all threads with same or greater priority
-  os::sleep(Thread::current(), 0, false);
-}
-
 // Note that yield semantics are defined by the scheduling class to which
 // the thread currently belongs.  Typically, yield will _not yield to
 // other equal or higher priority threads that reside on the dispatch queues
 // of other CPUs.
 
-os::YieldResult os::NakedYield() { thr_yield(); return os::YIELD_UNKNOWN; }
+void os::naked_yield() {
+  thr_yield();
+}
 
 // Interface for setting lwp priorities.  If we are using T2 libthread,
 // which forces the use of BoundThreads or we manually set UseBoundThreads,
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -3515,18 +3515,15 @@
 
 typedef BOOL (WINAPI * STTSignature)(void);
 
-os::YieldResult os::NakedYield() {
+void os::naked_yield() {
   // Use either SwitchToThread() or Sleep(0)
   // Consider passing back the return value from SwitchToThread().
   if (os::Kernel32Dll::SwitchToThreadAvailable()) {
-    return SwitchToThread() ? os::YIELD_SWITCHED : os::YIELD_NONEREADY;
+    SwitchToThread();
   } else {
     Sleep(0);
   }
-  return os::YIELD_UNKNOWN;
-}
-
-void os::yield() {  os::NakedYield(); }
+}
 
 // Win32 only gives you access to seven real priorities at a time,
 // so we compress Java's ten down to seven.  It would be better
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -1048,7 +1048,7 @@
   }
 
   // Let go of Threads_lock before yielding
-  os::yield(); // make sure that the compiler thread is started early (especially helpful on SOLARIS)
+  os::naked_yield(); // make sure that the compiler thread is started early (especially helpful on SOLARIS)
 
   return compiler_thread;
 }
--- a/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -134,7 +134,7 @@
     Threads::add(res);
     Thread::start(res);
   }
-  os::yield(); // This seems to help with initial start-up of SLT
+  os::naked_yield(); // This seems to help with initial start-up of SLT
   return res;
 }
 
--- a/hotspot/src/share/vm/prims/jni.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/prims/jni.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -3325,7 +3325,7 @@
     directBufferSupportInitializeEnded = 1;
   } else {
     while (!directBufferSupportInitializeEnded && !directBufferSupportInitializeFailed) {
-      os::yield();
+      os::naked_yield();
     }
   }
 
--- a/hotspot/src/share/vm/prims/jvm.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -3042,7 +3042,7 @@
   if (ConvertYieldToSleep) {
     os::sleep(thread, MinSleepInterval, false);
   } else {
-    os::yield();
+    os::naked_yield();
   }
 JVM_END
 
@@ -3072,7 +3072,7 @@
     // It appears that in certain GUI contexts, it may be beneficial to do a short sleep
     // for SOLARIS
     if (ConvertSleepToYield) {
-      os::yield();
+      os::naked_yield();
     } else {
       ThreadState old_state = thread->osthread()->get_state();
       thread->osthread()->set_state(SLEEPING);
--- a/hotspot/src/share/vm/runtime/os.hpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/runtime/os.hpp	Tue Jul 08 08:04:06 2014 -0700
@@ -442,16 +442,7 @@
   // ms = 0, will sleep for the least amount of time allowed by the OS.
   static void naked_short_sleep(jlong ms);
   static void infinite_sleep(); // never returns, use with CAUTION
-  static void yield();        // Yields to all threads with same priority
-  enum YieldResult {
-    YIELD_SWITCHED = 1,         // caller descheduled, other ready threads exist & ran
-    YIELD_NONEREADY = 0,        // No other runnable/ready threads.
-                                // platform-specific yield return immediately
-    YIELD_UNKNOWN = -1          // Unknown: platform doesn't support _SWITCHED or _NONEREADY
-    // YIELD_SWITCHED and YIELD_NONREADY imply the platform supports a "strong"
-    // yield that can be used in lieu of blocking.
-  } ;
-  static YieldResult NakedYield () ;
+  static void naked_yield () ;
   static OSReturn set_priority(Thread* thread, ThreadPriority priority);
   static OSReturn get_priority(const Thread* const thread, ThreadPriority& priority);
 
--- a/hotspot/src/share/vm/runtime/safepoint.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -322,7 +322,7 @@
         SpinPause() ;     // MP-Polite spin
       } else
       if (steps < DeferThrSuspendLoopCount) {
-        os::NakedYield() ;
+        os::naked_yield() ;
       } else {
         os::naked_short_sleep(1);
       }
--- a/hotspot/src/share/vm/runtime/synchronizer.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/runtime/synchronizer.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -449,7 +449,7 @@
     ++its;
     if (its > 10000 || !os::is_MP()) {
        if (its & 1) {
-         os::NakedYield();
+         os::naked_yield();
          TEVENT(Inflate: INFLATING - yield);
        } else {
          // Note that the following code attenuates the livelock problem but is not
@@ -479,7 +479,7 @@
            if ((YieldThenBlock++) >= 16) {
               Thread::current()->_ParkEvent->park(1);
            } else {
-              os::NakedYield();
+              os::naked_yield();
            }
          }
          Thread::muxRelease(InflationLocks + ix);
--- a/hotspot/src/share/vm/runtime/thread.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -4374,7 +4374,7 @@
            if (Yields > 5) {
              os::naked_short_sleep(1);
            } else {
-             os::NakedYield();
+             os::naked_yield();
              ++Yields;
            }
         } else {
--- a/hotspot/src/share/vm/services/memTracker.hpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/services/memTracker.hpp	Tue Jul 08 08:04:06 2014 -0700
@@ -484,7 +484,7 @@
       // as short sleep.
       os::naked_short_sleep(1);
 #else
-      os::NakedYield();
+      os::naked_yield();
 #endif
     }
   }
--- a/hotspot/src/share/vm/utilities/taskqueue.cpp	Mon Jul 07 12:08:07 2014 -0400
+++ b/hotspot/src/share/vm/utilities/taskqueue.cpp	Tue Jul 08 08:04:06 2014 -0700
@@ -142,7 +142,7 @@
 
 void ParallelTaskTerminator::yield() {
   assert(_offered_termination <= _n_threads, "Invariant");
-  os::yield();
+  os::naked_yield();
 }
 
 void ParallelTaskTerminator::sleep(uint millis) {