comparison src/share/vm/runtime/thread.hpp @ 7066:7d815d842ee0

Merge.
author Christian Haeubl <haeubl@ssw.jku.at>
date Fri, 23 Nov 2012 11:50:27 +0100
parents 679e6584c177
children 291ffc492eb6
comparison
equal deleted inserted replaced
7065:cfacf5d5bade 7066:7d815d842ee0
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
45 #if INCLUDE_NMT
44 #include "services/memRecorder.hpp" 46 #include "services/memRecorder.hpp"
47 #endif // INCLUDE_NMT
48
45 #include "trace/tracing.hpp" 49 #include "trace/tracing.hpp"
46 #include "utilities/exceptions.hpp" 50 #include "utilities/exceptions.hpp"
47 #include "utilities/top.hpp" 51 #include "utilities/top.hpp"
48 #ifndef SERIALGC 52 #ifndef SERIALGC
49 #include "gc_implementation/g1/dirtyCardQueue.hpp" 53 #include "gc_implementation/g1/dirtyCardQueue.hpp"
104 protected: 108 protected:
105 // Support for forcing alignment of thread objects for biased locking 109 // Support for forcing alignment of thread objects for biased locking
106 void* _real_malloc_address; 110 void* _real_malloc_address;
107 public: 111 public:
108 void* operator new(size_t size) { return allocate(size, true); } 112 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); } 113 void* operator new(size_t size, const std::nothrow_t& nothrow_constant) { return allocate(size, false); }
110 void operator delete(void* p); 114 void operator delete(void* p);
111 115
112 protected: 116 protected:
113 static void* allocate(size_t size, bool throw_excpt, MEMFLAGS flags = mtThread); 117 static void* allocate(size_t size, bool throw_excpt, MEMFLAGS flags = mtThread);
114 private: 118 private:
415 419
416 // Internal handle support 420 // Internal handle support
417 HandleArea* handle_area() const { return _handle_area; } 421 HandleArea* handle_area() const { return _handle_area; }
418 void set_handle_area(HandleArea* area) { _handle_area = area; } 422 void set_handle_area(HandleArea* area) { _handle_area = area; }
419 423
424 GrowableArray<Metadata*>* metadata_handles() const { return _metadata_handles; }
425 void set_metadata_handles(GrowableArray<Metadata*>* handles){ _metadata_handles = handles; }
426
420 // Thread-Local Allocation Buffer (TLAB) support 427 // Thread-Local Allocation Buffer (TLAB) support
421 ThreadLocalAllocBuffer& tlab() { return _tlab; } 428 ThreadLocalAllocBuffer& tlab() { return _tlab; }
422 void initialize_tlab() { 429 void initialize_tlab() {
423 if (UseTLAB) { 430 if (UseTLAB) {
424 tlab().initialize(); 431 tlab().initialize();
498 } 505 }
499 506
500 // Sweeper support 507 // Sweeper support
501 void nmethods_do(CodeBlobClosure* cf); 508 void nmethods_do(CodeBlobClosure* cf);
502 509
510 // jvmtiRedefineClasses support
511 void metadata_do(void f(Metadata*));
512
503 // Used by fast lock support 513 // Used by fast lock support
504 virtual bool is_lock_owned(address adr) const; 514 virtual bool is_lock_owned(address adr) const;
505 515
506 // Check if address is in the stack of the thread (not just for locks). 516 // Check if address is in the stack of the thread (not just for locks).
507 // Warning: the method can only be used on the running thread 517 // Warning: the method can only be used on the running thread
518 // Thread local resource area for temporary allocation within the VM 528 // Thread local resource area for temporary allocation within the VM
519 ResourceArea* _resource_area; 529 ResourceArea* _resource_area;
520 530
521 // Thread local handle area for allocation of handles within the VM 531 // Thread local handle area for allocation of handles within the VM
522 HandleArea* _handle_area; 532 HandleArea* _handle_area;
533 GrowableArray<Metadata*>* _metadata_handles;
523 534
524 // Support for stack overflow handling, get_thread, etc. 535 // Support for stack overflow handling, get_thread, etc.
525 address _stack_base; 536 address _stack_base;
526 size_t _stack_size; 537 size_t _stack_size;
527 uintptr_t _self_raw_id; // used by get_thread (mutable) 538 uintptr_t _self_raw_id; // used by get_thread (mutable)
709 virtual void run(); 720 virtual void run();
710 721
711 private: 722 private:
712 static WatcherThread* _watcher_thread; 723 static WatcherThread* _watcher_thread;
713 724
725 static bool _startable;
714 volatile static bool _should_terminate; // updated without holding lock 726 volatile static bool _should_terminate; // updated without holding lock
715 public: 727 public:
716 enum SomeConstants { 728 enum SomeConstants {
717 delay_interval = 10 // interrupt delay in milliseconds 729 delay_interval = 10 // interrupt delay in milliseconds
718 }; 730 };
725 737
726 // Printing 738 // Printing
727 char* name() const { return (char*)"VM Periodic Task Thread"; } 739 char* name() const { return (char*)"VM Periodic Task Thread"; }
728 void print_on(outputStream* st) const; 740 void print_on(outputStream* st) const;
729 void print() const { print_on(tty); } 741 void print() const { print_on(tty); }
742 void unpark();
730 743
731 // Returns the single instance of WatcherThread 744 // Returns the single instance of WatcherThread
732 static WatcherThread* watcher_thread() { return _watcher_thread; } 745 static WatcherThread* watcher_thread() { return _watcher_thread; }
733 746
734 // Create and start the single instance of WatcherThread, or stop it on shutdown 747 // Create and start the single instance of WatcherThread, or stop it on shutdown
735 static void start(); 748 static void start();
736 static void stop(); 749 static void stop();
750 // Only allow start once the VM is sufficiently initialized
751 // Otherwise the first task to enroll will trigger the start
752 static void make_startable();
753
754 private:
755 int sleep() const;
737 }; 756 };
738 757
739 758
740 class CompilerThread; 759 class CompilerThread;
741 760
745 friend class VMStructs; 764 friend class VMStructs;
746 private: 765 private:
747 JavaThread* _next; // The next thread in the Threads list 766 JavaThread* _next; // The next thread in the Threads list
748 oop _threadObj; // The Java level thread object 767 oop _threadObj; // The Java level thread object
749 768
750 // (thomaswue) Necessary for holding a compilation buffer and ci environment. Moved from CompilerThread to JavaThread in order to enable code installation from Java application code. 769 // (thomaswue) Necessary for holding a compilation buffer and ci environment.
770 // Moved up from CompilerThread to JavaThread in order to enable code
771 // installation from Java application code.
751 BufferBlob* _buffer_blob; 772 BufferBlob* _buffer_blob;
752 ciEnv* _env; 773 ciEnv* _env;
753 bool _is_compiling; 774 bool _is_compiling;
754 775
755 #ifdef ASSERT 776 #ifdef ASSERT
793 // This holds the pointer to array (yeah like there might be more than one) of 814 // This holds the pointer to array (yeah like there might be more than one) of
794 // description of compiled vframes that have locals that need to be updated. 815 // description of compiled vframes that have locals that need to be updated.
795 GrowableArray<jvmtiDeferredLocalVariableSet*>* _deferred_locals_updates; 816 GrowableArray<jvmtiDeferredLocalVariableSet*>* _deferred_locals_updates;
796 817
797 // Handshake value for fixing 6243940. We need a place for the i2c 818 // Handshake value for fixing 6243940. We need a place for the i2c
798 // adapter to store the callee methodOop. This value is NEVER live 819 // adapter to store the callee Method*. This value is NEVER live
799 // across a gc point so it does NOT have to be gc'd 820 // across a gc point so it does NOT have to be gc'd
800 // The handshake is open ended since we can't be certain that it will 821 // The handshake is open ended since we can't be certain that it will
801 // be NULLed. This is because we rarely ever see the race and end up 822 // be NULLed. This is because we rarely ever see the race and end up
802 // in handle_wrong_method which is the backend of the handshake. See 823 // in handle_wrong_method which is the backend of the handshake. See
803 // code in i2c adapters and handle_wrong_method. 824 // code in i2c adapters and handle_wrong_method.
804 825
805 methodOop _callee_target; 826 Method* _callee_target;
806 827
807 // Oop results of VM runtime calls 828 // Used to pass back results to the interpreter or generated code running Java code.
808 oop _vm_result; // Used to pass back an oop result into Java code, GC-preserved 829 oop _vm_result; // oop result is GC-preserved
809 oop _vm_result_2; // Used to pass back an oop result into Java code, GC-preserved 830 Metadata* _vm_result_2; // non-oop result
810 831
811 // See ReduceInitialCardMarks: this holds the precise space interval of 832 // See ReduceInitialCardMarks: this holds the precise space interval of
812 // the most recent slow path allocation for which compiled code has 833 // the most recent slow path allocation for which compiled code has
813 // elided card-marks for performance along the fast-path. 834 // elided card-marks for performance along the fast-path.
814 MemRegion _deferred_card_mark; 835 MemRegion _deferred_card_mark;
878 }; 899 };
879 900
880 private: 901 private:
881 902
882 #ifdef GRAAL 903 #ifdef GRAAL
883 // graal needs some place to put the dimensions
884 jint _graal_multinewarray_storage[256];
885
886 volatile oop _graal_deopt_info; 904 volatile oop _graal_deopt_info;
887 address _graal_alternate_call_target; 905 address _graal_alternate_call_target;
906 DebugScopedValue* _debug_scope;
888 #endif 907 #endif
889 #ifdef HIGH_LEVEL_INTERPRETER 908 #ifdef HIGH_LEVEL_INTERPRETER
890 bool _high_level_interpreter_in_vm; 909 bool _high_level_interpreter_in_vm;
891 #endif 910 #endif
892 911
1056 void set_doing_unsafe_access(bool val) { _doing_unsafe_access = val; } 1075 void set_doing_unsafe_access(bool val) { _doing_unsafe_access = val; }
1057 1076
1058 bool do_not_unlock_if_synchronized() { return _do_not_unlock_if_synchronized; } 1077 bool do_not_unlock_if_synchronized() { return _do_not_unlock_if_synchronized; }
1059 void set_do_not_unlock_if_synchronized(bool val) { _do_not_unlock_if_synchronized = val; } 1078 void set_do_not_unlock_if_synchronized(bool val) { _do_not_unlock_if_synchronized = val; }
1060 1079
1080 #if INCLUDE_NMT
1061 // native memory tracking 1081 // native memory tracking
1062 inline MemRecorder* get_recorder() const { return (MemRecorder*)_recorder; } 1082 inline MemRecorder* get_recorder() const { return (MemRecorder*)_recorder; }
1063 inline void set_recorder(MemRecorder* rc) { _recorder = (volatile MemRecorder*)rc; } 1083 inline void set_recorder(MemRecorder* rc) { _recorder = (volatile MemRecorder*)rc; }
1064 1084
1065 private: 1085 private:
1066 // per-thread memory recorder 1086 // per-thread memory recorder
1067 volatile MemRecorder* _recorder; 1087 volatile MemRecorder* _recorder;
1088 #endif // INCLUDE_NMT
1068 1089
1069 // Suspend/resume support for JavaThread 1090 // Suspend/resume support for JavaThread
1070 private: 1091 private:
1071 void set_ext_suspended() { set_suspend_flag (_ext_suspended); } 1092 void set_ext_suspended() { set_suspend_flag (_ext_suspended); }
1072 void clear_ext_suspended() { clear_suspend_flag(_ext_suspended); } 1093 void clear_ext_suspended() { clear_suspend_flag(_ext_suspended); }
1243 void clear_must_deopt_id() { _must_deopt_id = NULL; } 1264 void clear_must_deopt_id() { _must_deopt_id = NULL; }
1244 1265
1245 void set_deopt_nmethod(nmethod* nm) { _deopt_nmethod = nm; } 1266 void set_deopt_nmethod(nmethod* nm) { _deopt_nmethod = nm; }
1246 nmethod* deopt_nmethod() { return _deopt_nmethod; } 1267 nmethod* deopt_nmethod() { return _deopt_nmethod; }
1247 1268
1248 methodOop callee_target() const { return _callee_target; } 1269 Method* callee_target() const { return _callee_target; }
1249 void set_callee_target (methodOop x) { _callee_target = x; } 1270 void set_callee_target (Method* x) { _callee_target = x; }
1250 1271
1251 // Oop results of vm runtime calls 1272 // Oop results of vm runtime calls
1252 oop vm_result() const { return _vm_result; } 1273 oop vm_result() const { return _vm_result; }
1253 void set_vm_result (oop x) { _vm_result = x; } 1274 void set_vm_result (oop x) { _vm_result = x; }
1254 1275
1255 oop vm_result_2() const { return _vm_result_2; } 1276 Metadata* vm_result_2() const { return _vm_result_2; }
1256 void set_vm_result_2 (oop x) { _vm_result_2 = x; } 1277 void set_vm_result_2 (Metadata* x) { _vm_result_2 = x; }
1257 1278
1258 MemRegion deferred_card_mark() const { return _deferred_card_mark; } 1279 MemRegion deferred_card_mark() const { return _deferred_card_mark; }
1259 void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; } 1280 void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; }
1260 1281
1261 #ifdef GRAAL 1282 #ifdef GRAAL
1262 oop graal_deopt_info() const { return _graal_deopt_info; } 1283 oop graal_deopt_info() const { return _graal_deopt_info; }
1263 void set_graal_deopt_info(oop o) { _graal_deopt_info = o; } 1284 void set_graal_deopt_info(oop o) { _graal_deopt_info = o; }
1264 1285
1265 void set_graal_alternate_call_target(address a) { _graal_alternate_call_target = a; } 1286 void set_graal_alternate_call_target(address a) { _graal_alternate_call_target = a; }
1287
1288 DebugScopedValue* debug_scope() const { return _debug_scope; }
1289 void set_debug_scope(DebugScopedValue* ds) { _debug_scope = ds; }
1266 #endif 1290 #endif
1267 #ifdef HIGH_LEVEL_INTERPRETER 1291 #ifdef HIGH_LEVEL_INTERPRETER
1268 bool high_level_interpreter_in_vm() { return _high_level_interpreter_in_vm; } 1292 bool high_level_interpreter_in_vm() { return _high_level_interpreter_in_vm; }
1269 void set_high_level_interpreter_in_vm(bool value) { _high_level_interpreter_in_vm = value; } 1293 void set_high_level_interpreter_in_vm(bool value) { _high_level_interpreter_in_vm = value; }
1270 #endif 1294 #endif
1349 static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc ); } 1373 static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc ); }
1350 static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread ); } 1374 static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread ); }
1351 #ifdef GRAAL 1375 #ifdef GRAAL
1352 static ByteSize graal_deopt_info_offset() { return byte_offset_of(JavaThread, _graal_deopt_info ); } 1376 static ByteSize graal_deopt_info_offset() { return byte_offset_of(JavaThread, _graal_deopt_info ); }
1353 static ByteSize graal_alternate_call_target_offset() { return byte_offset_of(JavaThread, _graal_alternate_call_target); } 1377 static ByteSize graal_alternate_call_target_offset() { return byte_offset_of(JavaThread, _graal_alternate_call_target); }
1354 static ByteSize graal_multinewarray_storage_offset() { return byte_offset_of(JavaThread, _graal_multinewarray_storage); }
1355 #endif 1378 #endif
1356 #ifdef HIGH_LEVEL_INTERPRETER 1379 #ifdef HIGH_LEVEL_INTERPRETER
1357 static ByteSize high_level_interpreter_in_vm_offset() { return byte_offset_of(JavaThread, _high_level_interpreter_in_vm); } 1380 static ByteSize high_level_interpreter_in_vm_offset() { return byte_offset_of(JavaThread, _high_level_interpreter_in_vm); }
1358 #endif 1381 #endif
1359 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); } 1382 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); }
1432 // Memory operations 1455 // Memory operations
1433 void oops_do(OopClosure* f, CodeBlobClosure* cf); 1456 void oops_do(OopClosure* f, CodeBlobClosure* cf);
1434 1457
1435 // Sweeper operations 1458 // Sweeper operations
1436 void nmethods_do(CodeBlobClosure* cf); 1459 void nmethods_do(CodeBlobClosure* cf);
1460
1461 // RedefineClasses Support
1462 void metadata_do(void f(Metadata*));
1437 1463
1438 // Memory management operations 1464 // Memory management operations
1439 void gc_epilogue(); 1465 void gc_epilogue();
1440 void gc_prologue(); 1466 void gc_prologue();
1441 1467
1463 } 1489 }
1464 javaVFrame* last_java_vframe(RegisterMap* reg_map); 1490 javaVFrame* last_java_vframe(RegisterMap* reg_map);
1465 1491
1466 // Returns method at 'depth' java or native frames down the stack 1492 // Returns method at 'depth' java or native frames down the stack
1467 // Used for security checks 1493 // Used for security checks
1468 klassOop security_get_caller_class(int depth); 1494 Klass* security_get_caller_class(int depth);
1469 1495
1470 // Print stack trace in external format 1496 // Print stack trace in external format
1471 void print_stack_on(outputStream* st); 1497 void print_stack_on(outputStream* st);
1472 void print_stack() { print_stack_on(tty); } 1498 void print_stack() { print_stack_on(tty); }
1473 1499
1866 private: 1892 private:
1867 static JavaThread* _thread_list; 1893 static JavaThread* _thread_list;
1868 static int _number_of_threads; 1894 static int _number_of_threads;
1869 static int _number_of_non_daemon_threads; 1895 static int _number_of_non_daemon_threads;
1870 static int _return_code; 1896 static int _return_code;
1897 #ifdef ASSERT
1898 static bool _vm_complete;
1899 #endif
1871 1900
1872 public: 1901 public:
1873 // Thread management 1902 // Thread management
1874 // force_daemon is a concession to JNI, where we may need to add a 1903 // force_daemon is a concession to JNI, where we may need to add a
1875 // thread to the thread list before allocating its thread object 1904 // thread to the thread list before allocating its thread object
1913 static void restore_hcode_pointers(); 1942 static void restore_hcode_pointers();
1914 1943
1915 // Sweeper 1944 // Sweeper
1916 static void nmethods_do(CodeBlobClosure* cf); 1945 static void nmethods_do(CodeBlobClosure* cf);
1917 1946
1947 // RedefineClasses support
1948 static void metadata_do(void f(Metadata*));
1949
1918 static void gc_epilogue(); 1950 static void gc_epilogue();
1919 static void gc_prologue(); 1951 static void gc_prologue();
1952 #ifdef ASSERT
1953 static bool is_vm_complete() { return _vm_complete; }
1954 #endif
1920 1955
1921 // Verification 1956 // Verification
1922 static void verify(); 1957 static void verify();
1923 static void print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks); 1958 static void print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks);
1924 static void print(bool print_stacks, bool internal_format) { 1959 static void print(bool print_stacks, bool internal_format) {