1 /*
2 * Copyright (c) 1997, 2017, 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 *
314 }
315
316 void BytecodePrinter::print_constant(int i, outputStream* st) {
317 int orig_i = i;
318 if (!check_index(orig_i, i, st)) return;
319
320 ConstantPool* constants = method()->constants();
321 constantTag tag = constants->tag_at(i);
322
323 if (tag.is_int()) {
324 st->print_cr(" " INT32_FORMAT, constants->int_at(i));
325 } else if (tag.is_long()) {
326 st->print_cr(" " INT64_FORMAT, (int64_t)(constants->long_at(i)));
327 } else if (tag.is_float()) {
328 st->print_cr(" %f", constants->float_at(i));
329 } else if (tag.is_double()) {
330 st->print_cr(" %f", constants->double_at(i));
331 } else if (tag.is_string()) {
332 const char* string = constants->string_at_noresolve(i);
333 st->print_cr(" %s", string);
334 } else if (tag.is_klass() || tag.is_value_type()) {
335 st->print_cr(" %s", constants->resolved_klass_at(i)->external_name());
336 } else if (tag.is_unresolved_klass()) {
337 st->print_cr(" <unresolved klass at %d>", i);
338 } else if (tag.is_unresolved_value_type()) {
339 st->print_cr(" <unresolved value type at %d>", i);
340 } else if (tag.is_method_type()) {
341 int i2 = constants->method_type_index_at(i);
342 st->print(" <MethodType> %d", i2);
343 print_symbol(constants->symbol_at(i2), st);
344 } else if (tag.is_method_handle()) {
345 int kind = constants->method_handle_ref_kind_at(i);
346 int i2 = constants->method_handle_index_at(i);
347 st->print(" <MethodHandle of kind %d index at %d>", kind, i2);
348 print_field_or_method(-i, i2, st);
349 } else {
350 st->print_cr(" bad tag=%d at %d", tag.value(), i);
351 }
352 }
353
354 void BytecodePrinter::print_field_or_method(int i, outputStream* st) {
355 int orig_i = i;
356 if (!check_index(orig_i, i, st)) return;
357 print_field_or_method(orig_i, i, st);
358 }
359
|
1 /*
2 * Copyright (c) 1997, 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 *
314 }
315
316 void BytecodePrinter::print_constant(int i, outputStream* st) {
317 int orig_i = i;
318 if (!check_index(orig_i, i, st)) return;
319
320 ConstantPool* constants = method()->constants();
321 constantTag tag = constants->tag_at(i);
322
323 if (tag.is_int()) {
324 st->print_cr(" " INT32_FORMAT, constants->int_at(i));
325 } else if (tag.is_long()) {
326 st->print_cr(" " INT64_FORMAT, (int64_t)(constants->long_at(i)));
327 } else if (tag.is_float()) {
328 st->print_cr(" %f", constants->float_at(i));
329 } else if (tag.is_double()) {
330 st->print_cr(" %f", constants->double_at(i));
331 } else if (tag.is_string()) {
332 const char* string = constants->string_at_noresolve(i);
333 st->print_cr(" %s", string);
334 } else if (tag.is_klass()) {
335 st->print_cr(" %s", constants->resolved_klass_at(i)->external_name());
336 } else if (tag.is_unresolved_klass()) {
337 st->print_cr(" <unresolved klass at %d>", i);
338 } else if (tag.is_method_type()) {
339 int i2 = constants->method_type_index_at(i);
340 st->print(" <MethodType> %d", i2);
341 print_symbol(constants->symbol_at(i2), st);
342 } else if (tag.is_method_handle()) {
343 int kind = constants->method_handle_ref_kind_at(i);
344 int i2 = constants->method_handle_index_at(i);
345 st->print(" <MethodHandle of kind %d index at %d>", kind, i2);
346 print_field_or_method(-i, i2, st);
347 } else {
348 st->print_cr(" bad tag=%d at %d", tag.value(), i);
349 }
350 }
351
352 void BytecodePrinter::print_field_or_method(int i, outputStream* st) {
353 int orig_i = i;
354 if (!check_index(orig_i, i, st)) return;
355 print_field_or_method(orig_i, i, st);
356 }
357
|