src/share/vm/oops/cpCache.cpp

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 400,410 **** return resolved_references->obj_at(ref_index); } // RedefineClasses() API support: ! // If this constantPoolCacheEntry refers to old_method then update it // to refer to new_method. bool ConstantPoolCacheEntry::adjust_method_entry(Method* old_method, Method* new_method, bool * trace_name_printed) { if (is_vfinal()) { --- 400,410 ---- return resolved_references->obj_at(ref_index); } // RedefineClasses() API support: ! // If this ConstantPoolCacheEntry refers to old_method then update it // to refer to new_method. bool ConstantPoolCacheEntry::adjust_method_entry(Method* old_method, Method* new_method, bool * trace_name_printed) { if (is_vfinal()) {
*** 458,477 **** } return false; } ! #ifndef PRODUCT ! bool ConstantPoolCacheEntry::check_no_old_entries() { if (is_vfinal()) { Metadata* f2 = (Metadata*)_f2; ! return (f2->is_valid() && f2->is_method() && !((Method*)f2)->is_old()); ! } else { ! return (_f1 == NULL || (_f1->is_valid() && _f1->is_method() && !((Method*)_f1)->is_old())); } } - #endif bool ConstantPoolCacheEntry::is_interesting_method_entry(Klass* k) { if (!is_method_entry()) { // not a method entry so not interesting by default return false; --- 458,485 ---- } return false; } ! // a constant pool cache entry should never contain old or obsolete methods ! bool ConstantPoolCacheEntry::check_no_old_or_obsolete_entries() { if (is_vfinal()) { + // virtual and final so _f2 contains method ptr instead of vtable index Metadata* f2 = (Metadata*)_f2; ! // Return false if _f2 refers to an old or an obsolete method. ! // _f2 == NULL || !_f2->is_method() are just as unexpected here. ! return (f2 != NULL NOT_PRODUCT(&& f2->is_valid()) && f2->is_method() && ! !((Method*)f2)->is_old() && !((Method*)f2)->is_obsolete()); ! } else if (_f1 == NULL || ! (NOT_PRODUCT(_f1->is_valid() &&) !_f1->is_method())) { ! // _f1 == NULL || !_f1->is_method() are OK here ! return true; } + // return false if _f1 refers to an old or an obsolete method + return (NOT_PRODUCT(_f1->is_valid() &&) _f1->is_method() && + !((Method*)_f1)->is_old() && !((Method*)_f1)->is_obsolete()); } bool ConstantPoolCacheEntry::is_interesting_method_entry(Klass* k) { if (!is_method_entry()) { // not a method entry so not interesting by default return false;
*** 506,516 **** void ConstantPoolCacheEntry::print(outputStream* st, int index) const { // print separator if (index == 0) st->print_cr(" -------------"); // print entry st->print("%3d ("PTR_FORMAT") ", index, (intptr_t)this); ! st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index()); st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f1); st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f2); st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_flags); st->print_cr(" -------------"); } --- 514,525 ---- void ConstantPoolCacheEntry::print(outputStream* st, int index) const { // print separator if (index == 0) st->print_cr(" -------------"); // print entry st->print("%3d ("PTR_FORMAT") ", index, (intptr_t)this); ! st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), ! constant_pool_index()); st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f1); st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f2); st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_flags); st->print_cr(" -------------"); }
*** 551,561 **** } } } // RedefineClasses() API support: ! // If any entry of this constantPoolCache points to any of // old_methods, replace it with the corresponding new_method. void ConstantPoolCache::adjust_method_entries(Method** old_methods, Method** new_methods, int methods_length, bool * trace_name_printed) { if (methods_length == 0) { --- 560,570 ---- } } } // RedefineClasses() API support: ! // If any entry of this ConstantPoolCache points to any of // old_methods, replace it with the corresponding new_method. void ConstantPoolCache::adjust_method_entries(Method** old_methods, Method** new_methods, int methods_length, bool * trace_name_printed) { if (methods_length == 0) {
*** 570,580 **** if (!entry_at(i)->is_interesting_method_entry(old_holder)) { // skip uninteresting methods continue; } ! // The constantPoolCache contains entries for several different // things, but we only care about methods. In fact, we only care // about methods in the same class as the one that contains the // old_methods. At this point, we have an interesting entry. for (int j = 0; j < methods_length; j++) { --- 579,589 ---- if (!entry_at(i)->is_interesting_method_entry(old_holder)) { // skip uninteresting methods continue; } ! // The ConstantPoolCache contains entries for several different // things, but we only care about methods. In fact, we only care // about methods in the same class as the one that contains the // old_methods. At this point, we have an interesting entry. for (int j = 0; j < methods_length; j++) {
*** 589,611 **** } } } } ! #ifndef PRODUCT ! bool ConstantPoolCache::check_no_old_entries() { for (int i = 1; i < length(); i++) { if (entry_at(i)->is_interesting_method_entry(NULL) && ! !entry_at(i)->check_no_old_entries()) { return false; } } return true; } - #endif // PRODUCT // Printing void ConstantPoolCache::print_on(outputStream* st) const { assert(is_constantPoolCache(), "obj must be constant pool cache"); st->print_cr(internal_name()); --- 598,627 ---- } } } } ! // the constant pool cache should never contain old or obsolete methods ! bool ConstantPoolCache::check_no_old_or_obsolete_entries() { for (int i = 1; i < length(); i++) { if (entry_at(i)->is_interesting_method_entry(NULL) && ! !entry_at(i)->check_no_old_or_obsolete_entries()) { return false; } } return true; } + void ConstantPoolCache::dump_cache() { + for (int i = 1; i < length(); i++) { + if (entry_at(i)->is_interesting_method_entry(NULL)) { + entry_at(i)->print(tty, i); + } + } + } + // Printing void ConstantPoolCache::print_on(outputStream* st) const { assert(is_constantPoolCache(), "obj must be constant pool cache"); st->print_cr(internal_name());