diff --git a/src/os/bsd/vm/osThread_bsd.hpp b/src/os/bsd/vm/osThread_bsd.hpp index 914a0439c02129a2113500c8cab2cfd940b05b18..c72b36025f68e2c569ba69efef39e4b78cc367cc 100644 --- a/src/os/bsd/vm/osThread_bsd.hpp +++ b/src/os/bsd/vm/osThread_bsd.hpp @@ -42,25 +42,18 @@ #ifdef _ALLBSD_SOURCE #ifdef __APPLE__ - thread_t _thread_id; + typedef thread_t thread_id_t; #else - pthread_t _thread_id; + typedef pthread_t thread_id_t; #endif - // _pthread_id is the pthread id, which is used by library calls - // (e.g. pthread_kill). - pthread_t _pthread_id; - #else - // _thread_id is kernel thread id (similar to LWP id on Solaris). Each - // thread has a unique thread_id (BsdThreads or NPTL). It can be used - // to access /proc. - pid_t _thread_id; + typedef pid_t thread_id_t; +#endif // _pthread_id is the pthread id, which is used by library calls // (e.g. pthread_kill). pthread_t _pthread_id; -#endif sigset_t _caller_sigmask; // Caller's signal mask @@ -70,28 +63,11 @@ sigset_t caller_sigmask() const { return _caller_sigmask; } void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } -#ifdef _ALLBSD_SOURCE -#ifdef __APPLE__ - static size_t thread_id_size() { return sizeof(thread_t); } - thread_t thread_id() const { - return _thread_id; - } -#else - static size_t thread_id_size() { return sizeof(pthread_t); } - pthread_t thread_id() const { - return _thread_id; - } -#endif -#else - static size_t thread_id_size() { return sizeof(pid_t); } - pid_t thread_id() const { - return _thread_id; - } -#endif #ifndef PRODUCT // Used for debugging, return a unique integer for each thread. intptr_t thread_identifier() const { return (intptr_t)_pthread_id; } #endif + #ifdef ASSERT // We expect no reposition failures so kill vm if we get one. // @@ -99,21 +75,7 @@ return false; } #endif // ASSERT -#ifdef _ALLBSD_SOURCE -#ifdef __APPLE__ - void set_thread_id(thread_t id) { - _thread_id = id; - } -#else - void set_thread_id(pthread_t id) { - _thread_id = id; - } -#endif -#else - void set_thread_id(pid_t id) { - _thread_id = id; - } -#endif + pthread_t pthread_id() const { return _pthread_id; } diff --git a/src/os/linux/vm/osThread_linux.hpp b/src/os/linux/vm/osThread_linux.hpp index fe9fe6188faf96cbc658ac2690c7c0d4768e855c..904ab52e68fab53c642d117ca7de2b690f0f824e 100644 --- a/src/os/linux/vm/osThread_linux.hpp +++ b/src/os/linux/vm/osThread_linux.hpp @@ -24,6 +24,8 @@ #ifndef OS_LINUX_VM_OSTHREAD_LINUX_HPP #define OS_LINUX_VM_OSTHREAD_LINUX_HPP + public: + typedef pid_t thread_id_t; private: int _thread_type; @@ -37,13 +39,6 @@ _thread_type = type; } - private: - - // _thread_id is kernel thread id (similar to LWP id on Solaris). Each - // thread has a unique thread_id (LinuxThreads or NPTL). It can be used - // to access /proc. - pid_t _thread_id; - // _pthread_id is the pthread id, which is used by library calls // (e.g. pthread_kill). pthread_t _pthread_id; @@ -56,11 +51,6 @@ sigset_t caller_sigmask() const { return _caller_sigmask; } void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } - static size_t thread_id_size() { return sizeof(pid_t); } - - pid_t thread_id() const { - return _thread_id; - } #ifndef PRODUCT // Used for debugging, return a unique integer for each thread. int thread_identifier() const { return _thread_id; } @@ -72,9 +62,6 @@ return false; } #endif // ASSERT - void set_thread_id(pid_t id) { - _thread_id = id; - } pthread_t pthread_id() const { return _pthread_id; } diff --git a/src/os/solaris/vm/osThread_solaris.hpp b/src/os/solaris/vm/osThread_solaris.hpp index 6e79e1855dbd97ec2a0bede8c405f2708129d4fd..2a7a2470a0896754ac4bfc6dd374ce4c81b71177 100644 --- a/src/os/solaris/vm/osThread_solaris.hpp +++ b/src/os/solaris/vm/osThread_solaris.hpp @@ -26,9 +26,10 @@ #define OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP // This is embedded via include into the class OSThread + public: + typedef thread_t thread_id_t; private: - thread_t _thread_id; // Solaris thread id uint _lwp_id; // lwp ID, only used with bound threads int _native_priority; // Saved native priority when starting // a bound thread @@ -36,8 +37,6 @@ bool _vm_created_thread; // true if the VM created this thread, // false if primary thread or attached thread public: - static size_t thread_id_size() { return sizeof(thread_t); } - thread_t thread_id() const { return _thread_id; } uint lwp_id() const { return _lwp_id; } int native_priority() const { return _native_priority; } @@ -63,7 +62,6 @@ return true; } #endif - void set_thread_id(thread_t id) { _thread_id = id; } void set_lwp_id(uint id) { _lwp_id = id; } void set_native_priority(int prio) { _native_priority = prio; } diff --git a/src/os/windows/vm/osThread_windows.hpp b/src/os/windows/vm/osThread_windows.hpp index 28cd45c5c2fcb6a8b56fb896b2cf1c5a26058e2a..af07695aa752efd36ab6e8d661e0ea88e4ef4b57 100644 --- a/src/os/windows/vm/osThread_windows.hpp +++ b/src/os/windows/vm/osThread_windows.hpp @@ -25,12 +25,13 @@ #ifndef OS_WINDOWS_VM_OSTHREAD_WINDOWS_HPP #define OS_WINDOWS_VM_OSTHREAD_WINDOWS_HPP -typedef void* HANDLE; + typedef void* HANDLE; + public: + typedef unsigned long thread_id_t; private: // Win32-specific thread information HANDLE _thread_handle; // Win32 thread handle - unsigned long _thread_id; // Win32 thread id HANDLE _interrupt_event; // Event signalled on thread interrupt ThreadState _last_state; @@ -42,9 +43,6 @@ typedef void* HANDLE; HANDLE interrupt_event() const { return _interrupt_event; } void set_interrupt_event(HANDLE interrupt_event) { _interrupt_event = interrupt_event; } - - static size_t thread_id_size() { return sizeof(unsigned long); } - unsigned long thread_id() const { return _thread_id; } #ifndef PRODUCT // Used for debugging, return a unique integer for each thread. int thread_identifier() const { return _thread_id; } @@ -56,8 +54,6 @@ typedef void* HANDLE; return false; } #endif // ASSERT - void set_thread_id(unsigned long thread_id) { _thread_id = thread_id; } - bool is_try_mutex_enter() { return false; } // This is a temporary fix for the thread states during diff --git a/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp b/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp index 4ccf80744244c812e3fc1227b9e51a35dda4c860..b98d975408ac6f52cc7af5c99d42ab22125a9e5c 100644 --- a/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp +++ b/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp @@ -29,18 +29,12 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#ifdef __APPLE__ -#define OS_THREAD_ID_TYPE thread_t -#else -#define OS_THREAD_ID_TYPE pthread_t -#endif - #define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field, last_entry) \ \ /******************************/ \ /* Threads (NOTE: incomplete) */ \ /******************************/ \ - nonstatic_field(OSThread, _thread_id, OS_THREAD_ID_TYPE) \ + nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ nonstatic_field(OSThread, _pthread_id, pthread_t) \ /* This must be the last entry, and must be present */ \ last_entry() @@ -52,7 +46,7 @@ /* Posix Thread IDs */ \ /**********************/ \ \ - declare_unsigned_integer_type(thread_t) \ + declare_unsigned_integer_type(OSThread::thread_id_t) \ declare_unsigned_integer_type(pthread_t) \ \ /* This must be the last entry, and must be present */ \ diff --git a/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp b/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp index 4b0a3e63a2920ab0007fd43b3760dacc623ea75f..58fc94bbc3846d6c173c3fa09a244d51772e41f2 100644 --- a/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp +++ b/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -36,7 +36,7 @@ /******************************/ \ \ nonstatic_field(JavaThread, _base_of_stack_pointer, intptr_t*) \ - nonstatic_field(OSThread, _thread_id, pid_t) \ + nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ nonstatic_field(OSThread, _pthread_id, pthread_t) \ /* This must be the last entry, and must be present */ \ last_entry() @@ -48,7 +48,7 @@ /* POSIX Thread IDs */ \ /**********************/ \ \ - declare_integer_type(pid_t) \ + declare_integer_type(OSThread::thread_id_t) \ declare_unsigned_integer_type(pthread_t) \ \ /* This must be the last entry, and must be present */ \ diff --git a/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp b/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp index c54cb1d729d75fea96ac5d500196adf892f100c1..c01e6c91c2abaee87a54d66322b3f85c92d5c78b 100644 --- a/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp +++ b/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -34,7 +34,7 @@ /******************************/ \ /* Threads (NOTE: incomplete) */ \ /******************************/ \ - nonstatic_field(OSThread, _thread_id, pid_t) \ + nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ nonstatic_field(OSThread, _pthread_id, pthread_t) \ /* This must be the last entry, and must be present */ \ last_entry() @@ -46,7 +46,7 @@ /* Posix Thread IDs */ \ /**********************/ \ \ - declare_integer_type(pid_t) \ + declare_integer_type(OSThread::thread_id_t) \ declare_unsigned_integer_type(pthread_t) \ \ /* This must be the last entry, and must be present */ \ diff --git a/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp b/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp index 710e33690425acb4edcbf547357729b145e0bf92..58113a9ea49781257b4c9ee84e5192b9678f876d 100644 --- a/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp +++ b/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -36,7 +36,7 @@ /******************************/ \ \ nonstatic_field(JavaThread, _base_of_stack_pointer, intptr_t*) \ - nonstatic_field(OSThread, _thread_id, thread_t) \ + nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ /* This must be the last entry, and must be present */ \ last_entry() @@ -47,7 +47,7 @@ /* Solaris Thread IDs */ \ /**********************/ \ \ - declare_unsigned_integer_type(thread_t) \ + declare_unsigned_integer_type(OSThread::thread_id_t) \ \ /* This must be the last entry, and must be present */ \ last_entry() diff --git a/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp b/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp index 76338956021018bad7f368ab6aab1682306c750e..a2a4f7c60b7274b974b1dee7610fd65112d94a73 100644 --- a/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp +++ b/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -35,7 +35,7 @@ /* Threads (NOTE: incomplete) */ \ /******************************/ \ \ - nonstatic_field(OSThread, _thread_id, thread_t) \ + nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ \ /* This must be the last entry, and must be present */ \ last_entry() @@ -46,7 +46,7 @@ /* Solaris Thread IDs */ \ /**********************/ \ \ - declare_unsigned_integer_type(thread_t) \ + declare_unsigned_integer_type(OSThread::thread_id_t) \ \ /* This must be the last entry, and must be present */ \ last_entry() diff --git a/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp b/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp index 6df1f7226fadac85f1e41929331c88985ac7b16e..46e5f4c4251adcf69d1f9df79dba0da38a3ed1c3 100644 --- a/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp +++ b/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -35,7 +35,7 @@ /* Threads (NOTE: incomplete) */ \ /******************************/ \ \ - nonstatic_field(OSThread, _thread_id, unsigned long) \ + nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ unchecked_nonstatic_field(OSThread, _thread_handle, sizeof(HANDLE)) /* NOTE: no type */ \ \ /* This must be the last entry, and must be present */ \ diff --git a/src/share/vm/runtime/osThread.hpp b/src/share/vm/runtime/osThread.hpp index bb3fd79637b6f5cd122bd7b76f289eff0b26117c..c0f2b1932c99d2f4abc066001dab616fb6a53cc2 100644 --- a/src/share/vm/runtime/osThread.hpp +++ b/src/share/vm/runtime/osThread.hpp @@ -61,7 +61,6 @@ enum ThreadState { class OSThread: public CHeapObj { friend class VMStructs; private: - //void* _start_proc; // Thread start routine OSThreadStartFunc _start_proc; // Thread start routine void* _start_parm; // Thread start routine parameter volatile ThreadState _state; // Thread state *hint* @@ -77,10 +76,7 @@ class OSThread: public CHeapObj { void set_state(ThreadState state) { _state = state; } ThreadState get_state() { return _state; } - // Constructor OSThread(OSThreadStartFunc start_proc, void* start_parm); - - // Destructor ~OSThread(); // Accessors @@ -98,7 +94,6 @@ class OSThread: public CHeapObj { // For java intrinsics: static ByteSize interrupted_offset() { return byte_offset_of(OSThread, _interrupted); } - static ByteSize thread_id_offset() { return byte_offset_of(OSThread, _thread_id); } // Platform dependent stuff #ifdef TARGET_OS_FAMILY_linux @@ -114,6 +109,19 @@ class OSThread: public CHeapObj { # include "osThread_bsd.hpp" #endif + public: + static ByteSize thread_id_offset() { return byte_offset_of(OSThread, _thread_id); } + static size_t thread_id_size() { return sizeof(thread_id_t); } + + thread_id_t thread_id() const { return _thread_id; } + + void set_thread_id(thread_id_t id) { _thread_id = id; } + + private: + // _thread_id is kernel thread id (similar to LWP id on Solaris). Each + // thread has a unique thread_id (BsdThreads or NPTL). It can be used + // to access /proc. + thread_id_t _thread_id; };