< prev index next >

src/hotspot/share/oops/instanceKlass.cpp

Print this page

1088   bool debug_logging_enabled = log_is_enabled(Debug, class, init);
1089 
1090   // refer to the JVM book page 47 for description of steps
1091   // Step 1
1092   {
1093     Handle h_init_lock(THREAD, init_lock());
1094     ObjectLocker ol(h_init_lock, jt);
1095 
1096     // Step 2
1097     // If we were to use wait() instead of waitInterruptibly() then
1098     // we might end up throwing IE from link/symbol resolution sites
1099     // that aren't expected to throw.  This would wreak havoc.  See 6320309.
1100     while (is_being_initialized() && !is_reentrant_initialization(jt)) {
1101       if (debug_logging_enabled) {
1102         ResourceMark rm(jt);
1103         log_debug(class, init)("Thread \"%s\" waiting for initialization of %s by thread \"%s\"",
1104                                jt->name(), external_name(), init_thread_name());
1105       }
1106       wait = true;
1107       jt->set_class_to_be_initialized(this);
















1108       ol.wait_uninterruptibly(jt);
1109       jt->set_class_to_be_initialized(nullptr);
1110     }
1111 
1112     // Step 3
1113     if (is_being_initialized() && is_reentrant_initialization(jt)) {
1114       if (debug_logging_enabled) {
1115         ResourceMark rm(jt);
1116         log_debug(class, init)("Thread \"%s\" recursively initializing %s",
1117                                jt->name(), external_name());
1118       }
1119       DTRACE_CLASSINIT_PROBE_WAIT(recursive, -1, wait);
1120       return;
1121     }
1122 
1123     // Step 4
1124     if (is_initialized()) {
1125       if (debug_logging_enabled) {
1126         ResourceMark rm(jt);
1127         log_debug(class, init)("Thread \"%s\" found %s already initialized",

1088   bool debug_logging_enabled = log_is_enabled(Debug, class, init);
1089 
1090   // refer to the JVM book page 47 for description of steps
1091   // Step 1
1092   {
1093     Handle h_init_lock(THREAD, init_lock());
1094     ObjectLocker ol(h_init_lock, jt);
1095 
1096     // Step 2
1097     // If we were to use wait() instead of waitInterruptibly() then
1098     // we might end up throwing IE from link/symbol resolution sites
1099     // that aren't expected to throw.  This would wreak havoc.  See 6320309.
1100     while (is_being_initialized() && !is_reentrant_initialization(jt)) {
1101       if (debug_logging_enabled) {
1102         ResourceMark rm(jt);
1103         log_debug(class, init)("Thread \"%s\" waiting for initialization of %s by thread \"%s\"",
1104                                jt->name(), external_name(), init_thread_name());
1105       }
1106       wait = true;
1107       jt->set_class_to_be_initialized(this);
1108 
1109 #if INCLUDE_JFR
1110       ContinuationEntry* ce = jt->last_continuation();
1111       if (ce != nullptr && ce->is_virtual_thread()) {
1112         EventVirtualThreadPinned e;
1113         if (e.should_commit()) {
1114           ResourceMark rm(jt);
1115           char reason[256];
1116           jio_snprintf(reason, sizeof reason, "Waiting for initialization of klass %s", external_name());
1117           e.set_pinnedReason(reason);
1118           e.set_carrierThread(JFR_JVM_THREAD_ID(THREAD));
1119           e.commit();
1120         }
1121       }
1122  #endif
1123 
1124       ol.wait_uninterruptibly(jt);
1125       jt->set_class_to_be_initialized(nullptr);
1126     }
1127 
1128     // Step 3
1129     if (is_being_initialized() && is_reentrant_initialization(jt)) {
1130       if (debug_logging_enabled) {
1131         ResourceMark rm(jt);
1132         log_debug(class, init)("Thread \"%s\" recursively initializing %s",
1133                                jt->name(), external_name());
1134       }
1135       DTRACE_CLASSINIT_PROBE_WAIT(recursive, -1, wait);
1136       return;
1137     }
1138 
1139     // Step 4
1140     if (is_initialized()) {
1141       if (debug_logging_enabled) {
1142         ResourceMark rm(jt);
1143         log_debug(class, init)("Thread \"%s\" found %s already initialized",
< prev index next >