src/hotspot/share/ci/ciEnv.cpp
changeset 53469 1d953ae4d39f
parent 53345 91ab128a65a3
child 53582 881c5fbeb849
--- a/src/hotspot/share/ci/ciEnv.cpp	Thu Jan 24 14:43:56 2019 +0100
+++ b/src/hotspot/share/ci/ciEnv.cpp	Thu Jan 24 08:44:26 2019 -0500
@@ -915,8 +915,15 @@
   return JavaThread::current()->thread_state() == _thread_in_vm;
 }
 
+bool ciEnv::system_dictionary_modification_counter_changed_locked() {
+  assert_locked_or_safepoint(Compile_lock);
+  return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
+}
+
 bool ciEnv::system_dictionary_modification_counter_changed() {
-  return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
+  VM_ENTRY_MARK;
+  MutexLocker ml(Compile_lock, THREAD); // lock with safepoint check
+  return system_dictionary_modification_counter_changed_locked();
 }
 
 // ------------------------------------------------------------------
@@ -927,7 +934,7 @@
 void ciEnv::validate_compile_task_dependencies(ciMethod* target) {
   if (failing())  return;  // no need for further checks
 
-  bool counter_changed = system_dictionary_modification_counter_changed();
+  bool counter_changed = system_dictionary_modification_counter_changed_locked();
   Dependencies::DepType result = dependencies()->validate_dependencies(_task, counter_changed);
   if (result != Dependencies::end_marker) {
     if (result == Dependencies::call_site_target_value) {