hotspot/src/share/vm/oops/generateOopMap.hpp
author trims
Tue, 05 Apr 2011 14:12:31 -0700
changeset 8921 14bfe81f2a9d
parent 8076 96d498ec7ae1
child 13728 882756847a04
permissions -rw-r--r--
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass Summary: Update the copyright to be 2010 on all changed files in OpenJDK Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
8921
14bfe81f2a9d 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 8076
diff changeset
     2
 * Copyright (c) 1997, 2011, 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: 2131
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2131
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: 2131
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
#ifndef SHARE_VM_OOPS_GENERATEOOPMAP_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    26
#define SHARE_VM_OOPS_GENERATEOOPMAP_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    28
#include "interpreter/bytecodeStream.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    29
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    30
#include "memory/universe.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    31
#include "oops/methodOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    32
#include "oops/oopsHierarchy.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    33
#include "runtime/signature.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
    34
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// Forward definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class MethodOopMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class GenerateOopMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class BasicBlock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class CellTypeState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class StackMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// These two should be removed. But requires som code to be cleaned up
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
#define MAXARGSIZE      256      // This should be enough
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
#define MAX_LOCAL_VARS  65536    // 16-bit entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
typedef void (*jmpFct_t)(GenerateOopMap *c, int bcpDelta, int* data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//  RetTable
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// Contains maping between jsr targets and there return addresses. One-to-many mapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class RetTableEntry : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  static int _init_nof_jsrs;                      // Default size of jsrs list
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  int _target_bci;                                // Target PC address of jump (bytecode index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  GrowableArray<intptr_t> * _jsrs;                     // List of return addresses  (bytecode index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  RetTableEntry *_next;                           // Link to next entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
   RetTableEntry(int target, RetTableEntry *next)  { _target_bci=target; _jsrs = new GrowableArray<intptr_t>(_init_nof_jsrs); _next = next;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // Query
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  int target_bci() const                      { return _target_bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  int nof_jsrs() const                        { return _jsrs->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  int jsrs(int i) const                       { assert(i>=0 && i<nof_jsrs(), "Index out of bounds"); return _jsrs->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // Update entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  void add_jsr    (int return_bci)            { _jsrs->append(return_bci); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  void add_delta  (int bci, int delta);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  RetTableEntry * next()  const               { return _next; }
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
class RetTable VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  RetTableEntry *_first;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  static int _init_nof_entries;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  void add_jsr(int return_bci, int target_bci);   // Adds entry to list
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  RetTable()                                                  { _first = NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  void compute_ret_table(methodHandle method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  void update_ret_table(int bci, int delta);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  RetTableEntry* find_jsrs_for_target(int targBci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
// CellTypeState
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
class CellTypeState VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  unsigned int _state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // Masks for separating the BITS and INFO portions of a CellTypeState
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  enum { info_mask            = right_n_bits(28),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
         bits_mask            = (int)(~info_mask) };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // These constant are used for manipulating the BITS portion of a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // CellTypeState
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  enum { uninit_bit           = (int)(nth_bit(31)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
         ref_bit              = nth_bit(30),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
         val_bit              = nth_bit(29),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
         addr_bit             = nth_bit(28),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
         live_bits_mask       = (int)(bits_mask & ~uninit_bit) };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // These constants are used for manipulating the INFO portion of a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // CellTypeState
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  enum { top_info_bit         = nth_bit(27),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
         not_bottom_info_bit  = nth_bit(26),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
         info_data_mask       = right_n_bits(26),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
         info_conflict        = info_mask };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Within the INFO data, these values are used to distinguish different
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // kinds of references.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  enum { ref_not_lock_bit     = nth_bit(25),  // 0 if this reference is locked as a monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
         ref_slot_bit         = nth_bit(24),  // 1 if this reference is a "slot" reference,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
                                              // 0 if it is a "line" reference.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
         ref_data_mask        = right_n_bits(24) };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // These values are used to initialize commonly used CellTypeState
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // constants.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  enum { bottom_value         = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
         uninit_value         = (int)(uninit_bit | info_conflict),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
         ref_value            = ref_bit,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
         ref_conflict         = ref_bit | info_conflict,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
         val_value            = val_bit | info_conflict,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
         addr_value           = addr_bit,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
         addr_conflict        = addr_bit | info_conflict };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // Since some C++ constructors generate poor code for declarations of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // form...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  //   CellTypeState vector[length];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // ...we avoid making a constructor for this class.  CellTypeState values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // should be constructed using one of the make_* methods:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  static CellTypeState make_any(int state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    CellTypeState s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    s._state = state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    // Causes SS10 warning.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    // assert(s.is_valid_state(), "check to see if CellTypeState is valid");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    return s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  static CellTypeState make_bottom() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    return make_any(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  static CellTypeState make_top() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    return make_any(AllBits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  static CellTypeState make_addr(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    assert((bci >= 0) && (bci < info_data_mask), "check to see if ret addr is valid");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    return make_any(addr_bit | not_bottom_info_bit | (bci & info_data_mask));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  static CellTypeState make_slot_ref(int slot_num) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    assert(slot_num >= 0 && slot_num < ref_data_mask, "slot out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    return make_any(ref_bit | not_bottom_info_bit | ref_not_lock_bit | ref_slot_bit |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
                    (slot_num & ref_data_mask));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  static CellTypeState make_line_ref(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    assert(bci >= 0 && bci < ref_data_mask, "line out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    return make_any(ref_bit | not_bottom_info_bit | ref_not_lock_bit |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
                    (bci & ref_data_mask));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  static CellTypeState make_lock_ref(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    assert(bci >= 0 && bci < ref_data_mask, "line out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    return make_any(ref_bit | not_bottom_info_bit | (bci & ref_data_mask));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // Query methods:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  bool is_bottom() const                { return _state == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  bool is_live() const                  { return ((_state & live_bits_mask) != 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  bool is_valid_state() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    // Uninitialized and value cells must contain no data in their info field:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    if ((can_be_uninit() || can_be_value()) && !is_info_top()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    // The top bit is only set when all info bits are set:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    if (is_info_top() && ((_state & info_mask) != info_mask)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    // The not_bottom_bit must be set when any other info bit is set:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    if (is_info_bottom() && ((_state & info_mask) != 0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  bool is_address() const               { return ((_state & bits_mask) == addr_bit); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  bool is_reference() const             { return ((_state & bits_mask) == ref_bit); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  bool is_value() const                 { return ((_state & bits_mask) == val_bit); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  bool is_uninit() const                { return ((_state & bits_mask) == (uint)uninit_bit); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  bool can_be_address() const           { return ((_state & addr_bit) != 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  bool can_be_reference() const         { return ((_state & ref_bit) != 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  bool can_be_value() const             { return ((_state & val_bit) != 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  bool can_be_uninit() const            { return ((_state & uninit_bit) != 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  bool is_info_bottom() const           { return ((_state & not_bottom_info_bit) == 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  bool is_info_top() const              { return ((_state & top_info_bit) != 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  int  get_info() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    assert((!is_info_top() && !is_info_bottom()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
           "check to make sure top/bottom info is not used");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    return (_state & info_data_mask);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  bool is_good_address() const          { return is_address() && !is_info_top(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  bool is_lock_reference() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    return ((_state & (bits_mask | top_info_bit | ref_not_lock_bit)) == ref_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  bool is_nonlock_reference() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    return ((_state & (bits_mask | top_info_bit | ref_not_lock_bit)) == (ref_bit | ref_not_lock_bit));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  bool equal(CellTypeState a) const     { return _state == a._state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  bool equal_kind(CellTypeState a) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    return (_state & bits_mask) == (a._state & bits_mask);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  char to_char() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  // Merge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  CellTypeState merge (CellTypeState cts, int slot) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  // Debugging output
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  void print(outputStream *os);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // Default values of common values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  static CellTypeState bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  static CellTypeState uninit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  static CellTypeState ref;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  static CellTypeState value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  static CellTypeState refUninit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  static CellTypeState varUninit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  static CellTypeState top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  static CellTypeState addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
// BasicBlockStruct
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
class BasicBlock: ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  bool            _changed;                 // Reached a fixpoint or not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  enum Constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    _dead_basic_block = -2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    _unreached        = -1                  // Alive but not yet reached by analysis
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    // >=0                                  // Alive and has a merged state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  int             _bci;                     // Start of basic block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  int             _end_bci;                 // Bci of last instruction in basicblock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  int             _max_locals;              // Determines split between vars and stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  int             _max_stack;               // Determines split between stack and monitors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  CellTypeState*  _state;                   // State (vars, stack) at entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  int             _stack_top;               // -1 indicates bottom stack value.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  int             _monitor_top;             // -1 indicates bottom monitor stack value.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  CellTypeState* vars()                     { return _state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  CellTypeState* stack()                    { return _state + _max_locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  bool changed()                            { return _changed; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  void set_changed(bool s)                  { _changed = s; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  bool is_reachable() const                 { return _stack_top >= 0; }  // Analysis has reached this basicblock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  // All basicblocks that are unreachable are going to have a _stack_top == _dead_basic_block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  // This info. is setup in a pre-parse before the real abstract interpretation starts.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  bool is_dead() const                      { return _stack_top == _dead_basic_block; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  bool is_alive() const                     { return _stack_top != _dead_basic_block; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  void mark_as_alive()                      { assert(is_dead(), "must be dead"); _stack_top = _unreached; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
//  GenerateOopMap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
// Main class used to compute the pointer-maps in a MethodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
class GenerateOopMap VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // _monitor_top is set to this constant to indicate that a monitor matching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // problem was encountered prior to this point in control flow.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  enum { bad_monitors = -1 };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  // Main variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  methodHandle _method;                     // The method we are examine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  RetTable     _rt;                         // Contains the return address mappings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  int          _max_locals;                 // Cached value of no. of locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  int          _max_stack;                  // Cached value of max. stack depth
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  int          _max_monitors;               // Cached value of max. monitor stack depth
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  int          _has_exceptions;             // True, if exceptions exist for method
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1374
diff changeset
   305
  bool         _got_error;                  // True, if an error occurred during interpretation.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  Handle       _exception;                  // Exception if got_error is true.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  bool         _did_rewriting;              // was bytecodes rewritten
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  bool         _did_relocation;             // was relocation neccessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  bool         _monitor_safe;               // The monitors in this method have been determined
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
                                            // to be safe.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // Working Cell type state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  int            _state_len;                // Size of states
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  CellTypeState *_state;                    // list of states
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  char          *_state_vec_buf;            // Buffer used to print a readable version of a state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  int            _stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  int            _monitor_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  // Timing and statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  static elapsedTimer _total_oopmap_time;   // Holds cumulative oopmap generation time
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  static long         _total_byte_count;    // Holds cumulative number of bytes inspected
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  // Cell type methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  void            init_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  void            make_context_uninitialized ();
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   326
  int             methodsig_to_effect        (Symbol* signature, bool isStatic, CellTypeState* effect);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  bool            merge_local_state_vectors  (CellTypeState* cts, CellTypeState* bbts);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  bool            merge_monitor_state_vectors(CellTypeState* cts, CellTypeState* bbts);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  void            copy_state                 (CellTypeState *dst, CellTypeState *src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  void            merge_state_into_bb        (BasicBlock *bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  static void     merge_state                (GenerateOopMap *gom, int bcidelta, int* data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  void            set_var                    (int localNo, CellTypeState cts);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  CellTypeState   get_var                    (int localNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  CellTypeState   pop                        ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  void            push                       (CellTypeState cts);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  CellTypeState   monitor_pop                ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  void            monitor_push               (CellTypeState cts);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  CellTypeState * vars                       ()                                             { return _state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  CellTypeState * stack                      ()                                             { return _state+_max_locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  CellTypeState * monitors                   ()                                             { return _state+_max_locals+_max_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  void            replace_all_CTS_matches    (CellTypeState match,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
                                              CellTypeState replace);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  void            print_states               (outputStream *os, CellTypeState *vector, int num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  void            print_current_state        (outputStream   *os,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
                                              BytecodeStream *itr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
                                              bool            detailed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  void            report_monitor_mismatch    (const char *msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  // Basicblock info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  BasicBlock *    _basic_blocks;             // Array of basicblock info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  int             _gc_points;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  int             _bb_count;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   354
  BitMap          _bb_hdr_bits;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  // Basicblocks methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  void          initialize_bb               ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  void          mark_bbheaders_and_count_gc_points();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   359
  bool          is_bb_header                (int bci) const   {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   360
    return _bb_hdr_bits.at(bci);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   361
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  int           gc_points                   () const                          { return _gc_points; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  int           bb_count                    () const                          { return _bb_count; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   364
  void          set_bbmark_bit              (int bci) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   365
    _bb_hdr_bits.at_put(bci, true);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   366
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   367
  void          clear_bbmark_bit            (int bci) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   368
    _bb_hdr_bits.at_put(bci, false);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   369
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  BasicBlock *  get_basic_block_at          (int bci) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  BasicBlock *  get_basic_block_containing  (int bci) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  void          interp_bb                   (BasicBlock *bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  void          restore_state               (BasicBlock *bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  int           next_bb_start_pc            (BasicBlock *bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  void          update_basic_blocks         (int bci, int delta, int new_method_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  static void   bb_mark_fct                 (GenerateOopMap *c, int deltaBci, int *data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  // Dead code detection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  void          mark_reachable_code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  static void   reachable_basicblock        (GenerateOopMap *c, int deltaBci, int *data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  // Interpretation methods (primary)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  void  do_interpretation                   ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  void  init_basic_blocks                   ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  void  setup_method_entry_state            ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  void  interp_all                          ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  // Interpretation methods (secondary)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  void  interp1                             (BytecodeStream *itr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  void  do_exception_edge                   (BytecodeStream *itr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  void  check_type                          (CellTypeState expected, CellTypeState actual);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  void  ppstore                             (CellTypeState *in,  int loc_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  void  ppload                              (CellTypeState *out, int loc_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  void  ppush1                              (CellTypeState in);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  void  ppush                               (CellTypeState *in);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  void  ppop1                               (CellTypeState out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  void  ppop                                (CellTypeState *out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  void  ppop_any                            (int poplen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  void  pp                                  (CellTypeState *in, CellTypeState *out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  void  pp_new_ref                          (CellTypeState *in, int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  void  ppdupswap                           (int poplen, const char *out);
7111
ac1a0346bc0f 6981788: GC map generator sometimes picks up the wrong kind of instruction operand
jrose
parents: 5547
diff changeset
   402
  void  do_ldc                              (int bci);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  void  do_astore                           (int idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  void  do_jsr                              (int delta);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  void  do_field                            (int is_get, int is_static, int idx, int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  void  do_method                           (int is_static, int is_interface, int idx, int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  void  do_multianewarray                   (int dims, int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  void  do_monitorenter                     (int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  void  do_monitorexit                      (int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  void  do_return_monitor_check             ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  void  do_checkcast                        ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  CellTypeState *sigchar_to_effect          (char sigch, int bci, CellTypeState *out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  int copy_cts                              (CellTypeState *dst, CellTypeState *src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  // Error handling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  void  error_work                          (const char *format, va_list ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  void  report_error                        (const char *format, ...);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  void  verify_error                        (const char *format, ...);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  bool  got_error()                         { return _got_error; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  // Create result set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  bool  _report_result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  bool  _report_result_for_send;            // Unfortunatly, stackmaps for sends are special, so we need some extra
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  BytecodeStream *_itr_send;                // variables to handle them properly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  void  report_result                       ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  // Initvars
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  GrowableArray<intptr_t> * _init_vars;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  void  initialize_vars                     ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  void  add_to_ref_init_set                 (int localNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  // Conflicts rewrite logic
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1374
diff changeset
   435
  bool      _conflict;                      // True, if a conflict occurred during interpretation
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  int       _nof_refval_conflicts;          // No. of conflicts that require rewrites
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  int *     _new_var_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  void record_refval_conflict               (int varNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  void rewrite_refval_conflicts             ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  void rewrite_refval_conflict              (int from, int to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  bool rewrite_refval_conflict_inst         (BytecodeStream *i, int from, int to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  bool rewrite_load_or_store                (BytecodeStream *i, Bytecodes::Code bc, Bytecodes::Code bc0, unsigned int varNo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  void expand_current_instr                 (int bci, int ilen, int newIlen, u_char inst_buffer[]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  bool is_astore                            (BytecodeStream *itr, int *index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  bool is_aload                             (BytecodeStream *itr, int *index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  // List of bci's where a return address is on top of the stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  GrowableArray<intptr_t> *_ret_adr_tos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  bool stack_top_holds_ret_addr             (int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  void compute_ret_adr_at_TOS               ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  void update_ret_adr_at_TOS                (int bci, int delta);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  int  binsToHold                           (int no)                      { return  ((no+(BitsPerWord-1))/BitsPerWord); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  char *state_vec_to_string                 (CellTypeState* vec, int len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // Helper method. Can be used in subclasses to fx. calculate gc_points. If the current instuction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  // is a control transfer, then calls the jmpFct all possible destinations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  void  ret_jump_targets_do                 (BytecodeStream *bcs, jmpFct_t jmpFct, int varNo,int *data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  bool  jump_targets_do                     (BytecodeStream *bcs, jmpFct_t jmpFct, int *data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  friend class RelocCallback;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  GenerateOopMap(methodHandle method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  // Compute the map.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  void compute_map(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  void result_for_basicblock(int bci);    // Do a callback on fill_stackmap_for_opcodes for basicblock containing bci
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  // Query
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  int max_locals() const                           { return _max_locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  methodOop method() const                         { return _method(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  methodHandle method_as_handle() const            { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  bool did_rewriting()                             { return _did_rewriting; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  bool did_relocation()                            { return _did_relocation; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  static void print_time();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  // Monitor query
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  bool monitor_safe()                              { return _monitor_safe; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  // Specialization methods. Intended use:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  // - possible_gc_point must return true for every bci for which the stackmaps must be returned
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  // - fill_stackmap_prolog is called just before the result is reported. The arguments tells the estimated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  //   number of gc points
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  // - fill_stackmap_for_opcodes is called once for each bytecode index in order (0...code_length-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  // - fill_stackmap_epilog is called after all results has been reported. Note: Since the algorithm does not report
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  //   stackmaps for deadcode, fewer gc_points might have been encounted than assumed during the epilog. It is the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  //   responsibility of the subclass to count the correct number.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  // - fill_init_vars are called once with the result of the init_vars computation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  // All these methods are used during a call to: compute_map. Note: Non of the return results are valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  // after compute_map returns, since all values are allocated as resource objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  // All virtual method must be implemented in subclasses
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  virtual bool allow_rewrites             () const                        { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  virtual bool report_results             () const                        { return true;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  virtual bool report_init_vars           () const                        { return true;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  virtual bool possible_gc_point          (BytecodeStream *bcs)           { ShouldNotReachHere(); return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  virtual void fill_stackmap_prolog       (int nof_gc_points)             { ShouldNotReachHere(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  virtual void fill_stackmap_epilog       ()                              { ShouldNotReachHere(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  virtual void fill_stackmap_for_opcodes  (BytecodeStream *bcs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
                                           CellTypeState* vars,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
                                           CellTypeState* stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
                                           int stackTop)                  { ShouldNotReachHere(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  virtual void fill_init_vars             (GrowableArray<intptr_t> *init_vars) { ShouldNotReachHere();; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
// Subclass of the GenerateOopMap Class that just do rewrites of the method, if needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
// It does not store any oopmaps.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
class ResolveOopMapConflicts: public GenerateOopMap {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  bool _must_clear_locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  virtual bool report_results() const     { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  virtual bool report_init_vars() const   { return true;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  virtual bool allow_rewrites() const     { return true;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  virtual bool possible_gc_point          (BytecodeStream *bcs)           { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  virtual void fill_stackmap_prolog       (int nof_gc_points)             {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  virtual void fill_stackmap_epilog       ()                              {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  virtual void fill_stackmap_for_opcodes  (BytecodeStream *bcs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
                                           CellTypeState* vars,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
                                           CellTypeState* stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
                                           int stack_top)                 {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  virtual void fill_init_vars             (GrowableArray<intptr_t> *init_vars) { _must_clear_locals = init_vars->length() > 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  // Statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  static int _nof_invocations;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  static int _nof_rewrites;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  static int _nof_relocations;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  ResolveOopMapConflicts(methodHandle method) : GenerateOopMap(method) { _must_clear_locals = false; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  methodHandle do_potential_rewrite(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  bool must_clear_locals() const { return _must_clear_locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
// Subclass used by the compiler to generate pairing infomation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
class GeneratePairingInfo: public GenerateOopMap {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  virtual bool report_results() const     { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  virtual bool report_init_vars() const   { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  virtual bool allow_rewrites() const     { return false;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  virtual bool possible_gc_point          (BytecodeStream *bcs)           { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  virtual void fill_stackmap_prolog       (int nof_gc_points)             {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  virtual void fill_stackmap_epilog       ()                              {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  virtual void fill_stackmap_for_opcodes  (BytecodeStream *bcs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
                                           CellTypeState* vars,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
                                           CellTypeState* stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
                                           int stack_top)                 {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  virtual void fill_init_vars             (GrowableArray<intptr_t> *init_vars) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  GeneratePairingInfo(methodHandle method) : GenerateOopMap(method)       {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  // Call compute_map(CHECK) to generate info.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
   570
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7111
diff changeset
   571
#endif // SHARE_VM_OOPS_GENERATEOOPMAP_HPP