comparison src/share/vm/runtime/os.hpp @ 14909:4ca6dc0799b6

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