1 /* 2 * Copyright (c) 2023, 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 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "oops/method.hpp" 27 #include "oops/resolvedMethodEntry.hpp" 28 29 bool ResolvedMethodEntry::check_no_old_or_obsolete_entry() { 30 // return false if m refers to a non-deleted old or obsolete method 31 if (_method != nullptr) { 32 assert(_method->is_valid() && _method->is_method(), "m is a valid method"); 33 return !_method->is_old() && !_method->is_obsolete(); // old is always set for old and obsolete 34 } else { 35 return true; 36 } 37 } 38 39 void ResolvedMethodEntry::reset_entry() { 40 if (has_resolved_references_index()) { 41 u2 saved_resolved_references_index = _entry_specific._resolved_references_index; 42 u2 saved_cpool_index = _cpool_index; 43 memset(this, 0, sizeof(*this)); 44 set_resolved_references_index(saved_resolved_references_index); 45 _cpool_index = saved_cpool_index; 46 } else { 47 u2 saved_cpool_index = _cpool_index; 48 memset(this, 0, sizeof(*this)); 49 _cpool_index = saved_cpool_index; 50 } 51 } 52 53 void ResolvedMethodEntry::remove_unshareable_info() { 54 reset_entry(); 55 } 56 57 void ResolvedMethodEntry::print_on(outputStream* st) const { 58 st->print_cr("Method Entry:"); 59 60 if (method() != nullptr) { 61 st->print_cr(" - Method: " INTPTR_FORMAT " %s", p2i(method()), method()->external_name()); 62 } else { 63 st->print_cr("- Method: null"); 64 } 65 // Some fields are mutually exclusive and are only used by certain invoke codes 66 if (bytecode1() == Bytecodes::_invokeinterface && interface_klass() != nullptr) { 67 st->print_cr(" - Klass: " INTPTR_FORMAT " %s", p2i(interface_klass()), interface_klass()->external_name()); 68 } else { 69 st->print_cr("- Klass: null"); 70 } 71 if (bytecode1() == Bytecodes::_invokehandle) { 72 st->print_cr(" - Resolved References Index: %d", resolved_references_index()); 73 } else { 74 st->print_cr(" - Resolved References Index: none"); 75 } 76 if (bytecode2() == Bytecodes::_invokevirtual) { 77 #ifdef ASSERT 78 if (_has_table_index) { 79 st->print_cr(" - Table Index: %d", table_index()); 80 } 81 #else 82 st->print_cr(" - Table Index: %d", table_index()); 83 #endif 84 } else { 85 st->print_cr(" - Table Index: none"); 86 } 87 st->print_cr(" - CP Index: %d", constant_pool_index()); 88 st->print_cr(" - TOS: %s", type2name(as_BasicType((TosState)tos_state()))); 89 st->print_cr(" - Number of Parameters: %d", number_of_parameters()); 90 st->print_cr(" - Is Virtual Final: %d", is_vfinal()); 91 st->print_cr(" - Is Final: %d", is_final()); 92 st->print_cr(" - Is Forced Virtual: %d", is_forced_virtual()); 93 st->print_cr(" - Has Appendix: %d", has_appendix()); 94 st->print_cr(" - Has Local Signature: %d", has_local_signature()); 95 st->print_cr(" - Bytecode 1: %s", Bytecodes::name((Bytecodes::Code)bytecode1())); 96 st->print_cr(" - Bytecode 2: %s", Bytecodes::name((Bytecodes::Code)bytecode2())); 97 }