comparison src/share/vm/runtime/thread.hpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents a29e6e7b7a86 78bbf4d43a14
children 8f2fb6bec986
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
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.
247 debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops. 247 debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops.
248 248
249 // Used by SkipGCALot class. 249 // Used by SkipGCALot class.
250 NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot? 250 NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot?
251 251
252 // Record when GC is locked out via the GC_locker mechanism
253 CHECK_UNHANDLED_OOPS_ONLY(int _gc_locked_out_count;)
254
255 friend class No_Alloc_Verifier; 252 friend class No_Alloc_Verifier;
256 friend class No_Safepoint_Verifier; 253 friend class No_Safepoint_Verifier;
257 friend class Pause_No_Safepoint_Verifier; 254 friend class Pause_No_Safepoint_Verifier;
258 friend class ThreadLocalStorage; 255 friend class ThreadLocalStorage;
259 friend class GC_locker; 256 friend class GC_locker;
398 } 395 }
399 // Clear oops at safepoint so crashes point to unhandled oop violator 396 // Clear oops at safepoint so crashes point to unhandled oop violator
400 void clear_unhandled_oops() { 397 void clear_unhandled_oops() {
401 if (CheckUnhandledOops) unhandled_oops()->clear_unhandled_oops(); 398 if (CheckUnhandledOops) unhandled_oops()->clear_unhandled_oops();
402 } 399 }
403 bool is_gc_locked_out() { return _gc_locked_out_count > 0; }
404 #endif // CHECK_UNHANDLED_OOPS 400 #endif // CHECK_UNHANDLED_OOPS
405 401
406 #ifndef PRODUCT 402 #ifndef PRODUCT
407 bool skip_gcalot() { return _skip_gcalot; } 403 bool skip_gcalot() { return _skip_gcalot; }
408 void set_skip_gcalot(bool v) { _skip_gcalot = v; } 404 void set_skip_gcalot(bool v) { _skip_gcalot = v; }
700 696
701 public: 697 public:
702 NamedThread(); 698 NamedThread();
703 ~NamedThread(); 699 ~NamedThread();
704 // May only be called once per thread. 700 // May only be called once per thread.
705 void set_name(const char* format, ...); 701 void set_name(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
706 virtual bool is_Named_thread() const { return true; } 702 virtual bool is_Named_thread() const { return true; }
707 virtual char* name() const { return _name == NULL ? (char*)"Unknown Thread" : _name; } 703 virtual char* name() const { return _name == NULL ? (char*)"Unknown Thread" : _name; }
708 JavaThread *processed_thread() { return _processed_thread; } 704 JavaThread *processed_thread() { return _processed_thread; }
709 void set_processed_thread(JavaThread *thread) { _processed_thread = thread; } 705 void set_processed_thread(JavaThread *thread) { _processed_thread = thread; }
710 }; 706 };
929 public: 925 public:
930 static jlong* _graal_old_thread_counters; 926 static jlong* _graal_old_thread_counters;
931 static void collect_counters(typeArrayOop array); 927 static void collect_counters(typeArrayOop array);
932 private: 928 private:
933 #endif // GRAAL 929 #endif // GRAAL
934 StackGuardState _stack_guard_state;
935 930
936 nmethod* _scanned_nmethod; // nmethod being scanned by the sweeper 931 nmethod* _scanned_nmethod; // nmethod being scanned by the sweeper
932
933 StackGuardState _stack_guard_state;
934
935 // Precompute the limit of the stack as used in stack overflow checks.
936 // We load it from here to simplify the stack overflow check in assembly.
937 address _stack_overflow_limit;
937 938
938 // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is 939 // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is
939 // used to temp. parsing values into and out of the runtime system during exception handling for compiled 940 // used to temp. parsing values into and out of the runtime system during exception handling for compiled
940 // code) 941 // code)
941 volatile oop _exception_oop; // Exception thrown in compiled code 942 volatile oop _exception_oop; // Exception thrown in compiled code
1087 // Allocates a new Java level thread object for this thread. thread_name may be NULL. 1088 // Allocates a new Java level thread object for this thread. thread_name may be NULL.
1088 void allocate_threadObj(Handle thread_group, char* thread_name, bool daemon, TRAPS); 1089 void allocate_threadObj(Handle thread_group, char* thread_name, bool daemon, TRAPS);
1089 1090
1090 // Last frame anchor routines 1091 // Last frame anchor routines
1091 1092
1092 JavaFrameAnchor* frame_anchor(void) { return &_anchor; } 1093 JavaFrameAnchor* frame_anchor(void) { return &_anchor; }
1093 1094
1094 // last_Java_sp 1095 // last_Java_sp
1095 bool has_last_Java_frame() const { return _anchor.has_last_Java_frame(); } 1096 bool has_last_Java_frame() const { return _anchor.has_last_Java_frame(); }
1096 intptr_t* last_Java_sp() const { return _anchor.last_Java_sp(); } 1097 intptr_t* last_Java_sp() const { return _anchor.last_Java_sp(); }
1097 1098
1098 // last_Java_pc 1099 // last_Java_pc
1099 1100
1100 address last_Java_pc(void) { return _anchor.last_Java_pc(); } 1101 address last_Java_pc(void) { return _anchor.last_Java_pc(); }
1101 1102
1102 // Safepoint support 1103 // Safepoint support
1104 #ifndef PPC64
1103 JavaThreadState thread_state() const { return _thread_state; } 1105 JavaThreadState thread_state() const { return _thread_state; }
1104 void set_thread_state(JavaThreadState s) { _thread_state=s; } 1106 void set_thread_state(JavaThreadState s) { _thread_state = s; }
1105 ThreadSafepointState *safepoint_state() const { return _safepoint_state; } 1107 #else
1108 // Use membars when accessing volatile _thread_state. See
1109 // Threads::create_vm() for size checks.
1110 JavaThreadState thread_state() const {
1111 return (JavaThreadState) OrderAccess::load_acquire((volatile jint*)&_thread_state);
1112 }
1113 void set_thread_state(JavaThreadState s) {
1114 OrderAccess::release_store((volatile jint*)&_thread_state, (jint)s);
1115 }
1116 #endif
1117 ThreadSafepointState *safepoint_state() const { return _safepoint_state; }
1106 void set_safepoint_state(ThreadSafepointState *state) { _safepoint_state = state; } 1118 void set_safepoint_state(ThreadSafepointState *state) { _safepoint_state = state; }
1107 bool is_at_poll_safepoint() { return _safepoint_state->is_at_poll_safepoint(); } 1119 bool is_at_poll_safepoint() { return _safepoint_state->is_at_poll_safepoint(); }
1108 1120
1109 // thread has called JavaThread::exit() or is terminated 1121 // thread has called JavaThread::exit() or is terminated
1110 bool is_exiting() { return _terminated == _thread_exiting || is_terminated(); } 1122 bool is_exiting() { return _terminated == _thread_exiting || is_terminated(); }
1382 bool reguard_stack(address cur_sp); 1394 bool reguard_stack(address cur_sp);
1383 // Similar to above but see if current stackpoint is out of the guard area 1395 // Similar to above but see if current stackpoint is out of the guard area
1384 // and reguard if possible. 1396 // and reguard if possible.
1385 bool reguard_stack(void); 1397 bool reguard_stack(void);
1386 1398
1399 address stack_overflow_limit() { return _stack_overflow_limit; }
1400 void set_stack_overflow_limit() {
1401 _stack_overflow_limit = _stack_base - _stack_size +
1402 ((StackShadowPages +
1403 StackYellowPages +
1404 StackRedPages) * os::vm_page_size());
1405 }
1406
1387 // Misc. accessors/mutators 1407 // Misc. accessors/mutators
1388 void set_do_not_unlock(void) { _do_not_unlock_if_synchronized = true; } 1408 void set_do_not_unlock(void) { _do_not_unlock_if_synchronized = true; }
1389 void clr_do_not_unlock(void) { _do_not_unlock_if_synchronized = false; } 1409 void clr_do_not_unlock(void) { _do_not_unlock_if_synchronized = false; }
1390 bool do_not_unlock(void) { return _do_not_unlock_if_synchronized; } 1410 bool do_not_unlock(void) { return _do_not_unlock_if_synchronized; }
1391 1411
1421 static ByteSize graal_counters_offset() { return byte_offset_of(JavaThread, _graal_counters ); } 1441 static ByteSize graal_counters_offset() { return byte_offset_of(JavaThread, _graal_counters ); }
1422 #endif // GRAAL 1442 #endif // GRAAL
1423 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); } 1443 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); }
1424 static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc ); } 1444 static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc ); }
1425 static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); } 1445 static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); }
1446 static ByteSize stack_overflow_limit_offset() { return byte_offset_of(JavaThread, _stack_overflow_limit); }
1426 static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); } 1447 static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); }
1427 static ByteSize stack_guard_state_offset() { return byte_offset_of(JavaThread, _stack_guard_state ); } 1448 static ByteSize stack_guard_state_offset() { return byte_offset_of(JavaThread, _stack_guard_state ); }
1428 static ByteSize suspend_flags_offset() { return byte_offset_of(JavaThread, _suspend_flags ); } 1449 static ByteSize suspend_flags_offset() { return byte_offset_of(JavaThread, _suspend_flags ); }
1429 1450
1430 static ByteSize do_not_unlock_if_synchronized_offset() { return byte_offset_of(JavaThread, _do_not_unlock_if_synchronized); } 1451 static ByteSize do_not_unlock_if_synchronized_offset() { return byte_offset_of(JavaThread, _do_not_unlock_if_synchronized); }
1784 # include "thread_linux_arm.hpp" 1805 # include "thread_linux_arm.hpp"
1785 #endif 1806 #endif
1786 #ifdef TARGET_OS_ARCH_linux_ppc 1807 #ifdef TARGET_OS_ARCH_linux_ppc
1787 # include "thread_linux_ppc.hpp" 1808 # include "thread_linux_ppc.hpp"
1788 #endif 1809 #endif
1810 #ifdef TARGET_OS_ARCH_aix_ppc
1811 # include "thread_aix_ppc.hpp"
1812 #endif
1789 #ifdef TARGET_OS_ARCH_bsd_x86 1813 #ifdef TARGET_OS_ARCH_bsd_x86
1790 # include "thread_bsd_x86.hpp" 1814 # include "thread_bsd_x86.hpp"
1791 #endif 1815 #endif
1792 #ifdef TARGET_OS_ARCH_bsd_zero 1816 #ifdef TARGET_OS_ARCH_bsd_zero
1793 # include "thread_bsd_zero.hpp" 1817 # include "thread_bsd_zero.hpp"
1823 bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; } 1847 bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1824 bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; } 1848 bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1825 void set_done_attaching_via_jni() { _jni_attach_state = _attached_via_jni; OrderAccess::fence(); } 1849 void set_done_attaching_via_jni() { _jni_attach_state = _attached_via_jni; OrderAccess::fence(); }
1826 private: 1850 private:
1827 // This field is used to determine if a thread has claimed 1851 // This field is used to determine if a thread has claimed
1828 // a par_id: it is -1 if the thread has not claimed a par_id; 1852 // a par_id: it is UINT_MAX if the thread has not claimed a par_id;
1829 // otherwise its value is the par_id that has been claimed. 1853 // otherwise its value is the par_id that has been claimed.
1830 int _claimed_par_id; 1854 uint _claimed_par_id;
1831 public: 1855 public:
1832 int get_claimed_par_id() { return _claimed_par_id; } 1856 uint get_claimed_par_id() { return _claimed_par_id; }
1833 void set_claimed_par_id(int id) { _claimed_par_id = id;} 1857 void set_claimed_par_id(uint id) { _claimed_par_id = id;}
1834 }; 1858 };
1835 1859
1836 // Inline implementation of JavaThread::current 1860 // Inline implementation of JavaThread::current
1837 inline JavaThread* JavaThread::current() { 1861 inline JavaThread* JavaThread::current() {
1838 Thread* thread = ThreadLocalStorage::thread(); 1862 Thread* thread = ThreadLocalStorage::thread();