src/hotspot/share/ci/bcEscapeAnalyzer.cpp
author lfoltan
Mon, 23 Sep 2019 14:49:04 -0400
changeset 58273 08a5148e7c4e
parent 54052 a2d3ca8062b9
child 58962 2dcfc28a314d
permissions -rw-r--r--
8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type Summary: Consistently use is_reference_type when comparing type for T_OBJECT or T_ARRAY. Reviewed-by: dlong, coleenp, hseigel Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 54052
diff changeset
     2
 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5353
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5353
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5353
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6417
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6417
diff changeset
    26
#include "ci/bcEscapeAnalyzer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6417
diff changeset
    27
#include "ci/ciConstant.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6417
diff changeset
    28
#include "ci/ciField.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6417
diff changeset
    29
#include "ci/ciMethodBlocks.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6417
diff changeset
    30
#include "ci/ciStreams.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6417
diff changeset
    31
#include "interpreter/bytecode.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 28508
diff changeset
    32
#include "oops/oop.inline.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46620
diff changeset
    33
#include "utilities/align.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6417
diff changeset
    34
#include "utilities/bitMap.inline.hpp"
49593
4dd58ecc9912 8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents: 47216
diff changeset
    35
#include "utilities/copy.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  #define TRACE_BCEA(level, code)                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    if (EstimateArgEscape && BCEATraceLevel >= level) {                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
      code;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  #define TRACE_BCEA(level, code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
29355
6a13ec66ba95 8006960: hotspot, "impossible" assertion failure
thartmann
parents: 29081
diff changeset
    46
// Maintain a map of which arguments a local variable or
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// stack slot may contain.  In addition to tracking
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// arguments, it tracks two special values, "allocated"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// which represents any object allocated in the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// method, and "unknown" which is any other object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// Up to 30 arguments are handled, with the last one
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// representing summary information for any extra arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class BCEscapeAnalyzer::ArgumentMap {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  uint  _bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  enum {MAXBIT = 29,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
        ALLOCATED = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
        UNKNOWN = 2};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  uint int_to_bit(uint e) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    if (e > MAXBIT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
      e = MAXBIT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    return (1 << (e + 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  ArgumentMap()                         { _bits = 0;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  void set_bits(uint bits)              { _bits = bits;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  uint get_bits() const                 { return _bits;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  void clear()                          { _bits = 0;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  void set_all()                        { _bits = ~0u; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  bool is_empty() const                 { return _bits == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  bool contains(uint var) const         { return (_bits & int_to_bit(var)) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  bool is_singleton(uint var) const     { return (_bits == int_to_bit(var)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  bool contains_unknown() const         { return (_bits & UNKNOWN) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  bool contains_allocated() const       { return (_bits & ALLOCATED) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  bool contains_vars() const            { return (_bits & (((1 << MAXBIT) -1) << 2)) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  void set(uint var)                    { _bits = int_to_bit(var); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  void add(uint var)                    { _bits |= int_to_bit(var); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  void add_unknown()                    { _bits = UNKNOWN; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  void add_allocated()                  { _bits = ALLOCATED; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  void set_union(const ArgumentMap &am)     { _bits |= am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  void set_difference(const ArgumentMap &am) { _bits &=  ~am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  void operator=(const ArgumentMap &am) { _bits = am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  bool operator==(const ArgumentMap &am) { return _bits == am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  bool operator!=(const ArgumentMap &am) { return _bits != am._bits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
class BCEscapeAnalyzer::StateInfo {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  ArgumentMap *_vars;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  ArgumentMap *_stack;
28508
ee749a5ed4ca 8047130: Fewer escapes from escape analysis
iveresov
parents: 24449
diff changeset
    92
  int _stack_height;
ee749a5ed4ca 8047130: Fewer escapes from escape analysis
iveresov
parents: 24449
diff changeset
    93
  int _max_stack;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  bool _initialized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  ArgumentMap empty_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  StateInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    empty_map.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
6417
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   101
  ArgumentMap raw_pop()  { guarantee(_stack_height > 0, "stack underflow"); return _stack[--_stack_height]; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  ArgumentMap  apop()    { return raw_pop(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  void spop()            { raw_pop(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  void lpop()            { spop(); spop(); }
6417
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   105
  void raw_push(ArgumentMap i)   { guarantee(_stack_height < _max_stack, "stack overflow"); _stack[_stack_height++] = i; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  void apush(ArgumentMap i)      { raw_push(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  void spush()           { raw_push(empty_map); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  void lpush()           { spush(); spush(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
void BCEscapeAnalyzer::set_returned(ArgumentMap vars) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   113
  for (int i = 0; i < _arg_size; i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    if (vars.contains(i))
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
   115
      _arg_returned.set(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  _return_local = _return_local && !(vars.contains_unknown() || vars.contains_allocated());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  _return_allocated = _return_allocated && vars.contains_allocated() && !(vars.contains_unknown() || vars.contains_vars());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// return true if any element of vars is an argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
bool BCEscapeAnalyzer::is_argument(ArgumentMap vars) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   123
  for (int i = 0; i < _arg_size; i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    if (vars.contains(i))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
// return true if any element of vars is an arg_stack argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
bool BCEscapeAnalyzer::is_arg_stack(ArgumentMap vars){
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  if (_conservative)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    return true;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   134
  for (int i = 0; i < _arg_size; i++) {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
   135
    if (vars.contains(i) && _arg_stack.test(i))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
18955
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   141
// return true if all argument elements of vars are returned
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   142
bool BCEscapeAnalyzer::returns_all(ArgumentMap vars) {
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   143
  for (int i = 0; i < _arg_size; i++) {
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   144
    if (vars.contains(i) && !_arg_returned.test(i)) {
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   145
      return false;
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   146
    }
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   147
  }
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   148
  return true;
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   149
}
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   150
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
   151
void BCEscapeAnalyzer::clear_bits(ArgumentMap vars, VectorSet &bm) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   152
  for (int i = 0; i < _arg_size; i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    if (vars.contains(i)) {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
   154
      bm >>= i;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    }
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
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
void BCEscapeAnalyzer::set_method_escape(ArgumentMap vars) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  clear_bits(vars, _arg_local);
24449
2a4db2c09547 8043354: 8043354: Make is_return_allocated() respect allocated objects than can method-escape
rasbold
parents: 24424
diff changeset
   161
  if (vars.contains_allocated()) {
2a4db2c09547 8043354: 8043354: Make is_return_allocated() respect allocated objects than can method-escape
rasbold
parents: 24424
diff changeset
   162
    _allocated_escapes = true;
2a4db2c09547 8043354: 8043354: Make is_return_allocated() respect allocated objects than can method-escape
rasbold
parents: 24424
diff changeset
   163
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
11198
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   166
void BCEscapeAnalyzer::set_global_escape(ArgumentMap vars, bool merge) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  clear_bits(vars, _arg_local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  clear_bits(vars, _arg_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  if (vars.contains_allocated())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    _allocated_escapes = true;
11198
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   171
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   172
  if (merge && !vars.is_empty()) {
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   173
    // Merge new state into already processed block.
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   174
    // New state is not taken into account and
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   175
    // it may invalidate set_returned() result.
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   176
    if (vars.contains_unknown() || vars.contains_allocated()) {
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   177
      _return_local = false;
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   178
    }
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   179
    if (vars.contains_unknown() || vars.contains_vars()) {
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   180
      _return_allocated = false;
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   181
    }
18955
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   182
    if (_return_local && vars.contains_vars() && !returns_all(vars)) {
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   183
      // Return result should be invalidated if args in new
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   184
      // state are not recorded in return state.
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   185
      _return_local = false;
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 14478
diff changeset
   186
    }
11198
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
   187
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
void BCEscapeAnalyzer::set_dirty(ArgumentMap vars) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  clear_bits(vars, _dirty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   194
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
   195
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   196
  for (int i = 0; i < _arg_size; i++) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   197
    if (vars.contains(i)) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   198
      set_arg_modified(i, offs, size);
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
  }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   201
  if (vars.contains_unknown())
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   202
    _unknown_modified = true;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   203
}
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   204
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
bool BCEscapeAnalyzer::is_recursive_call(ciMethod* callee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  for (BCEscapeAnalyzer* scope = this; scope != NULL; scope = scope->_parent) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    if (scope->method() == callee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   214
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
   215
  if (offset == OFFSET_ANY)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   216
    return _arg_modified[arg] != 0;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   217
  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
   218
  bool modified = false;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   219
  int l = offset / HeapWordSize;
46620
750c6edff33b 8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents: 43437
diff changeset
   220
  int h = align_up(offset + size_in_bytes, HeapWordSize) / HeapWordSize;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   221
  if (l > ARG_OFFSET_MAX)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   222
    l = ARG_OFFSET_MAX;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   223
  if (h > ARG_OFFSET_MAX+1)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   224
    h = ARG_OFFSET_MAX + 1;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   225
  for (int i = l; i < h; i++) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   226
    modified = modified || (_arg_modified[arg] & (1 << i)) != 0;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   227
  }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   228
  return modified;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   229
}
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   230
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   231
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
   232
  if (offset == OFFSET_ANY) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   233
    _arg_modified[arg] =  (uint) -1;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   234
    return;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   235
  }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   236
  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
   237
  int l = offset / HeapWordSize;
46620
750c6edff33b 8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents: 43437
diff changeset
   238
  int h = align_up(offset + size_in_bytes, HeapWordSize) / HeapWordSize;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   239
  if (l > ARG_OFFSET_MAX)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   240
    l = ARG_OFFSET_MAX;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   241
  if (h > ARG_OFFSET_MAX+1)
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   242
    h = ARG_OFFSET_MAX + 1;
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   243
  for (int i = l; i < h; i++) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   244
    _arg_modified[arg] |= (1 << i);
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   245
  }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   246
}
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   247
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
void BCEscapeAnalyzer::invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // retrieve information about the callee
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  ciInstanceKlass* klass = target->holder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  ciInstanceKlass* calling_klass = method()->holder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  ciInstanceKlass* actual_recv = callee_holder;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   257
  // Some methods are obviously bindable without any type checks so
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   258
  // convert them directly to an invokespecial or invokestatic.
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11633
diff changeset
   259
  if (target->is_loaded() && !target->is_abstract() && target->can_be_statically_bound()) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11633
diff changeset
   260
    switch (code) {
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   261
    case Bytecodes::_invokevirtual:
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   262
      code = Bytecodes::_invokespecial;
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   263
      break;
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   264
    case Bytecodes::_invokehandle:
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   265
      code = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokespecial;
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   266
      break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46625
diff changeset
   267
    default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46625
diff changeset
   268
      break;
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11633
diff changeset
   269
    }
580
aed902488ae4 6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts
kvn
parents: 251
diff changeset
   270
  }
aed902488ae4 6700102: c2 assertion "counter_changed,"failed dependencies, but counter didn't change")" with AggressiveOpts
kvn
parents: 251
diff changeset
   271
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  // compute size of arguments
9329
79c74b9e2afe 7030715: JSR 292 JRuby test/test_super_call_site_caching.rb asserts with +DoEscapeAnalysis
never
parents: 8064
diff changeset
   273
  int arg_size = target->invoke_arg_size(code);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  int arg_base = MAX2(state._stack_height - arg_size, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // direct recursive calls are skipped if they can be bound statically without introducing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  // dependencies and if parameters are passed at the same position as in the current method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  // other calls are skipped if there are no unescaped arguments passed to them
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  bool directly_recursive = (method() == target) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
               (code != Bytecodes::_invokevirtual || target->is_final_method() || state._stack[arg_base] .is_empty());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // check if analysis of callee can safely be skipped
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  bool skip_callee = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  for (i = state._stack_height - 1; i >= arg_base && skip_callee; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    ArgumentMap arg = state._stack[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    skip_callee = !is_argument(arg) || !is_arg_stack(arg) || (directly_recursive && arg.is_singleton(i - arg_base));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  }
8063
3b8d1557d967 7011839: JSR 292 turn on escape analysis when using invokedynamic
twisti
parents: 7397
diff changeset
   288
  // For now we conservatively skip invokedynamic.
3b8d1557d967 7011839: JSR 292 turn on escape analysis when using invokedynamic
twisti
parents: 7397
diff changeset
   289
  if (code == Bytecodes::_invokedynamic) {
3b8d1557d967 7011839: JSR 292 turn on escape analysis when using invokedynamic
twisti
parents: 7397
diff changeset
   290
    skip_callee = true;
3b8d1557d967 7011839: JSR 292 turn on escape analysis when using invokedynamic
twisti
parents: 7397
diff changeset
   291
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  if (skip_callee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    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
   294
    for (i = 0; i < arg_size; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
      set_method_escape(state.raw_pop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   297
    _unknown_modified = true;  // assume the worst since we don't analyze the called method
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  // determine actual method (use CHA if necessary)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  ciMethod* inline_target = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  if (target->is_loaded() && klass->is_loaded()
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46625
diff changeset
   304
      && (klass->is_initialized() || (klass->is_interface() && target->holder()->is_initialized()))
14478
1c4a20806af7 8001077: remove ciMethod::will_link
bharadwaj
parents: 13728
diff changeset
   305
      && target->is_loaded()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    if (code == Bytecodes::_invokestatic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
        || code == Bytecodes::_invokespecial
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46625
diff changeset
   308
        || (code == Bytecodes::_invokevirtual && target->is_final_method())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
      inline_target = target;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
      inline_target = target->find_monomorphic_target(calling_klass, callee_holder, actual_recv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  if (inline_target != NULL && !is_recursive_call(inline_target)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    // analyze callee
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
    BCEscapeAnalyzer analyzer(inline_target, this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    // adjust escape state of actual parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    bool must_record_dependencies = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    for (i = arg_size - 1; i >= 0; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
      ArgumentMap arg = state.raw_pop();
29355
6a13ec66ba95 8006960: hotspot, "impossible" assertion failure
thartmann
parents: 29081
diff changeset
   323
      // Check if callee arg is a caller arg or an allocated object
6a13ec66ba95 8006960: hotspot, "impossible" assertion failure
thartmann
parents: 29081
diff changeset
   324
      bool allocated = arg.contains_allocated();
6a13ec66ba95 8006960: hotspot, "impossible" assertion failure
thartmann
parents: 29081
diff changeset
   325
      if (!(is_argument(arg) || allocated))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
        continue;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   327
      for (int j = 0; j < _arg_size; j++) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   328
        if (arg.contains(j)) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   329
          _arg_modified[j] |= analyzer._arg_modified[i];
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   330
        }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   331
      }
29355
6a13ec66ba95 8006960: hotspot, "impossible" assertion failure
thartmann
parents: 29081
diff changeset
   332
      if (!(is_arg_stack(arg) || allocated)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
        // arguments have already been recognized as escaping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      } else if (analyzer.is_arg_stack(i) && !analyzer.is_arg_returned(i)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
        set_method_escape(arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
        must_record_dependencies = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
        set_global_escape(arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   341
    _unknown_modified = _unknown_modified || analyzer.has_non_arg_side_affects();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    // record dependencies if at least one parameter retained stack-allocatable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    if (must_record_dependencies) {
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46625
diff changeset
   345
      if (code == Bytecodes::_invokeinterface ||
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46625
diff changeset
   346
          (code == Bytecodes::_invokevirtual && !target->is_final_method())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
        _dependencies.append(actual_recv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
        _dependencies.append(inline_target);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
      _dependencies.appendAll(analyzer.dependencies());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
    TRACE_BCEA(1, tty->print_cr("[EA] virtual method %s is not monomorphic.",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
                                target->name()->as_utf8()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    // conservatively mark all actual parameters as escaping globally
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    for (i = 0; i < arg_size; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
      ArgumentMap arg = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
      if (!is_argument(arg))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
        continue;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   360
      set_modified(arg, OFFSET_ANY, type2size[T_INT]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
      set_global_escape(arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   363
    _unknown_modified = true;  // assume the worst since we don't know the called method
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
bool BCEscapeAnalyzer::contains(uint arg_set1, uint arg_set2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  return ((~arg_set1) | arg_set2) == 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
void BCEscapeAnalyzer::iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  blk->set_processed();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  ciBytecodeStream s(method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  int limit_bci = blk->limit_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  bool fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  ArgumentMap allocated_obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  allocated_obj.add_allocated();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  ArgumentMap unknown_obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  unknown_obj.add_unknown();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  ArgumentMap empty_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  s.reset_to_bci(blk->start_bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  while (s.next() != ciBytecodeStream::EOBC() && s.cur_bci() < limit_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    fall_through = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    switch (s.cur_bc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      case Bytecodes::_nop:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
      case Bytecodes::_aconst_null:
11633
de5e87f50b2d 7140924: SIGSEGV in compiled code for sun.awt.X11.XDecoratedPeer.updateMinSizeHints
kvn
parents: 11198
diff changeset
   391
        state.apush(unknown_obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
      case Bytecodes::_iconst_m1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
      case Bytecodes::_iconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
      case Bytecodes::_iconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
      case Bytecodes::_iconst_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
      case Bytecodes::_iconst_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
      case Bytecodes::_iconst_4:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
      case Bytecodes::_iconst_5:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
      case Bytecodes::_fconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
      case Bytecodes::_fconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
      case Bytecodes::_fconst_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
      case Bytecodes::_bipush:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
      case Bytecodes::_sipush:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
      case Bytecodes::_lconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
      case Bytecodes::_lconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
      case Bytecodes::_dconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
      case Bytecodes::_dconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
      case Bytecodes::_ldc:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
      case Bytecodes::_ldc_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
      case Bytecodes::_ldc2_w:
6417
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   416
      {
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   417
        // Avoid calling get_constant() which will try to allocate
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   418
        // unloaded constant. We need only constant's type.
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   419
        int index = s.get_constant_pool_index();
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   420
        constantTag tag = s.get_constant_pool_tag(index);
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   421
        if (tag.is_long() || tag.is_double()) {
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   422
          // Only longs and doubles use 2 stack slots.
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   423
          state.lpush();
11633
de5e87f50b2d 7140924: SIGSEGV in compiled code for sun.awt.X11.XDecoratedPeer.updateMinSizeHints
kvn
parents: 11198
diff changeset
   424
        } else if (tag.basic_type() == T_OBJECT) {
de5e87f50b2d 7140924: SIGSEGV in compiled code for sun.awt.X11.XDecoratedPeer.updateMinSizeHints
kvn
parents: 11198
diff changeset
   425
          state.apush(unknown_obj);
6417
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   426
        } else {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
          state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
        break;
6417
82e8f98f22d8 6896381: CTW fails share/vm/ci/bcEscapeAnalyzer.cpp:99, assert(_stack_height < _max_stack,"stack overflow")
kvn
parents: 5928
diff changeset
   430
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
      case Bytecodes::_aload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
        state.apush(state._vars[s.get_index()]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
      case Bytecodes::_iload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
      case Bytecodes::_fload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
      case Bytecodes::_iload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
      case Bytecodes::_iload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
      case Bytecodes::_iload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
      case Bytecodes::_iload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      case Bytecodes::_fload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
      case Bytecodes::_fload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
      case Bytecodes::_fload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
      case Bytecodes::_fload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
      case Bytecodes::_lload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
      case Bytecodes::_dload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      case Bytecodes::_lload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      case Bytecodes::_lload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
      case Bytecodes::_lload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
      case Bytecodes::_lload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
      case Bytecodes::_dload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
      case Bytecodes::_dload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
      case Bytecodes::_dload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
      case Bytecodes::_dload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
      case Bytecodes::_aload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
        state.apush(state._vars[0]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
      case Bytecodes::_aload_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
        state.apush(state._vars[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
      case Bytecodes::_aload_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
        state.apush(state._vars[2]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
      case Bytecodes::_aload_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
        state.apush(state._vars[3]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
      case Bytecodes::_iaload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
      case Bytecodes::_faload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
      case Bytecodes::_baload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
      case Bytecodes::_caload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
      case Bytecodes::_saload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
      case Bytecodes::_laload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
      case Bytecodes::_daload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
      case Bytecodes::_aaload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
        { state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
          ArgumentMap array = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
          set_method_escape(array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
          state.apush(unknown_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
          set_dirty(array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
      case Bytecodes::_istore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
      case Bytecodes::_fstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
      case Bytecodes::_istore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
      case Bytecodes::_istore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
      case Bytecodes::_istore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
      case Bytecodes::_istore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
      case Bytecodes::_fstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
      case Bytecodes::_fstore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
      case Bytecodes::_fstore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
      case Bytecodes::_fstore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
      case Bytecodes::_lstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
      case Bytecodes::_dstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      case Bytecodes::_lstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
      case Bytecodes::_lstore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
      case Bytecodes::_lstore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
      case Bytecodes::_lstore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
      case Bytecodes::_dstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
      case Bytecodes::_dstore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
      case Bytecodes::_dstore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
      case Bytecodes::_dstore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
      case Bytecodes::_astore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
        state._vars[s.get_index()] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
      case Bytecodes::_astore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
        state._vars[0] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
      case Bytecodes::_astore_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
        state._vars[1] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
      case Bytecodes::_astore_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
        state._vars[2] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
      case Bytecodes::_astore_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
        state._vars[3] = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
      case Bytecodes::_iastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
      case Bytecodes::_fastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
      case Bytecodes::_bastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
      case Bytecodes::_castore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
      case Bytecodes::_sastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
        ArgumentMap arr = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
        set_method_escape(arr);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   542
        set_modified(arr, OFFSET_ANY, type2size[T_INT]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
      case Bytecodes::_lastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
      case Bytecodes::_dastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
        ArgumentMap arr = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
        set_method_escape(arr);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   552
        set_modified(arr, OFFSET_ANY, type2size[T_LONG]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
      case Bytecodes::_aastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
        set_global_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
        ArgumentMap arr = state.apop();
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   560
        set_modified(arr, OFFSET_ANY, type2size[T_OBJECT]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
      case Bytecodes::_pop:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
        state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
      case Bytecodes::_pop2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
        state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
        state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
      case Bytecodes::_dup:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
      case Bytecodes::_dup_x1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
      case Bytecodes::_dup_x2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
          ArgumentMap w3 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
          state.raw_push(w3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
      case Bytecodes::_dup2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
      case Bytecodes::_dup2_x1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
          ArgumentMap w3 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
          state.raw_push(w3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
      case Bytecodes::_dup2_x2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
          ArgumentMap w3 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
          ArgumentMap w4 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
          state.raw_push(w4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
          state.raw_push(w3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
      case Bytecodes::_swap:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
        { ArgumentMap w1 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
          ArgumentMap w2 = state.raw_pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
          state.raw_push(w1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
          state.raw_push(w2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
      case Bytecodes::_iadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
      case Bytecodes::_fadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
      case Bytecodes::_isub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
      case Bytecodes::_fsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
      case Bytecodes::_imul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
      case Bytecodes::_fmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
      case Bytecodes::_idiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
      case Bytecodes::_fdiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
      case Bytecodes::_irem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
      case Bytecodes::_frem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
      case Bytecodes::_iand:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
      case Bytecodes::_ior:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
      case Bytecodes::_ixor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
      case Bytecodes::_ladd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
      case Bytecodes::_dadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
      case Bytecodes::_lsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
      case Bytecodes::_dsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
      case Bytecodes::_lmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
      case Bytecodes::_dmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
      case Bytecodes::_ldiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
      case Bytecodes::_ddiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
      case Bytecodes::_lrem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
      case Bytecodes::_drem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
      case Bytecodes::_land:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
      case Bytecodes::_lor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
      case Bytecodes::_lxor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
      case Bytecodes::_ishl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
      case Bytecodes::_ishr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
      case Bytecodes::_iushr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
      case Bytecodes::_lshl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
      case Bytecodes::_lshr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
      case Bytecodes::_lushr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
      case Bytecodes::_ineg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
      case Bytecodes::_fneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
      case Bytecodes::_lneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
      case Bytecodes::_dneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
      case Bytecodes::_iinc:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
      case Bytecodes::_i2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
      case Bytecodes::_i2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
      case Bytecodes::_f2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
      case Bytecodes::_f2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
      case Bytecodes::_i2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
      case Bytecodes::_f2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
      case Bytecodes::_l2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
      case Bytecodes::_l2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
      case Bytecodes::_d2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
      case Bytecodes::_d2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
      case Bytecodes::_l2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
      case Bytecodes::_d2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
        state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
      case Bytecodes::_i2b:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
      case Bytecodes::_i2c:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
      case Bytecodes::_i2s:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
      case Bytecodes::_lcmp:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
      case Bytecodes::_dcmpl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
      case Bytecodes::_dcmpg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
      case Bytecodes::_fcmpl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
      case Bytecodes::_fcmpg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
      case Bytecodes::_ifeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
      case Bytecodes::_ifne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
      case Bytecodes::_iflt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
      case Bytecodes::_ifge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
      case Bytecodes::_ifgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
      case Bytecodes::_ifle:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
      case Bytecodes::_if_icmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
      case Bytecodes::_if_icmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
      case Bytecodes::_if_icmplt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
      case Bytecodes::_if_icmpge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
      case Bytecodes::_if_icmpgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
      case Bytecodes::_if_icmple:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
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
        successors.push(_methodBlocks->block_containing(dest_bci));
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::_if_acmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
      case Bytecodes::_if_acmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
      case Bytecodes::_goto:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
      case Bytecodes::_jsr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
        state.apush(empty_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
      case Bytecodes::_ret:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
        // we don't track  the destination of a "ret" instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
      case Bytecodes::_return:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
        assert(s.next_bci() == limit_bci, "return must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
      case Bytecodes::_tableswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
          state.spop();
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   808
          Bytecode_tableswitch sw(&s);
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   809
          int len = sw.length();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
          int dest_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
          for (int i = 0; i < len; i++) {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   812
            dest_bci = s.cur_bci() + sw.dest_offset_at(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
            assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
            successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
          }
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   816
          dest_bci = s.cur_bci() + sw.default_offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
          assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
          successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
          assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
          fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
      case Bytecodes::_lookupswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
          state.spop();
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   826
          Bytecode_lookupswitch sw(&s);
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   827
          int len = sw.number_of_pairs();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
          int dest_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
          for (int i = 0; i < len; i++) {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   830
            dest_bci = s.cur_bci() + sw.pair_at(i).offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
            assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
            successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
          }
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   834
          dest_bci = s.cur_bci() + sw.default_offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
          assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
          successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
          fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
      case Bytecodes::_ireturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
      case Bytecodes::_freturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
      case Bytecodes::_lreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
      case Bytecodes::_dreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
        state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
      case Bytecodes::_areturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
        set_returned(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
      case Bytecodes::_getstatic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
      case Bytecodes::_getfield:
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   856
        { bool ignored_will_link;
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   857
          ciField* field = s.get_field(ignored_will_link);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
          BasicType field_type = field->type()->basic_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
          if (s.cur_bc() != Bytecodes::_getstatic) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
            set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
          }
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 54052
diff changeset
   862
          if (is_reference_type(field_type)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
            state.apush(unknown_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
          } else if (type2size[field_type] == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
            state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
            state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
      case Bytecodes::_putstatic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
      case Bytecodes::_putfield:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
        { bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
          ciField* field = s.get_field(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
          BasicType field_type = field->type()->basic_type();
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 54052
diff changeset
   876
          if (is_reference_type(field_type)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
            set_global_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
          } else if (type2size[field_type] == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
            state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
            state.lpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
          if (s.cur_bc() != Bytecodes::_putstatic) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
            ArgumentMap p = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
            set_method_escape(p);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   886
            set_modified(p, will_link ? field->offset() : OFFSET_ANY, type2size[field_type]*HeapWordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
      case Bytecodes::_invokevirtual:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
      case Bytecodes::_invokespecial:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
      case Bytecodes::_invokestatic:
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 670
diff changeset
   893
      case Bytecodes::_invokedynamic:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
      case Bytecodes::_invokeinterface:
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   895
        { bool ignored_will_link;
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   896
          ciSignature* declared_signature = NULL;
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   897
          ciMethod* target = s.get_method(ignored_will_link, &declared_signature);
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   898
          ciKlass*  holder = s.get_declared_method_holder();
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   899
          assert(declared_signature != NULL, "cannot be null");
43437
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   900
          // If the current bytecode has an attached appendix argument,
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   901
          // push an unknown object to represent that argument. (Analysis
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   902
          // of dynamic call sites, especially invokehandle calls, needs
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   903
          // the appendix argument on the stack, in addition to "regular" arguments
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   904
          // pushed onto the stack by bytecode instructions preceding the call.)
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   905
          //
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   906
          // The escape analyzer does _not_ use the ciBytecodeStream::has_appendix(s)
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   907
          // method to determine whether the current bytecode has an appendix argument.
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   908
          // The has_appendix() method obtains the appendix from the
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   909
          // ConstantPoolCacheEntry::_f1 field, which can happen concurrently with
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   910
          // resolution of dynamic call sites. Callees in the
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   911
          // ciBytecodeStream::get_method() call above also access the _f1 field;
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   912
          // interleaving the get_method() and has_appendix() calls in the current
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   913
          // method with call site resolution can lead to an inconsistent view of
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   914
          // the current method's argument count. In particular, some interleaving(s)
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   915
          // can cause the method's argument count to not include the appendix, which
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   916
          // then leads to stack over-/underflow in the escape analyzer.
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   917
          //
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   918
          // Instead of pushing the argument if has_appendix() is true, the escape analyzer
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   919
          // pushes an appendix for all call sites targeted by invokedynamic and invokehandle
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   920
          // instructions, except if the call site is the _invokeBasic intrinsic
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   921
          // (that intrinsic is always targeted by an invokehandle instruction but does
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   922
          // not have an appendix argument).
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   923
          if (target->is_loaded() &&
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   924
              Bytecodes::has_optional_appendix(s.cur_bc_raw()) &&
90e15b78684e 8168926: C2: Bytecode escape analyzer crashes due to stack overflow
zmajo
parents: 32582
diff changeset
   925
              target->intrinsic_id() != vmIntrinsics::_invokeBasic) {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11633
diff changeset
   926
            state.apush(unknown_obj);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11633
diff changeset
   927
          }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11633
diff changeset
   928
          // Pass in raw bytecode because we need to see invokehandle instructions.
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11633
diff changeset
   929
          invoke(state, s.cur_bc_raw(), target, holder);
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   930
          // We are using the return type of the declared signature here because
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   931
          // it might be a more concrete type than the one from the target (for
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   932
          // e.g. invokedynamic and invokehandle).
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   933
          ciType* return_type = declared_signature->return_type();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
          if (!return_type->is_primitive_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
            state.apush(unknown_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
          } else if (return_type->is_one_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
            state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
          } else if (return_type->is_two_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
            state.lpush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
      case Bytecodes::_new:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
        state.apush(allocated_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
      case Bytecodes::_newarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
      case Bytecodes::_anewarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
        state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
        state.apush(allocated_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
      case Bytecodes::_multianewarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
        { int i = s.cur_bcp()[3];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
          while (i-- > 0) state.spop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
          state.apush(allocated_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
      case Bytecodes::_arraylength:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
      case Bytecodes::_athrow:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
        set_global_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
      case Bytecodes::_checkcast:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
        { ArgumentMap obj = state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
          set_method_escape(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
          state.apush(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
      case Bytecodes::_instanceof:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
        state.spush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
      case Bytecodes::_monitorenter:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
      case Bytecodes::_monitorexit:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
        state.apop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
      case Bytecodes::_wide:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
      case Bytecodes::_ifnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
      case Bytecodes::_ifnonnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
        set_method_escape(state.apop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
        int dest_bci = s.get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
      case Bytecodes::_goto_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
        int dest_bci = s.get_far_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
      case Bytecodes::_jsr_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
        int dest_bci = s.get_far_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
        assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
        assert(s.next_bci() == limit_bci, "branch must end block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
        state.apush(empty_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
        successors.push(_methodBlocks->block_containing(dest_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
        fall_through = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
      case Bytecodes::_breakpoint:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
  if (fall_through) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
    int fall_through_bci = s.cur_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
    if (fall_through_bci < _method->code_size()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
      assert(_methodBlocks->is_block_start(fall_through_bci), "must fall through to block start.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
      successors.push(_methodBlocks->block_containing(fall_through_bci));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
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
  1029
  StateInfo *d_state = blockstates + dest->index();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
  int nlocals = _method->max_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
  // exceptions may cause transfer of control to handlers in the middle of a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
  // block, so we don't merge the incoming state of exception handlers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
  if (dest->is_handler())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
  if (!d_state->_initialized ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
    // destination not initialized, just copy
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
    for (int i = 0; i < nlocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
      d_state->_vars[i] = s_state->_vars[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
    for (int i = 0; i < s_state->_stack_height; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
      d_state->_stack[i] = s_state->_stack[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
    d_state->_stack_height = s_state->_stack_height;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
    d_state->_max_stack = s_state->_max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
    d_state->_initialized = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
  } else if (!dest->processed()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
    // we have not yet walked the bytecodes of dest, we can merge
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
    // the states
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
    assert(d_state->_stack_height == s_state->_stack_height, "computed stack heights must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
    for (int i = 0; i < nlocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
      d_state->_vars[i].set_union(s_state->_vars[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
    for (int i = 0; i < s_state->_stack_height; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
      d_state->_stack[i].set_union(s_state->_stack[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
    // the bytecodes of dest have already been processed, mark any
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
    // arguments in the source state which are not in the dest state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
    // as global escape.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
    // Future refinement:  we only need to mark these variable to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
    // maximum escape of any variables in dest state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
    assert(d_state->_stack_height == s_state->_stack_height, "computed stack heights must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
    ArgumentMap extra_vars;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
    for (int i = 0; i < nlocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
      ArgumentMap t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
      t = s_state->_vars[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
      t.set_difference(d_state->_vars[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
      extra_vars.set_union(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
    for (int i = 0; i < s_state->_stack_height; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
      ArgumentMap t;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1073
      //extra_vars |= !d_state->_vars[i] & s_state->_vars[i];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
      t.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
      t = s_state->_stack[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
      t.set_difference(d_state->_stack[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
      extra_vars.set_union(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
    }
11198
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 9329
diff changeset
  1079
    set_global_escape(extra_vars, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
void BCEscapeAnalyzer::iterate_blocks(Arena *arena) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
  int numblocks = _methodBlocks->num_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
  int stkSize   = _method->max_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
  int numLocals = _method->max_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
  StateInfo state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
  int datacount = (numblocks + 1) * (stkSize + numLocals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
  int datasize = datacount * sizeof(ArgumentMap);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1091
  StateInfo *blockstates = (StateInfo *) arena->Amalloc(numblocks * sizeof(StateInfo));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
  ArgumentMap *statedata  = (ArgumentMap *) arena->Amalloc(datasize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
  for (int i = 0; i < datacount; i++) ::new ((void*)&statedata[i]) ArgumentMap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
  ArgumentMap *dp = statedata;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
  state._vars = dp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
  dp += numLocals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
  state._stack = dp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
  dp += stkSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
  state._initialized = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
  state._max_stack = stkSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
  for (int i = 0; i < numblocks; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
    blockstates[i]._vars = dp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
    dp += numLocals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
    blockstates[i]._stack = dp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
    dp += stkSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
    blockstates[i]._initialized = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
    blockstates[i]._stack_height = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
    blockstates[i]._max_stack  = stkSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
  GrowableArray<ciBlock *> worklist(arena, numblocks / 4, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
  GrowableArray<ciBlock *> successors(arena, 4, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
  _methodBlocks->clear_processed();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
  // initialize block 0 state from method signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
  ArgumentMap allVars;   // all oop arguments to method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
  ciSignature* sig = method()->signature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
  int j = 0;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1119
  ciBlock* first_blk = _methodBlocks->block_containing(0);
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1120
  int fb_i = first_blk->index();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
  if (!method()->is_static()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
    // record information for "this"
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1123
    blockstates[fb_i]._vars[j].set(j);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
    allVars.add(j);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
    j++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
  for (int i = 0; i < sig->count(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
    ciType* t = sig->type_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
    if (!t->is_primitive_type()) {
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1130
      blockstates[fb_i]._vars[j].set(j);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
      allVars.add(j);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
    j += t->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
  }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1135
  blockstates[fb_i]._initialized = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
  assert(j == _arg_size, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
  ArgumentMap unknown_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
  unknown_map.add_unknown();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1141
  worklist.push(first_blk);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
  while(worklist.length() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
    ciBlock *blk = worklist.pop();
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1144
    StateInfo *blkState = blockstates + blk->index();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
    if (blk->is_handler() || blk->is_ret_target()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
      // 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
  1147
      // that any variable could contain any argument
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
      for (int i = 0; i < numLocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
        state._vars[i] = allVars;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
      if (blk->is_handler()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
        state._stack_height = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
        state._stack_height = blkState->_stack_height;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
      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
  1157
// ??? should this be unknown_map ???
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
        state._stack[i] = allVars;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
      for (int i = 0; i < numLocals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
        state._vars[i] = blkState->_vars[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
      for (int i = 0; i < blkState->_stack_height; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
        state._stack[i] = blkState->_stack[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
      state._stack_height = blkState->_stack_height;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
    iterate_one_block(blk, state, successors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
    // if this block has any exception handlers, push them
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
    // onto successor list
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
    if (blk->has_handler()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
      DEBUG_ONLY(int handler_count = 0;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
      int blk_start = blk->start_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
      int blk_end = blk->limit_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
      for (int i = 0; i < numblocks; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
        ciBlock *b = _methodBlocks->block(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
        if (b->is_handler()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
          int ex_start = b->ex_start_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
          int ex_end = b->ex_limit_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
          if ((ex_start >= blk_start && ex_start < blk_end) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
              (ex_end > blk_start && ex_end <= blk_end)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
            successors.push(b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
          DEBUG_ONLY(handler_count++;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
      assert(handler_count > 0, "must find at least one handler");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
    // merge computed variable state with successors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
    while(successors.length() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
      ciBlock *succ = successors.pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
      merge_block_states(blockstates, succ, &state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
      if (!succ->processed())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
        worklist.push(succ);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1200
void BCEscapeAnalyzer::do_analysis() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
  Arena* arena = CURRENT_ENV->arena();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
  // identify basic blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
  _methodBlocks = _method->get_method_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
  iterate_blocks(arena);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
vmIntrinsics::ID BCEscapeAnalyzer::known_intrinsic() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
  vmIntrinsics::ID iid = method()->intrinsic_id();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
  if (iid == vmIntrinsics::_getClass ||
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1211
      iid == vmIntrinsics::_hashCode) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
    return iid;
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1213
  } else {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
    return vmIntrinsics::_none;
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1215
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1218
void BCEscapeAnalyzer::compute_escape_for_intrinsic(vmIntrinsics::ID iid) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
  switch (iid) {
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1220
    case vmIntrinsics::_getClass:
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1221
      _return_local = false;
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1222
      _return_allocated = false;
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1223
      break;
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1224
    case vmIntrinsics::_hashCode:
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1225
      // initialized state is correct
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1226
      break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
    assert(false, "unexpected intrinsic");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
void BCEscapeAnalyzer::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
  // clear escape information (method may have been deoptimized)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
  methodData()->clear_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
  // initialize escape state of object parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
  ciSignature* sig = method()->signature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
  int j = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
  if (!method()->is_static()) {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1242
    _arg_local.set(0);
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1243
    _arg_stack.set(0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
    j++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
  for (i = 0; i < sig->count(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
    ciType* t = sig->type_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
    if (!t->is_primitive_type()) {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1249
      _arg_local.set(j);
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1250
      _arg_stack.set(j);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
    j += t->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  assert(j == _arg_size, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
  // start with optimistic assumption
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
  ciType *rt = _method->return_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
  if (rt->is_primitive_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
    _return_local = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
    _return_allocated = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
    _return_local = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
    _return_allocated = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
  _allocated_escapes = false;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1266
  _unknown_modified = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
void BCEscapeAnalyzer::clear_escape_info() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
  ciSignature* sig = method()->signature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
  int arg_count = sig->count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
  ArgumentMap var;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1273
  if (!method()->is_static()) {
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1274
    arg_count++;  // allow for "this"
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1275
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
  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
  1277
    set_arg_modified(i, OFFSET_ANY, 4);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
    var.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
    var.set(i);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1280
    set_modified(var, OFFSET_ANY, 4);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
    set_global_escape(var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
  }
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1283
  _arg_local.Clear();
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1284
  _arg_stack.Clear();
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1285
  _arg_returned.Clear();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
  _return_local = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
  _return_allocated = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
  _allocated_escapes = true;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1289
  _unknown_modified = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
void BCEscapeAnalyzer::compute_escape_info() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
  assert(!methodData()->has_escape_info(), "do not overwrite escape info");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
  vmIntrinsics::ID iid = known_intrinsic();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
  // check if method can be analyzed
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1300
  if (iid == vmIntrinsics::_none && (method()->is_abstract() || method()->is_native() || !method()->holder()->is_initialized()
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
      || _level > MaxBCEAEstimateLevel
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
      || method()->code_size() > MaxBCEAEstimateSize)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
    if (BCEATraceLevel >= 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
      tty->print("Skipping method because: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
      if (method()->is_abstract())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
        tty->print_cr("method is abstract.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
      else if (method()->is_native())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
        tty->print_cr("method is native.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
      else if (!method()->holder()->is_initialized())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
        tty->print_cr("class of method is not initialized.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
      else if (_level > MaxBCEAEstimateLevel)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
        tty->print_cr("level (%d) exceeds MaxBCEAEstimateLevel (%d).",
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 22234
diff changeset
  1313
                      _level, (int) MaxBCEAEstimateLevel);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
      else if (method()->code_size() > MaxBCEAEstimateSize)
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 22234
diff changeset
  1315
        tty->print_cr("code size (%d) exceeds MaxBCEAEstimateSize (%d).",
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 22234
diff changeset
  1316
                      method()->code_size(), (int) MaxBCEAEstimateSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
      else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
    clear_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
  if (BCEATraceLevel >= 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
    tty->print("[EA] estimating escape information for");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
    if (iid != vmIntrinsics::_none)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
      tty->print(" intrinsic");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
    method()->print_short_name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
    tty->print_cr(" (%d bytes)", method()->code_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
  initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1335
  // 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
  1336
  // does not returns an object (_return_allocated is set in initialize()).
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1337
  if (_arg_local.Size() == 0 && !_return_allocated) {
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1338
    // 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
  1339
    // set pessimistic escape information.
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1340
    clear_escape_info();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1341
    methodData()->set_eflag(MethodData::allocated_escapes);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1342
    methodData()->set_eflag(MethodData::unknown_modified);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1343
    methodData()->set_eflag(MethodData::estimated);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
  if (iid != vmIntrinsics::_none)
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1348
    compute_escape_for_intrinsic(iid);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
  else {
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53199
diff changeset
  1350
    do_analysis();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1353
  // 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
  1354
  // dependencies or if method data is empty
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
  if (!has_dependencies() && !methodData()->is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
    for (i = 0; i < _arg_size; i++) {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1358
      if (_arg_local.test(i)) {
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1359
        assert(_arg_stack.test(i), "inconsistent escape info");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
        methodData()->set_arg_local(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
        methodData()->set_arg_stack(i);
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1362
      } else if (_arg_stack.test(i)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
        methodData()->set_arg_stack(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
      }
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1365
      if (_arg_returned.test(i)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
        methodData()->set_arg_returned(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
      }
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1368
      methodData()->set_arg_modified(i, _arg_modified[i]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
    if (_return_local) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1371
      methodData()->set_eflag(MethodData::return_local);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
    }
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1373
    if (_return_allocated) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1374
      methodData()->set_eflag(MethodData::return_allocated);
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1375
    }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1376
    if (_allocated_escapes) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1377
      methodData()->set_eflag(MethodData::allocated_escapes);
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1378
    }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1379
    if (_unknown_modified) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1380
      methodData()->set_eflag(MethodData::unknown_modified);
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1381
    }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1382
    methodData()->set_eflag(MethodData::estimated);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
void BCEscapeAnalyzer::read_escape_info() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
  assert(methodData()->has_escape_info(), "no escape info available");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
  // read escape information from method descriptor
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
  for (int i = 0; i < _arg_size; i++) {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1391
    if (methodData()->is_arg_local(i))
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1392
      _arg_local.set(i);
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1393
    if (methodData()->is_arg_stack(i))
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1394
      _arg_stack.set(i);
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1395
    if (methodData()->is_arg_returned(i))
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1396
      _arg_returned.set(i);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1397
    _arg_modified[i] = methodData()->arg_modified(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1399
  _return_local = methodData()->eflag_set(MethodData::return_local);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1400
  _return_allocated = methodData()->eflag_set(MethodData::return_allocated);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1401
  _allocated_escapes = methodData()->eflag_set(MethodData::allocated_escapes);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
  1402
  _unknown_modified = methodData()->eflag_set(MethodData::unknown_modified);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1406
#ifndef PRODUCT
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1407
void BCEscapeAnalyzer::dump() {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1408
  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
  1409
  method()->print_short_name();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1410
  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
  1411
  tty->print("     non-escaping args:      ");
29353
f0fd57a85296 8073956: Escape analysis dump misses args information
thartmann
parents: 29081
diff changeset
  1412
  _arg_local.print();
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1413
  tty->print("     stack-allocatable args: ");
29353
f0fd57a85296 8073956: Escape analysis dump misses args information
thartmann
parents: 29081
diff changeset
  1414
  _arg_stack.print();
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1415
  if (_return_local) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1416
    tty->print("     returned args:          ");
29353
f0fd57a85296 8073956: Escape analysis dump misses args information
thartmann
parents: 29081
diff changeset
  1417
    _arg_returned.print();
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1418
  } else if (is_return_allocated()) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1419
    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
  1420
  } else {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1421
    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
  1422
  }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1423
  tty->print("     modified args: ");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1424
  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
  1425
    if (_arg_modified[i] == 0)
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1426
      tty->print("    0");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1427
    else
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1428
      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
  1429
  }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1430
  tty->cr();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1431
  tty->print("     flags: ");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1432
  if (_return_allocated)
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1433
    tty->print(" return_allocated");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1434
  if (_allocated_escapes)
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1435
    tty->print(" allocated_escapes");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1436
  if (_unknown_modified)
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1437
    tty->print(" unknown_modified");
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1438
  tty->cr();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1439
}
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1440
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
BCEscapeAnalyzer::BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent)
51333
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 49593
diff changeset
  1443
    : _arena(CURRENT_ENV->arena())
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 49593
diff changeset
  1444
    , _conservative(method == NULL || !EstimateArgEscape)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
    , _method(method)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
    , _methodData(method ? method->method_data() : NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
    , _arg_size(method ? method->arg_size() : 0)
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1448
    , _arg_local(_arena)
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1449
    , _arg_stack(_arena)
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1450
    , _arg_returned(_arena)
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1451
    , _dirty(_arena)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
    , _return_local(false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
    , _return_allocated(false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
    , _allocated_escapes(false)
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1455
    , _unknown_modified(false)
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1456
    , _dependencies(_arena, 4, 0, NULL)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
    , _parent(parent)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
    , _level(parent == NULL ? 0 : parent->level() + 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
  if (!_conservative) {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1460
    _arg_local.Clear();
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1461
    _arg_stack.Clear();
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1462
    _arg_returned.Clear();
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1463
    _dirty.Clear();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
    Arena* arena = CURRENT_ENV->arena();
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
  1465
    _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
  1466
    Copy::zero_to_bytes(_arg_modified, _arg_size * sizeof(uint));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
    if (methodData() == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
    if (methodData()->has_escape_info()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
      TRACE_BCEA(2, tty->print_cr("[EA] Reading previous results for %s.%s",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
                                  method->holder()->name()->as_utf8(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
                                  method->name()->as_utf8()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
      read_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
      TRACE_BCEA(2, tty->print_cr("[EA] computing results for %s.%s",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
                                  method->holder()->name()->as_utf8(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
                                  method->name()->as_utf8()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
      compute_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
      methodData()->update_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
    }
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1483
#ifndef PRODUCT
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1484
    if (BCEATraceLevel >= 3) {
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1485
      // dump escape information
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1486
      dump();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1487
    }
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
  1488
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
void BCEscapeAnalyzer::copy_dependencies(Dependencies *deps) {
5353
30f4b75f8005 6943485: JVMTI always on capabilities change code generation too much
never
parents: 3261
diff changeset
  1493
  if (ciEnv::current()->jvmti_can_hotswap_or_post_breakpoint()) {
30f4b75f8005 6943485: JVMTI always on capabilities change code generation too much
never
parents: 3261
diff changeset
  1494
    // Also record evol dependencies so redefinition of the
30f4b75f8005 6943485: JVMTI always on capabilities change code generation too much
never
parents: 3261
diff changeset
  1495
    // callee will trigger recompilation.
30f4b75f8005 6943485: JVMTI always on capabilities change code generation too much
never
parents: 3261
diff changeset
  1496
    deps->assert_evol_method(method());
30f4b75f8005 6943485: JVMTI always on capabilities change code generation too much
never
parents: 3261
diff changeset
  1497
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
  for (int i = 0; i < _dependencies.length(); i+=2) {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1499
    ciKlass *k = _dependencies.at(i)->as_klass();
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
  1500
    ciMethod *m = _dependencies.at(i+1)->as_method();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
    deps->assert_unique_concrete_method(k, m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
}