src/hotspot/share/ci/bcEscapeAnalyzer.hpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 54052 a2d3ca8062b9
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
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: 4493
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4493
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: 4493
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    25
#ifndef SHARE_CI_BCESCAPEANALYZER_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    26
#define SHARE_CI_BCESCAPEANALYZER_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    28
#ifdef COMPILER2
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11198
diff changeset
    29
#include "ci/ciObject.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    30
#include "ci/ciMethod.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    31
#include "ci/ciMethodData.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    32
#include "code/dependencies.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    33
#include "libadt/vectset.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    34
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    35
#include "utilities/growableArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    36
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
    37
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// This class implements a fast, conservative analysis of effect of methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// on the escape state of their arguments.  The analysis is at the bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// level.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class  ciMethodBlocks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class  ciBlock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class BCEscapeAnalyzer : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
 private:
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
    47
  Arena*            _arena;        // ciEnv arena
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
    48
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  bool              _conservative; // If true, return maximally
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
                                   // conservative results.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  ciMethod*         _method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  ciMethodData*     _methodData;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  int               _arg_size;
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
    54
  VectorSet         _arg_local;
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
    55
  VectorSet         _arg_stack;
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
    56
  VectorSet         _arg_returned;
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
    57
  VectorSet         _dirty;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
    58
  enum{ ARG_OFFSET_MAX = 31};
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
    59
  uint              *_arg_modified;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  bool              _return_local;
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
    62
  bool              _return_allocated;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  bool              _allocated_escapes;
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
    64
  bool              _unknown_modified;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11198
diff changeset
    66
  GrowableArray<ciMetadata *> _dependencies;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  ciMethodBlocks   *_methodBlocks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  BCEscapeAnalyzer* _parent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  int               _level;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
4493
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 670
diff changeset
    73
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  class  ArgumentMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  class  StateInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
4493
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 670
diff changeset
    77
 private:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // helper functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  bool is_argument(int i)    { return i >= 0 && i < _arg_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  void set_returned(ArgumentMap vars);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  bool is_argument(ArgumentMap vars);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  bool is_arg_stack(ArgumentMap vars);
18955
be9410d4a97c 8020215: Different execution plan when using JIT vs interpreter
kvn
parents: 13728
diff changeset
    83
  bool returns_all(ArgumentMap vars);
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
    84
  void clear_bits(ArgumentMap vars, VectorSet &bs);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  void set_method_escape(ArgumentMap vars);
11198
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 7397
diff changeset
    86
  void set_global_escape(ArgumentMap vars, bool merge = false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  void set_dirty(ArgumentMap vars);
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
    88
  void set_modified(ArgumentMap vars, int offs, int size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  bool is_recursive_call(ciMethod* callee);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  void add_dependence(ciKlass *klass, ciMethod *meth);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  void propagate_dependencies(ciMethod *meth);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  void iterate_blocks(Arena *);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // analysis
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  void clear_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  void compute_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  vmIntrinsics::ID known_intrinsic();
54052
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53244
diff changeset
   104
  void compute_escape_for_intrinsic(vmIntrinsics::ID iid);
a2d3ca8062b9 8218201: Failures when vmIntrinsics::_getClass is not inlined
thartmann
parents: 53244
diff changeset
   105
  void do_analysis();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  void read_escape_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  bool contains(uint arg_set1, uint arg_set2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  ciMethod*         method() const               { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  ciMethodData*     methodData() const           { return _methodData; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  BCEscapeAnalyzer* parent() const               { return _parent; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  int               level() const                { return _level; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11198
diff changeset
   119
  GrowableArray<ciMetadata *>* dependencies()    { return &_dependencies; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  bool              has_dependencies() const     { return !_dependencies.is_empty(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // retrieval of interprocedural escape information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // The given argument does not escape the callee.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  bool is_arg_local(int i) const {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
   126
    return !_conservative && _arg_local.test(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // The given argument escapes the callee, but does not become globally
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // reachable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  bool is_arg_stack(int i) const {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
   132
    return !_conservative && _arg_stack.test(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // The given argument does not escape globally, and may be returned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  bool is_arg_returned(int i) const {
5928
f6e69b46e9e3 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 5547
diff changeset
   137
    return !_conservative && _arg_returned.test(i); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // True iff only input arguments are returned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  bool is_return_local() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    return !_conservative && _return_local;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // True iff only newly allocated unescaped objects are returned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  bool is_return_allocated() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    return !_conservative && _return_allocated && !_allocated_escapes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
218
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   149
  // Tracking of argument modification
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   150
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   151
  enum {OFFSET_ANY = -1};
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   152
  bool 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
   153
  void 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
   154
  bool has_non_arg_side_affects()    { return _unknown_modified; }
a0e996680b05 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 1
diff changeset
   155
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // Copy dependencies from this analysis into "deps"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  void copy_dependencies(Dependencies *deps);
251
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
   158
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
   159
#ifndef PRODUCT
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
   160
  // dump escape information
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
   161
  void dump();
cb2e73f71205 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 218
diff changeset
   162
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5928
diff changeset
   164
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
   165
#endif // SHARE_CI_BCESCAPEANALYZER_HPP