1789 jio_fprintf(defaultStream::error_stream(),
1790 "\nException: %s thrown from the UncaughtExceptionHandler"
1791 " in thread \"%s\"\n",
1792 pending_exception()->klass()->external_name(),
1793 get_thread_name());
1794 CLEAR_PENDING_EXCEPTION;
1795 }
1796 }
1797
1798 // Called before the java thread exit since we want to read info
1799 // from java_lang_Thread object
1800 EventThreadEnd event;
1801 if (event.should_commit()) {
1802 event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
1803 event.commit();
1804 }
1805
1806 // Call after last event on thread
1807 EVENT_THREAD_EXIT(this);
1808
1809 log_info(os, thread)("Thread " UINTX_FORMAT " %s.",
1810 os::current_thread_id(),
1811 exit_type == JavaThread::normal_exit ? "exiting" : "detaching");
1812
1813 // Call Thread.exit(). We try 3 times in case we got another Thread.stop during
1814 // the execution of the method. If that is not enough, then we don't really care. Thread.stop
1815 // is deprecated anyhow.
1816 if (!is_Compiler_thread()) {
1817 int count = 3;
1818 while (java_lang_Thread::threadGroup(threadObj()) != NULL && (count-- > 0)) {
1819 EXCEPTION_MARK;
1820 JavaValue result(T_VOID);
1821 KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
1822 JavaCalls::call_virtual(&result,
1823 threadObj, thread_klass,
1824 vmSymbols::exit_method_name(),
1825 vmSymbols::void_method_signature(),
1826 THREAD);
1827 CLEAR_PENDING_EXCEPTION;
1828 }
1829 }
1830 // notify JVMTI
1831 if (JvmtiExport::should_post_thread_life()) {
1832 JvmtiExport::post_thread_end(this);
1914 }
1915
1916 if (JvmtiEnv::environments_might_exist()) {
1917 JvmtiExport::cleanup_thread(this);
1918 }
1919
1920 // We must flush any deferred card marks before removing a thread from
1921 // the list of active threads.
1922 Universe::heap()->flush_deferred_store_barrier(this);
1923 assert(deferred_card_mark().is_empty(), "Should have been flushed");
1924
1925 #if INCLUDE_ALL_GCS
1926 // We must flush the G1-related buffers before removing a thread
1927 // from the list of active threads. We must do this after any deferred
1928 // card marks have been flushed (above) so that any entries that are
1929 // added to the thread's dirty card queue as a result are not lost.
1930 if (UseG1GC) {
1931 flush_barrier_queues();
1932 }
1933 #endif // INCLUDE_ALL_GCS
1934
1935 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
1936 Threads::remove(this);
1937 }
1938
1939 #if INCLUDE_ALL_GCS
1940 // Flush G1-related queues.
1941 void JavaThread::flush_barrier_queues() {
1942 satb_mark_queue().flush();
1943 dirty_card_queue().flush();
1944 }
1945
1946 void JavaThread::initialize_queues() {
1947 assert(!SafepointSynchronize::is_at_safepoint(),
1948 "we should not be at a safepoint");
1949
1950 SATBMarkQueue& satb_queue = satb_mark_queue();
1951 SATBMarkQueueSet& satb_queue_set = satb_mark_queue_set();
1952 // The SATB queue should have been constructed with its active
1953 // field set to false.
|
1789 jio_fprintf(defaultStream::error_stream(),
1790 "\nException: %s thrown from the UncaughtExceptionHandler"
1791 " in thread \"%s\"\n",
1792 pending_exception()->klass()->external_name(),
1793 get_thread_name());
1794 CLEAR_PENDING_EXCEPTION;
1795 }
1796 }
1797
1798 // Called before the java thread exit since we want to read info
1799 // from java_lang_Thread object
1800 EventThreadEnd event;
1801 if (event.should_commit()) {
1802 event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
1803 event.commit();
1804 }
1805
1806 // Call after last event on thread
1807 EVENT_THREAD_EXIT(this);
1808
1809 // Call Thread.exit(). We try 3 times in case we got another Thread.stop during
1810 // the execution of the method. If that is not enough, then we don't really care. Thread.stop
1811 // is deprecated anyhow.
1812 if (!is_Compiler_thread()) {
1813 int count = 3;
1814 while (java_lang_Thread::threadGroup(threadObj()) != NULL && (count-- > 0)) {
1815 EXCEPTION_MARK;
1816 JavaValue result(T_VOID);
1817 KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
1818 JavaCalls::call_virtual(&result,
1819 threadObj, thread_klass,
1820 vmSymbols::exit_method_name(),
1821 vmSymbols::void_method_signature(),
1822 THREAD);
1823 CLEAR_PENDING_EXCEPTION;
1824 }
1825 }
1826 // notify JVMTI
1827 if (JvmtiExport::should_post_thread_life()) {
1828 JvmtiExport::post_thread_end(this);
1910 }
1911
1912 if (JvmtiEnv::environments_might_exist()) {
1913 JvmtiExport::cleanup_thread(this);
1914 }
1915
1916 // We must flush any deferred card marks before removing a thread from
1917 // the list of active threads.
1918 Universe::heap()->flush_deferred_store_barrier(this);
1919 assert(deferred_card_mark().is_empty(), "Should have been flushed");
1920
1921 #if INCLUDE_ALL_GCS
1922 // We must flush the G1-related buffers before removing a thread
1923 // from the list of active threads. We must do this after any deferred
1924 // card marks have been flushed (above) so that any entries that are
1925 // added to the thread's dirty card queue as a result are not lost.
1926 if (UseG1GC) {
1927 flush_barrier_queues();
1928 }
1929 #endif // INCLUDE_ALL_GCS
1930
1931 log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").",
1932 exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
1933 os::current_thread_id());
1934
1935 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
1936 Threads::remove(this);
1937 }
1938
1939 #if INCLUDE_ALL_GCS
1940 // Flush G1-related queues.
1941 void JavaThread::flush_barrier_queues() {
1942 satb_mark_queue().flush();
1943 dirty_card_queue().flush();
1944 }
1945
1946 void JavaThread::initialize_queues() {
1947 assert(!SafepointSynchronize::is_at_safepoint(),
1948 "we should not be at a safepoint");
1949
1950 SATBMarkQueue& satb_queue = satb_mark_queue();
1951 SATBMarkQueueSet& satb_queue_set = satb_mark_queue_set();
1952 // The SATB queue should have been constructed with its active
1953 // field set to false.
|