< prev index next >

src/hotspot/share/code/dependencies.cpp

Print this page


   1 /*
   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.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 610   3, // unique_concrete_subtypes_2 ctxk, k1, k2
 611   3, // unique_concrete_methods_2 ctxk, m1, m2
 612   1, // no_finalizable_subclasses ctxk
 613   2  // call_site_target_value call_site, method_handle
 614 };
 615 
 616 const char* Dependencies::dep_name(Dependencies::DepType dept) {
 617   if (!dept_in_mask(dept, all_types))  return "?bad-dep?";
 618   return _dep_name[dept];
 619 }
 620 
 621 int Dependencies::dep_args(Dependencies::DepType dept) {
 622   if (!dept_in_mask(dept, all_types))  return -1;
 623   return _dep_args[dept];
 624 }
 625 
 626 void Dependencies::check_valid_dependency_type(DepType dept) {
 627   guarantee(FIRST_TYPE <= dept && dept < TYPE_LIMIT, "invalid dependency type: %d", (int) dept);
 628 }
 629 
 630 Dependencies::DepType Dependencies::validate_dependencies(CompileTask* task, char** failure_detail) {





















 631   int klass_violations = 0;
 632   DepType result = end_marker;
 633   for (Dependencies::DepStream deps(this); deps.next(); ) {

 634     Klass* witness = deps.check_dependency();
 635     if (witness != NULL) {
 636       if (klass_violations == 0) {
 637         result = deps.type();
 638         if (failure_detail != NULL && klass_violations == 0) {
 639           // Use a fixed size buffer to prevent the string stream from
 640           // resizing in the context of an inner resource mark.
 641           char* buffer = NEW_RESOURCE_ARRAY(char, O_BUFLEN);
 642           stringStream st(buffer, O_BUFLEN);
 643           deps.print_dependency(witness, true, &st);
 644           *failure_detail = st.as_string();
 645         }
 646       }
 647       klass_violations++;
 648       if (xtty == NULL) {





 649         // If we're not logging then a single violation is sufficient,
 650         // otherwise we want to log all the dependences which were
 651         // violated.
 652         break;
 653       }
 654     }
 655   }
 656 









 657   return result;
 658 }
 659 
 660 // for the sake of the compiler log, print out current dependencies:
 661 void Dependencies::log_all_dependencies() {
 662   if (log() == NULL)  return;
 663   ResourceMark rm;
 664   for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) {
 665     DepType dept = (DepType)deptv;
 666     GrowableArray<ciBaseObject*>* deps = _deps[dept];
 667     int deplen = deps->length();
 668     if (deplen == 0) {
 669       continue;
 670     }
 671     int stride = dep_args(dept);
 672     GrowableArray<ciBaseObject*>* ciargs = new GrowableArray<ciBaseObject*>(stride);
 673     for (int i = 0; i < deps->length(); i += stride) {
 674       for (int j = 0; j < stride; j++) {
 675         // flush out the identities before printing
 676         ciargs->push(deps->at(i+j));


   1 /*
   2  * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 610   3, // unique_concrete_subtypes_2 ctxk, k1, k2
 611   3, // unique_concrete_methods_2 ctxk, m1, m2
 612   1, // no_finalizable_subclasses ctxk
 613   2  // call_site_target_value call_site, method_handle
 614 };
 615 
 616 const char* Dependencies::dep_name(Dependencies::DepType dept) {
 617   if (!dept_in_mask(dept, all_types))  return "?bad-dep?";
 618   return _dep_name[dept];
 619 }
 620 
 621 int Dependencies::dep_args(Dependencies::DepType dept) {
 622   if (!dept_in_mask(dept, all_types))  return -1;
 623   return _dep_args[dept];
 624 }
 625 
 626 void Dependencies::check_valid_dependency_type(DepType dept) {
 627   guarantee(FIRST_TYPE <= dept && dept < TYPE_LIMIT, "invalid dependency type: %d", (int) dept);
 628 }
 629 
 630 Dependencies::DepType Dependencies::validate_dependencies(CompileTask* task, bool counter_changed, 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;
 653   DepType result = end_marker;
 654   for (Dependencies::DepStream deps(this); deps.next(); ) {
 655     if (!deps.is_klass_type())  continue;  // skip non-klass dependencies
 656     Klass* witness = deps.check_dependency();
 657     if (witness != NULL) {
 658       if (klass_violations == 0) {
 659         result = deps.type();
 660         if (failure_detail != NULL && klass_violations == 0) {
 661           // Use a fixed size buffer to prevent the string stream from
 662           // resizing in the context of an inner resource mark.
 663           char* buffer = NEW_RESOURCE_ARRAY(char, O_BUFLEN);
 664           stringStream st(buffer, O_BUFLEN);
 665           deps.print_dependency(witness, true, &st);
 666           *failure_detail = st.as_string();
 667         }
 668       }
 669       klass_violations++;
 670       if (!counter_changed) {
 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,
 677         // otherwise we want to log all the dependences which were
 678         // violated.
 679         break;
 680       }
 681     }
 682   }
 683 
 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;
 694 }
 695 
 696 // for the sake of the compiler log, print out current dependencies:
 697 void Dependencies::log_all_dependencies() {
 698   if (log() == NULL)  return;
 699   ResourceMark rm;
 700   for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) {
 701     DepType dept = (DepType)deptv;
 702     GrowableArray<ciBaseObject*>* deps = _deps[dept];
 703     int deplen = deps->length();
 704     if (deplen == 0) {
 705       continue;
 706     }
 707     int stride = dep_args(dept);
 708     GrowableArray<ciBaseObject*>* ciargs = new GrowableArray<ciBaseObject*>(stride);
 709     for (int i = 0; i < deps->length(); i += stride) {
 710       for (int j = 0; j < stride; j++) {
 711         // flush out the identities before printing
 712         ciargs->push(deps->at(i+j));


< prev index next >