Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/thread.hpp @ 6948:e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Nov 2012 23:14:12 +0100 |
parents | 957c266d8bc5 c284cf4781f0 |
children | 679e6584c177 |
comparison
equal
deleted
inserted
replaced
6711:ae13cc658b80 | 6948:e522a00b91aa |
---|---|
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; |
888 #endif | 906 #endif |
889 #ifdef HIGH_LEVEL_INTERPRETER | 907 #ifdef HIGH_LEVEL_INTERPRETER |
890 bool _high_level_interpreter_in_vm; | 908 bool _high_level_interpreter_in_vm; |
1056 void set_doing_unsafe_access(bool val) { _doing_unsafe_access = val; } | 1074 void set_doing_unsafe_access(bool val) { _doing_unsafe_access = val; } |
1057 | 1075 |
1058 bool do_not_unlock_if_synchronized() { return _do_not_unlock_if_synchronized; } | 1076 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; } | 1077 void set_do_not_unlock_if_synchronized(bool val) { _do_not_unlock_if_synchronized = val; } |
1060 | 1078 |
1079 #if INCLUDE_NMT | |
1061 // native memory tracking | 1080 // native memory tracking |
1062 inline MemRecorder* get_recorder() const { return (MemRecorder*)_recorder; } | 1081 inline MemRecorder* get_recorder() const { return (MemRecorder*)_recorder; } |
1063 inline void set_recorder(MemRecorder* rc) { _recorder = (volatile MemRecorder*)rc; } | 1082 inline void set_recorder(MemRecorder* rc) { _recorder = (volatile MemRecorder*)rc; } |
1064 | 1083 |
1065 private: | 1084 private: |
1066 // per-thread memory recorder | 1085 // per-thread memory recorder |
1067 volatile MemRecorder* _recorder; | 1086 volatile MemRecorder* _recorder; |
1087 #endif // INCLUDE_NMT | |
1068 | 1088 |
1069 // Suspend/resume support for JavaThread | 1089 // Suspend/resume support for JavaThread |
1070 private: | 1090 private: |
1071 void set_ext_suspended() { set_suspend_flag (_ext_suspended); } | 1091 void set_ext_suspended() { set_suspend_flag (_ext_suspended); } |
1072 void clear_ext_suspended() { clear_suspend_flag(_ext_suspended); } | 1092 void clear_ext_suspended() { clear_suspend_flag(_ext_suspended); } |
1243 void clear_must_deopt_id() { _must_deopt_id = NULL; } | 1263 void clear_must_deopt_id() { _must_deopt_id = NULL; } |
1244 | 1264 |
1245 void set_deopt_nmethod(nmethod* nm) { _deopt_nmethod = nm; } | 1265 void set_deopt_nmethod(nmethod* nm) { _deopt_nmethod = nm; } |
1246 nmethod* deopt_nmethod() { return _deopt_nmethod; } | 1266 nmethod* deopt_nmethod() { return _deopt_nmethod; } |
1247 | 1267 |
1248 methodOop callee_target() const { return _callee_target; } | 1268 Method* callee_target() const { return _callee_target; } |
1249 void set_callee_target (methodOop x) { _callee_target = x; } | 1269 void set_callee_target (Method* x) { _callee_target = x; } |
1250 | 1270 |
1251 // Oop results of vm runtime calls | 1271 // Oop results of vm runtime calls |
1252 oop vm_result() const { return _vm_result; } | 1272 oop vm_result() const { return _vm_result; } |
1253 void set_vm_result (oop x) { _vm_result = x; } | 1273 void set_vm_result (oop x) { _vm_result = x; } |
1254 | 1274 |
1255 oop vm_result_2() const { return _vm_result_2; } | 1275 Metadata* vm_result_2() const { return _vm_result_2; } |
1256 void set_vm_result_2 (oop x) { _vm_result_2 = x; } | 1276 void set_vm_result_2 (Metadata* x) { _vm_result_2 = x; } |
1257 | 1277 |
1258 MemRegion deferred_card_mark() const { return _deferred_card_mark; } | 1278 MemRegion deferred_card_mark() const { return _deferred_card_mark; } |
1259 void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; } | 1279 void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; } |
1260 | 1280 |
1261 #ifdef GRAAL | 1281 #ifdef GRAAL |
1349 static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc ); } | 1369 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 ); } | 1370 static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread ); } |
1351 #ifdef GRAAL | 1371 #ifdef GRAAL |
1352 static ByteSize graal_deopt_info_offset() { return byte_offset_of(JavaThread, _graal_deopt_info ); } | 1372 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); } | 1373 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 | 1374 #endif |
1356 #ifdef HIGH_LEVEL_INTERPRETER | 1375 #ifdef HIGH_LEVEL_INTERPRETER |
1357 static ByteSize high_level_interpreter_in_vm_offset() { return byte_offset_of(JavaThread, _high_level_interpreter_in_vm); } | 1376 static ByteSize high_level_interpreter_in_vm_offset() { return byte_offset_of(JavaThread, _high_level_interpreter_in_vm); } |
1358 #endif | 1377 #endif |
1359 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); } | 1378 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); } |
1432 // Memory operations | 1451 // Memory operations |
1433 void oops_do(OopClosure* f, CodeBlobClosure* cf); | 1452 void oops_do(OopClosure* f, CodeBlobClosure* cf); |
1434 | 1453 |
1435 // Sweeper operations | 1454 // Sweeper operations |
1436 void nmethods_do(CodeBlobClosure* cf); | 1455 void nmethods_do(CodeBlobClosure* cf); |
1456 | |
1457 // RedefineClasses Support | |
1458 void metadata_do(void f(Metadata*)); | |
1437 | 1459 |
1438 // Memory management operations | 1460 // Memory management operations |
1439 void gc_epilogue(); | 1461 void gc_epilogue(); |
1440 void gc_prologue(); | 1462 void gc_prologue(); |
1441 | 1463 |
1463 } | 1485 } |
1464 javaVFrame* last_java_vframe(RegisterMap* reg_map); | 1486 javaVFrame* last_java_vframe(RegisterMap* reg_map); |
1465 | 1487 |
1466 // Returns method at 'depth' java or native frames down the stack | 1488 // Returns method at 'depth' java or native frames down the stack |
1467 // Used for security checks | 1489 // Used for security checks |
1468 klassOop security_get_caller_class(int depth); | 1490 Klass* security_get_caller_class(int depth); |
1469 | 1491 |
1470 // Print stack trace in external format | 1492 // Print stack trace in external format |
1471 void print_stack_on(outputStream* st); | 1493 void print_stack_on(outputStream* st); |
1472 void print_stack() { print_stack_on(tty); } | 1494 void print_stack() { print_stack_on(tty); } |
1473 | 1495 |
1866 private: | 1888 private: |
1867 static JavaThread* _thread_list; | 1889 static JavaThread* _thread_list; |
1868 static int _number_of_threads; | 1890 static int _number_of_threads; |
1869 static int _number_of_non_daemon_threads; | 1891 static int _number_of_non_daemon_threads; |
1870 static int _return_code; | 1892 static int _return_code; |
1893 #ifdef ASSERT | |
1894 static bool _vm_complete; | |
1895 #endif | |
1871 | 1896 |
1872 public: | 1897 public: |
1873 // Thread management | 1898 // Thread management |
1874 // force_daemon is a concession to JNI, where we may need to add a | 1899 // 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 | 1900 // thread to the thread list before allocating its thread object |
1913 static void restore_hcode_pointers(); | 1938 static void restore_hcode_pointers(); |
1914 | 1939 |
1915 // Sweeper | 1940 // Sweeper |
1916 static void nmethods_do(CodeBlobClosure* cf); | 1941 static void nmethods_do(CodeBlobClosure* cf); |
1917 | 1942 |
1943 // RedefineClasses support | |
1944 static void metadata_do(void f(Metadata*)); | |
1945 | |
1918 static void gc_epilogue(); | 1946 static void gc_epilogue(); |
1919 static void gc_prologue(); | 1947 static void gc_prologue(); |
1948 #ifdef ASSERT | |
1949 static bool is_vm_complete() { return _vm_complete; } | |
1950 #endif | |
1920 | 1951 |
1921 // Verification | 1952 // Verification |
1922 static void verify(); | 1953 static void verify(); |
1923 static void print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks); | 1954 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) { | 1955 static void print(bool print_stacks, bool internal_format) { |