hotspot/src/share/vm/ci/ciEnv.cpp
changeset 10503 04b74421bdea
parent 10008 d84de97ad847
child 10508 233d2e7c462d
equal deleted inserted replaced
10502:17598114b94c 10503:04b74421bdea
   882 bool ciEnv::system_dictionary_modification_counter_changed() {
   882 bool ciEnv::system_dictionary_modification_counter_changed() {
   883   return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
   883   return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
   884 }
   884 }
   885 
   885 
   886 // ------------------------------------------------------------------
   886 // ------------------------------------------------------------------
   887 // ciEnv::check_for_system_dictionary_modification
   887 // ciEnv::validate_compile_task_dependencies
   888 // Check for changes to the system dictionary during compilation
   888 //
   889 // class loads, evolution, breakpoints
   889 // Check for changes during compilation (e.g. class loads, evolution,
   890 void ciEnv::check_for_system_dictionary_modification(ciMethod* target) {
   890 // breakpoints, call site invalidation).
       
   891 void ciEnv::validate_compile_task_dependencies(ciMethod* target) {
   891   if (failing())  return;  // no need for further checks
   892   if (failing())  return;  // no need for further checks
   892 
   893 
   893   // Dependencies must be checked when the system dictionary changes.
   894   // First, check non-klass dependencies as we might return early and
   894   // If logging is enabled all violated dependences will be recorded in
   895   // not check klass dependencies if the system dictionary
   895   // the log.  In debug mode check dependencies even if the system
   896   // modification counter hasn't changed (see below).
   896   // dictionary hasn't changed to verify that no invalid dependencies
   897   for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
   897   // were inserted.  Any violated dependences in this case are dumped to
   898     if (deps.is_klass_type())  continue;  // skip klass dependencies
   898   // the tty.
   899     klassOop witness = deps.check_dependency();
   899 
   900     if (witness != NULL) {
       
   901       record_failure("invalid non-klass dependency");
       
   902       return;
       
   903     }
       
   904   }
       
   905 
       
   906   // Klass dependencies must be checked when the system dictionary
       
   907   // changes.  If logging is enabled all violated dependences will be
       
   908   // recorded in the log.  In debug mode check dependencies even if
       
   909   // the system dictionary hasn't changed to verify that no invalid
       
   910   // dependencies were inserted.  Any violated dependences in this
       
   911   // case are dumped to the tty.
   900   bool counter_changed = system_dictionary_modification_counter_changed();
   912   bool counter_changed = system_dictionary_modification_counter_changed();
   901   bool test_deps = counter_changed;
   913   bool test_deps = counter_changed;
   902   DEBUG_ONLY(test_deps = true);
   914   DEBUG_ONLY(test_deps = true);
   903   if (!test_deps)  return;
   915   if (!test_deps)  return;
   904 
   916 
   905   bool print_failures = false;
   917   bool print_failures = false;
   906   DEBUG_ONLY(print_failures = !counter_changed);
   918   DEBUG_ONLY(print_failures = !counter_changed);
   907 
       
   908   bool keep_going = (print_failures || xtty != NULL);
   919   bool keep_going = (print_failures || xtty != NULL);
   909 
   920   int klass_violations = 0;
   910   int violated = 0;
       
   911 
   921 
   912   for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
   922   for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
       
   923     if (!deps.is_klass_type())  continue;  // skip non-klass dependencies
   913     klassOop witness = deps.check_dependency();
   924     klassOop witness = deps.check_dependency();
   914     if (witness != NULL) {
   925     if (witness != NULL) {
   915       ++violated;
   926       klass_violations++;
   916       if (print_failures)  deps.print_dependency(witness, /*verbose=*/ true);
   927       if (print_failures)  deps.print_dependency(witness, /*verbose=*/ true);
   917       // If there's no log and we're not sanity-checking, we're done.
   928     }
   918       if (!keep_going)     break;
   929     // If there's no log and we're not sanity-checking, we're done.
   919     }
   930     if (!keep_going)  break;
   920   }
   931   }
   921 
   932 
   922   if (violated != 0) {
   933   if (klass_violations != 0) {
   923     assert(counter_changed, "failed dependencies, but counter didn't change");
   934     assert(counter_changed, "failed dependencies, but counter didn't change");
   924     record_failure("concurrent class loading");
   935     record_failure("concurrent class loading");
   925   }
   936   }
   926 }
   937 }
   927 
   938 
   976       }
   987       }
   977 
   988 
   978       // Encode the dependencies now, so we can check them right away.
   989       // Encode the dependencies now, so we can check them right away.
   979       dependencies()->encode_content_bytes();
   990       dependencies()->encode_content_bytes();
   980 
   991 
   981       // Check for {class loads, evolution, breakpoints} during compilation
   992       // Check for {class loads, evolution, breakpoints, ...} during compilation
   982       check_for_system_dictionary_modification(target);
   993       validate_compile_task_dependencies(target);
   983     }
   994     }
   984 
   995 
   985     methodHandle method(THREAD, target->get_methodOop());
   996     methodHandle method(THREAD, target->get_methodOop());
   986 
   997 
   987     if (failing()) {
   998     if (failing()) {