comparison src/share/vm/runtime/thread.hpp @ 4006:436b4a3231bf

7098194: integrate macosx-port changes Summary: Integrate bsd-port/hotspot and macosx-port/hotspot changes as of 2011.09.29. Reviewed-by: kvn, dholmes, never, phh Contributed-by: Christos Zoulas <christos@zoulas.com>, Greg Lewis <glewis@eyesbeyond.com>, Kurt Miller <kurt@intricatesoftware.com>, Alexander Strange <astrange@apple.com>, Mike Swingler <swingler@apple.com>, Roger Hoover <rhoover@apple.com>, Victor Hernandez <vhernandez@apple.com>, Pratik Solanki <psolanki@apple.com>
author dcubed
date Thu, 13 Oct 2011 09:35:42 -0700
parents f08d439fab8c
children 04b9a2566eec 94ec88ca68e2
comparison
equal deleted inserted replaced
4005:2ef3386478e6 4006:436b4a3231bf
307 static ThreadPriority get_priority(const Thread* const thread); 307 static ThreadPriority get_priority(const Thread* const thread);
308 static void start(Thread* thread); 308 static void start(Thread* thread);
309 static void interrupt(Thread* thr); 309 static void interrupt(Thread* thr);
310 static bool is_interrupted(Thread* thr, bool clear_interrupted); 310 static bool is_interrupted(Thread* thr, bool clear_interrupted);
311 311
312 void set_native_thread_name(const char *name) {
313 assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
314 os::set_native_thread_name(name);
315 }
316
312 ObjectMonitor** omInUseList_addr() { return (ObjectMonitor **)&omInUseList; } 317 ObjectMonitor** omInUseList_addr() { return (ObjectMonitor **)&omInUseList; }
313 Monitor* SR_lock() const { return _SR_lock; } 318 Monitor* SR_lock() const { return _SR_lock; }
314 319
315 bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; } 320 bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
316 321
816 // handlers thread is in 821 // handlers thread is in
817 volatile bool _doing_unsafe_access; // Thread may fault due to unsafe access 822 volatile bool _doing_unsafe_access; // Thread may fault due to unsafe access
818 bool _do_not_unlock_if_synchronized; // Do not unlock the receiver of a synchronized method (since it was 823 bool _do_not_unlock_if_synchronized; // Do not unlock the receiver of a synchronized method (since it was
819 // never locked) when throwing an exception. Used by interpreter only. 824 // never locked) when throwing an exception. Used by interpreter only.
820 825
821 // Flag to mark a JNI thread in the process of attaching - See CR 6404306 826 // JNI attach states:
822 // This flag is never set true other than at construction, and in that case 827 enum JNIAttachStates {
823 // is shortly thereafter set false 828 _not_attaching_via_jni = 1, // thread is not attaching via JNI
824 volatile bool _is_attaching; 829 _attaching_via_jni, // thread is attaching via JNI
830 _attached_via_jni // thread has attached via JNI
831 };
832
833 // A regular JavaThread's _jni_attach_state is _not_attaching_via_jni.
834 // A native thread that is attaching via JNI starts with a value
835 // of _attaching_via_jni and transitions to _attached_via_jni.
836 volatile JNIAttachStates _jni_attach_state;
825 837
826 public: 838 public:
827 // State of the stack guard pages for this thread. 839 // State of the stack guard pages for this thread.
828 enum StackGuardState { 840 enum StackGuardState {
829 stack_guard_unused, // not needed 841 stack_guard_unused, // not needed
887 899
888 void initialize(); // Initialized the instance variables 900 void initialize(); // Initialized the instance variables
889 901
890 public: 902 public:
891 // Constructor 903 // Constructor
892 JavaThread(bool is_attaching = false); // for main thread and JNI attached threads 904 JavaThread(bool is_attaching_via_jni = false); // for main thread and JNI attached threads
893 JavaThread(ThreadFunction entry_point, size_t stack_size = 0); 905 JavaThread(ThreadFunction entry_point, size_t stack_size = 0);
894 ~JavaThread(); 906 ~JavaThread();
895 907
896 #ifdef ASSERT 908 #ifdef ASSERT
897 // verify this JavaThread hasn't be published in the Threads::list yet 909 // verify this JavaThread hasn't be published in the Threads::list yet
1639 public: 1651 public:
1640 GrowableArray<MonitorInfo*>* cached_monitor_info() { return _cached_monitor_info; } 1652 GrowableArray<MonitorInfo*>* cached_monitor_info() { return _cached_monitor_info; }
1641 void set_cached_monitor_info(GrowableArray<MonitorInfo*>* info) { _cached_monitor_info = info; } 1653 void set_cached_monitor_info(GrowableArray<MonitorInfo*>* info) { _cached_monitor_info = info; }
1642 1654
1643 // clearing/querying jni attach status 1655 // clearing/querying jni attach status
1644 bool is_attaching() const { return _is_attaching; } 1656 bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1645 void set_attached() { _is_attaching = false; OrderAccess::fence(); } 1657 bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1658 void set_done_attaching_via_jni() { _jni_attach_state = _attached_via_jni; OrderAccess::fence(); }
1646 private: 1659 private:
1647 // This field is used to determine if a thread has claimed 1660 // This field is used to determine if a thread has claimed
1648 // a par_id: it is -1 if the thread has not claimed a par_id; 1661 // a par_id: it is -1 if the thread has not claimed a par_id;
1649 // otherwise its value is the par_id that has been claimed. 1662 // otherwise its value is the par_id that has been claimed.
1650 int _claimed_par_id; 1663 int _claimed_par_id;