src/hotspot/share/code/dependencies.cpp
changeset 55635 0fb70c9118ce
parent 54721 3661ad97da8f
child 58177 4932dce35882
equal deleted inserted replaced
55634:0f1e29c77e50 55635:0fb70c9118ce
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   625 
   625 
   626 void Dependencies::check_valid_dependency_type(DepType dept) {
   626 void Dependencies::check_valid_dependency_type(DepType dept) {
   627   guarantee(FIRST_TYPE <= dept && dept < TYPE_LIMIT, "invalid dependency type: %d", (int) dept);
   627   guarantee(FIRST_TYPE <= dept && dept < TYPE_LIMIT, "invalid dependency type: %d", (int) dept);
   628 }
   628 }
   629 
   629 
   630 Dependencies::DepType Dependencies::validate_dependencies(CompileTask* task, bool counter_changed, char** failure_detail) {
   630 Dependencies::DepType Dependencies::validate_dependencies(CompileTask* task, char** failure_detail) {
   631   // First, check non-klass dependencies as we might return early and
       
   632   // not check klass dependencies if the system dictionary
       
   633   // modification counter hasn't changed (see below).
       
   634   for (Dependencies::DepStream deps(this); deps.next(); ) {
       
   635     if (deps.is_klass_type())  continue;  // skip klass dependencies
       
   636     Klass* witness = deps.check_dependency();
       
   637     if (witness != NULL) {
       
   638       return deps.type();
       
   639     }
       
   640   }
       
   641 
       
   642   // Klass dependencies must be checked when the system dictionary
       
   643   // changes.  If logging is enabled all violated dependences will be
       
   644   // recorded in the log.  In debug mode check dependencies even if
       
   645   // the system dictionary hasn't changed to verify that no invalid
       
   646   // dependencies were inserted.  Any violated dependences in this
       
   647   // case are dumped to the tty.
       
   648   if (!counter_changed && !trueInDebug) {
       
   649     return end_marker;
       
   650   }
       
   651 
       
   652   int klass_violations = 0;
   631   int klass_violations = 0;
   653   DepType result = end_marker;
   632   DepType result = end_marker;
   654   for (Dependencies::DepStream deps(this); deps.next(); ) {
   633   for (Dependencies::DepStream deps(this); deps.next(); ) {
   655     if (!deps.is_klass_type())  continue;  // skip non-klass dependencies
       
   656     Klass* witness = deps.check_dependency();
   634     Klass* witness = deps.check_dependency();
   657     if (witness != NULL) {
   635     if (witness != NULL) {
   658       if (klass_violations == 0) {
   636       if (klass_violations == 0) {
   659         result = deps.type();
   637         result = deps.type();
   660         if (failure_detail != NULL && klass_violations == 0) {
   638         if (failure_detail != NULL && klass_violations == 0) {
   665           deps.print_dependency(witness, true, &st);
   643           deps.print_dependency(witness, true, &st);
   666           *failure_detail = st.as_string();
   644           *failure_detail = st.as_string();
   667         }
   645         }
   668       }
   646       }
   669       klass_violations++;
   647       klass_violations++;
   670       if (!counter_changed) {
   648       if (xtty == NULL) {
   671         // Dependence failed but counter didn't change.  Log a message
       
   672         // describing what failed and allow the assert at the end to
       
   673         // trigger.
       
   674         deps.print_dependency(witness);
       
   675       } else if (xtty == NULL) {
       
   676         // If we're not logging then a single violation is sufficient,
   649         // If we're not logging then a single violation is sufficient,
   677         // otherwise we want to log all the dependences which were
   650         // otherwise we want to log all the dependences which were
   678         // violated.
   651         // violated.
   679         break;
   652         break;
   680       }
   653       }
   681     }
   654     }
   682   }
   655   }
   683 
   656 
   684   if (klass_violations != 0) {
       
   685 #ifdef ASSERT
       
   686     if (task != NULL && !counter_changed && !PrintCompilation) {
       
   687       // Print out the compile task that failed
       
   688       task->print_tty();
       
   689     }
       
   690 #endif
       
   691     assert(counter_changed, "failed dependencies, but counter didn't change");
       
   692   }
       
   693   return result;
   657   return result;
   694 }
   658 }
   695 
   659 
   696 // for the sake of the compiler log, print out current dependencies:
   660 // for the sake of the compiler log, print out current dependencies:
   697 void Dependencies::log_all_dependencies() {
   661 void Dependencies::log_all_dependencies() {