src/share/vm/oops/cpCache.cpp

changeset 4566
461a3adac4d1
parent 4542
db9981fd3124
parent 4562
8d9fc28831cc
child 4712
3efdfd6ddbf2
     1.1 --- a/src/share/vm/oops/cpCache.cpp	Fri Feb 08 10:08:40 2013 +0100
     1.2 +++ b/src/share/vm/oops/cpCache.cpp	Fri Feb 08 09:14:06 2013 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -402,8 +402,9 @@
    1.11  }
    1.12  
    1.13  
    1.14 +#if INCLUDE_JVMTI
    1.15  // RedefineClasses() API support:
    1.16 -// If this constantPoolCacheEntry refers to old_method then update it
    1.17 +// If this ConstantPoolCacheEntry refers to old_method then update it
    1.18  // to refer to new_method.
    1.19  bool ConstantPoolCacheEntry::adjust_method_entry(Method* old_method,
    1.20         Method* new_method, bool * trace_name_printed) {
    1.21 @@ -461,16 +462,24 @@
    1.22    return false;
    1.23  }
    1.24  
    1.25 -#ifndef PRODUCT
    1.26 -bool ConstantPoolCacheEntry::check_no_old_entries() {
    1.27 +// a constant pool cache entry should never contain old or obsolete methods
    1.28 +bool ConstantPoolCacheEntry::check_no_old_or_obsolete_entries() {
    1.29    if (is_vfinal()) {
    1.30 +    // virtual and final so _f2 contains method ptr instead of vtable index
    1.31      Metadata* f2 = (Metadata*)_f2;
    1.32 -    return (f2->is_valid() && f2->is_method() && !((Method*)f2)->is_old());
    1.33 -  } else {
    1.34 -    return (_f1 == NULL || (_f1->is_valid() && _f1->is_method() && !((Method*)_f1)->is_old()));
    1.35 +    // Return false if _f2 refers to an old or an obsolete method.
    1.36 +    // _f2 == NULL || !_f2->is_method() are just as unexpected here.
    1.37 +    return (f2 != NULL NOT_PRODUCT(&& f2->is_valid()) && f2->is_method() &&
    1.38 +            !((Method*)f2)->is_old() && !((Method*)f2)->is_obsolete());
    1.39 +  } else if (_f1 == NULL ||
    1.40 +             (NOT_PRODUCT(_f1->is_valid() &&) !_f1->is_method())) {
    1.41 +    // _f1 == NULL || !_f1->is_method() are OK here
    1.42 +    return true;
    1.43    }
    1.44 +  // return false if _f1 refers to an old or an obsolete method
    1.45 +  return (NOT_PRODUCT(_f1->is_valid() &&) _f1->is_method() &&
    1.46 +          !((Method*)_f1)->is_old() && !((Method*)_f1)->is_obsolete());
    1.47  }
    1.48 -#endif
    1.49  
    1.50  bool ConstantPoolCacheEntry::is_interesting_method_entry(Klass* k) {
    1.51    if (!is_method_entry()) {
    1.52 @@ -503,13 +512,15 @@
    1.53    // the method is in the interesting class so the entry is interesting
    1.54    return true;
    1.55  }
    1.56 +#endif // INCLUDE_JVMTI
    1.57  
    1.58  void ConstantPoolCacheEntry::print(outputStream* st, int index) const {
    1.59    // print separator
    1.60    if (index == 0) st->print_cr("                 -------------");
    1.61    // print entry
    1.62    st->print("%3d  ("PTR_FORMAT")  ", index, (intptr_t)this);
    1.63 -    st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index());
    1.64 +  st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(),
    1.65 +               constant_pool_index());
    1.66    st->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)_f1);
    1.67    st->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)_f2);
    1.68    st->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)_flags);
    1.69 @@ -553,8 +564,9 @@
    1.70    }
    1.71  }
    1.72  
    1.73 +#if INCLUDE_JVMTI
    1.74  // RedefineClasses() API support:
    1.75 -// If any entry of this constantPoolCache points to any of
    1.76 +// If any entry of this ConstantPoolCache points to any of
    1.77  // old_methods, replace it with the corresponding new_method.
    1.78  void ConstantPoolCache::adjust_method_entries(Method** old_methods, Method** new_methods,
    1.79                                                       int methods_length, bool * trace_name_printed) {
    1.80 @@ -573,7 +585,7 @@
    1.81        continue;
    1.82      }
    1.83  
    1.84 -    // The constantPoolCache contains entries for several different
    1.85 +    // The ConstantPoolCache contains entries for several different
    1.86      // things, but we only care about methods. In fact, we only care
    1.87      // about methods in the same class as the one that contains the
    1.88      // old_methods. At this point, we have an interesting entry.
    1.89 @@ -592,17 +604,25 @@
    1.90    }
    1.91  }
    1.92  
    1.93 -#ifndef PRODUCT
    1.94 -bool ConstantPoolCache::check_no_old_entries() {
    1.95 +// the constant pool cache should never contain old or obsolete methods
    1.96 +bool ConstantPoolCache::check_no_old_or_obsolete_entries() {
    1.97    for (int i = 1; i < length(); i++) {
    1.98      if (entry_at(i)->is_interesting_method_entry(NULL) &&
    1.99 -       !entry_at(i)->check_no_old_entries()) {
   1.100 +        !entry_at(i)->check_no_old_or_obsolete_entries()) {
   1.101        return false;
   1.102      }
   1.103    }
   1.104    return true;
   1.105  }
   1.106 -#endif // PRODUCT
   1.107 +
   1.108 +void ConstantPoolCache::dump_cache() {
   1.109 +  for (int i = 1; i < length(); i++) {
   1.110 +    if (entry_at(i)->is_interesting_method_entry(NULL)) {
   1.111 +      entry_at(i)->print(tty, i);
   1.112 +    }
   1.113 +  }
   1.114 +}
   1.115 +#endif // INCLUDE_JVMTI
   1.116  
   1.117  
   1.118  // Printing

mercurial