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 "classfile/classPrinter.hpp"
26 #include "classfile/javaClasses.inline.hpp"
27 #include "interpreter/bytecodeHistogram.hpp"
28 #include "interpreter/bytecodes.hpp"
29 #include "interpreter/bytecodeStream.hpp"
30 #include "interpreter/bytecodeTracer.hpp"
31 #include "interpreter/interpreter.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "oops/constantPool.inline.hpp"
34 #include "oops/method.hpp"
35 #include "oops/methodData.hpp"
36 #include "runtime/atomicAccess.hpp"
37 #include "runtime/handles.inline.hpp"
38 #include "runtime/mutexLocker.hpp"
39 #include "runtime/osThread.hpp"
40 #include "utilities/align.hpp"
41
42 // Prints the current bytecode and its attributes using bytecode-specific information.
43
44 class BytecodePrinter {
286
287 int bsm = constants->bootstrap_method_ref_index_at(cp_index);
288 st->print(" bsm=%d", bsm);
289
290 Symbol* name = constants->uncached_name_ref_at(cp_index);
291 Symbol* signature = constants->uncached_signature_ref_at(cp_index);
292 const char* sep = tag.is_dynamic_constant() ? ":" : "";
293 st->print_cr(" %d <%s%s%s>", cp_index, name->as_C_string(), sep, signature->as_C_string());
294 }
295
296 void BytecodePrinter::print_invokedynamic(int indy_index, int cp_index, outputStream* st) {
297 print_dynamic(cp_index, st);
298
299 if (ClassPrinter::has_mode(_flags, ClassPrinter::PRINT_DYNAMIC)) {
300 print_bsm(cp_index, st);
301
302 if (is_linked()) {
303 ResolvedIndyEntry* indy_entry = constants()->resolved_indy_entry_at(indy_index);
304 st->print(" ResolvedIndyEntry: ");
305 indy_entry->print_on(st);
306 }
307 }
308 }
309
310 // cp_index: must be the cp_index of a JVM_CONSTANT_{Dynamic, DynamicInError, InvokeDynamic}
311 void BytecodePrinter::print_bsm(int cp_index, outputStream* st) {
312 assert(constants()->tag_at(cp_index).has_bootstrap(), "must be");
313 int bsm = constants()->bootstrap_method_ref_index_at(cp_index);
314 const char* ref_kind = "";
315 switch (constants()->method_handle_ref_kind_at(bsm)) {
316 case JVM_REF_getField : ref_kind = "REF_getField"; break;
317 case JVM_REF_getStatic : ref_kind = "REF_getStatic"; break;
318 case JVM_REF_putField : ref_kind = "REF_putField"; break;
319 case JVM_REF_putStatic : ref_kind = "REF_putStatic"; break;
320 case JVM_REF_invokeVirtual : ref_kind = "REF_invokeVirtual"; break;
321 case JVM_REF_invokeStatic : ref_kind = "REF_invokeStatic"; break;
322 case JVM_REF_invokeSpecial : ref_kind = "REF_invokeSpecial"; break;
323 case JVM_REF_newInvokeSpecial : ref_kind = "REF_newInvokeSpecial"; break;
324 case JVM_REF_invokeInterface : ref_kind = "REF_invokeInterface"; break;
325 default : ShouldNotReachHere();
|
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 "cds/heapShared.hpp"
26 #include "classfile/classPrinter.hpp"
27 #include "classfile/javaClasses.inline.hpp"
28 #include "interpreter/bytecodeHistogram.hpp"
29 #include "interpreter/bytecodes.hpp"
30 #include "interpreter/bytecodeStream.hpp"
31 #include "interpreter/bytecodeTracer.hpp"
32 #include "interpreter/interpreter.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "oops/constantPool.inline.hpp"
35 #include "oops/method.hpp"
36 #include "oops/methodData.hpp"
37 #include "runtime/atomicAccess.hpp"
38 #include "runtime/handles.inline.hpp"
39 #include "runtime/mutexLocker.hpp"
40 #include "runtime/osThread.hpp"
41 #include "utilities/align.hpp"
42
43 // Prints the current bytecode and its attributes using bytecode-specific information.
44
45 class BytecodePrinter {
287
288 int bsm = constants->bootstrap_method_ref_index_at(cp_index);
289 st->print(" bsm=%d", bsm);
290
291 Symbol* name = constants->uncached_name_ref_at(cp_index);
292 Symbol* signature = constants->uncached_signature_ref_at(cp_index);
293 const char* sep = tag.is_dynamic_constant() ? ":" : "";
294 st->print_cr(" %d <%s%s%s>", cp_index, name->as_C_string(), sep, signature->as_C_string());
295 }
296
297 void BytecodePrinter::print_invokedynamic(int indy_index, int cp_index, outputStream* st) {
298 print_dynamic(cp_index, st);
299
300 if (ClassPrinter::has_mode(_flags, ClassPrinter::PRINT_DYNAMIC)) {
301 print_bsm(cp_index, st);
302
303 if (is_linked()) {
304 ResolvedIndyEntry* indy_entry = constants()->resolved_indy_entry_at(indy_index);
305 st->print(" ResolvedIndyEntry: ");
306 indy_entry->print_on(st);
307 if (indy_entry->has_appendix()) {
308 oop apx = constants()->resolved_reference_from_indy(indy_index);
309 st->print_cr(" - appendix = " INTPTR_FORMAT, p2i(apx));
310 }
311 }
312 }
313 }
314
315 // cp_index: must be the cp_index of a JVM_CONSTANT_{Dynamic, DynamicInError, InvokeDynamic}
316 void BytecodePrinter::print_bsm(int cp_index, outputStream* st) {
317 assert(constants()->tag_at(cp_index).has_bootstrap(), "must be");
318 int bsm = constants()->bootstrap_method_ref_index_at(cp_index);
319 const char* ref_kind = "";
320 switch (constants()->method_handle_ref_kind_at(bsm)) {
321 case JVM_REF_getField : ref_kind = "REF_getField"; break;
322 case JVM_REF_getStatic : ref_kind = "REF_getStatic"; break;
323 case JVM_REF_putField : ref_kind = "REF_putField"; break;
324 case JVM_REF_putStatic : ref_kind = "REF_putStatic"; break;
325 case JVM_REF_invokeVirtual : ref_kind = "REF_invokeVirtual"; break;
326 case JVM_REF_invokeStatic : ref_kind = "REF_invokeStatic"; break;
327 case JVM_REF_invokeSpecial : ref_kind = "REF_invokeSpecial"; break;
328 case JVM_REF_newInvokeSpecial : ref_kind = "REF_newInvokeSpecial"; break;
329 case JVM_REF_invokeInterface : ref_kind = "REF_invokeInterface"; break;
330 default : ShouldNotReachHere();
|