comparison src/share/vm/runtime/thread.hpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents 120820e30baa d2a62e0f25eb
children e522a00b91aa
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
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 // ***************************************************************
266 int omFreeCount; // length of omFreeList 271 int omFreeCount; // length of omFreeList
267 int omFreeProvision; // reload chunk size 272 int omFreeProvision; // reload chunk size
268 ObjectMonitor* omInUseList; // SLL to track monitors in circulation 273 ObjectMonitor* omInUseList; // SLL to track monitors in circulation
269 int omInUseCount; // length of omInUseList 274 int omInUseCount; // length of omInUseList
270 275
276 #ifdef ASSERT
277 private:
278 bool _visited_for_critical_count;
279
280 public:
281 void set_visited_for_critical_count(bool z) { _visited_for_critical_count = z; }
282 bool was_visited_for_critical_count() const { return _visited_for_critical_count; }
283 #endif
284
271 public: 285 public:
272 enum { 286 enum {
273 is_definitely_current_thread = true 287 is_definitely_current_thread = true
274 }; 288 };
275 289
537 void print_on(outputStream* st) const; 551 void print_on(outputStream* st) const;
538 void print() const { print_on(tty); } 552 void print() const { print_on(tty); }
539 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;
540 554
541 // Debug-only code 555 // Debug-only code
542
543 #ifdef ASSERT 556 #ifdef ASSERT
544 private: 557 private:
545 // 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.
546 Monitor* _owned_locks; 559 Monitor* _owned_locks;
547 // 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,
1043 void set_doing_unsafe_access(bool val) { _doing_unsafe_access = val; } 1056 void set_doing_unsafe_access(bool val) { _doing_unsafe_access = val; }
1044 1057
1045 bool do_not_unlock_if_synchronized() { return _do_not_unlock_if_synchronized; } 1058 bool do_not_unlock_if_synchronized() { return _do_not_unlock_if_synchronized; }
1046 void set_do_not_unlock_if_synchronized(bool val) { _do_not_unlock_if_synchronized = val; } 1059 void set_do_not_unlock_if_synchronized(bool val) { _do_not_unlock_if_synchronized = val; }
1047 1060
1061 // native memory tracking
1062 inline MemRecorder* get_recorder() const { return (MemRecorder*)_recorder; }
1063 inline void set_recorder(MemRecorder* rc) { _recorder = (volatile MemRecorder*)rc; }
1064
1065 private:
1066 // per-thread memory recorder
1067 volatile MemRecorder* _recorder;
1048 1068
1049 // Suspend/resume support for JavaThread 1069 // Suspend/resume support for JavaThread
1050
1051 private: 1070 private:
1052 void set_ext_suspended() { set_suspend_flag (_ext_suspended); } 1071 void set_ext_suspended() { set_suspend_flag (_ext_suspended); }
1053 void clear_ext_suspended() { clear_suspend_flag(_ext_suspended); } 1072 void clear_ext_suspended() { clear_suspend_flag(_ext_suspended); }
1054 1073
1055 public: 1074 public:
1487 ThreadProfiler* set_thread_profiler(ThreadProfiler* tp) { 1506 ThreadProfiler* set_thread_profiler(ThreadProfiler* tp) {
1488 ThreadProfiler* result = _thread_profiler; 1507 ThreadProfiler* result = _thread_profiler;
1489 _thread_profiler = tp; 1508 _thread_profiler = tp;
1490 return result; 1509 return result;
1491 } 1510 }
1511
1512 // NMT (Native memory tracking) support.
1513 // This flag helps NMT to determine if this JavaThread will be blocked
1514 // at safepoint. If not, ThreadCritical is needed for writing memory records.
1515 // JavaThread is only safepoint visible when it is in Threads' thread list,
1516 // it is not visible until it is added to the list and becomes invisible
1517 // once it is removed from the list.
1518 public:
1519 bool is_safepoint_visible() const { return _safepoint_visible; }
1520 void set_safepoint_visible(bool visible) { _safepoint_visible = visible; }
1521 private:
1522 bool _safepoint_visible;
1492 1523
1493 // Static operations 1524 // Static operations
1494 public: 1525 public:
1495 // Returns the running thread as a JavaThread 1526 // Returns the running thread as a JavaThread
1496 static inline JavaThread* current(); 1527 static inline JavaThread* current();