Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/os.hpp @ 14518:d8041d695d19
Merged with jdk9/dev/hotspot changeset 3812c088b945
author | twisti |
---|---|
date | Tue, 11 Mar 2014 18:45:59 -0700 |
parents | cefad50507d8 bb9356ec5967 |
children | 4ca6dc0799b6 |
comparison
equal
deleted
inserted
replaced
14141:f97c5ec83832 | 14518:d8041d695d19 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
39 # include <setjmp.h> | 39 # include <setjmp.h> |
40 #endif | 40 #endif |
41 #ifdef TARGET_OS_FAMILY_windows | 41 #ifdef TARGET_OS_FAMILY_windows |
42 # include "jvm_windows.h" | 42 # include "jvm_windows.h" |
43 #endif | 43 #endif |
44 #ifdef TARGET_OS_FAMILY_aix | |
45 # include "jvm_aix.h" | |
46 # include <setjmp.h> | |
47 #endif | |
44 #ifdef TARGET_OS_FAMILY_bsd | 48 #ifdef TARGET_OS_FAMILY_bsd |
45 # include "jvm_bsd.h" | 49 # include "jvm_bsd.h" |
46 # include <setjmp.h> | 50 # include <setjmp.h> |
47 #endif | 51 #endif |
48 | 52 |
159 | 163 |
160 static jlong javaTimeMillis(); | 164 static jlong javaTimeMillis(); |
161 static jlong javaTimeNanos(); | 165 static jlong javaTimeNanos(); |
162 static void javaTimeNanos_info(jvmtiTimerInfo *info_ptr); | 166 static void javaTimeNanos_info(jvmtiTimerInfo *info_ptr); |
163 static void run_periodic_checks(); | 167 static void run_periodic_checks(); |
168 static bool supports_monotonic_clock(); | |
164 | 169 |
165 | 170 |
166 // Returns the elapsed time in seconds since the vm started. | 171 // Returns the elapsed time in seconds since the vm started. |
167 static double elapsedTime(); | 172 static double elapsedTime(); |
168 | 173 |
393 // Previously this function calculated the exact address of this | 398 // Previously this function calculated the exact address of this |
394 // thread's serialize page, and checked if the faulting address | 399 // thread's serialize page, and checked if the faulting address |
395 // was equal. However, some platforms mask off faulting addresses | 400 // was equal. However, some platforms mask off faulting addresses |
396 // to the page size, so now we just check that the address is | 401 // to the page size, so now we just check that the address is |
397 // within the page. This makes the thread argument unnecessary, | 402 // within the page. This makes the thread argument unnecessary, |
398 // but we retain the NULL check to preserve existing behaviour. | 403 // but we retain the NULL check to preserve existing behavior. |
399 if (thread == NULL) return false; | 404 if (thread == NULL) return false; |
400 address page = (address) _mem_serialize_page; | 405 address page = (address) _mem_serialize_page; |
401 return addr >= page && addr < (page + os::vm_page_size()); | 406 return addr >= page && addr < (page + os::vm_page_size()); |
402 } | 407 } |
403 | 408 |
428 | 433 |
429 // thread id on Linux/64bit is 64bit, on Windows and Solaris, it's 32bit | 434 // thread id on Linux/64bit is 64bit, on Windows and Solaris, it's 32bit |
430 static intx current_thread_id(); | 435 static intx current_thread_id(); |
431 static int current_process_id(); | 436 static int current_process_id(); |
432 static int sleep(Thread* thread, jlong ms, bool interruptable); | 437 static int sleep(Thread* thread, jlong ms, bool interruptable); |
433 static int naked_sleep(); | 438 // Short standalone OS sleep suitable for slow path spin loop. |
439 // Ignores Thread.interrupt() (so keep it short). | |
440 // ms = 0, will sleep for the least amount of time allowed by the OS. | |
441 static void naked_short_sleep(jlong ms); | |
434 static void infinite_sleep(); // never returns, use with CAUTION | 442 static void infinite_sleep(); // never returns, use with CAUTION |
435 static void yield(); // Yields to all threads with same priority | 443 static void yield(); // Yields to all threads with same priority |
436 enum YieldResult { | 444 enum YieldResult { |
437 YIELD_SWITCHED = 1, // caller descheduled, other ready threads exist & ran | 445 YIELD_SWITCHED = 1, // caller descheduled, other ready threads exist & ran |
438 YIELD_NONEREADY = 0, // No other runnable/ready threads. | 446 YIELD_NONEREADY = 0, // No other runnable/ready threads. |
538 // Find out whether the pc is in the static code for jvm.dll/libjvm.so. | 546 // Find out whether the pc is in the static code for jvm.dll/libjvm.so. |
539 static bool address_is_in_vm(address addr); | 547 static bool address_is_in_vm(address addr); |
540 | 548 |
541 // Loads .dll/.so and | 549 // Loads .dll/.so and |
542 // in case of error it checks if .dll/.so was built for the | 550 // in case of error it checks if .dll/.so was built for the |
543 // same architecture as Hotspot is running on | 551 // same architecture as HotSpot is running on |
544 static void* dll_load(const char *name, char *ebuf, int ebuflen); | 552 static void* dll_load(const char *name, char *ebuf, int ebuflen); |
545 | 553 |
546 // lookup symbol in a shared library | 554 // lookup symbol in a shared library |
547 static void* dll_lookup(void* handle, const char* name); | 555 static void* dll_lookup(void* handle, const char* name); |
548 | 556 |
767 # include "os_posix.hpp" | 775 # include "os_posix.hpp" |
768 #endif | 776 #endif |
769 #ifdef TARGET_OS_FAMILY_windows | 777 #ifdef TARGET_OS_FAMILY_windows |
770 # include "os_windows.hpp" | 778 # include "os_windows.hpp" |
771 #endif | 779 #endif |
780 #ifdef TARGET_OS_FAMILY_aix | |
781 # include "os_aix.hpp" | |
782 # include "os_posix.hpp" | |
783 #endif | |
772 #ifdef TARGET_OS_FAMILY_bsd | 784 #ifdef TARGET_OS_FAMILY_bsd |
773 # include "os_posix.hpp" | 785 # include "os_posix.hpp" |
774 # include "os_bsd.hpp" | 786 # include "os_bsd.hpp" |
775 #endif | 787 #endif |
776 #ifdef TARGET_OS_ARCH_linux_x86 | 788 #ifdef TARGET_OS_ARCH_linux_x86 |
795 # include "os_linux_arm.hpp" | 807 # include "os_linux_arm.hpp" |
796 #endif | 808 #endif |
797 #ifdef TARGET_OS_ARCH_linux_ppc | 809 #ifdef TARGET_OS_ARCH_linux_ppc |
798 # include "os_linux_ppc.hpp" | 810 # include "os_linux_ppc.hpp" |
799 #endif | 811 #endif |
812 #ifdef TARGET_OS_ARCH_aix_ppc | |
813 # include "os_aix_ppc.hpp" | |
814 #endif | |
800 #ifdef TARGET_OS_ARCH_bsd_x86 | 815 #ifdef TARGET_OS_ARCH_bsd_x86 |
801 # include "os_bsd_x86.hpp" | 816 # include "os_bsd_x86.hpp" |
802 #endif | 817 #endif |
803 #ifdef TARGET_OS_ARCH_bsd_zero | 818 #ifdef TARGET_OS_ARCH_bsd_zero |
804 # include "os_bsd_zero.hpp" | 819 # include "os_bsd_zero.hpp" |
820 #endif | |
821 | |
822 #ifndef OS_NATIVE_THREAD_CREATION_FAILED_MSG | |
823 #define OS_NATIVE_THREAD_CREATION_FAILED_MSG "unable to create native thread: possibly out of memory or process/resource limits reached" | |
805 #endif | 824 #endif |
806 | 825 |
807 public: | 826 public: |
808 #ifndef PLATFORM_PRINT_NATIVE_STACK | 827 #ifndef PLATFORM_PRINT_NATIVE_STACK |
809 // No platform-specific code for printing the native stack. | 828 // No platform-specific code for printing the native stack. |
824 static OSReturn get_native_priority(const Thread* const thread, int* priority_ptr); | 843 static OSReturn get_native_priority(const Thread* const thread, int* priority_ptr); |
825 static int java_to_os_priority[CriticalPriority + 1]; | 844 static int java_to_os_priority[CriticalPriority + 1]; |
826 // Hint to the underlying OS that a task switch would not be good. | 845 // Hint to the underlying OS that a task switch would not be good. |
827 // Void return because it's a hint and can fail. | 846 // Void return because it's a hint and can fail. |
828 static void hint_no_preempt(); | 847 static void hint_no_preempt(); |
848 static const char* native_thread_creation_failed_msg() { | |
849 return OS_NATIVE_THREAD_CREATION_FAILED_MSG; | |
850 } | |
829 | 851 |
830 // Used at creation if requested by the diagnostic flag PauseAtStartup. | 852 // Used at creation if requested by the diagnostic flag PauseAtStartup. |
831 // Causes the VM to wait until an external stimulus has been applied | 853 // Causes the VM to wait until an external stimulus has been applied |
832 // (for Unix, that stimulus is a signal, for Windows, an external | 854 // (for Unix, that stimulus is a signal, for Windows, an external |
833 // ResumeThread call) | 855 // ResumeThread call) |