48 #include "memory/universe.inline.hpp"
49 #include "oops/instanceKlass.hpp"
50 #include "oops/objArrayOop.hpp"
51 #include "oops/oop.inline.hpp"
52 #include "oops/symbol.hpp"
53 #include "oops/verifyOopClosure.hpp"
54 #include "prims/jvm.h"
55 #include "prims/jvm_misc.hpp"
56 #include "prims/jvmtiExport.hpp"
57 #include "prims/jvmtiThreadState.hpp"
58 #include "prims/privilegedStack.hpp"
59 #include "runtime/arguments.hpp"
60 #include "runtime/atomic.hpp"
61 #include "runtime/biasedLocking.hpp"
62 #include "runtime/commandLineFlagConstraintList.hpp"
63 #include "runtime/commandLineFlagWriteableList.hpp"
64 #include "runtime/commandLineFlagRangeList.hpp"
65 #include "runtime/deoptimization.hpp"
66 #include "runtime/frame.inline.hpp"
67 #include "runtime/globals.hpp"
68 #include "runtime/init.hpp"
69 #include "runtime/interfaceSupport.hpp"
70 #include "runtime/java.hpp"
71 #include "runtime/javaCalls.hpp"
72 #include "runtime/jniPeriodicChecker.hpp"
73 #include "runtime/timerTrace.hpp"
74 #include "runtime/memprofiler.hpp"
75 #include "runtime/mutexLocker.hpp"
76 #include "runtime/objectMonitor.hpp"
77 #include "runtime/orderAccess.inline.hpp"
78 #include "runtime/osThread.hpp"
79 #include "runtime/safepoint.hpp"
80 #include "runtime/safepointMechanism.inline.hpp"
81 #include "runtime/sharedRuntime.hpp"
82 #include "runtime/statSampler.hpp"
83 #include "runtime/stubRoutines.hpp"
84 #include "runtime/sweeper.hpp"
85 #include "runtime/task.hpp"
86 #include "runtime/thread.inline.hpp"
87 #include "runtime/threadCritical.hpp"
1478 _parker = Parker::Allocate(this);
1479
1480 #ifndef PRODUCT
1481 _jmp_ring_index = 0;
1482 for (int ji = 0; ji < jump_ring_buffer_size; ji++) {
1483 record_jump(NULL, NULL, NULL, 0);
1484 }
1485 #endif // PRODUCT
1486
1487 // Setup safepoint state info for this thread
1488 ThreadSafepointState::create(this);
1489
1490 debug_only(_java_call_counter = 0);
1491
1492 // JVMTI PopFrame support
1493 _popframe_condition = popframe_inactive;
1494 _popframe_preserved_args = NULL;
1495 _popframe_preserved_args_size = 0;
1496 _frames_to_pop_failed_realloc = 0;
1497
1498 pd_initialize();
1499 }
1500
1501 #if INCLUDE_ALL_GCS
1502 SATBMarkQueueSet JavaThread::_satb_mark_queue_set;
1503 DirtyCardQueueSet JavaThread::_dirty_card_queue_set;
1504 #endif // INCLUDE_ALL_GCS
1505
1506 JavaThread::JavaThread(bool is_attaching_via_jni) :
1507 Thread()
1508 #if INCLUDE_ALL_GCS
1509 , _satb_mark_queue(&_satb_mark_queue_set),
1510 _dirty_card_queue(&_dirty_card_queue_set)
1511 #endif // INCLUDE_ALL_GCS
1512 {
1513 initialize();
1514 if (is_attaching_via_jni) {
1515 _jni_attach_state = _attaching_via_jni;
1516 } else {
1517 _jni_attach_state = _not_attaching_via_jni;
1894 // the list of active threads.
1895 Universe::heap()->flush_deferred_store_barrier(this);
1896 assert(deferred_card_mark().is_empty(), "Should have been flushed");
1897
1898 #if INCLUDE_ALL_GCS
1899 // We must flush the G1-related buffers before removing a thread
1900 // from the list of active threads. We must do this after any deferred
1901 // card marks have been flushed (above) so that any entries that are
1902 // added to the thread's dirty card queue as a result are not lost.
1903 if (UseG1GC) {
1904 flush_barrier_queues();
1905 }
1906 #endif // INCLUDE_ALL_GCS
1907
1908 log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").",
1909 exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
1910 os::current_thread_id());
1911
1912 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
1913 Threads::remove(this);
1914 }
1915
1916 #if INCLUDE_ALL_GCS
1917 // Flush G1-related queues.
1918 void JavaThread::flush_barrier_queues() {
1919 satb_mark_queue().flush();
1920 dirty_card_queue().flush();
1921 }
1922
1923 void JavaThread::initialize_queues() {
1924 assert(!SafepointSynchronize::is_at_safepoint(),
1925 "we should not be at a safepoint");
1926
1927 SATBMarkQueue& satb_queue = satb_mark_queue();
1928 SATBMarkQueueSet& satb_queue_set = satb_mark_queue_set();
1929 // The SATB queue should have been constructed with its active
1930 // field set to false.
1931 assert(!satb_queue.is_active(), "SATB queue should not be active");
1932 assert(satb_queue.is_empty(), "SATB queue should be empty");
1933 // If we are creating the thread during a marking cycle, we should
|
48 #include "memory/universe.inline.hpp"
49 #include "oops/instanceKlass.hpp"
50 #include "oops/objArrayOop.hpp"
51 #include "oops/oop.inline.hpp"
52 #include "oops/symbol.hpp"
53 #include "oops/verifyOopClosure.hpp"
54 #include "prims/jvm.h"
55 #include "prims/jvm_misc.hpp"
56 #include "prims/jvmtiExport.hpp"
57 #include "prims/jvmtiThreadState.hpp"
58 #include "prims/privilegedStack.hpp"
59 #include "runtime/arguments.hpp"
60 #include "runtime/atomic.hpp"
61 #include "runtime/biasedLocking.hpp"
62 #include "runtime/commandLineFlagConstraintList.hpp"
63 #include "runtime/commandLineFlagWriteableList.hpp"
64 #include "runtime/commandLineFlagRangeList.hpp"
65 #include "runtime/deoptimization.hpp"
66 #include "runtime/frame.inline.hpp"
67 #include "runtime/globals.hpp"
68 #include "runtime/handshake.hpp"
69 #include "runtime/init.hpp"
70 #include "runtime/interfaceSupport.hpp"
71 #include "runtime/java.hpp"
72 #include "runtime/javaCalls.hpp"
73 #include "runtime/jniPeriodicChecker.hpp"
74 #include "runtime/timerTrace.hpp"
75 #include "runtime/memprofiler.hpp"
76 #include "runtime/mutexLocker.hpp"
77 #include "runtime/objectMonitor.hpp"
78 #include "runtime/orderAccess.inline.hpp"
79 #include "runtime/osThread.hpp"
80 #include "runtime/safepoint.hpp"
81 #include "runtime/safepointMechanism.inline.hpp"
82 #include "runtime/sharedRuntime.hpp"
83 #include "runtime/statSampler.hpp"
84 #include "runtime/stubRoutines.hpp"
85 #include "runtime/sweeper.hpp"
86 #include "runtime/task.hpp"
87 #include "runtime/thread.inline.hpp"
88 #include "runtime/threadCritical.hpp"
1479 _parker = Parker::Allocate(this);
1480
1481 #ifndef PRODUCT
1482 _jmp_ring_index = 0;
1483 for (int ji = 0; ji < jump_ring_buffer_size; ji++) {
1484 record_jump(NULL, NULL, NULL, 0);
1485 }
1486 #endif // PRODUCT
1487
1488 // Setup safepoint state info for this thread
1489 ThreadSafepointState::create(this);
1490
1491 debug_only(_java_call_counter = 0);
1492
1493 // JVMTI PopFrame support
1494 _popframe_condition = popframe_inactive;
1495 _popframe_preserved_args = NULL;
1496 _popframe_preserved_args_size = 0;
1497 _frames_to_pop_failed_realloc = 0;
1498
1499 if (SafepointMechanism::uses_thread_local_poll()) {
1500 SafepointMechanism::initialize_header(this);
1501 }
1502
1503 pd_initialize();
1504 }
1505
1506 #if INCLUDE_ALL_GCS
1507 SATBMarkQueueSet JavaThread::_satb_mark_queue_set;
1508 DirtyCardQueueSet JavaThread::_dirty_card_queue_set;
1509 #endif // INCLUDE_ALL_GCS
1510
1511 JavaThread::JavaThread(bool is_attaching_via_jni) :
1512 Thread()
1513 #if INCLUDE_ALL_GCS
1514 , _satb_mark_queue(&_satb_mark_queue_set),
1515 _dirty_card_queue(&_dirty_card_queue_set)
1516 #endif // INCLUDE_ALL_GCS
1517 {
1518 initialize();
1519 if (is_attaching_via_jni) {
1520 _jni_attach_state = _attaching_via_jni;
1521 } else {
1522 _jni_attach_state = _not_attaching_via_jni;
1899 // the list of active threads.
1900 Universe::heap()->flush_deferred_store_barrier(this);
1901 assert(deferred_card_mark().is_empty(), "Should have been flushed");
1902
1903 #if INCLUDE_ALL_GCS
1904 // We must flush the G1-related buffers before removing a thread
1905 // from the list of active threads. We must do this after any deferred
1906 // card marks have been flushed (above) so that any entries that are
1907 // added to the thread's dirty card queue as a result are not lost.
1908 if (UseG1GC) {
1909 flush_barrier_queues();
1910 }
1911 #endif // INCLUDE_ALL_GCS
1912
1913 log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").",
1914 exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
1915 os::current_thread_id());
1916
1917 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
1918 Threads::remove(this);
1919
1920 // If someone set a handshake on us just as we entered exit path, we simple cancel it.
1921 if (ThreadLocalHandshakes) {
1922 cancel_handshake();
1923 }
1924 }
1925
1926 #if INCLUDE_ALL_GCS
1927 // Flush G1-related queues.
1928 void JavaThread::flush_barrier_queues() {
1929 satb_mark_queue().flush();
1930 dirty_card_queue().flush();
1931 }
1932
1933 void JavaThread::initialize_queues() {
1934 assert(!SafepointSynchronize::is_at_safepoint(),
1935 "we should not be at a safepoint");
1936
1937 SATBMarkQueue& satb_queue = satb_mark_queue();
1938 SATBMarkQueueSet& satb_queue_set = satb_mark_queue_set();
1939 // The SATB queue should have been constructed with its active
1940 // field set to false.
1941 assert(!satb_queue.is_active(), "SATB queue should not be active");
1942 assert(satb_queue.is_empty(), "SATB queue should be empty");
1943 // If we are creating the thread during a marking cycle, we should
|