src/hotspot/share/oops/generateOopMap.cpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 58722 cba8afa5cfed
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 53838
diff changeset
     2
 * Copyright (c) 1997, 2019, 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: 5402
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5402
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: 5402
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: 7111
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    26
#include "interpreter/bytecodeStream.hpp"
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
    27
#include "logging/log.hpp"
46701
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46630
diff changeset
    28
#include "logging/logStream.hpp"
48157
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47822
diff changeset
    29
#include "memory/allocation.inline.hpp"
53838
c8c9bd65c198 8219229: Make ConstantPool::tag_at and release_tag_at_put inlineable
redestad
parents: 52881
diff changeset
    30
#include "oops/constantPool.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    31
#include "oops/generateOopMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    32
#include "oops/oop.inline.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
    33
#include "oops/symbol.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    34
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    35
#include "runtime/java.hpp"
49177
eebf559c9e0d 8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents: 48826
diff changeset
    36
#include "runtime/os.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    37
#include "runtime/relocator.hpp"
37161
e881f320966e 8150015: Integrate TraceTime with Unified Logging more seamlessly
rehn
parents: 33593
diff changeset
    38
#include "runtime/timerTrace.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    39
#include "utilities/bitMap.inline.hpp"
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
    40
#include "utilities/ostream.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    41
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// Compute stack layouts for each instruction in method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//  Problems:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
//  - What to do about jsr with different types of local vars?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//  Need maps that are conditional on jsr path?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//  - Jsr and exceptions should be done more efficiently (the retAddr stuff)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//  Alternative:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//  - Could extend verifier to provide this information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//    For: one fewer abstract interpreter to maintain. Against: the verifier
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//    solves a bigger problem so slower (undesirable to force verification of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
//    everything?).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//  Algorithm:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
//    Partition bytecodes into basic blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
//    For each basic block: store entry state (vars, stack). For instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
//    inside basic blocks we do not store any state (instead we recompute it
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
//    from state produced by previous instruction).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
//    Perform abstract interpretation of bytecodes over this lattice:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
//                _--'#'--_
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
//               /  /  \   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
//             /   /     \   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
//            /    |     |     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//          'r'   'v'   'p'   ' '
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
//           \     |     |     /
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
//            \    \     /    /
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
//              \   \   /    /
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
//                -- '@' --
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
//    '#'  top, result of conflict merge
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
//    'r'  reference type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
//    'v'  value type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
//    'p'  pc type for jsr/ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
//    ' '  uninitialized; never occurs on operand stack in Java
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
//    '@'  bottom/unexecuted; initial state each bytecode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
//    Basic block headers are the only merge points. We use this iteration to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
//    compute the information:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
//    find basic blocks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
//    initialize them with uninitialized state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
//    initialize first BB according to method signature;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
//    mark first BB changed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
//    while (some BB is changed) do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
//      perform abstract interpration of all bytecodes in BB;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
//      merge exit state of BB into entry state of all successor BBs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
//      noting if any of these change;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
//    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
//  One additional complication is necessary. The jsr instruction pushes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
//  a return PC on the stack (a 'p' type in the abstract interpretation).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
//  To be able to process "ret" bytecodes, we keep track of these return
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
//  PC's in a 'retAddrs' structure in abstract interpreter context (when
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
//  processing a "ret" bytecodes, it is not sufficient to know that it gets
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
//  an argument of the right type 'p'; we need to know which address it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
//  returns to).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// (Note this comment is borrowed form the original author of the algorithm)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
// ComputeCallStack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// Specialization of SignatureIterator - compute the effects of a call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
class ComputeCallStack : public SignatureIterator {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  CellTypeState *_effect;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  int _idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  void setup();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  void set(CellTypeState state)         { _effect[_idx++] = state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  int  length()                         { return _idx; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  virtual void do_bool  ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  virtual void do_char  ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  virtual void do_float ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  virtual void do_byte  ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  virtual void do_short ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  virtual void do_int   ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  virtual void do_void  ()              { set(CellTypeState::bottom);};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  virtual void do_object(int begin, int end)  { set(CellTypeState::ref); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  virtual void do_array (int begin, int end)  { set(CellTypeState::ref); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  void do_double()                      { set(CellTypeState::value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
                                          set(CellTypeState::value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  void do_long  ()                      { set(CellTypeState::value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
                                           set(CellTypeState::value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   133
  ComputeCallStack(Symbol* signature) : SignatureIterator(signature) {};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // Compute methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  int compute_for_parameters(bool is_static, CellTypeState *effect) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    _idx    = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    _effect = effect;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    if (!is_static)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
      effect[_idx++] = CellTypeState::ref;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    iterate_parameters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    return length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  int compute_for_returntype(CellTypeState *effect) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    _idx    = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    _effect = effect;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    iterate_returntype();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    set(CellTypeState::bottom);  // Always terminate with a bottom state, so ppush works
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    return length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
//=========================================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
// ComputeEntryStack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
// Specialization of SignatureIterator - in order to set up first stack frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
class ComputeEntryStack : public SignatureIterator {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  CellTypeState *_effect;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  int _idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  void setup();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  void set(CellTypeState state)         { _effect[_idx++] = state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  int  length()                         { return _idx; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  virtual void do_bool  ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  virtual void do_char  ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  virtual void do_float ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  virtual void do_byte  ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  virtual void do_short ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  virtual void do_int   ()              { set(CellTypeState::value); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  virtual void do_void  ()              { set(CellTypeState::bottom);};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  virtual void do_object(int begin, int end)  { set(CellTypeState::make_slot_ref(_idx)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  virtual void do_array (int begin, int end)  { set(CellTypeState::make_slot_ref(_idx)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  void do_double()                      { set(CellTypeState::value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
                                          set(CellTypeState::value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  void do_long  ()                      { set(CellTypeState::value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
                                          set(CellTypeState::value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   187
  ComputeEntryStack(Symbol* signature) : SignatureIterator(signature) {};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // Compute methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  int compute_for_parameters(bool is_static, CellTypeState *effect) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    _idx    = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    _effect = effect;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    if (!is_static)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      effect[_idx++] = CellTypeState::make_slot_ref(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    iterate_parameters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    return length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  int compute_for_returntype(CellTypeState *effect) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    _idx    = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    _effect = effect;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    iterate_returntype();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    set(CellTypeState::bottom);  // Always terminate with a bottom state, so ppush works
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    return length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
//=====================================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
// Implementation of RetTable/RetTableEntry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
// Contains function to itereate through all bytecodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
// and find all return entry points
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
int RetTable::_init_nof_entries = 10;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
int RetTableEntry::_init_nof_jsrs = 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
48157
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47822
diff changeset
   222
RetTableEntry::RetTableEntry(int target, RetTableEntry *next) {
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47822
diff changeset
   223
  _target_bci = target;
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47822
diff changeset
   224
  _jsrs = new GrowableArray<intptr_t>(_init_nof_jsrs);
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47822
diff changeset
   225
  _next = next;
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47822
diff changeset
   226
}
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47822
diff changeset
   227
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
void RetTableEntry::add_delta(int bci, int delta) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  if (_target_bci > bci) _target_bci += delta;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  for (int k = 0; k < _jsrs->length(); k++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    int jsr = _jsrs->at(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    if (jsr > bci) _jsrs->at_put(k, jsr+delta);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 22230
diff changeset
   237
void RetTable::compute_ret_table(const methodHandle& method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  BytecodeStream i(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  Bytecodes::Code bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  while( (bytecode = i.next()) >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    switch (bytecode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
      case Bytecodes::_jsr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
        add_jsr(i.next_bci(), i.dest());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
      case Bytecodes::_jsr_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
        add_jsr(i.next_bci(), i.dest_w());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
        break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
   249
      default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
   250
        break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
void RetTable::add_jsr(int return_bci, int target_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  RetTableEntry* entry = _first;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  // Scan table for entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  for (;entry && entry->target_bci() != target_bci; entry = entry->next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  if (!entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    // Allocate new entry and put in list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    entry = new RetTableEntry(target_bci, _first);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    _first = entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  // Now "entry" is set.  Make sure that the entry is initialized
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  // and has room for the new jsr.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  entry->add_jsr(return_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
RetTableEntry* RetTable::find_jsrs_for_target(int targBci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  RetTableEntry *cur = _first;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  while(cur) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    assert(cur->target_bci() != -1, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    if (cur->target_bci() == targBci)  return cur;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    cur = cur->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
// The instruction at bci is changing size by "delta".  Update the return map.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
void RetTable::update_ret_table(int bci, int delta) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  RetTableEntry *cur = _first;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  while(cur) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    cur->add_delta(bci, delta);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    cur = cur->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
// Celltype state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
CellTypeState CellTypeState::bottom      = CellTypeState::make_bottom();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
CellTypeState CellTypeState::uninit      = CellTypeState::make_any(uninit_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
CellTypeState CellTypeState::ref         = CellTypeState::make_any(ref_conflict);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
CellTypeState CellTypeState::value       = CellTypeState::make_any(val_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
CellTypeState CellTypeState::refUninit   = CellTypeState::make_any(ref_conflict | uninit_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
CellTypeState CellTypeState::top         = CellTypeState::make_top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
CellTypeState CellTypeState::addr        = CellTypeState::make_any(addr_conflict);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
// Commonly used constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
static CellTypeState epsilonCTS[1] = { CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
static CellTypeState   refCTS   = CellTypeState::ref;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
static CellTypeState   valCTS   = CellTypeState::value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
static CellTypeState    vCTS[2] = { CellTypeState::value, CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
static CellTypeState    rCTS[2] = { CellTypeState::ref,   CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
static CellTypeState   rrCTS[3] = { CellTypeState::ref,   CellTypeState::ref,   CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
static CellTypeState   vrCTS[3] = { CellTypeState::value, CellTypeState::ref,   CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
static CellTypeState   vvCTS[3] = { CellTypeState::value, CellTypeState::value, CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
static CellTypeState  rvrCTS[4] = { CellTypeState::ref,   CellTypeState::value, CellTypeState::ref,   CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
static CellTypeState  vvrCTS[4] = { CellTypeState::value, CellTypeState::value, CellTypeState::ref,   CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
static CellTypeState  vvvCTS[4] = { CellTypeState::value, CellTypeState::value, CellTypeState::value, CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
static CellTypeState vvvrCTS[5] = { CellTypeState::value, CellTypeState::value, CellTypeState::value, CellTypeState::ref,   CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
static CellTypeState vvvvCTS[5] = { CellTypeState::value, CellTypeState::value, CellTypeState::value, CellTypeState::value, CellTypeState::bottom };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
char CellTypeState::to_char() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  if (can_be_reference()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    if (can_be_value() || can_be_address())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
      return '#';    // Conflict that needs to be rewritten
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
      return 'r';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  } else if (can_be_value())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    return 'v';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  else if (can_be_address())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    return 'p';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  else if (can_be_uninit())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    return ' ';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    return '@';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
// Print a detailed CellTypeState.  Indicate all bits that are set.  If
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
// the CellTypeState represents an address or a reference, print the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
// value of the additional information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
void CellTypeState::print(outputStream *os) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  if (can_be_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    os->print("(p");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    os->print("( ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  if (can_be_reference()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    os->print("r");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    os->print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  if (can_be_value()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    os->print("v");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    os->print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  if (can_be_uninit()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    os->print("u|");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    os->print(" |");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  if (is_info_top()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    os->print("Top)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  } else if (is_info_bottom()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    os->print("Bot)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    if (is_reference()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
      int info = get_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
      int data = info & ~(ref_not_lock_bit | ref_slot_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
      if (info & ref_not_lock_bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
        // Not a monitor lock reference.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
        if (info & ref_slot_bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
          // slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
          os->print("slot%d)", data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
          // line
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
          os->print("line%d)", data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
        // lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
        os->print("lock%d)", data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
      os->print("%d)", get_info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
// Basicblock handling methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37242
diff changeset
   392
void GenerateOopMap::initialize_bb() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  _gc_points = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  _bb_count  = 0;
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37242
diff changeset
   395
  _bb_hdr_bits.reinitialize(method()->code_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
void GenerateOopMap::bb_mark_fct(GenerateOopMap *c, int bci, int *data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  assert(bci>= 0 && bci < c->method()->code_size(), "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  if (c->is_bb_header(bci))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
     return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  if (TraceNewOopMapGeneration) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
     tty->print_cr("Basicblock#%d begins at: %d", c->_bb_count, bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  c->set_bbmark_bit(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  c->_bb_count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
void GenerateOopMap::mark_bbheaders_and_count_gc_points() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  initialize_bb();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  bool fellThrough = false;  // False to get first BB marked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  // First mark all exception handlers as start of a basic-block
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
   417
  ExceptionTable excps(method());
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
   418
  for(int i = 0; i < excps.length(); i ++) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
   419
    bb_mark_fct(this, excps.handler_pc(i), NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  // Then iterate through the code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  BytecodeStream bcs(_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  Bytecodes::Code bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  while( (bytecode = bcs.next()) >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    int bci = bcs.bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    if (!fellThrough)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
        bb_mark_fct(this, bci, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
    fellThrough = jump_targets_do(&bcs, &GenerateOopMap::bb_mark_fct, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
     /* We will also mark successors of jsr's as basic block headers. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    switch (bytecode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
      case Bytecodes::_jsr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
        assert(!fellThrough, "should not happen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
        bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      case Bytecodes::_jsr_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
        assert(!fellThrough, "should not happen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
        bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
        break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
   444
      default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
   445
        break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    if (possible_gc_point(&bcs))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      _gc_points++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
46502
116a09d8f142 8180755: Remove use of bitMap.inline.hpp include from instanceKlass.hpp and c1_ValueSet.hpp
tschatzl
parents: 38658
diff changeset
   453
void GenerateOopMap::set_bbmark_bit(int bci) {
116a09d8f142 8180755: Remove use of bitMap.inline.hpp include from instanceKlass.hpp and c1_ValueSet.hpp
tschatzl
parents: 38658
diff changeset
   454
  _bb_hdr_bits.at_put(bci, true);
116a09d8f142 8180755: Remove use of bitMap.inline.hpp include from instanceKlass.hpp and c1_ValueSet.hpp
tschatzl
parents: 38658
diff changeset
   455
}
116a09d8f142 8180755: Remove use of bitMap.inline.hpp include from instanceKlass.hpp and c1_ValueSet.hpp
tschatzl
parents: 38658
diff changeset
   456
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
void GenerateOopMap::reachable_basicblock(GenerateOopMap *c, int bci, int *data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  assert(bci>= 0 && bci < c->method()->code_size(), "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  BasicBlock* bb = c->get_basic_block_at(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  if (bb->is_dead()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    bb->mark_as_alive();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    *data = 1; // Mark basicblock as changed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
void GenerateOopMap::mark_reachable_code() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  int change = 1; // int to get function pointers to work
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  // Mark entry basic block as alive and all exception handlers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  _basic_blocks[0].mark_as_alive();
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
   472
  ExceptionTable excps(method());
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
   473
  for(int i = 0; i < excps.length(); i++) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
   474
    BasicBlock *bb = get_basic_block_at(excps.handler_pc(i));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
    // If block is not already alive (due to multiple exception handlers to same bb), then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
    // make it alive
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
    if (bb->is_dead()) bb->mark_as_alive();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  BytecodeStream bcs(_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  // Iterate through all basic blocks until we reach a fixpoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  while (change) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    change = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    for (int i = 0; i < _bb_count; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
      BasicBlock *bb = &_basic_blocks[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
      if (bb->is_alive()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
        // Position bytecodestream at last bytecode in basicblock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
        bcs.set_start(bb->_end_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
        bcs.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
        Bytecodes::Code bytecode = bcs.code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
        int bci = bcs.bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
        assert(bci == bb->_end_bci, "wrong bci");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
        bool fell_through = jump_targets_do(&bcs, &GenerateOopMap::reachable_basicblock, &change);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
        // We will also mark successors of jsr's as alive.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
        switch (bytecode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
          case Bytecodes::_jsr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
          case Bytecodes::_jsr_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
            assert(!fell_through, "should not happen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
            reachable_basicblock(this, bci + Bytecodes::length_for(bytecode), &change);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
            break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
   505
          default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
   506
            break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
        if (fell_through) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
          // Mark successor as alive
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
          if (bb[1].is_dead()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
            bb[1].mark_as_alive();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
            change = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
/* If the current instruction in "c" has no effect on control flow,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
   returns "true".  Otherwise, calls "jmpFct" one or more times, with
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
   "c", an appropriate "pcDelta", and "data" as arguments, then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
   returns "false".  There is one exception: if the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
   instruction is a "ret", returns "false" without calling "jmpFct".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
   Arrangements for tracking the control flow of a "ret" must be made
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
   externally. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
bool GenerateOopMap::jump_targets_do(BytecodeStream *bcs, jmpFct_t jmpFct, int *data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  int bci = bcs->bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  switch (bcs->code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
    case Bytecodes::_ifeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    case Bytecodes::_ifne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
    case Bytecodes::_iflt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    case Bytecodes::_ifge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
    case Bytecodes::_ifgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
    case Bytecodes::_ifle:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
    case Bytecodes::_if_icmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    case Bytecodes::_if_icmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    case Bytecodes::_if_icmplt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    case Bytecodes::_if_icmpge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    case Bytecodes::_if_icmpgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    case Bytecodes::_if_icmple:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
    case Bytecodes::_if_acmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    case Bytecodes::_if_acmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    case Bytecodes::_ifnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    case Bytecodes::_ifnonnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
      (*jmpFct)(this, bcs->dest(), data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
      (*jmpFct)(this, bci + 3, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
    case Bytecodes::_goto:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
      (*jmpFct)(this, bcs->dest(), data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    case Bytecodes::_goto_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
      (*jmpFct)(this, bcs->dest_w(), data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    case Bytecodes::_tableswitch:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   558
      { Bytecode_tableswitch tableswitch(method(), bcs->bcp());
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   559
        int len = tableswitch.length();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   561
        (*jmpFct)(this, bci + tableswitch.default_offset(), data); /* Default. jump address */
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
        while (--len >= 0) {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   563
          (*jmpFct)(this, bci + tableswitch.dest_offset_at(len), data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    case Bytecodes::_lookupswitch:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   569
      { Bytecode_lookupswitch lookupswitch(method(), bcs->bcp());
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   570
        int npairs = lookupswitch.number_of_pairs();
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   571
        (*jmpFct)(this, bci + lookupswitch.default_offset(), data); /* Default. */
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
        while(--npairs >= 0) {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   573
          LookupswitchPair pair = lookupswitch.pair_at(npairs);
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   574
          (*jmpFct)(this, bci + pair.offset(), data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    case Bytecodes::_jsr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
      assert(bcs->is_wide()==false, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
      (*jmpFct)(this, bcs->dest(), data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
    case Bytecodes::_jsr_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
      (*jmpFct)(this, bcs->dest_w(), data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    case Bytecodes::_wide:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
    case Bytecodes::_athrow:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
    case Bytecodes::_ireturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    case Bytecodes::_lreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
    case Bytecodes::_freturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    case Bytecodes::_dreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
    case Bytecodes::_areturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
    case Bytecodes::_return:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
    case Bytecodes::_ret:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
/* Requires "pc" to be the head of a basic block; returns that basic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
   block. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
BasicBlock *GenerateOopMap::get_basic_block_at(int bci) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  BasicBlock* bb = get_basic_block_containing(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  assert(bb->_bci == bci, "should have found BB");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  return bb;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
// Requires "pc" to be the start of an instruction; returns the basic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
//   block containing that instruction. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
BasicBlock  *GenerateOopMap::get_basic_block_containing(int bci) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  BasicBlock *bbs = _basic_blocks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  int lo = 0, hi = _bb_count - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  while (lo <= hi) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    int m = (lo + hi) / 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
    int mbci = bbs[m]._bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    int nbci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
    if ( m == _bb_count-1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
      assert( bci >= mbci && bci < method()->code_size(), "sanity check failed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
      return bbs+m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
      nbci = bbs[m+1]._bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
    if ( mbci <= bci && bci < nbci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
      return bbs+m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
    } else if (mbci < bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
      lo = m + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
      assert(mbci > bci, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
      hi = m - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  fatal("should have found BB");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
void GenerateOopMap::restore_state(BasicBlock *bb)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  memcpy(_state, bb->_state, _state_len*sizeof(CellTypeState));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  _stack_top = bb->_stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  _monitor_top = bb->_monitor_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
int GenerateOopMap::next_bb_start_pc(BasicBlock *bb) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
 int bbNum = bb - _basic_blocks + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
 if (bbNum == _bb_count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
    return method()->code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
 return _basic_blocks[bbNum]._bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
// CellType handling methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
18055
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   666
// Allocate memory and throw LinkageError if failure.
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   667
#define ALLOC_RESOURCE_ARRAY(var, type, count) \
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   668
  var = NEW_RESOURCE_ARRAY_RETURN_NULL(type, count);              \
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   669
  if (var == NULL) {                                              \
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   670
    report_error("Cannot reserve enough memory to analyze this method"); \
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   671
    return;                                                       \
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   672
  }
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   673
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   674
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
void GenerateOopMap::init_state() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
  _state_len     = _max_locals + _max_stack + _max_monitors;
18055
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   677
  ALLOC_RESOURCE_ARRAY(_state, CellTypeState, _state_len);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  memset(_state, 0, _state_len * sizeof(CellTypeState));
18055
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   679
  int count = MAX3(_max_locals, _max_stack, _max_monitors) + 1/*for null terminator char */;
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   680
  ALLOC_RESOURCE_ARRAY(_state_vec_buf, char, count);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
void GenerateOopMap::make_context_uninitialized() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  CellTypeState* vs = vars();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  for (int i = 0; i < _max_locals; i++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
      vs[i] = CellTypeState::uninit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  _stack_top = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  _monitor_top = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   693
int GenerateOopMap::methodsig_to_effect(Symbol* signature, bool is_static, CellTypeState* effect) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  ComputeEntryStack ces(signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  return ces.compute_for_parameters(is_static, effect);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
// Return result of merging cts1 and cts2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
CellTypeState CellTypeState::merge(CellTypeState cts, int slot) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
  CellTypeState result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
  assert(!is_bottom() && !cts.is_bottom(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
         "merge of bottom values is handled elsewhere");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
  result._state = _state | cts._state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  // If the top bit is set, we don't need to do any more work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
  if (!result.is_info_top()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    assert((result.can_be_address() || result.can_be_reference()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
           "only addresses and references have non-top info");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
    if (!equal(cts)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
      // The two values being merged are different.  Raise to top.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
      if (result.is_reference()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
        result = CellTypeState::make_slot_ref(slot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
        result._state |= info_conflict;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
  assert(result.is_valid_state(), "checking that CTS merge maintains legal state");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
// Merge the variable state for locals and stack from cts into bbts.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
bool GenerateOopMap::merge_local_state_vectors(CellTypeState* cts,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
                                               CellTypeState* bbts) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  int len = _max_locals + _stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  bool change = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  for (i = len - 1; i >= 0; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
    CellTypeState v = cts[i].merge(bbts[i], i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
    change = change || !v.equal(bbts[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
    bbts[i] = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
  return change;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
// Merge the monitor stack state from cts into bbts.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
bool GenerateOopMap::merge_monitor_state_vectors(CellTypeState* cts,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
                                                 CellTypeState* bbts) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
  bool change = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  if (_max_monitors > 0 && _monitor_top != bad_monitors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
    // If there are no monitors in the program, or there has been
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
    // a monitor matching error before this point in the program,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
    // then we do not merge in the monitor state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
    int base = _max_locals + _max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
    int len = base + _monitor_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
    for (int i = len - 1; i >= base; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
      CellTypeState v = cts[i].merge(bbts[i], i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
      // Can we prove that, when there has been a change, it will already
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
      // have been detected at this point?  That would make this equal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
      // check here unnecessary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
      change = change || !v.equal(bbts[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
      bbts[i] = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  return change;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
void GenerateOopMap::copy_state(CellTypeState *dst, CellTypeState *src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  int len = _max_locals + _stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
  for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
    if (src[i].is_nonlock_reference()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
      dst[i] = CellTypeState::make_slot_ref(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
      dst[i] = src[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  if (_max_monitors > 0 && _monitor_top != bad_monitors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
    int base = _max_locals + _max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
    len = base + _monitor_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
    for (int i = base; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
      dst[i] = src[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
// Merge the states for the current block and the next.  As long as a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
// block is reachable the locals and stack must be merged.  If the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
// stack heights don't match then this is a verification error and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
// it's impossible to interpret the code.  Simultaneously monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
// states are being check to see if they nest statically.  If monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
// depths match up then their states are merged.  Otherwise the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
// mismatch is simply recorded and interpretation continues since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
// monitor matching is purely informational and doesn't say anything
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
// about the correctness of the code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
void GenerateOopMap::merge_state_into_bb(BasicBlock *bb) {
16374
634539171c19 8009022: [parfait] Null pointer deference in hotspot/src/share/vm/oops/generateOopMap.cpp
morris
parents: 15799
diff changeset
   796
  guarantee(bb != NULL, "null basicblock");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
  assert(bb->is_alive(), "merging state into a dead basicblock");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
  if (_stack_top == bb->_stack_top) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    // always merge local state even if monitors don't match.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
    if (merge_local_state_vectors(_state, bb->_state)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
      bb->set_changed(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    if (_monitor_top == bb->_monitor_top) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
      // monitors still match so continue merging monitor states.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
      if (merge_monitor_state_vectors(_state, bb->_state)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
        bb->set_changed(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
    } else {
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
   810
      if (log_is_enabled(Info, monitormismatch)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
        report_monitor_mismatch("monitor stack height merge conflict");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
      // When the monitor stacks are not matched, we set _monitor_top to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
      // bad_monitors.  This signals that, from here on, the monitor stack cannot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
      // be trusted.  In particular, monitorexit bytecodes may throw
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
      // exceptions.  We mark this block as changed so that the change
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
      // propagates properly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
      bb->_monitor_top = bad_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
      bb->set_changed(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
      _monitor_safe = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
  } else if (!bb->is_reachable()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
    // First time we look at this  BB
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
    copy_state(bb->_state, _state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
    bb->_stack_top = _stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
    bb->_monitor_top = _monitor_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
    bb->set_changed(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
    verify_error("stack height conflict: %d vs. %d",  _stack_top, bb->_stack_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
void GenerateOopMap::merge_state(GenerateOopMap *gom, int bci, int* data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
   gom->merge_state_into_bb(gom->get_basic_block_at(bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
void GenerateOopMap::set_var(int localNo, CellTypeState cts) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  assert(cts.is_reference() || cts.is_value() || cts.is_address(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
         "wrong celltypestate");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
  if (localNo < 0 || localNo > _max_locals) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
    verify_error("variable write error: r%d", localNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  vars()[localNo] = cts;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
CellTypeState GenerateOopMap::get_var(int localNo) {
5402
c51fd0c1d005 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 4567
diff changeset
   848
  assert(localNo < _max_locals + _nof_refval_conflicts, "variable read error");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  if (localNo < 0 || localNo > _max_locals) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
    verify_error("variable read error: r%d", localNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
    return valCTS; // just to pick something;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  return vars()[localNo];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
CellTypeState GenerateOopMap::pop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  if ( _stack_top <= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
    verify_error("stack underflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
    return valCTS; // just to pick something
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
  return  stack()[--_stack_top];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
void GenerateOopMap::push(CellTypeState cts) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
  if ( _stack_top >= _max_stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
    verify_error("stack overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
  stack()[_stack_top++] = cts;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
CellTypeState GenerateOopMap::monitor_pop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
  assert(_monitor_top != bad_monitors, "monitor_pop called on error monitor stack");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  if (_monitor_top == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
    // We have detected a pop of an empty monitor stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
    _monitor_safe = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
     _monitor_top = bad_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
   879
    if (log_is_enabled(Info, monitormismatch)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
      report_monitor_mismatch("monitor stack underflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
    return CellTypeState::ref; // just to keep the analysis going.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
  return  monitors()[--_monitor_top];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
void GenerateOopMap::monitor_push(CellTypeState cts) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  assert(_monitor_top != bad_monitors, "monitor_push called on error monitor stack");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
  if (_monitor_top >= _max_monitors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
    // Some monitorenter is being executed more than once.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
    // This means that the monitor stack cannot be simulated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
    _monitor_safe = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
    _monitor_top = bad_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
   895
    if (log_is_enabled(Info, monitormismatch)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
      report_monitor_mismatch("monitor stack overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
  monitors()[_monitor_top++] = cts;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
// Interpretation handling methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
void GenerateOopMap::do_interpretation()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  // "i" is just for debugging, so we can detect cases where this loop is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
  // iterated more than once.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
  do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
    if (TraceNewOopMapGeneration) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
      tty->print("\n\nIteration #%d of do_interpretation loop, method:\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
      method()->print_name(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
      tty->print("\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
    _conflict = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
    _monitor_safe = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
    // init_state is now called from init_basic_blocks.  The length of a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
    // state vector cannot be determined until we have made a pass through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
    // the bytecodes counting the possible monitor entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
    if (!_got_error) init_basic_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
    if (!_got_error) setup_method_entry_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
    if (!_got_error) interp_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
    if (!_got_error) rewrite_refval_conflicts();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
    i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  } while (_conflict && !_got_error);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
void GenerateOopMap::init_basic_blocks() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
  // Note: Could consider reserving only the needed space for each BB's state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  // (entry stack may not be of maximal height for every basic block).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
  // But cumbersome since we don't know the stack heights yet.  (Nor the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
  // monitor stack heights...)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
18055
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
   939
  ALLOC_RESOURCE_ARRAY(_basic_blocks, BasicBlock, _bb_count);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
  // Make a pass through the bytecodes.  Count the number of monitorenters.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  // This can be used an upper bound on the monitor stack depth in programs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  // which obey stack discipline with their monitor usage.  Initialize the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
  // known information about basic blocks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
  BytecodeStream j(_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
  Bytecodes::Code bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
  int bbNo = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
  int monitor_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  int prev_bci = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
  while( (bytecode = j.next()) >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
    if (j.code() == Bytecodes::_monitorenter) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
      monitor_count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
    int bci = j.bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
    if (is_bb_header(bci)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
      // Initialize the basicblock structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
      BasicBlock *bb   = _basic_blocks + bbNo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
      bb->_bci         = bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
      bb->_max_locals  = _max_locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
      bb->_max_stack   = _max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
      bb->set_changed(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
      bb->_stack_top   = BasicBlock::_dead_basic_block; // Initialize all basicblocks are dead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
      bb->_monitor_top = bad_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
      if (bbNo > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
        _basic_blocks[bbNo - 1]._end_bci = prev_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
      bbNo++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
    // Remember prevous bci.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
    prev_bci = bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
  // Set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
  _basic_blocks[bbNo-1]._end_bci = prev_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   980
  // Check that the correct number of basicblocks was found
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   981
  if (bbNo !=_bb_count) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   982
    if (bbNo < _bb_count) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   983
      verify_error("jump into the middle of instruction?");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   984
      return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   985
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   986
      verify_error("extra basic blocks - should not happen?");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   987
      return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   988
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   989
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   990
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
  _max_monitors = monitor_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
  // Now that we have a bound on the depth of the monitor stack, we can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
  // initialize the CellTypeState-related information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
  init_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
10275
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
   997
  // We allocate space for all state-vectors for all basicblocks in one huge
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
   998
  // chunk.  Then in the next part of the code, we set a pointer in each
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
   999
  // _basic_block that points to each piece.
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1000
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1001
  // The product of bbNo and _state_len can get large if there are lots of
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1002
  // basic blocks and stack/locals/monitors.  Need to check to make sure
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1003
  // we don't overflow the capacity of a pointer.
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1004
  if ((unsigned)bbNo > UINTPTR_MAX / sizeof(CellTypeState) / _state_len) {
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1005
    report_error("The amount of memory required to analyze this method "
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1006
                 "exceeds addressable range");
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1007
    return;
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1008
  }
fd163a3b3591 7020373: JSR rewriting can overflow memory address size variables
kamg
parents: 8076
diff changeset
  1009
18055
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
  1010
  CellTypeState *basicBlockState;
ba8c01e0d016 7158805: Better rewriting of nested subroutine calls
hseigel
parents: 16374
diff changeset
  1011
  ALLOC_RESOURCE_ARRAY(basicBlockState, CellTypeState, bbNo * _state_len);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
  memset(basicBlockState, 0, bbNo * _state_len * sizeof(CellTypeState));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
  // Make a pass over the basicblocks and assign their state vectors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
  for (int blockNum=0; blockNum < bbNo; blockNum++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
    BasicBlock *bb = _basic_blocks + blockNum;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
    bb->_state = basicBlockState + blockNum * _state_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
    if (blockNum + 1 < bbNo) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
      address bcp = _method->bcp_from(bb->_end_bci);
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1022
      int bc_len = Bytecodes::java_length_at(_method(), bcp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
      assert(bb->_end_bci + bc_len == bb[1]._bci, "unmatched bci info in basicblock");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
  { BasicBlock *bb = &_basic_blocks[bbNo-1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
    address bcp = _method->bcp_from(bb->_end_bci);
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1030
    int bc_len = Bytecodes::java_length_at(_method(), bcp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
    assert(bb->_end_bci + bc_len == _method->code_size(), "wrong end bci");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
  // Mark all alive blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
  mark_reachable_code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
void GenerateOopMap::setup_method_entry_state() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
    // Initialize all locals to 'uninit' and set stack-height to 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
    make_context_uninitialized();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
    // Initialize CellState type of arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
    methodsig_to_effect(method()->signature(), method()->is_static(), vars());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
    // If some references must be pre-assigned to null, then set that up
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
    initialize_vars();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
    // This is the start state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
    merge_state_into_bb(&_basic_blocks[0]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
    assert(_basic_blocks[0].changed(), "we are not getting off the ground");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
// The instruction at bci is changing size by "delta".  Update the basic blocks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
void GenerateOopMap::update_basic_blocks(int bci, int delta,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
                                         int new_method_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
  assert(new_method_size >= method()->code_size() + delta,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
         "new method size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37242
diff changeset
  1062
  _bb_hdr_bits.reinitialize(new_method_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
  for(int k = 0; k < _bb_count; k++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
    if (_basic_blocks[k]._bci > bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
      _basic_blocks[k]._bci     += delta;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
      _basic_blocks[k]._end_bci += delta;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
    }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1069
    _bb_hdr_bits.at_put(_basic_blocks[k]._bci, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
// Initvars handling
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
void GenerateOopMap::initialize_vars() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
  for (int k = 0; k < _init_vars->length(); k++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
    _state[_init_vars->at(k)] = CellTypeState::make_slot_ref(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
void GenerateOopMap::add_to_ref_init_set(int localNo) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
  if (TraceNewOopMapGeneration)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
    tty->print_cr("Added init vars: %d", localNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
  // Is it already in the set?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
  if (_init_vars->contains(localNo) )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
   _init_vars->append(localNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
// Interpreration code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
void GenerateOopMap::interp_all() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
  bool change = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
  while (change && !_got_error) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
    change = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
    for (int i = 0; i < _bb_count && !_got_error; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
      BasicBlock *bb = &_basic_blocks[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
      if (bb->changed()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
         if (_got_error) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
         change = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
         bb->set_changed(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
         interp_bb(bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
void GenerateOopMap::interp_bb(BasicBlock *bb) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
  // We do not want to do anything in case the basic-block has not been initialized. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
  // will happen in the case where there is dead-code hang around in a method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
  assert(bb->is_reachable(), "should be reachable or deadcode exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
  restore_state(bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  BytecodeStream itr(_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
  // Set iterator interval to be the current basicblock
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
  int lim_bci = next_bb_start_pc(bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
  itr.set_interval(bb->_bci, lim_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
  assert(lim_bci != bb->_bci, "must be at least one instruction in a basicblock");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
  itr.next(); // read first instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
  // Iterates through all bytecodes except the last in a basic block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
  // We handle the last one special, since there is controlflow change.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
  while(itr.next_bci() < lim_bci && !_got_error) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
    if (_has_exceptions || _monitor_top != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
      // We do not need to interpret the results of exceptional
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
      // continuation from this instruction when the method has no
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
      // exception handlers and the monitor stack is currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
      // empty.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
      do_exception_edge(&itr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
    interp1(&itr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
    itr.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
  // Handle last instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
  if (!_got_error) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
    assert(itr.next_bci() == lim_bci, "must point to end");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
    if (_has_exceptions || _monitor_top != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
      do_exception_edge(&itr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
    interp1(&itr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
    bool fall_through = jump_targets_do(&itr, GenerateOopMap::merge_state, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
    if (_got_error)  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
    if (itr.code() == Bytecodes::_ret) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
      assert(!fall_through, "cannot be set if ret instruction");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
      // Automatically handles 'wide' ret indicies
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
      ret_jump_targets_do(&itr, GenerateOopMap::merge_state, itr.get_index(), NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
    } else if (fall_through) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
     // Hit end of BB, but the instr. was a fall-through instruction,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
     // so perform transition as if the BB ended in a "jump".
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
     if (lim_bci != bb[1]._bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
       verify_error("bytecodes fell through last instruction");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
       return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
     merge_state_into_bb(bb + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
void GenerateOopMap::do_exception_edge(BytecodeStream* itr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
  // Only check exception edge, if bytecode can trap
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
  if (!Bytecodes::can_trap(itr->code())) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
  switch (itr->code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
    case Bytecodes::_aload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
      // These bytecodes can trap for rewriting.  We need to assume that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
      // they do not throw exceptions to make the monitor analysis work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
    case Bytecodes::_ireturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
    case Bytecodes::_lreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
    case Bytecodes::_freturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
    case Bytecodes::_dreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
    case Bytecodes::_areturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
    case Bytecodes::_return:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
      // If the monitor stack height is not zero when we leave the method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
      // then we are either exiting with a non-empty stack or we have
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
      // found monitor trouble earlier in our analysis.  In either case,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
      // assume an exception could be taken here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
      if (_monitor_top == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
        return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
    case Bytecodes::_monitorexit:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
      // If the monitor stack height is bad_monitors, then we have detected a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
      // monitor matching problem earlier in the analysis.  If the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
      // monitor stack height is 0, we are about to pop a monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
      // off of an empty stack.  In either case, the bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
      // could throw an exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
      if (_monitor_top != bad_monitors && _monitor_top != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
        return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
      break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1205
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1206
    default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1207
      break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
  if (_has_exceptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
    int bci = itr->bci();
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  1212
    ExceptionTable exct(method());
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  1213
    for(int i = 0; i< exct.length(); i++) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  1214
      int start_pc   = exct.start_pc(i);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  1215
      int end_pc     = exct.end_pc(i);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  1216
      int handler_pc = exct.handler_pc(i);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  1217
      int catch_type = exct.catch_type_index(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
      if (start_pc <= bci && bci < end_pc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
        BasicBlock *excBB = get_basic_block_at(handler_pc);
16374
634539171c19 8009022: [parfait] Null pointer deference in hotspot/src/share/vm/oops/generateOopMap.cpp
morris
parents: 15799
diff changeset
  1221
        guarantee(excBB != NULL, "no basic block for exception");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
        CellTypeState *excStk = excBB->stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
        CellTypeState *cOpStck = stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
        CellTypeState cOpStck_0 = cOpStck[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
        int cOpStackTop = _stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
        // Exception stacks are always the same.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
        assert(method()->max_stack() > 0, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
        // We remembered the size and first element of "cOpStck"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
        // above; now we temporarily set them to the appropriate
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
        // values for an exception handler. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
        cOpStck[0] = CellTypeState::make_slot_ref(_max_locals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
        _stack_top = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
        merge_state_into_bb(excBB);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
        // Now undo the temporary change.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
        cOpStck[0] = cOpStck_0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
        _stack_top = cOpStackTop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
        // If this is a "catch all" handler, then we do not need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
        // consider any additional handlers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
        if (catch_type == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
          return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
  // It is possible that none of the exception handlers would have caught
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
  // the exception.  In this case, we will exit the method.  We must
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
  // ensure that the monitor stack is empty in this case.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  if (_monitor_top == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
  // We pessimistically assume that this exception can escape the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
  // method. (It is possible that it will always be caught, but
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
  // we don't care to analyse the types of the catch clauses.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
  // We don't set _monitor_top to bad_monitors because there are no successors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
  // to this exceptional exit.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
  1265
  if (log_is_enabled(Info, monitormismatch) && _monitor_safe) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
    // We check _monitor_safe so that we only report the first mismatched
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
    // exceptional exit.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
    report_monitor_mismatch("non-empty monitor stack at exceptional exit");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
  _monitor_safe = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
void GenerateOopMap::report_monitor_mismatch(const char *msg) {
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
  1275
  ResourceMark rm;
46701
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46630
diff changeset
  1276
  LogStream ls(Log(monitormismatch)::info());
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46630
diff changeset
  1277
  ls.print("Monitor mismatch in method ");
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46630
diff changeset
  1278
  method()->print_short_name(&ls);
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46630
diff changeset
  1279
  ls.print_cr(": %s", msg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
void GenerateOopMap::print_states(outputStream *os,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
                                  CellTypeState* vec, int num) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
  for (int i = 0; i < num; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
    vec[i].print(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
// Print the state values at the current bytecode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
void GenerateOopMap::print_current_state(outputStream   *os,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
                                         BytecodeStream *currentBC,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
                                         bool            detailed) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
  if (detailed) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
    os->print("     %4d vars     = ", currentBC->bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
    print_states(os, vars(), _max_locals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
    os->print("    %s", Bytecodes::name(currentBC->code()));
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1297
  } else {
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1298
    os->print("    %4d  vars = '%s' ", currentBC->bci(),  state_vec_to_string(vars(), _max_locals));
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1299
    os->print("     stack = '%s' ", state_vec_to_string(stack(), _stack_top));
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1300
    if (_monitor_top != bad_monitors) {
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1301
      os->print("  monitors = '%s'  \t%s", state_vec_to_string(monitors(), _monitor_top), Bytecodes::name(currentBC->code()));
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1302
    } else {
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1303
      os->print("  [bad monitor stack]");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
    }
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1305
  }
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1306
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1307
  switch(currentBC->code()) {
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1308
    case Bytecodes::_invokevirtual:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1309
    case Bytecodes::_invokespecial:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1310
    case Bytecodes::_invokestatic:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1311
    case Bytecodes::_invokedynamic:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1312
    case Bytecodes::_invokeinterface: {
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1313
      int idx = currentBC->has_index_u4() ? currentBC->get_index_u4() : currentBC->get_index_u2_cpcache();
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1314
      ConstantPool* cp      = method()->constants();
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1315
      int nameAndTypeIdx    = cp->name_and_type_ref_index_at(idx);
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1316
      int signatureIdx      = cp->signature_ref_index_at(nameAndTypeIdx);
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1317
      Symbol* signature     = cp->symbol_at(signatureIdx);
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1318
      os->print("%s", signature->as_C_string());
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1319
    }
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1320
    default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1321
      break;
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1322
  }
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1323
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1324
  if (detailed) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
    os->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
    os->print("          stack    = ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
    print_states(os, stack(), _stack_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
    os->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
    if (_monitor_top != bad_monitors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
      os->print("          monitors = ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
      print_states(os, monitors(), _monitor_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
      os->print("          [bad monitor stack]");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
  }
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1336
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  1337
  os->cr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
// Sets the current state to be the state after executing the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
// current instruction, starting in the current state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
void GenerateOopMap::interp1(BytecodeStream *itr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
  if (TraceNewOopMapGeneration) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
    print_current_state(tty, itr, TraceNewOopMapGenerationDetailed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
  // Should we report the results? Result is reported *before* the instruction at the current bci is executed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
  // However, not for calls. For calls we do not want to include the arguments, so we postpone the reporting until
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
  // they have been popped (in method ppl).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
  if (_report_result == true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
    switch(itr->code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
      case Bytecodes::_invokevirtual:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
      case Bytecodes::_invokespecial:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
      case Bytecodes::_invokestatic:
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 2131
diff changeset
  1355
      case Bytecodes::_invokedynamic:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
      case Bytecodes::_invokeinterface:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
        _itr_send = itr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
        _report_result_for_send = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
       fill_stackmap_for_opcodes(itr, vars(), stack(), _stack_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
  // abstract interpretation of current opcode
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
  switch(itr->code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
    case Bytecodes::_nop:                                           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
    case Bytecodes::_goto:                                          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
    case Bytecodes::_goto_w:                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
    case Bytecodes::_iinc:                                          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
    case Bytecodes::_return:            do_return_monitor_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
    case Bytecodes::_aconst_null:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
    case Bytecodes::_new:               ppush1(CellTypeState::make_line_ref(itr->bci()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
    case Bytecodes::_iconst_m1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
    case Bytecodes::_iconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
    case Bytecodes::_iconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
    case Bytecodes::_iconst_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
    case Bytecodes::_iconst_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
    case Bytecodes::_iconst_4:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
    case Bytecodes::_iconst_5:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
    case Bytecodes::_fconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
    case Bytecodes::_fconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
    case Bytecodes::_fconst_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
    case Bytecodes::_bipush:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
    case Bytecodes::_sipush:            ppush1(valCTS);             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
    case Bytecodes::_lconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
    case Bytecodes::_lconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
    case Bytecodes::_dconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
    case Bytecodes::_dconst_1:          ppush(vvCTS);               break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
    case Bytecodes::_ldc2_w:            ppush(vvCTS);               break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
7111
ac1a0346bc0f 6981788: GC map generator sometimes picks up the wrong kind of instruction operand
jrose
parents: 6176
diff changeset
  1399
    case Bytecodes::_ldc:               // fall through:
ac1a0346bc0f 6981788: GC map generator sometimes picks up the wrong kind of instruction operand
jrose
parents: 6176
diff changeset
  1400
    case Bytecodes::_ldc_w:             do_ldc(itr->bci());         break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
    case Bytecodes::_iload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
    case Bytecodes::_fload:             ppload(vCTS, itr->get_index()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
    case Bytecodes::_lload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
    case Bytecodes::_dload:             ppload(vvCTS,itr->get_index()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
    case Bytecodes::_aload:             ppload(rCTS, itr->get_index()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
    case Bytecodes::_iload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
    case Bytecodes::_fload_0:           ppload(vCTS, 0);            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
    case Bytecodes::_iload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
    case Bytecodes::_fload_1:           ppload(vCTS, 1);            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
    case Bytecodes::_iload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
    case Bytecodes::_fload_2:           ppload(vCTS, 2);            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
    case Bytecodes::_iload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
    case Bytecodes::_fload_3:           ppload(vCTS, 3);            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
    case Bytecodes::_lload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
    case Bytecodes::_dload_0:           ppload(vvCTS, 0);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
    case Bytecodes::_lload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
    case Bytecodes::_dload_1:           ppload(vvCTS, 1);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
    case Bytecodes::_lload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
    case Bytecodes::_dload_2:           ppload(vvCTS, 2);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
    case Bytecodes::_lload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
    case Bytecodes::_dload_3:           ppload(vvCTS, 3);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
    case Bytecodes::_aload_0:           ppload(rCTS, 0);            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
    case Bytecodes::_aload_1:           ppload(rCTS, 1);            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
    case Bytecodes::_aload_2:           ppload(rCTS, 2);            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
    case Bytecodes::_aload_3:           ppload(rCTS, 3);            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
    case Bytecodes::_iaload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
    case Bytecodes::_faload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
    case Bytecodes::_baload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
    case Bytecodes::_caload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
    case Bytecodes::_saload:            pp(vrCTS, vCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
    case Bytecodes::_laload:            pp(vrCTS, vvCTS);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
    case Bytecodes::_daload:            pp(vrCTS, vvCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
    case Bytecodes::_aaload:            pp_new_ref(vrCTS, itr->bci()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
    case Bytecodes::_istore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
    case Bytecodes::_fstore:            ppstore(vCTS, itr->get_index()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
    case Bytecodes::_lstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
    case Bytecodes::_dstore:            ppstore(vvCTS, itr->get_index()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
    case Bytecodes::_astore:            do_astore(itr->get_index());     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
    case Bytecodes::_istore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
    case Bytecodes::_fstore_0:          ppstore(vCTS, 0);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
    case Bytecodes::_istore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
    case Bytecodes::_fstore_1:          ppstore(vCTS, 1);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
    case Bytecodes::_istore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
    case Bytecodes::_fstore_2:          ppstore(vCTS, 2);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
    case Bytecodes::_istore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
    case Bytecodes::_fstore_3:          ppstore(vCTS, 3);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
    case Bytecodes::_lstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
    case Bytecodes::_dstore_0:          ppstore(vvCTS, 0);          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
    case Bytecodes::_lstore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
    case Bytecodes::_dstore_1:          ppstore(vvCTS, 1);          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
    case Bytecodes::_lstore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
    case Bytecodes::_dstore_2:          ppstore(vvCTS, 2);          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
    case Bytecodes::_lstore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
    case Bytecodes::_dstore_3:          ppstore(vvCTS, 3);          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
    case Bytecodes::_astore_0:          do_astore(0);               break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
    case Bytecodes::_astore_1:          do_astore(1);               break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
    case Bytecodes::_astore_2:          do_astore(2);               break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
    case Bytecodes::_astore_3:          do_astore(3);               break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
    case Bytecodes::_iastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
    case Bytecodes::_fastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
    case Bytecodes::_bastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
    case Bytecodes::_castore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
    case Bytecodes::_sastore:           ppop(vvrCTS);               break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
    case Bytecodes::_lastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
    case Bytecodes::_dastore:           ppop(vvvrCTS);              break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
    case Bytecodes::_aastore:           ppop(rvrCTS);               break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
    case Bytecodes::_pop:               ppop_any(1);                break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
    case Bytecodes::_pop2:              ppop_any(2);                break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
    case Bytecodes::_dup:               ppdupswap(1, "11");         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
    case Bytecodes::_dup_x1:            ppdupswap(2, "121");        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
    case Bytecodes::_dup_x2:            ppdupswap(3, "1321");       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
    case Bytecodes::_dup2:              ppdupswap(2, "2121");       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
    case Bytecodes::_dup2_x1:           ppdupswap(3, "21321");      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
    case Bytecodes::_dup2_x2:           ppdupswap(4, "214321");     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
    case Bytecodes::_swap:              ppdupswap(2, "12");         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
    case Bytecodes::_iadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
    case Bytecodes::_fadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
    case Bytecodes::_isub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
    case Bytecodes::_fsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
    case Bytecodes::_imul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
    case Bytecodes::_fmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
    case Bytecodes::_idiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
    case Bytecodes::_fdiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
    case Bytecodes::_irem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
    case Bytecodes::_frem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
    case Bytecodes::_ishl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
    case Bytecodes::_ishr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
    case Bytecodes::_iushr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
    case Bytecodes::_iand:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
    case Bytecodes::_ior:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
    case Bytecodes::_ixor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
    case Bytecodes::_l2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
    case Bytecodes::_l2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
    case Bytecodes::_d2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
    case Bytecodes::_d2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
    case Bytecodes::_fcmpl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
    case Bytecodes::_fcmpg:             pp(vvCTS, vCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
    case Bytecodes::_ladd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
    case Bytecodes::_dadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
    case Bytecodes::_lsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
    case Bytecodes::_dsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
    case Bytecodes::_lmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
    case Bytecodes::_dmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
    case Bytecodes::_ldiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
    case Bytecodes::_ddiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
    case Bytecodes::_lrem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
    case Bytecodes::_drem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
    case Bytecodes::_land:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
    case Bytecodes::_lor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
    case Bytecodes::_lxor:              pp(vvvvCTS, vvCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
    case Bytecodes::_ineg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
    case Bytecodes::_fneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
    case Bytecodes::_i2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
    case Bytecodes::_f2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
    case Bytecodes::_i2c:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
    case Bytecodes::_i2s:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
    case Bytecodes::_i2b:               pp(vCTS, vCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
    case Bytecodes::_lneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
    case Bytecodes::_dneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
    case Bytecodes::_l2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
    case Bytecodes::_d2l:               pp(vvCTS, vvCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
    case Bytecodes::_lshl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
    case Bytecodes::_lshr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
    case Bytecodes::_lushr:             pp(vvvCTS, vvCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
    case Bytecodes::_i2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
    case Bytecodes::_i2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
    case Bytecodes::_f2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1552
    case Bytecodes::_f2d:               pp(vCTS, vvCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
    case Bytecodes::_lcmp:              pp(vvvvCTS, vCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
    case Bytecodes::_dcmpl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
    case Bytecodes::_dcmpg:             pp(vvvvCTS, vCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
    case Bytecodes::_ifeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
    case Bytecodes::_ifne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
    case Bytecodes::_iflt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
    case Bytecodes::_ifge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
    case Bytecodes::_ifgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
    case Bytecodes::_ifle:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
    case Bytecodes::_tableswitch:       ppop1(valCTS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
    case Bytecodes::_ireturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
    case Bytecodes::_freturn:           do_return_monitor_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
                                        ppop1(valCTS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
    case Bytecodes::_if_icmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
    case Bytecodes::_if_icmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
    case Bytecodes::_if_icmplt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
    case Bytecodes::_if_icmpge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1574
    case Bytecodes::_if_icmpgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1575
    case Bytecodes::_if_icmple:         ppop(vvCTS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1577
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1578
    case Bytecodes::_lreturn:           do_return_monitor_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
                                        ppop(vvCTS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
    case Bytecodes::_dreturn:           do_return_monitor_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
                                        ppop(vvCTS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
    case Bytecodes::_if_acmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
    case Bytecodes::_if_acmpne:         ppop(rrCTS);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
    case Bytecodes::_jsr:               do_jsr(itr->dest());         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
    case Bytecodes::_jsr_w:             do_jsr(itr->dest_w());       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
10251
71b8938a2821 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 8076
diff changeset
  1592
    case Bytecodes::_getstatic:         do_field(true,  true,  itr->get_index_u2_cpcache(), itr->bci()); break;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 5402
diff changeset
  1593
    case Bytecodes::_putstatic:         do_field(false, true,  itr->get_index_u2_cpcache(), itr->bci()); break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 5402
diff changeset
  1594
    case Bytecodes::_getfield:          do_field(true,  false, itr->get_index_u2_cpcache(), itr->bci()); break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 5402
diff changeset
  1595
    case Bytecodes::_putfield:          do_field(false, false, itr->get_index_u2_cpcache(), itr->bci()); break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4429
diff changeset
  1597
    case Bytecodes::_invokevirtual:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 5402
diff changeset
  1598
    case Bytecodes::_invokespecial:     do_method(false, false, itr->get_index_u2_cpcache(), itr->bci()); break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 5402
diff changeset
  1599
    case Bytecodes::_invokestatic:      do_method(true,  false, itr->get_index_u2_cpcache(), itr->bci()); break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 5402
diff changeset
  1600
    case Bytecodes::_invokedynamic:     do_method(true,  false, itr->get_index_u4(),         itr->bci()); break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 5402
diff changeset
  1601
    case Bytecodes::_invokeinterface:   do_method(false, true,  itr->get_index_u2_cpcache(), itr->bci()); break;
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4429
diff changeset
  1602
    case Bytecodes::_newarray:
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4429
diff changeset
  1603
    case Bytecodes::_anewarray:         pp_new_ref(vCTS, itr->bci()); break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
    case Bytecodes::_checkcast:         do_checkcast(); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
    case Bytecodes::_arraylength:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
    case Bytecodes::_instanceof:        pp(rCTS, vCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
    case Bytecodes::_monitorenter:      do_monitorenter(itr->bci()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
    case Bytecodes::_monitorexit:       do_monitorexit(itr->bci()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
    case Bytecodes::_athrow:            // handled by do_exception_edge() BUT ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
                                        // vlh(apple): do_exception_edge() does not get
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
                                        // called if method has no exception handlers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
                                        if ((!_has_exceptions) && (_monitor_top > 0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
                                          _monitor_safe = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
                                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
    case Bytecodes::_areturn:           do_return_monitor_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
                                        ppop1(refCTS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
                                        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
    case Bytecodes::_ifnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
    case Bytecodes::_ifnonnull:         ppop1(refCTS); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
    case Bytecodes::_multianewarray:    do_multianewarray(*(itr->bcp()+3), itr->bci()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
    case Bytecodes::_wide:              fatal("Iterator should skip this bytecode"); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
    case Bytecodes::_ret:                                           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
    // Java opcodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
    case Bytecodes::_lookupswitch:      ppop1(valCTS);             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
         tty->print("unexpected opcode: %d\n", itr->code());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
         ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1637
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
void GenerateOopMap::check_type(CellTypeState expected, CellTypeState actual) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
  if (!expected.equal_kind(actual)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
    verify_error("wrong type on stack (found: %c expected: %c)", actual.to_char(), expected.to_char());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
void GenerateOopMap::ppstore(CellTypeState *in, int loc_no) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
  while(!(*in).is_bottom()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
    CellTypeState expected =*in++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
    CellTypeState actual   = pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
    check_type(expected, actual);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
    assert(loc_no >= 0, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
    set_var(loc_no++, actual);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
void GenerateOopMap::ppload(CellTypeState *out, int loc_no) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
  while(!(*out).is_bottom()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
    CellTypeState out1 = *out++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
    CellTypeState vcts = get_var(loc_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
    assert(out1.can_be_reference() || out1.can_be_value(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
           "can only load refs. and values.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
    if (out1.is_reference()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
      assert(loc_no>=0, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
      if (!vcts.is_reference()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
        // We were asked to push a reference, but the type of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
        // variable can be something else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
        _conflict = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1666
        if (vcts.can_be_uninit()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
          // It is a ref-uninit conflict (at least). If there are other
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1668
          // problems, we'll get them in the next round
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
          add_to_ref_init_set(loc_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
          vcts = out1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
          // It wasn't a ref-uninit conflict. So must be a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
          // ref-val or ref-pc conflict. Split the variable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
          record_refval_conflict(loc_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
          vcts = out1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
        push(out1); // recover...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
        push(vcts); // preserve reference.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
      // Otherwise it is a conflict, but one that verification would
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
      // have caught if illegal. In particular, it can't be a topCTS
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
      // resulting from mergeing two difference pcCTS's since the verifier
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
      // would have rejected any use of such a merge.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
      push(out1); // handle val/init conflict
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
    loc_no++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1690
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
void GenerateOopMap::ppdupswap(int poplen, const char *out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
  CellTypeState actual[5];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
  assert(poplen < 5, "this must be less than length of actual vector");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
38658
34f9c45625d8 8140594: Various minor code improvements (compiler)
goetz
parents: 38177
diff changeset
  1696
  // Pop all arguments.
34f9c45625d8 8140594: Various minor code improvements (compiler)
goetz
parents: 38177
diff changeset
  1697
  for (int i = 0; i < poplen; i++) {
34f9c45625d8 8140594: Various minor code improvements (compiler)
goetz
parents: 38177
diff changeset
  1698
    actual[i] = pop();
34f9c45625d8 8140594: Various minor code improvements (compiler)
goetz
parents: 38177
diff changeset
  1699
  }
34f9c45625d8 8140594: Various minor code improvements (compiler)
goetz
parents: 38177
diff changeset
  1700
  // Field _state is uninitialized when calling push.
34f9c45625d8 8140594: Various minor code improvements (compiler)
goetz
parents: 38177
diff changeset
  1701
  for (int i = poplen; i < 5; i++) {
34f9c45625d8 8140594: Various minor code improvements (compiler)
goetz
parents: 38177
diff changeset
  1702
    actual[i] = CellTypeState::uninit;
34f9c45625d8 8140594: Various minor code improvements (compiler)
goetz
parents: 38177
diff changeset
  1703
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
  // put them back
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
  char push_ch = *out++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
  while (push_ch != '\0') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
    int idx = push_ch - '1';
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
    assert(idx >= 0 && idx < poplen, "wrong arguments");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
    push(actual[idx]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
    push_ch = *out++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
void GenerateOopMap::ppop1(CellTypeState out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
  CellTypeState actual = pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
  check_type(out, actual);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
void GenerateOopMap::ppop(CellTypeState *out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
  while (!(*out).is_bottom()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
    ppop1(*out++);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
void GenerateOopMap::ppush1(CellTypeState in) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
  assert(in.is_reference() | in.is_value(), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
  push(in);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1730
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
void GenerateOopMap::ppush(CellTypeState *in) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
  while (!(*in).is_bottom()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
    ppush1(*in++);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
void GenerateOopMap::pp(CellTypeState *in, CellTypeState *out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
  ppop(in);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
  ppush(out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
void GenerateOopMap::pp_new_ref(CellTypeState *in, int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
  ppop(in);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
  ppush1(CellTypeState::make_line_ref(bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
void GenerateOopMap::ppop_any(int poplen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
  if (_stack_top >= poplen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
    _stack_top -= poplen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
    verify_error("stack underflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
// Replace all occurences of the state 'match' with the state 'replace'
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
// in our current state vector.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
void GenerateOopMap::replace_all_CTS_matches(CellTypeState match,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
                                             CellTypeState replace) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
  int len = _max_locals + _stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
  bool change = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
  for (i = len - 1; i >= 0; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
    if (match.equal(_state[i])) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
      _state[i] = replace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
  if (_monitor_top > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
    int base = _max_locals + _max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
    len = base + _monitor_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
    for (i = len - 1; i >= base; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
      if (match.equal(_state[i])) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
        _state[i] = replace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
void GenerateOopMap::do_checkcast() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
  CellTypeState actual = pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
  check_type(refCTS, actual);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
  push(actual);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
void GenerateOopMap::do_monitorenter(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
  CellTypeState actual = pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
  if (_monitor_top == bad_monitors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
  // Bail out when we get repeated locks on an identical monitor.  This case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
  // isn't too hard to handle and can be made to work if supporting nested
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
  // redundant synchronized statements becomes a priority.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
  // See also "Note" in do_monitorexit(), below.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
  if (actual.is_lock_reference()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
    _monitor_top = bad_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
    _monitor_safe = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
  1801
    if (log_is_enabled(Info, monitormismatch)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
      report_monitor_mismatch("nested redundant lock -- bailout...");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
  CellTypeState lock = CellTypeState::make_lock_ref(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1808
  check_type(refCTS, actual);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
  if (!actual.is_info_top()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
    replace_all_CTS_matches(actual, lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
    monitor_push(lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
void GenerateOopMap::do_monitorexit(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
  CellTypeState actual = pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
  if (_monitor_top == bad_monitors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
  check_type(refCTS, actual);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1821
  CellTypeState expected = monitor_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1822
  if (!actual.is_lock_reference() || !expected.equal(actual)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1823
    // The monitor we are exiting is not verifiably the one
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1824
    // on the top of our monitor stack.  This causes a monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1825
    // mismatch.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1826
    _monitor_top = bad_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1827
    _monitor_safe = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1828
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
    // We need to mark this basic block as changed so that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1830
    // this monitorexit will be visited again.  We need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
    // do this to ensure that we have accounted for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1832
    // possibility that this bytecode will throw an
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
    // exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
    BasicBlock* bb = get_basic_block_containing(bci);
16374
634539171c19 8009022: [parfait] Null pointer deference in hotspot/src/share/vm/oops/generateOopMap.cpp
morris
parents: 15799
diff changeset
  1835
    guarantee(bb != NULL, "no basic block for bci");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
    bb->set_changed(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
    bb->_monitor_top = bad_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1838
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
  1839
    if (log_is_enabled(Info, monitormismatch)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
      report_monitor_mismatch("improper monitor pair");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
    // This code is a fix for the case where we have repeated
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
    // locking of the same object in straightline code.  We clear
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1845
    // out the lock when it is popped from the monitor stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1846
    // and replace it with an unobtrusive reference value that can
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1847
    // be locked again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1848
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1849
    // Note: when generateOopMap is fixed to properly handle repeated,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1850
    //       nested, redundant locks on the same object, then this
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1851
    //       fix will need to be removed at that time.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1852
    replace_all_CTS_matches(actual, CellTypeState::make_line_ref(bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1853
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1854
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1855
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1856
void GenerateOopMap::do_return_monitor_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
  if (_monitor_top > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1858
    // The monitor stack must be empty when we leave the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1859
    // for the monitors to be properly matched.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1860
    _monitor_safe = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1861
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1862
    // Since there are no successors to the *return bytecode, it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1863
    // isn't necessary to set _monitor_top to bad_monitors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1864
37203
90eabed33a6c 8150084: Convert TraceMonitorMismatch to Unified Logging.
mockner
parents: 37161
diff changeset
  1865
    if (log_is_enabled(Info, monitormismatch)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1866
      report_monitor_mismatch("non-empty monitor stack at return");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1867
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1868
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1869
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1870
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1871
void GenerateOopMap::do_jsr(int targ_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1872
  push(CellTypeState::make_addr(targ_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1873
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
7111
ac1a0346bc0f 6981788: GC map generator sometimes picks up the wrong kind of instruction operand
jrose
parents: 6176
diff changeset
  1877
void GenerateOopMap::do_ldc(int bci) {
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 58722
diff changeset
  1878
  Bytecode_loadconstant ldc(methodHandle(Thread::current(), method()), bci);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1879
  ConstantPool* cp  = method()->constants();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1880
  constantTag tag = cp->tag_at(ldc.pool_index()); // idx is index in resolved_references
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1881
  BasicType       bt  = ldc.result_type();
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48157
diff changeset
  1882
#ifdef ASSERT
52881
dfdc025ad9ea 8214275: CondyRepeatFailedResolution asserts "Dynamic constant has no fixed basic type"
lfoltan
parents: 49177
diff changeset
  1883
  BasicType   tag_bt = (tag.is_dynamic_constant() || tag.is_dynamic_constant_in_error()) ? bt : tag.basic_type();
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48157
diff changeset
  1884
  assert(bt == tag_bt, "same result");
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48157
diff changeset
  1885
#endif
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1886
  CellTypeState   cts;
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48157
diff changeset
  1887
  if (is_reference_type(bt)) {  // could be T_ARRAY with condy
22230
2b4b260229d0 8029351: assert(bt != T_OBJECT) failed: Guard is incorrect in VM:defmeth
drchase
parents: 18055
diff changeset
  1888
    assert(!tag.is_string_index() && !tag.is_klass_index(), "Unexpected index tag");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1889
    cts = CellTypeState::make_line_ref(bci);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1890
  } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1891
    cts = valCTS;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1892
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1893
  ppush1(cts);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1894
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1895
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1896
void GenerateOopMap::do_multianewarray(int dims, int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1897
  assert(dims >= 1, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1898
  for(int i = dims -1; i >=0; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1899
    ppop1(valCTS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1900
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1901
  ppush1(CellTypeState::make_line_ref(bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1902
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1903
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1904
void GenerateOopMap::do_astore(int idx) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1905
  CellTypeState r_or_p = pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
  if (!r_or_p.is_address() && !r_or_p.is_reference()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
    // We actually expected ref or pc, but we only report that we expected a ref. It does not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
    // really matter (at least for now)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
    verify_error("wrong type on stack (found: %c, expected: {pr})", r_or_p.to_char());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1912
  set_var(idx, r_or_p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
// Copies bottom/zero terminated CTS string from "src" into "dst".
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
//   Does NOT terminate with a bottom. Returns the number of cells copied.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
int GenerateOopMap::copy_cts(CellTypeState *dst, CellTypeState *src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
  int idx = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
  while (!src[idx].is_bottom()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
    dst[idx] = src[idx];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
    idx++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
  return idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1925
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
void GenerateOopMap::do_field(int is_get, int is_static, int idx, int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1927
  // Dig up signature for field in constant pool
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1928
  ConstantPool* cp     = method()->constants();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1929
  int nameAndTypeIdx     = cp->name_and_type_ref_index_at(idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
  int signatureIdx       = cp->signature_ref_index_at(nameAndTypeIdx);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
  1931
  Symbol* signature      = cp->symbol_at(signatureIdx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1933
  // Parse signature (espcially simple for fields)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
  assert(signature->utf8_length() > 0, "field signatures cannot have zero length");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
  // The signature is UFT8 encoded, but the first char is always ASCII for signatures.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
  char sigch = (char)*(signature->base());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
  CellTypeState temp[4];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
  CellTypeState *eff  = sigchar_to_effect(sigch, bci, temp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
  CellTypeState in[4];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
  CellTypeState *out;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
  int i =  0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
  if (is_get) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
    out = eff;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
    out = epsilonCTS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
    i   = copy_cts(in, eff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1950
  if (!is_static) in[i++] = CellTypeState::ref;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
  in[i] = CellTypeState::bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
  assert(i<=3, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
  pp(in, out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1956
void GenerateOopMap::do_method(int is_static, int is_interface, int idx, int bci) {
4429
d7eb4e2099aa 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 3261
diff changeset
  1957
 // Dig up signature for field in constant pool
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1958
  ConstantPool* cp  = _method->constants();
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
  1959
  Symbol* signature   = cp->signature_ref_at(idx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
  // Parse method signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
  CellTypeState out[4];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
  CellTypeState in[MAXARGSIZE+1];   // Includes result
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
  ComputeCallStack cse(signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
  // Compute return type
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
  int res_length=  cse.compute_for_returntype(out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1969
  // Temporary hack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
  if (out[0].equal(CellTypeState::ref) && out[1].equal(CellTypeState::bottom)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
    out[0] = CellTypeState::make_line_ref(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
  assert(res_length<=4, "max value should be vv");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
  // Compute arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1977
  int arg_length = cse.compute_for_parameters(is_static != 0, in);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1978
  assert(arg_length<=MAXARGSIZE, "too many locals");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1980
  // Pop arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
  for (int i = arg_length - 1; i >= 0; i--) ppop1(in[i]);// Do args in reverse order.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
  // Report results
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
  if (_report_result_for_send == true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
     fill_stackmap_for_opcodes(_itr_send, vars(), stack(), _stack_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
     _report_result_for_send = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
  // Push return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
  ppush(out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
// This is used to parse the signature for fields, since they are very simple...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
CellTypeState *GenerateOopMap::sigchar_to_effect(char sigch, int bci, CellTypeState *out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
  // Object and array
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 53838
diff changeset
  1996
  if (sigch==JVM_SIGNATURE_CLASS || sigch==JVM_SIGNATURE_ARRAY) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
    out[0] = CellTypeState::make_line_ref(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
    out[1] = CellTypeState::bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
    return out;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
  }
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 53838
diff changeset
  2001
  if (sigch == JVM_SIGNATURE_LONG || sigch == JVM_SIGNATURE_DOUBLE) return vvCTS;  // Long and Double
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 53838
diff changeset
  2002
  if (sigch == JVM_SIGNATURE_VOID) return epsilonCTS; // Void
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 53838
diff changeset
  2003
  return vCTS;                                        // Otherwise
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
long GenerateOopMap::_total_byte_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
elapsedTimer GenerateOopMap::_total_oopmap_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
// This function assumes "bcs" is at a "ret" instruction and that the vars
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
// state is valid for that instruction. Furthermore, the ret instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
// must be the last instruction in "bb" (we store information about the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
// "ret" in "bb").
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
void GenerateOopMap::ret_jump_targets_do(BytecodeStream *bcs, jmpFct_t jmpFct, int varNo, int *data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
  CellTypeState ra = vars()[varNo];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
  if (!ra.is_good_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
    verify_error("ret returns from two jsr subroutines?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
  int target = ra.get_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
  RetTableEntry* rtEnt = _rt.find_jsrs_for_target(target);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
  int bci = bcs->bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
  for (int i = 0; i < rtEnt->nof_jsrs(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
    int target_bci = rtEnt->jsrs(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
    // Make sure a jrtRet does not set the changed bit for dead basicblock.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
    BasicBlock* jsr_bb    = get_basic_block_containing(target_bci - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
    debug_only(BasicBlock* target_bb = &jsr_bb[1];)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
    assert(target_bb  == get_basic_block_at(target_bci), "wrong calc. of successor basicblock");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
    bool alive = jsr_bb->is_alive();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
    if (TraceNewOopMapGeneration) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
      tty->print("pc = %d, ret -> %d alive: %s\n", bci, target_bci, alive ? "true" : "false");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
    if (alive) jmpFct(this, target_bci, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
// Debug method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
char* GenerateOopMap::state_vec_to_string(CellTypeState* vec, int len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
  int checklen = MAX3(_max_locals, _max_stack, _max_monitors) + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
  assert(len < checklen, "state_vec_buf overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
  for (int i = 0; i < len; i++) _state_vec_buf[i] = vec[i].to_char();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
  _state_vec_buf[len] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
  return _state_vec_buf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2048
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
void GenerateOopMap::print_time() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
  tty->print_cr ("Accumulated oopmap times:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
  tty->print_cr ("---------------------------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
  tty->print_cr ("  Total : %3.3f sec.", GenerateOopMap::_total_oopmap_time.seconds());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
  tty->print_cr ("  (%3.0f bytecodes per sec) ",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
  GenerateOopMap::_total_byte_count / GenerateOopMap::_total_oopmap_time.seconds());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
//  ============ Main Entry Point ===========
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
//
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 22230
diff changeset
  2061
GenerateOopMap::GenerateOopMap(const methodHandle& method) {
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1374
diff changeset
  2062
  // We have to initialize all variables here, that can be queried directly
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
  _method = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
  _max_locals=0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
  _init_vars = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2066
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
  // If we are doing a detailed trace, include the regular trace information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
  if (TraceNewOopMapGenerationDetailed) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
    TraceNewOopMapGeneration = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
void GenerateOopMap::compute_map(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
  if (TimeOopMap2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2078
    method()->print_short_name(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
    tty->print("  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2080
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2081
  if (TimeOopMap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
    _total_byte_count += method()->code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
  TraceTime t_single("oopmap time", TimeOopMap2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
  TraceTime t_all(NULL, &_total_oopmap_time, TimeOopMap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
  // Initialize values
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
  _got_error      = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
  _conflict       = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
  _max_locals     = method()->max_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
  _max_stack      = method()->max_stack();
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  2093
  _has_exceptions = (method()->has_exception_handler());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
  _nof_refval_conflicts = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
  _init_vars      = new GrowableArray<intptr_t>(5);  // There are seldom more than 5 init_vars
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
  _report_result  = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2097
  _report_result_for_send = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
  _new_var_map    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2099
  _ret_adr_tos    = new GrowableArray<intptr_t>(5);  // 5 seems like a good number;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2100
  _did_rewriting  = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2101
  _did_relocation = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2102
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
  if (TraceNewOopMapGeneration) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
    tty->print("Method name: %s\n", method()->name()->as_C_string());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
    if (Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
      _method->print_codes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
      tty->print_cr("Exception table:");
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  2108
      ExceptionTable excps(method());
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  2109
      for(int i = 0; i < excps.length(); i ++) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  2110
        tty->print_cr("[%d - %d] -> %d",
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 10278
diff changeset
  2111
                      excps.start_pc(i), excps.end_pc(i), excps.handler_pc(i));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2116
  // if no code - do nothing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2117
  // compiler needs info
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
  if (method()->code_size() == 0 || _max_locals + method()->max_stack() == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
    fill_stackmap_prolog(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
    fill_stackmap_epilog();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2121
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2122
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
  // Step 1: Compute all jump targets and their return value
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2124
  if (!_got_error)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2125
    _rt.compute_ret_table(_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2126
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2127
  // Step 2: Find all basic blocks and count GC points
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2128
  if (!_got_error)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
    mark_bbheaders_and_count_gc_points();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2130
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
  // Step 3: Calculate stack maps
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
  if (!_got_error)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2133
    do_interpretation();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2134
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
  // Step 4:Return results
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2136
  if (!_got_error && report_results())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
     report_result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
  if (_got_error) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
    THROW_HANDLE(_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
// Error handling methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
// These methods create an exception for the current thread which is thrown
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
// at the bottom of the call stack, when it returns to compute_map().  The
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
// _got_error flag controls execution.  NOT TODO: The VM exception propagation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
// mechanism using TRAPS/CHECKs could be used here instead but it would need
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
// to be added as a parameter to every function and checked for every call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
// The tons of extra code it would generate didn't seem worth the change.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
void GenerateOopMap::error_work(const char *format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
  _got_error = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
  char msg_buffer[512];
49177
eebf559c9e0d 8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents: 48826
diff changeset
  2155
  os::vsnprintf(msg_buffer, sizeof(msg_buffer), format, ap);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
  // Append method name
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2157
  char msg_buffer2[512];
49177
eebf559c9e0d 8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents: 48826
diff changeset
  2158
  os::snprintf(msg_buffer2, sizeof(msg_buffer2), "%s in method %s", msg_buffer, method()->name()->as_C_string());
47822
7437dc810834 8190797: OSR compilation fails with "assert(__the_thread__->can_call_java()) failed: can not load classes with compiler thread"
thartmann
parents: 47765
diff changeset
  2159
  if (Thread::current()->can_call_java()) {
7437dc810834 8190797: OSR compilation fails with "assert(__the_thread__->can_call_java()) failed: can not load classes with compiler thread"
thartmann
parents: 47765
diff changeset
  2160
    _exception = Exceptions::new_exception(Thread::current(),
7437dc810834 8190797: OSR compilation fails with "assert(__the_thread__->can_call_java()) failed: can not load classes with compiler thread"
thartmann
parents: 47765
diff changeset
  2161
                  vmSymbols::java_lang_LinkageError(), msg_buffer2);
7437dc810834 8190797: OSR compilation fails with "assert(__the_thread__->can_call_java()) failed: can not load classes with compiler thread"
thartmann
parents: 47765
diff changeset
  2162
  } else {
7437dc810834 8190797: OSR compilation fails with "assert(__the_thread__->can_call_java()) failed: can not load classes with compiler thread"
thartmann
parents: 47765
diff changeset
  2163
    // We cannot instantiate an exception object from a compiler thread.
7437dc810834 8190797: OSR compilation fails with "assert(__the_thread__->can_call_java()) failed: can not load classes with compiler thread"
thartmann
parents: 47765
diff changeset
  2164
    // Exit the VM with a useful error message.
7437dc810834 8190797: OSR compilation fails with "assert(__the_thread__->can_call_java()) failed: can not load classes with compiler thread"
thartmann
parents: 47765
diff changeset
  2165
    fatal("%s", msg_buffer2);
7437dc810834 8190797: OSR compilation fails with "assert(__the_thread__->can_call_java()) failed: can not load classes with compiler thread"
thartmann
parents: 47765
diff changeset
  2166
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
void GenerateOopMap::report_error(const char *format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
  error_work(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
void GenerateOopMap::verify_error(const char *format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
  // We do not distinguish between different types of errors for verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
  // errors.  Let the verifier give a better message.
47822
7437dc810834 8190797: OSR compilation fails with "assert(__the_thread__->can_call_java()) failed: can not load classes with compiler thread"
thartmann
parents: 47765
diff changeset
  2178
  report_error("Illegal class file encountered. Try running with -Xverify:all");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
// Report result opcodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
void GenerateOopMap::report_result() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
  if (TraceNewOopMapGeneration) tty->print_cr("Report result pass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2187
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
  // We now want to report the result of the parse
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
  _report_result = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
  // Prolog code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
  fill_stackmap_prolog(_gc_points);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
   // Mark everything changed, then do one interpretation pass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
  for (int i = 0; i<_bb_count; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
    if (_basic_blocks[i].is_reachable()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
      _basic_blocks[i].set_changed(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
      interp_bb(&_basic_blocks[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2199
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2200
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
  // Note: Since we are skipping dead-code when we are reporting results, then
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2203
  // the no. of encountered gc-points might be fewer than the previously number
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2204
  // we have counted. (dead-code is a pain - it should be removed before we get here)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2205
  fill_stackmap_epilog();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2206
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2207
  // Report initvars
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2208
  fill_init_vars(_init_vars);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2209
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2210
  _report_result = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2211
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2212
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2213
void GenerateOopMap::result_for_basicblock(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
 if (TraceNewOopMapGeneration) tty->print_cr("Report result pass for basicblock");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2216
  // We now want to report the result of the parse
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2217
  _report_result = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2218
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2219
  // Find basicblock and report results
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
  BasicBlock* bb = get_basic_block_containing(bci);
16374
634539171c19 8009022: [parfait] Null pointer deference in hotspot/src/share/vm/oops/generateOopMap.cpp
morris
parents: 15799
diff changeset
  2221
  guarantee(bb != NULL, "no basic block for bci");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2222
  assert(bb->is_reachable(), "getting result from unreachable basicblock");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
  bb->set_changed(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2224
  interp_bb(bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2228
// Conflict handling code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2229
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
void GenerateOopMap::record_refval_conflict(int varNo) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
  assert(varNo>=0 && varNo< _max_locals, "index out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
  if (TraceOopMapRewrites) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
     tty->print("### Conflict detected (local no: %d)\n", varNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2237
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
  if (!_new_var_map) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
    _new_var_map = NEW_RESOURCE_ARRAY(int, _max_locals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2240
    for (int k = 0; k < _max_locals; k++)  _new_var_map[k] = k;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
  if ( _new_var_map[varNo] == varNo) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
    // Check if max. number of locals has been reached
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
    if (_max_locals + _nof_refval_conflicts >= MAX_LOCAL_VARS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
      report_error("Rewriting exceeded local variable limit");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
    _new_var_map[varNo] = _max_locals + _nof_refval_conflicts;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
    _nof_refval_conflicts++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
void GenerateOopMap::rewrite_refval_conflicts()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
  // We can get here two ways: Either a rewrite conflict was detected, or
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
  // an uninitialize reference was detected. In the second case, we do not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2258
  // do any rewriting, we just want to recompute the reference set with the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2259
  // new information
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
  int nof_conflicts = 0;              // Used for debugging only
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
  if ( _nof_refval_conflicts == 0 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
     return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
  // Check if rewrites are allowed in this parse.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
  if (!allow_rewrites() && !IgnoreRewrites) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
    fatal("Rewriting method not allowed at this stage");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2269
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2272
  // This following flag is to tempoary supress rewrites. The locals that might conflict will
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
  // all be set to contain values. This is UNSAFE - however, until the rewriting has been completely
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
  // tested it is nice to have.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2275
  if (IgnoreRewrites) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
    if (Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
       tty->print("rewrites suppressed for local no. ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
       for (int l = 0; l < _max_locals; l++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2279
         if (_new_var_map[l] != l) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2280
           tty->print("%d ", l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
           vars()[l] = CellTypeState::value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2282
         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2283
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2284
       tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2285
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2286
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2287
    // That was that...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
    _new_var_map = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2289
    _nof_refval_conflicts = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2290
    _conflict = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2291
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2292
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2293
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2294
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2295
  // Tracing flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2296
  _did_rewriting = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2297
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2298
  if (TraceOopMapRewrites) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2299
    tty->print_cr("ref/value conflict for method %s - bytecodes are getting rewritten", method()->name()->as_C_string());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2300
    method()->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2301
    method()->print_codes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2302
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2303
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2304
  assert(_new_var_map!=NULL, "nothing to rewrite");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2305
  assert(_conflict==true, "We should not be here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2306
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2307
  compute_ret_adr_at_TOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2308
  if (!_got_error) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2309
    for (int k = 0; k < _max_locals && !_got_error; k++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2310
      if (_new_var_map[k] != k) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2311
        if (TraceOopMapRewrites) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2312
          tty->print_cr("Rewriting: %d -> %d", k, _new_var_map[k]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2313
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2314
        rewrite_refval_conflict(k, _new_var_map[k]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2315
        if (_got_error) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2316
        nof_conflicts++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2317
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2318
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2319
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2320
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2321
  assert(nof_conflicts == _nof_refval_conflicts, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2322
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2323
  // Adjust the number of locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2324
  method()->set_max_locals(_max_locals+_nof_refval_conflicts);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2325
  _max_locals += _nof_refval_conflicts;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2326
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2327
  // That was that...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2328
  _new_var_map = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2329
  _nof_refval_conflicts = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2330
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2331
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2332
void GenerateOopMap::rewrite_refval_conflict(int from, int to) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2333
  bool startOver;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2334
  do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2335
    // Make sure that the BytecodeStream is constructed in the loop, since
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2336
    // during rewriting a new method oop is going to be used, and the next time
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2337
    // around we want to use that.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2338
    BytecodeStream bcs(_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2339
    startOver = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2340
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2341
    while( !startOver && !_got_error &&
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2342
           // test bcs in case method changed and it became invalid
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2343
           bcs.next() >=0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2344
      startOver = rewrite_refval_conflict_inst(&bcs, from, to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2345
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2346
  } while (startOver && !_got_error);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2347
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2348
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2349
/* If the current instruction is one that uses local variable "from"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2350
   in a ref way, change it to use "to". There's a subtle reason why we
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2351
   renumber the ref uses and not the non-ref uses: non-ref uses may be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2352
   2 slots wide (double, long) which would necessitate keeping track of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2353
   whether we should add one or two variables to the method. If the change
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2354
   affected the width of some instruction, returns "TRUE"; otherwise, returns "FALSE".
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2355
   Another reason for moving ref's value is for solving (addr, ref) conflicts, which
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2356
   both uses aload/astore methods.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2357
*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2358
bool GenerateOopMap::rewrite_refval_conflict_inst(BytecodeStream *itr, int from, int to) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2359
  Bytecodes::Code bc = itr->code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2360
  int index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2361
  int bci = itr->bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2362
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2363
  if (is_aload(itr, &index) && index == from) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2364
    if (TraceOopMapRewrites) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2365
      tty->print_cr("Rewriting aload at bci: %d", bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2366
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2367
    return rewrite_load_or_store(itr, Bytecodes::_aload, Bytecodes::_aload_0, to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2368
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2369
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2370
  if (is_astore(itr, &index) && index == from) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2371
    if (!stack_top_holds_ret_addr(bci)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2372
      if (TraceOopMapRewrites) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2373
        tty->print_cr("Rewriting astore at bci: %d", bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2374
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2375
      return rewrite_load_or_store(itr, Bytecodes::_astore, Bytecodes::_astore_0, to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2376
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2377
      if (TraceOopMapRewrites) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2378
        tty->print_cr("Supress rewriting of astore at bci: %d", bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2379
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2380
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2381
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2382
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2383
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2384
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2385
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2386
// The argument to this method is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2387
// bc : Current bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2388
// bcN : either _aload or _astore
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2389
// bc0 : either _aload_0 or _astore_0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2390
bool GenerateOopMap::rewrite_load_or_store(BytecodeStream *bcs, Bytecodes::Code bcN, Bytecodes::Code bc0, unsigned int varNo) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2391
  assert(bcN == Bytecodes::_astore   || bcN == Bytecodes::_aload,   "wrong argument (bcN)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2392
  assert(bc0 == Bytecodes::_astore_0 || bc0 == Bytecodes::_aload_0, "wrong argument (bc0)");
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  2393
  int ilen = Bytecodes::length_at(_method(), bcs->bcp());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2394
  int newIlen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2395
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2396
  if (ilen == 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2397
    // Original instruction was wide; keep it wide for simplicity
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2398
    newIlen = 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2399
  } else if (varNo < 4)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2400
     newIlen = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2401
  else if (varNo >= 256)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2402
     newIlen = 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2403
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2404
     newIlen = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2405
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2406
  // If we need to relocate in order to patch the byte, we
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2407
  // do the patching in a temp. buffer, that is passed to the reloc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2408
  // The patching of the bytecode stream is then done by the Relocator.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2409
  // This is neccesary, since relocating the instruction at a certain bci, might
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2410
  // also relocate that instruction, e.g., if a _goto before it gets widen to a _goto_w.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2411
  // Hence, we do not know which bci to patch after relocation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2412
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2413
  assert(newIlen <= 4, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2414
  u_char inst_buffer[4]; // Max. instruction size is 4.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2415
  address bcp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2416
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2417
  if (newIlen != ilen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2418
    // Relocation needed do patching in temp. buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2419
    bcp = (address)inst_buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2420
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2421
    bcp = _method->bcp_from(bcs->bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2422
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2423
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2424
  // Patch either directly in Method* or in temp. buffer
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2425
  if (newIlen == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2426
    assert(varNo < 4, "varNo too large");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2427
    *bcp = bc0 + varNo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2428
  } else if (newIlen == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2429
    assert(varNo < 256, "2-byte index needed!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2430
    *(bcp + 0) = bcN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2431
    *(bcp + 1) = varNo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2432
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2433
    assert(newIlen == 4, "Wrong instruction length");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2434
    *(bcp + 0) = Bytecodes::_wide;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2435
    *(bcp + 1) = bcN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2436
    Bytes::put_Java_u2(bcp+2, varNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2437
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2438
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2439
  if (newIlen != ilen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2440
    expand_current_instr(bcs->bci(), ilen, newIlen, inst_buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2441
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2442
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2443
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2444
  return (newIlen != ilen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2445
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2446
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2447
class RelocCallback : public RelocatorListener {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2448
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2449
  GenerateOopMap* _gom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2450
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2451
   RelocCallback(GenerateOopMap* gom) { _gom = gom; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2452
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2453
  // Callback method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2454
  virtual void relocated(int bci, int delta, int new_code_length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2455
    _gom->update_basic_blocks  (bci, delta, new_code_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2456
    _gom->update_ret_adr_at_TOS(bci, delta);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2457
    _gom->_rt.update_ret_table (bci, delta);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2458
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2459
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2460
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2461
// Returns true if expanding was succesful. Otherwise, reports an error and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2462
// returns false.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2463
void GenerateOopMap::expand_current_instr(int bci, int ilen, int newIlen, u_char inst_buffer[]) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2464
  Thread *THREAD = Thread::current();  // Could really have TRAPS argument.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2465
  RelocCallback rcb(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2466
  Relocator rc(_method, &rcb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2467
  methodHandle m= rc.insert_space_at(bci, newIlen, inst_buffer, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2468
  if (m.is_null() || HAS_PENDING_EXCEPTION) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2469
    report_error("could not rewrite method - exception occurred or bytecode buffer overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2470
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2471
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2472
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2473
  // Relocator returns a new method oop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2474
  _did_relocation = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2475
  _method = m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2476
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2477
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2478
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2479
bool GenerateOopMap::is_astore(BytecodeStream *itr, int *index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2480
  Bytecodes::Code bc = itr->code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2481
  switch(bc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2482
    case Bytecodes::_astore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2483
    case Bytecodes::_astore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2484
    case Bytecodes::_astore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2485
    case Bytecodes::_astore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2486
      *index = bc - Bytecodes::_astore_0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2487
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2488
    case Bytecodes::_astore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2489
      *index = itr->get_index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2490
      return true;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  2491
    default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  2492
      return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2493
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2494
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2495
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2496
bool GenerateOopMap::is_aload(BytecodeStream *itr, int *index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2497
  Bytecodes::Code bc = itr->code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2498
  switch(bc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2499
    case Bytecodes::_aload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2500
    case Bytecodes::_aload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2501
    case Bytecodes::_aload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2502
    case Bytecodes::_aload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2503
      *index = bc - Bytecodes::_aload_0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2504
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2505
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2506
    case Bytecodes::_aload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2507
      *index = itr->get_index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2508
      return true;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  2509
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  2510
    default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
  2511
      return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2512
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2513
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2514
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2515
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2516
// Return true iff the top of the operand stack holds a return address at
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2517
// the current instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2518
bool GenerateOopMap::stack_top_holds_ret_addr(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2519
  for(int i = 0; i < _ret_adr_tos->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2520
    if (_ret_adr_tos->at(i) == bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2521
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2522
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2523
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2524
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2525
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2526
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2527
void GenerateOopMap::compute_ret_adr_at_TOS() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2528
  assert(_ret_adr_tos != NULL, "must be initialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2529
  _ret_adr_tos->clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2530
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2531
  for (int i = 0; i < bb_count(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2532
    BasicBlock* bb = &_basic_blocks[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2533
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2534
    // Make sure to only check basicblocks that are reachable
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2535
    if (bb->is_reachable()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2536
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2537
      // For each Basic block we check all instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2538
      BytecodeStream bcs(_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2539
      bcs.set_interval(bb->_bci, next_bb_start_pc(bb));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2540
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2541
      restore_state(bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2542
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2543
      while (bcs.next()>=0 && !_got_error) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2544
        // TDT: should this be is_good_address() ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2545
        if (_stack_top > 0 && stack()[_stack_top-1].is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2546
          _ret_adr_tos->append(bcs.bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2547
          if (TraceNewOopMapGeneration) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2548
            tty->print_cr("Ret_adr TOS at bci: %d", bcs.bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2549
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2550
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2551
        interp1(&bcs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2552
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2553
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2554
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2555
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2556
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2557
void GenerateOopMap::update_ret_adr_at_TOS(int bci, int delta) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2558
  for(int i = 0; i < _ret_adr_tos->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2559
    int v = _ret_adr_tos->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2560
    if (v > bci)  _ret_adr_tos->at_put(i, v + delta);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2561
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2562
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2563
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2564
// ===================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2565
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2566
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2567
int ResolveOopMapConflicts::_nof_invocations  = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2568
int ResolveOopMapConflicts::_nof_rewrites     = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2569
int ResolveOopMapConflicts::_nof_relocations  = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2570
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2571
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2572
methodHandle ResolveOopMapConflicts::do_potential_rewrite(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2573
  compute_map(CHECK_(methodHandle()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2574
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2575
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2576
  // Tracking and statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2577
  if (PrintRewrites) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2578
    _nof_invocations++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2579
    if (did_rewriting()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2580
      _nof_rewrites++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2581
      if (did_relocation()) _nof_relocations++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2582
      tty->print("Method was rewritten %s: ", (did_relocation()) ? "and relocated" : "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2583
      method()->print_value(); tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2584
      tty->print_cr("Cand.: %d rewrts: %d (%d%%) reloc.: %d (%d%%)",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2585
          _nof_invocations,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2586
          _nof_rewrites,    (_nof_rewrites    * 100) / _nof_invocations,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2587
          _nof_relocations, (_nof_relocations * 100) / _nof_invocations);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2588
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2589
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2590
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2591
  return methodHandle(THREAD, method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2592
}