src/hotspot/share/interpreter/bytecodeTracer.cpp
author psandoz
Fri, 08 Sep 2017 10:46:46 -0700
changeset 48826 c4d9d1b08e2e
parent 47216 71c04702a3d5
child 49340 4e82736053ae
permissions -rw-r--r--
8186209: Tool support for ConstantDynamic 8186046: Minimal ConstantDynamic support 8190972: Ensure that AOT/Graal filters out class files containing CONSTANT_Dynamic ahead of full AOT support Reviewed-by: acorn, coleenp, kvn Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
35898
ddc274f0052f 8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents: 33604
diff changeset
     2
 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4567
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4567
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4567
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6062
diff changeset
    25
#include "precompiled.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 24424
diff changeset
    26
#include "classfile/javaClasses.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6062
diff changeset
    27
#include "interpreter/bytecodeHistogram.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6062
diff changeset
    28
#include "interpreter/bytecodeTracer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6062
diff changeset
    29
#include "interpreter/bytecodes.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6062
diff changeset
    30
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6062
diff changeset
    31
#include "interpreter/interpreterRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6062
diff changeset
    32
#include "memory/resourceArea.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
    33
#include "oops/methodData.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
    34
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6062
diff changeset
    35
#include "runtime/mutexLocker.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6062
diff changeset
    36
#include "runtime/timer.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46620
diff changeset
    37
#include "utilities/align.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// Standard closure for BytecodeTracer: prints the current bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// and its attributes using bytecode-specific information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class BytecodePrinter: public BytecodeClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // %%% This field is not GC-ed, and so can contain garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // between critical sections.  Use only pointer-comparison
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // operations on the pointer, except within a critical section.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // (Also, ensure that occasional false positives are benign.)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
    49
  Method* _current_method;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  bool      _is_wide;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    51
  Bytecodes::Code _code;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  address   _next_pc;                // current decoding position
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
46620
750c6edff33b 8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents: 35898
diff changeset
    54
  void      align()                  { _next_pc = align_up(_next_pc, sizeof(jint)); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  int       get_byte()               { return *(jbyte*) _next_pc++; }  // signed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  short     get_short()              { short i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  int       get_int()                { int i=Bytes::get_Java_u4(_next_pc); _next_pc+=4; return i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    59
  int       get_index_u1()           { return *(address)_next_pc++; }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    60
  int       get_index_u2()           { int i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
    61
  int       get_index_u1_cpcache()   { return get_index_u1() + ConstantPool::CPCACHE_INDEX_TAG; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
    62
  int       get_index_u2_cpcache()   { int i=Bytes::get_native_u2(_next_pc); _next_pc+=2; return i + ConstantPool::CPCACHE_INDEX_TAG; }
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    63
  int       get_index_u4()           { int i=Bytes::get_native_u4(_next_pc); _next_pc+=4; return i; }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    64
  int       get_index_special()      { return (is_wide()) ? get_index_u2() : get_index_u1(); }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
    65
  Method* method()                 { return _current_method; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  bool      is_wide()                { return _is_wide; }
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    67
  Bytecodes::Code raw_code()         { return Bytecodes::Code(_code); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    70
  bool      check_index(int i, int& cp_index, outputStream* st = tty);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
    71
  bool      check_cp_cache_index(int i, int& cp_index, outputStream* st = tty);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
    72
  bool      check_obj_index(int i, int& cp_index, outputStream* st = tty);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
    73
  bool      check_invokedynamic_index(int i, int& cp_index, outputStream* st = tty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  void      print_constant(int i, outputStream* st = tty);
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
    75
  void      print_field_or_method(int i, outputStream* st = tty);
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
    76
  void      print_field_or_method(int orig_i, int i, outputStream* st = tty);
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    77
  void      print_attributes(int bci, outputStream* st = tty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  void      bytecode_epilog(int bci, outputStream* st = tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  BytecodePrinter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    _is_wide = false;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    83
    _code = Bytecodes::_illegal;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // This method is called while executing the raw bytecodes, so none of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // the adjustments that BytecodeStream performs applies.
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 29081
diff changeset
    88
  void trace(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    if (_current_method != method()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      // Note 1: This code will not work as expected with true MT/MP.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      //         Need an explicit lock or a different solution.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      // It is possible for this block to be skipped, if a garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      // _current_method pointer happens to have the same bits as
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
      // the incoming method.  We could lose a line of trace output.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      // This is acceptable in a debug-only feature.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      st->cr();
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 9946
diff changeset
    98
      st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      method->print_name(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      _current_method = method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    Bytecodes::Code code;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    if (is_wide()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
      // bcp wasn't advanced if previous bytecode was _wide.
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7436
diff changeset
   106
      code = Bytecodes::code_at(method(), bcp+1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    } else {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7436
diff changeset
   108
      code = Bytecodes::code_at(method(), bcp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    }
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   110
    _code = code;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   111
     int bci = bcp - method->code_base();
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 9946
diff changeset
   112
    st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    if (Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
      st->print("%8d  %4d  " INTPTR_FORMAT " " INTPTR_FORMAT " %s",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
           BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
      st->print("%8d  %4d  %s",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
           BytecodeCounter::counter_value(), bci, Bytecodes::name(code));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    _next_pc = is_wide() ? bcp+2 : bcp+1;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   121
    print_attributes(bci);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    // Set is_wide for the next one, since the caller of this doesn't skip
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    // the next bytecode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    _is_wide = (code == Bytecodes::_wide);
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   125
    _code = Bytecodes::_illegal;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   128
  // Used for Method*::print_codes().  The input bcp comes from
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // BytecodeStream, which will skip wide bytecodes.
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 29081
diff changeset
   130
  void trace(const methodHandle& method, address bcp, outputStream* st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    _current_method = method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    ResourceMark rm;
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7436
diff changeset
   133
    Bytecodes::Code code = Bytecodes::code_at(method(), bcp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    // Set is_wide
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    _is_wide = (code == Bytecodes::_wide);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    if (is_wide()) {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7436
diff changeset
   137
      code = Bytecodes::code_at(method(), bcp+1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    }
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   139
    _code = code;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    int bci = bcp - method->code_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    // Print bytecode index and name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    if (is_wide()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      st->print("%d %s_w", bci, Bytecodes::name(code));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
      st->print("%d %s", bci, Bytecodes::name(code));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    _next_pc = is_wide() ? bcp+2 : bcp+1;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   148
    print_attributes(bci, st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    bytecode_epilog(bci, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// Implementation of BytecodeTracer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// %%% This set_closure thing seems overly general, given that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
// nobody uses it.  Also, if BytecodePrinter weren't hidden
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   158
// then Method* could use instances of it directly and it
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
// would be easier to remove races on _current_method and bcp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
// Since this is not product functionality, we can defer cleanup.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
BytecodeClosure* BytecodeTracer::_closure = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
static BytecodePrinter std_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
BytecodeClosure* BytecodeTracer::std_closure() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  return &::std_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 29081
diff changeset
   170
void BytecodeTracer::trace(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  if (TraceBytecodes && BytecodeCounter::counter_value() >= TraceBytecodesAt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    ttyLocker ttyl;  // 5065316: keep the following output coherent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    // The ttyLocker also prevents races between two threads
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    // trying to use the single instance of BytecodePrinter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    // Using the ttyLocker prevents the system from coming to
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   176
    // a safepoint within this code, which is sensitive to Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    // movement.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    // There used to be a leaf mutex here, but the ttyLocker will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    // work just as well, as long as the printing operations never block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    // We put the locker on the static trace method, not the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    // virtual one, because the clients of this module go through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    // the static method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    _closure->trace(method, bcp, tos, tos2, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 29081
diff changeset
   189
void BytecodeTracer::trace(const methodHandle& method, address bcp, outputStream* st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  ttyLocker ttyl;  // 5065316: keep the following output coherent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  _closure->trace(method, bcp, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   194
void print_symbol(Symbol* sym, outputStream* st) {
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   195
  char buf[40];
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   196
  int len = sym->utf8_length();
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   197
  if (len >= (int)sizeof(buf)) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   198
    st->print_cr(" %s...[%d]", sym->as_C_string(buf, sizeof(buf)), len);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   199
  } else {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   200
    st->print(" ");
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   201
    sym->print_on(st); st->cr();
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   202
  }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   203
}
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   204
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
void print_oop(oop value, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  if (value == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    st->print_cr(" NULL");
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   208
  } else if (java_lang_String::is_instance(value)) {
9946
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9116
diff changeset
   209
    char buf[40];
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9116
diff changeset
   210
    int len = java_lang_String::utf8_length(value);
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9116
diff changeset
   211
    java_lang_String::as_utf8_string(value, buf, sizeof(buf));
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9116
diff changeset
   212
    if (len >= (int)sizeof(buf)) {
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9116
diff changeset
   213
      st->print_cr(" %s...[%d]", buf, len);
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9116
diff changeset
   214
    } else {
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9116
diff changeset
   215
      st->print_cr(" %s", buf);
b3d5b50e2289 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 9116
diff changeset
   216
    }
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   217
  } else {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23526
diff changeset
   218
    st->print_cr(" " INTPTR_FORMAT, p2i((void *)value));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   222
bool BytecodePrinter::check_index(int i, int& cp_index, outputStream* st) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   223
  ConstantPool* constants = method()->constants();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   224
  int ilimit = constants->length();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   225
  Bytecodes::Code code = raw_code();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   226
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   227
  ConstantPoolCache* cache = NULL;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   228
  if (Bytecodes::uses_cp_cache(code)) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   229
    bool okay = true;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   230
    switch (code) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   231
    case Bytecodes::_fast_aldc:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   232
    case Bytecodes::_fast_aldc_w:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   233
      okay = check_obj_index(i, cp_index, st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   234
      break;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   235
    case Bytecodes::_invokedynamic:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   236
      okay = check_invokedynamic_index(i, cp_index, st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   237
      break;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   238
    default:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   239
      okay = check_cp_cache_index(i, cp_index, st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   240
      break;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   241
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   242
    if (!okay) return false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   243
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   244
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   245
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   246
  // check cp index
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   247
  if (cp_index >= 0 && cp_index < ilimit) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   248
    if (WizardMode)  st->print(" cp[%d]", cp_index);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   249
    return true;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   250
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   251
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   252
  st->print_cr(" CP[%d] not in CP", cp_index);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   253
  return false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   254
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   255
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   256
bool BytecodePrinter::check_cp_cache_index(int i, int& cp_index, outputStream* st) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   257
  ConstantPool* constants = method()->constants();
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   258
  int ilimit = constants->length(), climit = 0;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   259
  Bytecodes::Code code = raw_code();
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   260
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   261
  ConstantPoolCache* cache = constants->cache();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   262
  // If rewriter hasn't run, the index is the cp_index
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   263
  if (cache == NULL) {
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   264
    cp_index = i;
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   265
    return true;
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   266
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   267
  //climit = cache->length();  // %%% private!
35898
ddc274f0052f 8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents: 33604
diff changeset
   268
  size_t size = cache->size() * wordSize;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   269
  size -= sizeof(ConstantPoolCache);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   270
  size /= sizeof(ConstantPoolCacheEntry);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   271
  climit = (int) size;
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   272
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   273
#ifdef ASSERT
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   274
  {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   275
    const int CPCACHE_INDEX_TAG = ConstantPool::CPCACHE_INDEX_TAG;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   276
    if (i >= CPCACHE_INDEX_TAG && i < climit + CPCACHE_INDEX_TAG) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   277
      i -= CPCACHE_INDEX_TAG;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   278
    } else {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   279
      st->print_cr(" CP[%d] missing bias?", i);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   280
      return false;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   281
    }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   282
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   283
#endif //ASSERT
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   284
  if (i >= 0 && i < climit) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   285
    cp_index = cache->entry_at(i)->constant_pool_index();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   286
  } else {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23526
diff changeset
   287
    st->print_cr("%d not in CP[*]?", i);
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   288
      return false;
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   289
    }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   290
  return true;
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   291
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   292
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   293
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   294
bool BytecodePrinter::check_obj_index(int i, int& cp_index, outputStream* st) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   295
  ConstantPool* constants = method()->constants();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   296
  i -= ConstantPool::CPCACHE_INDEX_TAG;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   297
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   298
  if (i >= 0 && i < constants->resolved_references()->length()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   299
     cp_index = constants->object_to_cp_index(i);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   300
     return true;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   301
  } else {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23526
diff changeset
   302
    st->print_cr("%d not in OBJ[*]?", i);
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   303
  return false;
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   304
}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   305
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   306
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   307
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   308
bool BytecodePrinter::check_invokedynamic_index(int i, int& cp_index, outputStream* st) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   309
  ConstantPool* constants = method()->constants();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   310
  assert(ConstantPool::is_invokedynamic_index(i), "not secondary index?");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   311
  i = ConstantPool::decode_invokedynamic_index(i) + ConstantPool::CPCACHE_INDEX_TAG;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   312
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   313
  return check_cp_cache_index(i, cp_index, st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   314
}
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   315
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
void BytecodePrinter::print_constant(int i, outputStream* st) {
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   317
  int orig_i = i;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   318
  if (!check_index(orig_i, i, st))  return;
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   319
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   320
  ConstantPool* constants = method()->constants();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  constantTag tag = constants->tag_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  if (tag.is_int()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    st->print_cr(" " INT32_FORMAT, constants->int_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  } else if (tag.is_long()) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23526
diff changeset
   326
    st->print_cr(" " INT64_FORMAT, (int64_t)(constants->long_at(i)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  } else if (tag.is_float()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    st->print_cr(" %f", constants->float_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  } else if (tag.is_double()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    st->print_cr(" %f", constants->double_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  } else if (tag.is_string()) {
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   332
    const char* string = constants->string_at_noresolve(i);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   333
    st->print_cr(" %s", string);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  } else if (tag.is_klass()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   335
    st->print_cr(" %s", constants->resolved_klass_at(i)->external_name());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  } else if (tag.is_unresolved_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
    st->print_cr(" <unresolved klass at %d>", i);
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   338
  } else if (tag.is_method_type()) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   339
    int i2 = constants->method_type_index_at(i);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   340
    st->print(" <MethodType> %d", i2);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   341
    print_symbol(constants->symbol_at(i2), st);
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   342
  } else if (tag.is_method_handle()) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   343
    int kind = constants->method_handle_ref_kind_at(i);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   344
    int i2 = constants->method_handle_index_at(i);
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23526
diff changeset
   345
    st->print(" <MethodHandle of kind %d index at %d>", kind, i2);
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   346
    print_field_or_method(-i, i2, st);
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   347
  } else {
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   348
    st->print_cr(" bad tag=%d at %d", tag.value(), i);
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   349
  }
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   350
}
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   351
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   352
void BytecodePrinter::print_field_or_method(int i, outputStream* st) {
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   353
  int orig_i = i;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   354
  if (!check_index(orig_i, i, st))  return;
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   355
  print_field_or_method(orig_i, i, st);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   356
}
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   357
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   358
void BytecodePrinter::print_field_or_method(int orig_i, int i, outputStream* st) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   359
  ConstantPool* constants = method()->constants();
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   360
  constantTag tag = constants->tag_at(i);
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   361
6062
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   362
  bool has_klass = true;
4429
d7eb4e2099aa 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 3261
diff changeset
   363
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   364
  switch (tag.value()) {
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   365
  case JVM_CONSTANT_InterfaceMethodref:
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   366
  case JVM_CONSTANT_Methodref:
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   367
  case JVM_CONSTANT_Fieldref:
6062
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   368
    break;
4429
d7eb4e2099aa 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 3261
diff changeset
   369
  case JVM_CONSTANT_NameAndType:
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   370
  case JVM_CONSTANT_Dynamic:
6062
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   371
  case JVM_CONSTANT_InvokeDynamic:
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   372
    has_klass = false;
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   373
    break;
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   374
  default:
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   375
    st->print_cr(" bad tag=%d at %d", tag.value(), i);
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   376
    return;
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   377
  }
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   378
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   379
  Symbol* name = constants->uncached_name_ref_at(i);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   380
  Symbol* signature = constants->uncached_signature_ref_at(i);
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   381
  const char* sep = (tag.is_field() ? "/" : "");
6062
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   382
  if (has_klass) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   383
    Symbol* klass = constants->klass_name_at(constants->uncached_klass_ref_index_at(i));
6062
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   384
    st->print_cr(" %d <%s.%s%s%s> ", i, klass->as_C_string(), name->as_C_string(), sep, signature->as_C_string());
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   385
  } else {
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   386
    if (tag.is_dynamic_constant() || tag.is_invoke_dynamic()) {
6062
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   387
      int bsm = constants->invoke_dynamic_bootstrap_method_ref_index_at(i);
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   388
      st->print(" bsm=%d", bsm);
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   389
    }
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   390
    st->print_cr(" %d <%s%s%s>", i, name->as_C_string(), sep, signature->as_C_string());
bab93afe9df7 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 5882
diff changeset
   391
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   395
void BytecodePrinter::print_attributes(int bci, outputStream* st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  // Show attributes of pre-rewritten codes
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   397
  Bytecodes::Code code = Bytecodes::java_code(raw_code());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  // If the code doesn't have any fields there's nothing to print.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // note this is ==1 because the tableswitch and lookupswitch are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  // zero size (for some reason) and we want to print stuff out for them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  if (Bytecodes::length_for(code) == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
    st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  switch(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    // Java specific bytecodes only matter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    case Bytecodes::_bipush:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
      st->print_cr(" " INT32_FORMAT, get_byte());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    case Bytecodes::_sipush:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
      st->print_cr(" " INT32_FORMAT, get_short());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    case Bytecodes::_ldc:
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   415
      if (Bytecodes::uses_cp_cache(raw_code())) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   416
        print_constant(get_index_u1_cpcache(), st);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   417
      } else {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   418
        print_constant(get_index_u1(), st);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   419
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    case Bytecodes::_ldc_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    case Bytecodes::_ldc2_w:
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   424
      if (Bytecodes::uses_cp_cache(raw_code())) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   425
        print_constant(get_index_u2_cpcache(), st);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   426
      } else {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   427
        print_constant(get_index_u2(), st);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   428
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    case Bytecodes::_iload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
    case Bytecodes::_lload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    case Bytecodes::_fload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    case Bytecodes::_dload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    case Bytecodes::_aload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
    case Bytecodes::_istore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    case Bytecodes::_lstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    case Bytecodes::_fstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    case Bytecodes::_dstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    case Bytecodes::_astore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
      st->print_cr(" #%d", get_index_special());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    case Bytecodes::_iinc:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
      { int index = get_index_special();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
        jint offset = is_wide() ? get_short(): get_byte();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
        st->print_cr(" #%d " INT32_FORMAT, index, offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    case Bytecodes::_newarray: {
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   452
        BasicType atype = (BasicType)get_index_u1();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
        const char* str = type2name(atype);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
        if (str == NULL || atype == T_OBJECT || atype == T_ARRAY) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
          assert(false, "Unidentified basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
        st->print_cr(" %s", str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    case Bytecodes::_anewarray: {
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   461
        int klass_index = get_index_u2();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   462
        ConstantPool* constants = method()->constants();
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   463
        Symbol* name = constants->klass_name_at(klass_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
        st->print_cr(" %s ", name->as_C_string());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    case Bytecodes::_multianewarray: {
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   468
        int klass_index = get_index_u2();
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   469
        int nof_dims = get_index_u1();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   470
        ConstantPool* constants = method()->constants();
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   471
        Symbol* name = constants->klass_name_at(klass_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
        st->print_cr(" %s %d", name->as_C_string(), nof_dims);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
    case Bytecodes::_ifeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
    case Bytecodes::_ifnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    case Bytecodes::_iflt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    case Bytecodes::_ifle:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
    case Bytecodes::_ifne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    case Bytecodes::_ifnonnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
    case Bytecodes::_ifgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    case Bytecodes::_ifge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    case Bytecodes::_if_icmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    case Bytecodes::_if_icmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    case Bytecodes::_if_icmplt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
    case Bytecodes::_if_icmpgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
    case Bytecodes::_if_icmple:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
    case Bytecodes::_if_icmpge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
    case Bytecodes::_if_acmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
    case Bytecodes::_if_acmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
    case Bytecodes::_goto:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
    case Bytecodes::_jsr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
      st->print_cr(" %d", bci + get_short());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
    case Bytecodes::_goto_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    case Bytecodes::_jsr_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
      st->print_cr(" %d", bci + get_int());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
    case Bytecodes::_ret: st->print_cr(" %d", get_index_special()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
    case Bytecodes::_tableswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
      { align();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
        int  default_dest = bci + get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
        int  lo           = get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
        int  hi           = get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
        int  len          = hi - lo + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
        jint* dest        = NEW_RESOURCE_ARRAY(jint, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
        for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
          dest[i] = bci + get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
        st->print(" %d " INT32_FORMAT " " INT32_FORMAT " ",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
                      default_dest, lo, hi);
33604
ad1cd9269bd4 8139116: Fixes for warning "format not a string literal"
goetz
parents: 33593
diff changeset
   516
        const char *comma = "";
ad1cd9269bd4 8139116: Fixes for warning "format not a string literal"
goetz
parents: 33593
diff changeset
   517
        for (int ll = lo; ll <= hi; ll++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
          int idx = ll - lo;
33604
ad1cd9269bd4 8139116: Fixes for warning "format not a string literal"
goetz
parents: 33593
diff changeset
   519
          st->print("%s %d:" INT32_FORMAT " (delta: %d)", comma, ll, dest[idx], dest[idx]-bci);
ad1cd9269bd4 8139116: Fixes for warning "format not a string literal"
goetz
parents: 33593
diff changeset
   520
          comma = ",";
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
        st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
    case Bytecodes::_lookupswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
      { align();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
        int  default_dest = bci + get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
        int  len          = get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
        jint* key         = NEW_RESOURCE_ARRAY(jint, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
        jint* dest        = NEW_RESOURCE_ARRAY(jint, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
        for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
          key [i] = get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
          dest[i] = bci + get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
        };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
        st->print(" %d %d ", default_dest, len);
33604
ad1cd9269bd4 8139116: Fixes for warning "format not a string literal"
goetz
parents: 33593
diff changeset
   536
        const char *comma = "";
ad1cd9269bd4 8139116: Fixes for warning "format not a string literal"
goetz
parents: 33593
diff changeset
   537
        for (int ll = 0; ll < len; ll++)  {
ad1cd9269bd4 8139116: Fixes for warning "format not a string literal"
goetz
parents: 33593
diff changeset
   538
          st->print("%s " INT32_FORMAT ":" INT32_FORMAT, comma, key[ll], dest[ll]);
ad1cd9269bd4 8139116: Fixes for warning "format not a string literal"
goetz
parents: 33593
diff changeset
   539
          comma = ",";
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
        st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    case Bytecodes::_putstatic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    case Bytecodes::_getstatic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    case Bytecodes::_putfield:
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   548
    case Bytecodes::_getfield:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   549
      print_field_or_method(get_index_u2_cpcache(), st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    case Bytecodes::_invokevirtual:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
    case Bytecodes::_invokespecial:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    case Bytecodes::_invokestatic:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   555
      print_field_or_method(get_index_u2_cpcache(), st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    case Bytecodes::_invokeinterface:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   559
      { int i = get_index_u2_cpcache();
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   560
        int n = get_index_u1();
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   561
        get_byte();            // ignore zero byte
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   562
        print_field_or_method(i, st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   566
    case Bytecodes::_invokedynamic:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   567
      print_field_or_method(get_index_u4(), st);
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   568
      break;
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   569
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    case Bytecodes::_new:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
    case Bytecodes::_checkcast:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    case Bytecodes::_instanceof:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   573
      { int i = get_index_u2();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   574
        ConstantPool* constants = method()->constants();
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   575
        Symbol* name = constants->klass_name_at(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
        st->print_cr(" %d <%s>", i, name->as_C_string());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    case Bytecodes::_wide:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
      // length is zero not one, but printed with no more info.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
void BytecodePrinter::bytecode_epilog(int bci, outputStream* st) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10966
diff changeset
   592
  MethodData* mdo = method()->method_data();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  if (mdo != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    ProfileData* data = mdo->bci_to_data(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
    if (data != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
      st->print("  %d", mdo->dp_to_di(data->dp()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
      st->fill_to(6);
22916
582da2ed4dfa 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents: 20282
diff changeset
   598
      data->print_data_on(st, mdo);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
}