< prev index next >

src/share/vm/runtime/os.hpp

Print this page
rev 11647 : 8161258: Simplify including platform files.
Summary: Include patform files with macros cpu_header() etc. Do various cleanups of macro usages. Remove _64/_32 from adlc generated files and platform .hpp files. Merge stubRoutines_x86*.hpp. Remove empty mutex_<os>* files.
Reviewed-by: dholmes, coleenp, kbarrett


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_OS_HPP
  26 #define SHARE_VM_RUNTIME_OS_HPP
  27 
  28 #include "jvmtifiles/jvmti.h"

  29 #include "runtime/extendedPC.hpp"
  30 #include "runtime/handles.hpp"
  31 #ifdef TARGET_OS_FAMILY_linux
  32 # include "jvm_linux.h"
  33 # include <setjmp.h>
  34 #endif
  35 #ifdef TARGET_OS_FAMILY_solaris
  36 # include "jvm_solaris.h"
  37 # include <setjmp.h>
  38 #endif
  39 #ifdef TARGET_OS_FAMILY_windows
  40 # include "jvm_windows.h"
  41 #endif
  42 #ifdef TARGET_OS_FAMILY_aix
  43 # include "jvm_aix.h"
  44 # include <setjmp.h>
  45 #endif
  46 #ifdef TARGET_OS_FAMILY_bsd
  47 # include "jvm_bsd.h"
  48 # include <setjmp.h>
  49 # ifdef __APPLE__
  50 #  include <mach/mach_time.h>
  51 # endif
  52 #endif
  53 
  54 class AgentLibrary;
  55 
  56 // os defines the interface to operating system; this includes traditional
  57 // OS services (time, I/O) as well as other functionality with system-
  58 // dependent code.
  59 
  60 typedef void (*dll_func)(...);
  61 
  62 class Thread;
  63 class JavaThread;
  64 class Event;
  65 class DLL;
  66 class FileHandle;
  67 class NativeCallStack;
  68 
  69 template<class E> class GrowableArray;
  70 
  71 // %%%%% Moved ThreadState, START_FN, OSThread to new osThread.hpp. -- Rose


 799   static int loadavg(double loadavg[], int nelem);
 800 
 801   // Hook for os specific jvm options that we don't want to abort on seeing
 802   static bool obsolete_option(const JavaVMOption *option);
 803 
 804   // Amount beyond the callee frame size that we bang the stack.
 805   static int extra_bang_size_in_bytes();
 806 
 807   static char** split_path(const char* path, int* n);
 808 
 809   // Extensions
 810 #include "runtime/os_ext.hpp"
 811 
 812  public:
 813   class CrashProtectionCallback : public StackObj {
 814   public:
 815     virtual void call() = 0;
 816   };
 817 
 818   // Platform dependent stuff
 819 #ifdef TARGET_OS_FAMILY_linux
 820 # include "os_linux.hpp"
 821 # include "os_posix.hpp"
 822 #endif
 823 #ifdef TARGET_OS_FAMILY_solaris
 824 # include "os_solaris.hpp"
 825 # include "os_posix.hpp"
 826 #endif
 827 #ifdef TARGET_OS_FAMILY_windows
 828 # include "os_windows.hpp"
 829 #endif
 830 #ifdef TARGET_OS_FAMILY_aix
 831 # include "os_aix.hpp"
 832 # include "os_posix.hpp"
 833 #endif
 834 #ifdef TARGET_OS_FAMILY_bsd
 835 # include "os_posix.hpp"
 836 # include "os_bsd.hpp"
 837 #endif
 838 #ifdef TARGET_OS_ARCH_linux_x86
 839 # include "os_linux_x86.hpp"
 840 #endif
 841 #ifdef TARGET_OS_ARCH_linux_sparc
 842 # include "os_linux_sparc.hpp"
 843 #endif
 844 #ifdef TARGET_OS_ARCH_linux_zero
 845 # include "os_linux_zero.hpp"
 846 #endif
 847 #ifdef TARGET_OS_ARCH_solaris_x86
 848 # include "os_solaris_x86.hpp"
 849 #endif
 850 #ifdef TARGET_OS_ARCH_solaris_sparc
 851 # include "os_solaris_sparc.hpp"
 852 #endif
 853 #ifdef TARGET_OS_ARCH_windows_x86
 854 # include "os_windows_x86.hpp"
 855 #endif
 856 #ifdef TARGET_OS_ARCH_linux_arm
 857 # include "os_linux_arm.hpp"
 858 #endif
 859 #ifdef TARGET_OS_ARCH_linux_ppc
 860 # include "os_linux_ppc.hpp"
 861 #endif
 862 #ifdef TARGET_OS_ARCH_aix_ppc
 863 # include "os_aix_ppc.hpp"
 864 #endif
 865 #ifdef TARGET_OS_ARCH_linux_aarch64
 866 # include "os_linux_aarch64.hpp"
 867 #endif
 868 #ifdef TARGET_OS_ARCH_bsd_x86
 869 # include "os_bsd_x86.hpp"
 870 #endif
 871 #ifdef TARGET_OS_ARCH_bsd_zero
 872 # include "os_bsd_zero.hpp"
 873 #endif


 874 
 875 #ifndef OS_NATIVE_THREAD_CREATION_FAILED_MSG
 876 #define OS_NATIVE_THREAD_CREATION_FAILED_MSG "unable to create native thread: possibly out of memory or process/resource limits reached"
 877 #endif
 878 
 879  public:
 880 #ifndef PLATFORM_PRINT_NATIVE_STACK
 881   // No platform-specific code for printing the native stack.
 882   static bool platform_print_native_stack(outputStream* st, const void* context,
 883                                           char *buf, int buf_size) {
 884     return false;
 885   }
 886 #endif
 887 
 888   // debugging support (mostly used by debug.cpp but also fatal error handler)
 889   static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address
 890 
 891   static bool dont_yield();                     // when true, JVM_Yield() is nop
 892   static void print_statistics();
 893 


 920     void* ucontext() const { return _ucontext; }
 921   private:
 922     Thread* _thread;
 923     void* _ucontext;
 924   };
 925 
 926   class SuspendedThreadTask {
 927   public:
 928     SuspendedThreadTask(Thread* thread) : _thread(thread), _done(false) {}
 929     virtual ~SuspendedThreadTask() {}
 930     void run();
 931     bool is_done() { return _done; }
 932     virtual void do_task(const SuspendedThreadTaskContext& context) = 0;
 933   protected:
 934   private:
 935     void internal_do_task();
 936     Thread* _thread;
 937     bool _done;
 938   };
 939 
 940 #ifndef TARGET_OS_FAMILY_windows
 941   // Suspend/resume support
 942   // Protocol:
 943   //
 944   // a thread starts in SR_RUNNING
 945   //
 946   // SR_RUNNING can go to
 947   //   * SR_SUSPEND_REQUEST when the WatcherThread wants to suspend it
 948   // SR_SUSPEND_REQUEST can go to
 949   //   * SR_RUNNING if WatcherThread decides it waited for SR_SUSPENDED too long (timeout)
 950   //   * SR_SUSPENDED if the stopped thread receives the signal and switches state
 951   // SR_SUSPENDED can go to
 952   //   * SR_WAKEUP_REQUEST when the WatcherThread has done the work and wants to resume
 953   // SR_WAKEUP_REQUEST can go to
 954   //   * SR_RUNNING when the stopped thread receives the signal
 955   //   * SR_WAKEUP_REQUEST on timeout (resend the signal and try again)
 956   class SuspendResume {
 957    public:
 958     enum State {
 959       SR_RUNNING,
 960       SR_SUSPEND_REQUEST,


 991     State request_wakeup() {
 992       return switch_state(SR_SUSPENDED, SR_WAKEUP_REQUEST);
 993     }
 994 
 995     State running() {
 996       return switch_state(SR_WAKEUP_REQUEST, SR_RUNNING);
 997     }
 998 
 999     bool is_running() const {
1000       return _state == SR_RUNNING;
1001     }
1002 
1003     bool is_suspend_request() const {
1004       return _state == SR_SUSPEND_REQUEST;
1005     }
1006 
1007     bool is_suspended() const {
1008       return _state == SR_SUSPENDED;
1009     }
1010   };
1011 #endif
1012 
1013 
1014  protected:
1015   static long _rand_seed;                   // seed for random number generator
1016   static int _processor_count;              // number of processors
1017 
1018   static char* format_boot_path(const char* format_string,
1019                                 const char* home,
1020                                 int home_len,
1021                                 char fileSep,
1022                                 char pathSep);
1023   static bool set_boot_path(char fileSep, char pathSep);
1024 
1025 };
1026 
1027 // Note that "PAUSE" is almost always used with synchronization
1028 // so arguably we should provide Atomic::SpinPause() instead
1029 // of the global SpinPause() with C linkage.
1030 // It'd also be eligible for inlining on many platforms.
1031 


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_OS_HPP
  26 #define SHARE_VM_RUNTIME_OS_HPP
  27 
  28 #include "jvmtifiles/jvmti.h"
  29 #include "prims/jvm.h"
  30 #include "runtime/extendedPC.hpp"
  31 #include "runtime/handles.hpp"
  32 #include "utilities/macros.hpp"
  33 #ifndef _WINDOWS
  34 # include <setjmp.h>
  35 #endif
  36 #ifdef __APPLE__














  37 # include <mach/mach_time.h>

  38 #endif
  39 
  40 class AgentLibrary;
  41 
  42 // os defines the interface to operating system; this includes traditional
  43 // OS services (time, I/O) as well as other functionality with system-
  44 // dependent code.
  45 
  46 typedef void (*dll_func)(...);
  47 
  48 class Thread;
  49 class JavaThread;
  50 class Event;
  51 class DLL;
  52 class FileHandle;
  53 class NativeCallStack;
  54 
  55 template<class E> class GrowableArray;
  56 
  57 // %%%%% Moved ThreadState, START_FN, OSThread to new osThread.hpp. -- Rose


 785   static int loadavg(double loadavg[], int nelem);
 786 
 787   // Hook for os specific jvm options that we don't want to abort on seeing
 788   static bool obsolete_option(const JavaVMOption *option);
 789 
 790   // Amount beyond the callee frame size that we bang the stack.
 791   static int extra_bang_size_in_bytes();
 792 
 793   static char** split_path(const char* path, int* n);
 794 
 795   // Extensions
 796 #include "runtime/os_ext.hpp"
 797 
 798  public:
 799   class CrashProtectionCallback : public StackObj {
 800   public:
 801     virtual void call() = 0;
 802   };
 803 
 804   // Platform dependent stuff
 805 #ifndef _WINDOWS















 806 # include "os_posix.hpp"





































 807 #endif
 808 #include OS_CPU_HEADER(os)
 809 #include OS_HEADER(os)
 810 
 811 #ifndef OS_NATIVE_THREAD_CREATION_FAILED_MSG
 812 #define OS_NATIVE_THREAD_CREATION_FAILED_MSG "unable to create native thread: possibly out of memory or process/resource limits reached"
 813 #endif
 814 
 815  public:
 816 #ifndef PLATFORM_PRINT_NATIVE_STACK
 817   // No platform-specific code for printing the native stack.
 818   static bool platform_print_native_stack(outputStream* st, const void* context,
 819                                           char *buf, int buf_size) {
 820     return false;
 821   }
 822 #endif
 823 
 824   // debugging support (mostly used by debug.cpp but also fatal error handler)
 825   static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address
 826 
 827   static bool dont_yield();                     // when true, JVM_Yield() is nop
 828   static void print_statistics();
 829 


 856     void* ucontext() const { return _ucontext; }
 857   private:
 858     Thread* _thread;
 859     void* _ucontext;
 860   };
 861 
 862   class SuspendedThreadTask {
 863   public:
 864     SuspendedThreadTask(Thread* thread) : _thread(thread), _done(false) {}
 865     virtual ~SuspendedThreadTask() {}
 866     void run();
 867     bool is_done() { return _done; }
 868     virtual void do_task(const SuspendedThreadTaskContext& context) = 0;
 869   protected:
 870   private:
 871     void internal_do_task();
 872     Thread* _thread;
 873     bool _done;
 874   };
 875 
 876 #ifndef _WINDOWS
 877   // Suspend/resume support
 878   // Protocol:
 879   //
 880   // a thread starts in SR_RUNNING
 881   //
 882   // SR_RUNNING can go to
 883   //   * SR_SUSPEND_REQUEST when the WatcherThread wants to suspend it
 884   // SR_SUSPEND_REQUEST can go to
 885   //   * SR_RUNNING if WatcherThread decides it waited for SR_SUSPENDED too long (timeout)
 886   //   * SR_SUSPENDED if the stopped thread receives the signal and switches state
 887   // SR_SUSPENDED can go to
 888   //   * SR_WAKEUP_REQUEST when the WatcherThread has done the work and wants to resume
 889   // SR_WAKEUP_REQUEST can go to
 890   //   * SR_RUNNING when the stopped thread receives the signal
 891   //   * SR_WAKEUP_REQUEST on timeout (resend the signal and try again)
 892   class SuspendResume {
 893    public:
 894     enum State {
 895       SR_RUNNING,
 896       SR_SUSPEND_REQUEST,


 927     State request_wakeup() {
 928       return switch_state(SR_SUSPENDED, SR_WAKEUP_REQUEST);
 929     }
 930 
 931     State running() {
 932       return switch_state(SR_WAKEUP_REQUEST, SR_RUNNING);
 933     }
 934 
 935     bool is_running() const {
 936       return _state == SR_RUNNING;
 937     }
 938 
 939     bool is_suspend_request() const {
 940       return _state == SR_SUSPEND_REQUEST;
 941     }
 942 
 943     bool is_suspended() const {
 944       return _state == SR_SUSPENDED;
 945     }
 946   };
 947 #endif // !WINDOWS
 948 
 949 
 950  protected:
 951   static long _rand_seed;                   // seed for random number generator
 952   static int _processor_count;              // number of processors
 953 
 954   static char* format_boot_path(const char* format_string,
 955                                 const char* home,
 956                                 int home_len,
 957                                 char fileSep,
 958                                 char pathSep);
 959   static bool set_boot_path(char fileSep, char pathSep);
 960 
 961 };
 962 
 963 // Note that "PAUSE" is almost always used with synchronization
 964 // so arguably we should provide Atomic::SpinPause() instead
 965 // of the global SpinPause() with C linkage.
 966 // It'd also be eligible for inlining on many platforms.
 967 
< prev index next >