39 #include "runtime/park.hpp" |
39 #include "runtime/park.hpp" |
40 #include "runtime/safepoint.hpp" |
40 #include "runtime/safepoint.hpp" |
41 #include "runtime/stubRoutines.hpp" |
41 #include "runtime/stubRoutines.hpp" |
42 #include "runtime/threadLocalStorage.hpp" |
42 #include "runtime/threadLocalStorage.hpp" |
43 #include "runtime/unhandledOops.hpp" |
43 #include "runtime/unhandledOops.hpp" |
|
44 #include "services/memRecorder.hpp" |
44 #include "trace/tracing.hpp" |
45 #include "trace/tracing.hpp" |
45 #include "utilities/exceptions.hpp" |
46 #include "utilities/exceptions.hpp" |
46 #include "utilities/top.hpp" |
47 #include "utilities/top.hpp" |
47 #ifndef SERIALGC |
48 #ifndef SERIALGC |
48 #include "gc_implementation/g1/dirtyCardQueue.hpp" |
49 #include "gc_implementation/g1/dirtyCardQueue.hpp" |
98 // Exception handling |
99 // Exception handling |
99 // (Note: _pending_exception and friends are in ThreadShadow) |
100 // (Note: _pending_exception and friends are in ThreadShadow) |
100 //oop _pending_exception; // pending exception for current thread |
101 //oop _pending_exception; // pending exception for current thread |
101 // const char* _exception_file; // file information for exception (debugging only) |
102 // const char* _exception_file; // file information for exception (debugging only) |
102 // int _exception_line; // line information for exception (debugging only) |
103 // int _exception_line; // line information for exception (debugging only) |
103 |
104 protected: |
104 // Support for forcing alignment of thread objects for biased locking |
105 // Support for forcing alignment of thread objects for biased locking |
105 void* _real_malloc_address; |
106 void* _real_malloc_address; |
106 public: |
107 public: |
107 void* operator new(size_t size); |
108 void* operator new(size_t size) { return allocate(size, true); } |
|
109 void* operator new(size_t size, std::nothrow_t& nothrow_constant) { return allocate(size, false); } |
108 void operator delete(void* p); |
110 void operator delete(void* p); |
|
111 |
|
112 protected: |
|
113 static void* allocate(size_t size, bool throw_excpt, MEMFLAGS flags = mtThread); |
109 private: |
114 private: |
110 |
115 |
111 // *************************************************************** |
116 // *************************************************************** |
112 // Suspend and resume support |
117 // Suspend and resume support |
113 // *************************************************************** |
118 // *************************************************************** |
546 void print_on(outputStream* st) const; |
551 void print_on(outputStream* st) const; |
547 void print() const { print_on(tty); } |
552 void print() const { print_on(tty); } |
548 virtual void print_on_error(outputStream* st, char* buf, int buflen) const; |
553 virtual void print_on_error(outputStream* st, char* buf, int buflen) const; |
549 |
554 |
550 // Debug-only code |
555 // Debug-only code |
551 |
|
552 #ifdef ASSERT |
556 #ifdef ASSERT |
553 private: |
557 private: |
554 // Deadlock detection support for Mutex locks. List of locks own by thread. |
558 // Deadlock detection support for Mutex locks. List of locks own by thread. |
555 Monitor* _owned_locks; |
559 Monitor* _owned_locks; |
556 // Mutex::set_owner_implementation is the only place where _owned_locks is modified, |
560 // Mutex::set_owner_implementation is the only place where _owned_locks is modified, |
1025 void set_doing_unsafe_access(bool val) { _doing_unsafe_access = val; } |
1029 void set_doing_unsafe_access(bool val) { _doing_unsafe_access = val; } |
1026 |
1030 |
1027 bool do_not_unlock_if_synchronized() { return _do_not_unlock_if_synchronized; } |
1031 bool do_not_unlock_if_synchronized() { return _do_not_unlock_if_synchronized; } |
1028 void set_do_not_unlock_if_synchronized(bool val) { _do_not_unlock_if_synchronized = val; } |
1032 void set_do_not_unlock_if_synchronized(bool val) { _do_not_unlock_if_synchronized = val; } |
1029 |
1033 |
|
1034 // native memory tracking |
|
1035 inline MemRecorder* get_recorder() const { return (MemRecorder*)_recorder; } |
|
1036 inline void set_recorder(MemRecorder* rc) { _recorder = (volatile MemRecorder*)rc; } |
|
1037 |
|
1038 private: |
|
1039 // per-thread memory recorder |
|
1040 volatile MemRecorder* _recorder; |
1030 |
1041 |
1031 // Suspend/resume support for JavaThread |
1042 // Suspend/resume support for JavaThread |
1032 |
|
1033 private: |
1043 private: |
1034 void set_ext_suspended() { set_suspend_flag (_ext_suspended); } |
1044 void set_ext_suspended() { set_suspend_flag (_ext_suspended); } |
1035 void clear_ext_suspended() { clear_suspend_flag(_ext_suspended); } |
1045 void clear_ext_suspended() { clear_suspend_flag(_ext_suspended); } |
1036 |
1046 |
1037 public: |
1047 public: |
1450 ThreadProfiler* set_thread_profiler(ThreadProfiler* tp) { |
1460 ThreadProfiler* set_thread_profiler(ThreadProfiler* tp) { |
1451 ThreadProfiler* result = _thread_profiler; |
1461 ThreadProfiler* result = _thread_profiler; |
1452 _thread_profiler = tp; |
1462 _thread_profiler = tp; |
1453 return result; |
1463 return result; |
1454 } |
1464 } |
|
1465 |
|
1466 // NMT (Native memory tracking) support. |
|
1467 // This flag helps NMT to determine if this JavaThread will be blocked |
|
1468 // at safepoint. If not, ThreadCritical is needed for writing memory records. |
|
1469 // JavaThread is only safepoint visible when it is in Threads' thread list, |
|
1470 // it is not visible until it is added to the list and becomes invisible |
|
1471 // once it is removed from the list. |
|
1472 public: |
|
1473 bool is_safepoint_visible() const { return _safepoint_visible; } |
|
1474 void set_safepoint_visible(bool visible) { _safepoint_visible = visible; } |
|
1475 private: |
|
1476 bool _safepoint_visible; |
1455 |
1477 |
1456 // Static operations |
1478 // Static operations |
1457 public: |
1479 public: |
1458 // Returns the running thread as a JavaThread |
1480 // Returns the running thread as a JavaThread |
1459 static inline JavaThread* current(); |
1481 static inline JavaThread* current(); |