hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp
author kvn
Thu, 15 May 2008 22:40:43 -0700
changeset 580 aed902488ae4
parent 251 cb2e73f71205
child 670 ddf3e9583f2f
permissions -rw-r--r--
6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts Summary: Bytecode Escape Analyzer does not have the check for the case described in 6389127. Reviewed-by: never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
#include "incls/_bcEscapeAnalyzer.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  #define TRACE_BCEA(level, code)                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
    if (EstimateArgEscape && BCEATraceLevel >= level) {                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
      code;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  #define TRACE_BCEA(level, code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// Maintain a map of which aguments a local variable or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// stack slot may contain.  In addition to tracking
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// arguments, it tracks two special values, "allocated"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// which represents any object allocated in the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// method, and "unknown" which is any other object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// Up to 30 arguments are handled, with the last one
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// representing summary information for any extra arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class BCEscapeAnalyzer::ArgumentMap {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  uint  _bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  enum {MAXBIT = 29,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
        ALLOCATED = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
        UNKNOWN = 2};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  uint int_to_bit(uint e) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    if (e > MAXBIT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
      e = MAXBIT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    return (1 << (e + 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  ArgumentMap()                         { _bits = 0;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  void set_bits(uint bits)              { _bits = bits;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  uint get_bits() const                 { return _bits;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  void clear()                          { _bits = 0;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  void set_all()                        { _bits = ~0u; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  bool is_empty() const                 { return _bits == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  bool contains(uint var) const         { return (_bits & int_to_bit(var)) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  bool is_singleton(uint var) const     { return (_bits == int_to_bit(var)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  bool contains_unknown() const         { return (_bits & UNKNOWN) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  bool contains_allocated() const       { return (_bits & ALLOCATED) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  bool contains_vars() const            { return (_bits & (((1 << MAXBIT) -1) << 2)) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  void set(uint var)                    { _bits = int_to_bit(var); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  void add(uint var)                    { _bits |= int_to_bit(var); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  void add_unknown()                    { _bits = UNKNOWN; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  void add_allocated()                  { _bits = ALLOCATED; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  void set_union(const ArgumentMap &am)     { _bits |= am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  void set_intersect(const ArgumentMap &am) { _bits |= am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  void set_difference(const ArgumentMap &am) { _bits &=  ~am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  void operator=(const ArgumentMap &am) { _bits = am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  bool operator==(const ArgumentMap &am) { return _bits == am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  bool operator!=(const ArgumentMap &am) { return _bits != am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
class BCEscapeAnalyzer::StateInfo {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  ArgumentMap *_vars;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  ArgumentMap *_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  short _stack_height;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  short _max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  bool _initialized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  ArgumentMap empty_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  StateInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    empty_map.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  ArgumentMap raw_pop()  { assert(_stack_height > 0, "stack underflow"); return _stack[--_stack_height]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  ArgumentMap  apop()    { return raw_pop(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  void spop()            { raw_pop(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  void lpop()            { spop(); spop(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  void raw_push(ArgumentMap i)   { assert(_stack_height < _max_stack, "stack overflow"); _stack[_stack_height++] = i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  void apush(ArgumentMap i)      { raw_push(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  void spush()           { raw_push(empty_map); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  void lpush()           { spush(); spush(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
void BCEscapeAnalyzer::set_returned(ArgumentMap vars) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   107
  for (int i = 0; i < _arg_size; i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    if (vars.contains(i))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
      _arg_returned.set_bit(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  _return_local = _return_local && !(vars.contains_unknown() || vars.contains_allocated());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  _return_allocated = _return_allocated && vars.contains_allocated() && !(vars.contains_unknown() || vars.contains_vars());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
// return true if any element of vars is an argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
bool BCEscapeAnalyzer::is_argument(ArgumentMap vars) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   117
  for (int i = 0; i < _arg_size; i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    if (vars.contains(i))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
// return true if any element of vars is an arg_stack argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
bool BCEscapeAnalyzer::is_arg_stack(ArgumentMap vars){
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  if (_conservative)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    return true;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   128
  for (int i = 0; i < _arg_size; i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    if (vars.contains(i) && _arg_stack.at(i))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
void BCEscapeAnalyzer::clear_bits(ArgumentMap vars, BitMap &bm) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   136
  for (int i = 0; i < _arg_size; i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    if (vars.contains(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
      bm.clear_bit(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
}
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   142
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
void BCEscapeAnalyzer::set_method_escape(ArgumentMap vars) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  clear_bits(vars, _arg_local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
void BCEscapeAnalyzer::set_global_escape(ArgumentMap vars) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  clear_bits(vars, _arg_local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  clear_bits(vars, _arg_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  if (vars.contains_allocated())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    _allocated_escapes = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
void BCEscapeAnalyzer::set_dirty(ArgumentMap vars) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  clear_bits(vars, _dirty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   158
void BCEscapeAnalyzer::set_modified(ArgumentMap vars, int offs, int size) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   159
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   160
  for (int i = 0; i < _arg_size; i++) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   161
    if (vars.contains(i)) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   162
      set_arg_modified(i, offs, size);
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   163
    }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   164
  }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   165
  if (vars.contains_unknown())
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   166
    _unknown_modified = true;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   167
}
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   168
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
bool BCEscapeAnalyzer::is_recursive_call(ciMethod* callee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  for (BCEscapeAnalyzer* scope = this; scope != NULL; scope = scope->_parent) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    if (scope->method() == callee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   178
bool BCEscapeAnalyzer::is_arg_modified(int arg, int offset, int size_in_bytes) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   179
  if (offset == OFFSET_ANY)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   180
    return _arg_modified[arg] != 0;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   181
  assert(arg >= 0 && arg < _arg_size, "must be an argument.");
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   182
  bool modified = false;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   183
  int l = offset / HeapWordSize;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   184
  int h = round_to(offset + size_in_bytes, HeapWordSize) / HeapWordSize;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   185
  if (l > ARG_OFFSET_MAX)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   186
    l = ARG_OFFSET_MAX;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   187
  if (h > ARG_OFFSET_MAX+1)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   188
    h = ARG_OFFSET_MAX + 1;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   189
  for (int i = l; i < h; i++) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   190
    modified = modified || (_arg_modified[arg] & (1 << i)) != 0;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   191
  }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   192
  return modified;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   193
}
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   194
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   195
void BCEscapeAnalyzer::set_arg_modified(int arg, int offset, int size_in_bytes) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   196
  if (offset == OFFSET_ANY) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   197
    _arg_modified[arg] =  (uint) -1;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   198
    return;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   199
  }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   200
  assert(arg >= 0 && arg < _arg_size, "must be an argument.");
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   201
  int l = offset / HeapWordSize;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   202
  int h = round_to(offset + size_in_bytes, HeapWordSize) / HeapWordSize;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   203
  if (l > ARG_OFFSET_MAX)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   204
    l = ARG_OFFSET_MAX;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   205
  if (h > ARG_OFFSET_MAX+1)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   206
    h = ARG_OFFSET_MAX + 1;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   207
  for (int i = l; i < h; i++) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   208
    _arg_modified[arg] |= (1 << i);
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   209
  }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   210
}
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   211
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
void BCEscapeAnalyzer::invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // retrieve information about the callee
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  ciInstanceKlass* klass = target->holder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  ciInstanceKlass* calling_klass = method()->holder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  ciInstanceKlass* actual_recv = callee_holder;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
580
aed902488ae4 6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts
kvn
parents: 251
diff changeset
   221
  // some methods are obviously bindable without any type checks so
aed902488ae4 6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts
kvn
parents: 251
diff changeset
   222
  // convert them directly to an invokespecial.
aed902488ae4 6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts
kvn
parents: 251
diff changeset
   223
  if (target->is_loaded() && !target->is_abstract() &&
aed902488ae4 6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts
kvn
parents: 251
diff changeset
   224
      target->can_be_statically_bound() && code == Bytecodes::_invokevirtual) {
aed902488ae4 6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts
kvn
parents: 251
diff changeset
   225
    code = Bytecodes::_invokespecial;
aed902488ae4 6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts
kvn
parents: 251
diff changeset
   226
  }
aed902488ae4 6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts
kvn
parents: 251
diff changeset
   227
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  // compute size of arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  int arg_size = target->arg_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  if (!target->is_loaded() && code == Bytecodes::_invokestatic) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    arg_size--;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  int arg_base = MAX2(state._stack_height - arg_size, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  // direct recursive calls are skipped if they can be bound statically without introducing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  // dependencies and if parameters are passed at the same position as in the current method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // other calls are skipped if there are no unescaped arguments passed to them
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  bool directly_recursive = (method() == target) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
               (code != Bytecodes::_invokevirtual || target->is_final_method() || state._stack[arg_base] .is_empty());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // check if analysis of callee can safely be skipped
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  bool skip_callee = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  for (i = state._stack_height - 1; i >= arg_base && skip_callee; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    ArgumentMap arg = state._stack[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    skip_callee = !is_argument(arg) || !is_arg_stack(arg) || (directly_recursive && arg.is_singleton(i - arg_base));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  if (skip_callee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    TRACE_BCEA(3, tty->print_cr("[EA] skipping method %s::%s", holder->name()->as_utf8(), target->name()->as_utf8()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    for (i = 0; i < arg_size; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
      set_method_escape(state.raw_pop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   252
    _unknown_modified = true;  // assume the worst since we don't analyze the called method
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // determine actual method (use CHA if necessary)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  ciMethod* inline_target = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  if (target->is_loaded() && klass->is_loaded()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
      && (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
      && target->will_link(klass, callee_holder, code)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    if (code == Bytecodes::_invokestatic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
        || code == Bytecodes::_invokespecial
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
        || code == Bytecodes::_invokevirtual && target->is_final_method()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
      inline_target = target;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
      inline_target = target->find_monomorphic_target(calling_klass, callee_holder, actual_recv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  if (inline_target != NULL && !is_recursive_call(inline_target)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    // analyze callee
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    BCEscapeAnalyzer analyzer(inline_target, this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    // adjust escape state of actual parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    bool must_record_dependencies = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    for (i = arg_size - 1; i >= 0; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
      ArgumentMap arg = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
      if (!is_argument(arg))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
        continue;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   280
      for (int j = 0; j < _arg_size; j++) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   281
        if (arg.contains(j)) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   282
          _arg_modified[j] |= analyzer._arg_modified[i];
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   283
        }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   284
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
      if (!is_arg_stack(arg)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
        // arguments have already been recognized as escaping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
      } else if (analyzer.is_arg_stack(i) && !analyzer.is_arg_returned(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
        set_method_escape(arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
        must_record_dependencies = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
        set_global_escape(arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   294
    _unknown_modified = _unknown_modified || analyzer.has_non_arg_side_affects();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    // record dependencies if at least one parameter retained stack-allocatable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    if (must_record_dependencies) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
      if (code == Bytecodes::_invokeinterface || code == Bytecodes::_invokevirtual && !target->is_final_method()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
        _dependencies.append(actual_recv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
        _dependencies.append(inline_target);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
      _dependencies.appendAll(analyzer.dependencies());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    TRACE_BCEA(1, tty->print_cr("[EA] virtual method %s is not monomorphic.",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
                                target->name()->as_utf8()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    // conservatively mark all actual parameters as escaping globally
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    for (i = 0; i < arg_size; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
      ArgumentMap arg = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      if (!is_argument(arg))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
        continue;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   312
      set_modified(arg, OFFSET_ANY, type2size[T_INT]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
      set_global_escape(arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   315
    _unknown_modified = true;  // assume the worst since we don't know the called method
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
bool BCEscapeAnalyzer::contains(uint arg_set1, uint arg_set2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  return ((~arg_set1) | arg_set2) == 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
void BCEscapeAnalyzer::iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  blk->set_processed();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  ciBytecodeStream s(method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  int limit_bci = blk->limit_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  bool fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  ArgumentMap allocated_obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  allocated_obj.add_allocated();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  ArgumentMap unknown_obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  unknown_obj.add_unknown();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  ArgumentMap empty_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  s.reset_to_bci(blk->start_bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  while (s.next() != ciBytecodeStream::EOBC() && s.cur_bci() < limit_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    fall_through = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    switch (s.cur_bc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
      case Bytecodes::_nop:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
      case Bytecodes::_aconst_null:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
        state.apush(empty_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
      case Bytecodes::_iconst_m1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
      case Bytecodes::_iconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      case Bytecodes::_iconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      case Bytecodes::_iconst_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
      case Bytecodes::_iconst_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
      case Bytecodes::_iconst_4:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
      case Bytecodes::_iconst_5:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      case Bytecodes::_fconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
      case Bytecodes::_fconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
      case Bytecodes::_fconst_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
      case Bytecodes::_bipush:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
      case Bytecodes::_sipush:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
      case Bytecodes::_lconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
      case Bytecodes::_lconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
      case Bytecodes::_dconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
      case Bytecodes::_dconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
      case Bytecodes::_ldc:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
      case Bytecodes::_ldc_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
      case Bytecodes::_ldc2_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
        if (type2size[s.get_constant().basic_type()] == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
          state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
          state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
      case Bytecodes::_aload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
        state.apush(state._vars[s.get_index()]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      case Bytecodes::_iload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
      case Bytecodes::_fload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
      case Bytecodes::_iload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
      case Bytecodes::_iload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      case Bytecodes::_iload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
      case Bytecodes::_iload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
      case Bytecodes::_fload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
      case Bytecodes::_fload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
      case Bytecodes::_fload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
      case Bytecodes::_fload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
      case Bytecodes::_lload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
      case Bytecodes::_dload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
      case Bytecodes::_lload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
      case Bytecodes::_lload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
      case Bytecodes::_lload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
      case Bytecodes::_lload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
      case Bytecodes::_dload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
      case Bytecodes::_dload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
      case Bytecodes::_dload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
      case Bytecodes::_dload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
      case Bytecodes::_aload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
        state.apush(state._vars[0]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
      case Bytecodes::_aload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
        state.apush(state._vars[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
      case Bytecodes::_aload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
        state.apush(state._vars[2]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
      case Bytecodes::_aload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
        state.apush(state._vars[3]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
      case Bytecodes::_iaload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
      case Bytecodes::_faload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
      case Bytecodes::_baload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
      case Bytecodes::_caload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
      case Bytecodes::_saload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
      case Bytecodes::_laload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      case Bytecodes::_daload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
      case Bytecodes::_aaload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
        { state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
          ArgumentMap array = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
          set_method_escape(array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
          state.apush(unknown_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
          set_dirty(array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
      case Bytecodes::_istore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
      case Bytecodes::_fstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
      case Bytecodes::_istore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
      case Bytecodes::_istore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      case Bytecodes::_istore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
      case Bytecodes::_istore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
      case Bytecodes::_fstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
      case Bytecodes::_fstore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
      case Bytecodes::_fstore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
      case Bytecodes::_fstore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      case Bytecodes::_lstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      case Bytecodes::_dstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
      case Bytecodes::_lstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
      case Bytecodes::_lstore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
      case Bytecodes::_lstore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
      case Bytecodes::_lstore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
      case Bytecodes::_dstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
      case Bytecodes::_dstore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
      case Bytecodes::_dstore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
      case Bytecodes::_dstore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
      case Bytecodes::_astore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
        state._vars[s.get_index()] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
      case Bytecodes::_astore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
        state._vars[0] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
      case Bytecodes::_astore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
        state._vars[1] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
      case Bytecodes::_astore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
        state._vars[2] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
      case Bytecodes::_astore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
        state._vars[3] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
      case Bytecodes::_iastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
      case Bytecodes::_fastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
      case Bytecodes::_bastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
      case Bytecodes::_castore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
      case Bytecodes::_sastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
        ArgumentMap arr = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
        set_method_escape(arr);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   485
        set_modified(arr, OFFSET_ANY, type2size[T_INT]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
      case Bytecodes::_lastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
      case Bytecodes::_dastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
        ArgumentMap arr = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
        set_method_escape(arr);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   495
        set_modified(arr, OFFSET_ANY, type2size[T_LONG]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
      case Bytecodes::_aastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
        set_global_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
        ArgumentMap arr = state.apop();
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   503
        set_modified(arr, OFFSET_ANY, type2size[T_OBJECT]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
      case Bytecodes::_pop:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
        state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
      case Bytecodes::_pop2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
        state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
        state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
      case Bytecodes::_dup:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
      case Bytecodes::_dup_x1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
      case Bytecodes::_dup_x2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
          ArgumentMap w3 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
          state.raw_push(w3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
      case Bytecodes::_dup2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
      case Bytecodes::_dup2_x1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
          ArgumentMap w3 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
          state.raw_push(w3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
      case Bytecodes::_dup2_x2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
          ArgumentMap w3 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
          ArgumentMap w4 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
          state.raw_push(w4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
          state.raw_push(w3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
      case Bytecodes::_swap:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
          state.raw_push(w2);
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
      case Bytecodes::_iadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
      case Bytecodes::_fadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
      case Bytecodes::_isub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
      case Bytecodes::_fsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
      case Bytecodes::_imul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
      case Bytecodes::_fmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
      case Bytecodes::_idiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
      case Bytecodes::_fdiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
      case Bytecodes::_irem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
      case Bytecodes::_frem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
      case Bytecodes::_iand:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
      case Bytecodes::_ior:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
      case Bytecodes::_ixor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
      case Bytecodes::_ladd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
      case Bytecodes::_dadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
      case Bytecodes::_lsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
      case Bytecodes::_dsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
      case Bytecodes::_lmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
      case Bytecodes::_dmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
      case Bytecodes::_ldiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
      case Bytecodes::_ddiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
      case Bytecodes::_lrem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
      case Bytecodes::_drem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
      case Bytecodes::_land:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
      case Bytecodes::_lor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
      case Bytecodes::_lxor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
      case Bytecodes::_ishl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
      case Bytecodes::_ishr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
      case Bytecodes::_iushr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
      case Bytecodes::_lshl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
      case Bytecodes::_lshr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
      case Bytecodes::_lushr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
      case Bytecodes::_ineg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
      case Bytecodes::_fneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
      case Bytecodes::_lneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
      case Bytecodes::_dneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
      case Bytecodes::_iinc:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
      case Bytecodes::_i2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
      case Bytecodes::_i2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
      case Bytecodes::_f2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
      case Bytecodes::_f2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
      case Bytecodes::_i2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
      case Bytecodes::_f2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
      case Bytecodes::_l2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
      case Bytecodes::_l2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
      case Bytecodes::_d2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
      case Bytecodes::_d2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
      case Bytecodes::_l2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
      case Bytecodes::_d2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
      case Bytecodes::_i2b:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
      case Bytecodes::_i2c:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
      case Bytecodes::_i2s:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
      case Bytecodes::_lcmp:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
      case Bytecodes::_dcmpl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
      case Bytecodes::_dcmpg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
      case Bytecodes::_fcmpl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
      case Bytecodes::_fcmpg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
      case Bytecodes::_ifeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
      case Bytecodes::_ifne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
      case Bytecodes::_iflt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
      case Bytecodes::_ifge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
      case Bytecodes::_ifgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
      case Bytecodes::_ifle:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
      case Bytecodes::_if_icmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
      case Bytecodes::_if_icmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
      case Bytecodes::_if_icmplt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
      case Bytecodes::_if_icmpge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
      case Bytecodes::_if_icmpgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
      case Bytecodes::_if_icmple:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
      case Bytecodes::_if_acmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
      case Bytecodes::_if_acmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
      case Bytecodes::_goto:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
      case Bytecodes::_jsr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
        state.apush(empty_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
      case Bytecodes::_ret:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
        // we don't track  the destination of a "ret" instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
      case Bytecodes::_return:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
        assert(s.next_bci() == limit_bci, "return must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
      case Bytecodes::_tableswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
          state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
          Bytecode_tableswitch* switch_ = Bytecode_tableswitch_at(s.cur_bcp());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
          int len = switch_->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
          int dest_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
          for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
            dest_bci = s.cur_bci() + switch_->dest_offset_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
            assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
            successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
          dest_bci = s.cur_bci() + switch_->default_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
          assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
          successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
          assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
          fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
      case Bytecodes::_lookupswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
          state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
          Bytecode_lookupswitch* switch_ = Bytecode_lookupswitch_at(s.cur_bcp());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
          int len = switch_->number_of_pairs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
          int dest_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
          for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
            dest_bci = s.cur_bci() + switch_->pair_at(i)->offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
            assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
            successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
          dest_bci = s.cur_bci() + switch_->default_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
          assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
          successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
          fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
      case Bytecodes::_ireturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
      case Bytecodes::_freturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
      case Bytecodes::_lreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
      case Bytecodes::_dreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
      case Bytecodes::_areturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
        set_returned(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
      case Bytecodes::_getstatic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
      case Bytecodes::_getfield:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
        { bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
          ciField* field = s.get_field(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
          BasicType field_type = field->type()->basic_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
          if (s.cur_bc() != Bytecodes::_getstatic) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
            set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
          if (field_type == T_OBJECT || field_type == T_ARRAY) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
            state.apush(unknown_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
          } else if (type2size[field_type] == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
            state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
            state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
      case Bytecodes::_putstatic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
      case Bytecodes::_putfield:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
        { bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
          ciField* field = s.get_field(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
          BasicType field_type = field->type()->basic_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
          if (field_type == T_OBJECT || field_type == T_ARRAY) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
            set_global_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
          } else if (type2size[field_type] == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
            state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
            state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
          if (s.cur_bc() != Bytecodes::_putstatic) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
            ArgumentMap p = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
            set_method_escape(p);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   829
            set_modified(p, will_link ? field->offset() : OFFSET_ANY, type2size[field_type]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
      case Bytecodes::_invokevirtual:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
      case Bytecodes::_invokespecial:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
      case Bytecodes::_invokestatic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
      case Bytecodes::_invokeinterface:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
        { bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
          ciMethod* target = s.get_method(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
          ciKlass* holder = s.get_declared_method_holder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
          invoke(state, s.cur_bc(), target, holder);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
          ciType* return_type = target->return_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
          if (!return_type->is_primitive_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
            state.apush(unknown_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
          } else if (return_type->is_one_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
            state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
          } else if (return_type->is_two_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
            state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
      case Bytecodes::_xxxunusedxxx:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
      case Bytecodes::_new:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
        state.apush(allocated_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
      case Bytecodes::_newarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
      case Bytecodes::_anewarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
        state.apush(allocated_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
      case Bytecodes::_multianewarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
        { int i = s.cur_bcp()[3];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
          while (i-- > 0) state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
          state.apush(allocated_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
      case Bytecodes::_arraylength:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
      case Bytecodes::_athrow:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
        set_global_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
      case Bytecodes::_checkcast:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
        { ArgumentMap obj = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
          set_method_escape(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
          state.apush(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
      case Bytecodes::_instanceof:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
      case Bytecodes::_monitorenter:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
      case Bytecodes::_monitorexit:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
        state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
      case Bytecodes::_wide:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
      case Bytecodes::_ifnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
      case Bytecodes::_ifnonnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
      case Bytecodes::_goto_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
        int dest_bci = s.get_far_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
      case Bytecodes::_jsr_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
        int dest_bci = s.get_far_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
        state.apush(empty_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
      case Bytecodes::_breakpoint:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  if (fall_through) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
    int fall_through_bci = s.cur_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
    if (fall_through_bci < _method->code_size()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
      assert(_methodBlocks->is_block_start(fall_through_bci), "must fall through to block start.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
      successors.push(_methodBlocks->block_containing(fall_through_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
void BCEscapeAnalyzer::merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   940
  StateInfo *d_state = blockstates + dest->index();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
  int nlocals = _method->max_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  // exceptions may cause transfer of control to handlers in the middle of a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
  // block, so we don't merge the incoming state of exception handlers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
  if (dest->is_handler())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
  if (!d_state->_initialized ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
    // destination not initialized, just copy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
    for (int i = 0; i < nlocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
      d_state->_vars[i] = s_state->_vars[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
    for (int i = 0; i < s_state->_stack_height; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
      d_state->_stack[i] = s_state->_stack[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
    d_state->_stack_height = s_state->_stack_height;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
    d_state->_max_stack = s_state->_max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
    d_state->_initialized = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  } else if (!dest->processed()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
    // we have not yet walked the bytecodes of dest, we can merge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
    // the states
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
    assert(d_state->_stack_height == s_state->_stack_height, "computed stack heights must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
    for (int i = 0; i < nlocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
      d_state->_vars[i].set_union(s_state->_vars[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
    for (int i = 0; i < s_state->_stack_height; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
      d_state->_stack[i].set_union(s_state->_stack[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
    // the bytecodes of dest have already been processed, mark any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
    // arguments in the source state which are not in the dest state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
    // as global escape.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
    // Future refinement:  we only need to mark these variable to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
    // maximum escape of any variables in dest state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
    assert(d_state->_stack_height == s_state->_stack_height, "computed stack heights must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
    ArgumentMap extra_vars;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
    for (int i = 0; i < nlocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
      ArgumentMap t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
      t = s_state->_vars[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
      t.set_difference(d_state->_vars[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
      extra_vars.set_union(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
    for (int i = 0; i < s_state->_stack_height; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
      ArgumentMap t;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   984
      //extra_vars |= !d_state->_vars[i] & s_state->_vars[i];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
      t.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
      t = s_state->_stack[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
      t.set_difference(d_state->_stack[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
      extra_vars.set_union(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
    set_global_escape(extra_vars);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
void BCEscapeAnalyzer::iterate_blocks(Arena *arena) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
  int numblocks = _methodBlocks->num_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
  int stkSize   = _method->max_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
  int numLocals = _method->max_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
  StateInfo state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
  int datacount = (numblocks + 1) * (stkSize + numLocals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
  int datasize = datacount * sizeof(ArgumentMap);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1002
  StateInfo *blockstates = (StateInfo *) arena->Amalloc(numblocks * sizeof(StateInfo));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
  ArgumentMap *statedata  = (ArgumentMap *) arena->Amalloc(datasize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
  for (int i = 0; i < datacount; i++) ::new ((void*)&statedata[i]) ArgumentMap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
  ArgumentMap *dp = statedata;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
  state._vars = dp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
  dp += numLocals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
  state._stack = dp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
  dp += stkSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
  state._initialized = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
  state._max_stack = stkSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
  for (int i = 0; i < numblocks; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
    blockstates[i]._vars = dp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
    dp += numLocals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
    blockstates[i]._stack = dp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
    dp += stkSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
    blockstates[i]._initialized = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
    blockstates[i]._stack_height = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
    blockstates[i]._max_stack  = stkSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
  GrowableArray<ciBlock *> worklist(arena, numblocks / 4, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
  GrowableArray<ciBlock *> successors(arena, 4, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
  _methodBlocks->clear_processed();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
  // initialize block 0 state from method signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
  ArgumentMap allVars;   // all oop arguments to method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
  ciSignature* sig = method()->signature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
  int j = 0;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1030
  ciBlock* first_blk = _methodBlocks->block_containing(0);
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1031
  int fb_i = first_blk->index();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
  if (!method()->is_static()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
    // record information for "this"
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1034
    blockstates[fb_i]._vars[j].set(j);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
    allVars.add(j);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
    j++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
  for (int i = 0; i < sig->count(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
    ciType* t = sig->type_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
    if (!t->is_primitive_type()) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1041
      blockstates[fb_i]._vars[j].set(j);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
      allVars.add(j);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
    j += t->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
  }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1046
  blockstates[fb_i]._initialized = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
  assert(j == _arg_size, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  ArgumentMap unknown_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
  unknown_map.add_unknown();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1052
  worklist.push(first_blk);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
  while(worklist.length() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
    ciBlock *blk = worklist.pop();
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1055
    StateInfo *blkState = blockstates + blk->index();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
    if (blk->is_handler() || blk->is_ret_target()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
      // for an exception handler or a target of a ret instruction, we assume the worst case,
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1058
      // that any variable could contain any argument
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
      for (int i = 0; i < numLocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
        state._vars[i] = allVars;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
      if (blk->is_handler()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
        state._stack_height = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
        state._stack_height = blkState->_stack_height;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
      for (int i = 0; i < state._stack_height; i++) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1068
// ??? should this be unknown_map ???
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
        state._stack[i] = allVars;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
      for (int i = 0; i < numLocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
        state._vars[i] = blkState->_vars[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
      for (int i = 0; i < blkState->_stack_height; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
        state._stack[i] = blkState->_stack[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
      state._stack_height = blkState->_stack_height;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
    iterate_one_block(blk, state, successors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
    // if this block has any exception handlers, push them
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
    // onto successor list
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
    if (blk->has_handler()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
      DEBUG_ONLY(int handler_count = 0;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
      int blk_start = blk->start_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
      int blk_end = blk->limit_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
      for (int i = 0; i < numblocks; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
        ciBlock *b = _methodBlocks->block(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
        if (b->is_handler()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
          int ex_start = b->ex_start_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
          int ex_end = b->ex_limit_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
          if ((ex_start >= blk_start && ex_start < blk_end) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
              (ex_end > blk_start && ex_end <= blk_end)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
            successors.push(b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
          DEBUG_ONLY(handler_count++;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
      assert(handler_count > 0, "must find at least one handler");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
    // merge computed variable state with successors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
    while(successors.length() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
      ciBlock *succ = successors.pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
      merge_block_states(blockstates, succ, &state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
      if (!succ->processed())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
        worklist.push(succ);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
bool BCEscapeAnalyzer::do_analysis() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
  Arena* arena = CURRENT_ENV->arena();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
  // identify basic blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
  _methodBlocks = _method->get_method_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
  iterate_blocks(arena);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
  // TEMPORARY
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
vmIntrinsics::ID BCEscapeAnalyzer::known_intrinsic() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  vmIntrinsics::ID iid = method()->intrinsic_id();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
  if (iid == vmIntrinsics::_getClass ||
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1125
      iid ==  vmIntrinsics::_fillInStackTrace ||
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
      iid == vmIntrinsics::_hashCode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
    return iid;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
    return vmIntrinsics::_none;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
bool BCEscapeAnalyzer::compute_escape_for_intrinsic(vmIntrinsics::ID iid) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1133
  ArgumentMap arg;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1134
  arg.clear();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
  switch (iid) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
  case vmIntrinsics::_getClass:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
    _return_local = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
    break;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1139
  case vmIntrinsics::_fillInStackTrace:
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1140
    arg.set(0); // 'this'
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1141
    set_returned(arg);
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1142
    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
  case vmIntrinsics::_hashCode:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
    // initialized state is correct
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
    assert(false, "unexpected intrinsic");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
void BCEscapeAnalyzer::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
  // clear escape information (method may have been deoptimized)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
  methodData()->clear_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
  // initialize escape state of object parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
  ciSignature* sig = method()->signature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
  int j = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
  if (!method()->is_static()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
    _arg_local.set_bit(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
    _arg_stack.set_bit(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
    j++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
  for (i = 0; i < sig->count(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
    ciType* t = sig->type_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
    if (!t->is_primitive_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
      _arg_local.set_bit(j);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
      _arg_stack.set_bit(j);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
    j += t->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
  assert(j == _arg_size, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
  // start with optimistic assumption
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
  ciType *rt = _method->return_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
  if (rt->is_primitive_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
    _return_local = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
    _return_allocated = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
    _return_local = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
    _return_allocated = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
  _allocated_escapes = false;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1186
  _unknown_modified = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
void BCEscapeAnalyzer::clear_escape_info() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
  ciSignature* sig = method()->signature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
  int arg_count = sig->count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
  ArgumentMap var;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1193
  if (!method()->is_static()) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1194
    arg_count++;  // allow for "this"
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1195
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
  for (int i = 0; i < arg_count; i++) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1197
    set_arg_modified(i, OFFSET_ANY, 4);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
    var.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
    var.set(i);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1200
    set_modified(var, OFFSET_ANY, 4);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
    set_global_escape(var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
  _arg_local.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
  _arg_stack.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
  _arg_returned.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
  _return_local = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
  _return_allocated = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
  _allocated_escapes = true;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1209
  _unknown_modified = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
void BCEscapeAnalyzer::compute_escape_info() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
  assert(!methodData()->has_escape_info(), "do not overwrite escape info");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
  vmIntrinsics::ID iid = known_intrinsic();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
  // check if method can be analyzed
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
  if (iid ==  vmIntrinsics::_none && (method()->is_abstract() || method()->is_native() || !method()->holder()->is_initialized()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
      || _level > MaxBCEAEstimateLevel
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
      || method()->code_size() > MaxBCEAEstimateSize)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
    if (BCEATraceLevel >= 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
      tty->print("Skipping method because: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
      if (method()->is_abstract())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
        tty->print_cr("method is abstract.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
      else if (method()->is_native())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
        tty->print_cr("method is native.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
      else if (!method()->holder()->is_initialized())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
        tty->print_cr("class of method is not initialized.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
      else if (_level > MaxBCEAEstimateLevel)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
        tty->print_cr("level (%d) exceeds MaxBCEAEstimateLevel (%d).",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
                      _level, MaxBCEAEstimateLevel);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
      else if (method()->code_size() > MaxBCEAEstimateSize)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
        tty->print_cr("code size (%d) exceeds MaxBCEAEstimateSize.",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
                      method()->code_size(), MaxBCEAEstimateSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
      else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
    clear_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
  if (BCEATraceLevel >= 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
    tty->print("[EA] estimating escape information for");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
    if (iid != vmIntrinsics::_none)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
      tty->print(" intrinsic");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
    method()->print_short_name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
    tty->print_cr(" (%d bytes)", method()->code_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
  bool success;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
  initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1257
  // Do not scan method if it has no object parameters and
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1258
  // does not returns an object (_return_allocated is set in initialize()).
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1259
  if (_arg_local.is_empty() && !_return_allocated) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1260
    // Clear all info since method's bytecode was not analysed and
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1261
    // set pessimistic escape information.
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1262
    clear_escape_info();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1263
    methodData()->set_eflag(methodDataOopDesc::allocated_escapes);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1264
    methodData()->set_eflag(methodDataOopDesc::unknown_modified);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
    methodData()->set_eflag(methodDataOopDesc::estimated);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
  if (iid != vmIntrinsics::_none)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
    success = compute_escape_for_intrinsic(iid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
    success = do_analysis();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1275
  // don't store interprocedural escape information if it introduces
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1276
  // dependencies or if method data is empty
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
  if (!has_dependencies() && !methodData()->is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
    for (i = 0; i < _arg_size; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
      if (_arg_local.at(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
        assert(_arg_stack.at(i), "inconsistent escape info");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
        methodData()->set_arg_local(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
        methodData()->set_arg_stack(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
      } else if (_arg_stack.at(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
        methodData()->set_arg_stack(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
      if (_arg_returned.at(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
        methodData()->set_arg_returned(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
      }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1290
      methodData()->set_arg_modified(i, _arg_modified[i]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
    if (_return_local) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
      methodData()->set_eflag(methodDataOopDesc::return_local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
    }
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1295
    if (_return_allocated) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1296
      methodData()->set_eflag(methodDataOopDesc::return_allocated);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1297
    }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1298
    if (_allocated_escapes) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1299
      methodData()->set_eflag(methodDataOopDesc::allocated_escapes);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1300
    }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1301
    if (_unknown_modified) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1302
      methodData()->set_eflag(methodDataOopDesc::unknown_modified);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1303
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
    methodData()->set_eflag(methodDataOopDesc::estimated);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
void BCEscapeAnalyzer::read_escape_info() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
  assert(methodData()->has_escape_info(), "no escape info available");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
  // read escape information from method descriptor
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
  for (int i = 0; i < _arg_size; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
    _arg_local.at_put(i, methodData()->is_arg_local(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
    _arg_stack.at_put(i, methodData()->is_arg_stack(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
    _arg_returned.at_put(i, methodData()->is_arg_returned(i));
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1316
    _arg_modified[i] = methodData()->arg_modified(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
  _return_local = methodData()->eflag_set(methodDataOopDesc::return_local);
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1319
  _return_allocated = methodData()->eflag_set(methodDataOopDesc::return_allocated);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1320
  _allocated_escapes = methodData()->eflag_set(methodDataOopDesc::allocated_escapes);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1321
  _unknown_modified = methodData()->eflag_set(methodDataOopDesc::unknown_modified);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1325
#ifndef PRODUCT
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1326
void BCEscapeAnalyzer::dump() {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1327
  tty->print("[EA] estimated escape information for");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1328
  method()->print_short_name();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1329
  tty->print_cr(has_dependencies() ? " (not stored)" : "");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1330
  tty->print("     non-escaping args:      ");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1331
  _arg_local.print_on(tty);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1332
  tty->print("     stack-allocatable args: ");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1333
  _arg_stack.print_on(tty);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1334
  if (_return_local) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1335
    tty->print("     returned args:          ");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1336
    _arg_returned.print_on(tty);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1337
  } else if (is_return_allocated()) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1338
    tty->print_cr("     return allocated value");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1339
  } else {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1340
    tty->print_cr("     return non-local value");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1341
  }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1342
  tty->print("     modified args: ");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1343
  for (int i = 0; i < _arg_size; i++) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1344
    if (_arg_modified[i] == 0)
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1345
      tty->print("    0");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1346
    else
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1347
      tty->print("    0x%x", _arg_modified[i]);
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1348
  }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1349
  tty->cr();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1350
  tty->print("     flags: ");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1351
  if (_return_allocated)
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1352
    tty->print(" return_allocated");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1353
  if (_allocated_escapes)
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1354
    tty->print(" allocated_escapes");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1355
  if (_unknown_modified)
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1356
    tty->print(" unknown_modified");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1357
  tty->cr();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1358
}
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1359
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
BCEscapeAnalyzer::BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
    : _conservative(method == NULL || !EstimateArgEscape)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
    , _method(method)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
    , _methodData(method ? method->method_data() : NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
    , _arg_size(method ? method->arg_size() : 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
    , _stack()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
    , _arg_local(_arg_size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
    , _arg_stack(_arg_size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
    , _arg_returned(_arg_size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
    , _dirty(_arg_size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
    , _return_local(false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
    , _return_allocated(false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
    , _allocated_escapes(false)
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1374
    , _unknown_modified(false)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
    , _dependencies()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
    , _parent(parent)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
    , _level(parent == NULL ? 0 : parent->level() + 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
  if (!_conservative) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
    _arg_local.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
    _arg_stack.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
    _arg_returned.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
    _dirty.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
    Arena* arena = CURRENT_ENV->arena();
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1384
    _arg_modified = (uint *) arena->Amalloc(_arg_size * sizeof(uint));
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1385
    Copy::zero_to_bytes(_arg_modified, _arg_size * sizeof(uint));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
    if (methodData() == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
    bool printit = _method->should_print_assembly();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
    if (methodData()->has_escape_info()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
      TRACE_BCEA(2, tty->print_cr("[EA] Reading previous results for %s.%s",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
                                  method->holder()->name()->as_utf8(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
                                  method->name()->as_utf8()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
      read_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
      TRACE_BCEA(2, tty->print_cr("[EA] computing results for %s.%s",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
                                  method->holder()->name()->as_utf8(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
                                  method->name()->as_utf8()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
      compute_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
      methodData()->update_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
    }
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1403
#ifndef PRODUCT
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1404
    if (BCEATraceLevel >= 3) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1405
      // dump escape information
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1406
      dump();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1407
    }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1408
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
void BCEscapeAnalyzer::copy_dependencies(Dependencies *deps) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
  if(!has_dependencies())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
  for (int i = 0; i < _dependencies.length(); i+=2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
    ciKlass *k = _dependencies[i]->as_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
    ciMethod *m = _dependencies[i+1]->as_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
    deps->assert_unique_concrete_method(k, m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
}