hotspot/src/share/vm/opto/escape.hpp
author iveresov
Thu, 22 Jan 2015 11:25:23 -0800
changeset 28723 0a36120cb225
parent 27424 77a7f4a2463b
child 30629 b6e5ad2f18d5
permissions -rw-r--r--
8071302: assert(!_reg_node[reg_lo] || edge_from_to(_reg_node[reg_lo], def)) failed: after block local Summary: Add merge nodes to node to block mapping Reviewed-by: kvn, vlivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
     2
 * Copyright (c) 2005, 2012, 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: 4471
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4471
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: 4471
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: 7122
diff changeset
    25
#ifndef SHARE_VM_OPTO_ESCAPE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7122
diff changeset
    26
#define SHARE_VM_OPTO_ESCAPE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7122
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7122
diff changeset
    28
#include "opto/addnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7122
diff changeset
    29
#include "opto/node.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7122
diff changeset
    30
#include "utilities/growableArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7122
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// Adaptation for C2 of the escape analysis algorithm described in:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    35
// [Choi99] Jong-Deok Shoi, Manish Gupta, Mauricio Seffano,
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    36
//          Vugranam C. Sreedhar, Sam Midkiff,
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    37
//          "Escape Analysis for Java", Procedings of ACM SIGPLAN
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    38
//          OOPSLA  Conference, November 1, 1999
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// The flow-insensitive analysis described in the paper has been implemented.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    42
// The analysis requires construction of a "connection graph" (CG) for
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    43
// the method being analyzed.  The nodes of the connection graph are:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//     -  Java objects (JO)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//     -  Local variables (LV)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
//     -  Fields of an object (OF),  these also include array elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// The CG contains 3 types of edges:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    51
//   -  PointsTo  (-P>)    {LV, OF} to JO
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    52
//   -  Deferred  (-D>)    from {LV, OF} to {LV, OF}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//   -  Field     (-F>)    from JO to OF
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// The following  utility functions is used by the algorithm:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
//
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    57
//   PointsTo(n) - n is any CG node, it returns the set of JO that n could
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    58
//                 point to.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
//
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    60
// The algorithm describes how to construct the connection graph
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    61
// in the following 4 cases:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
//          Case                  Edges Created
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
//
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    65
// (1)   p   = new T()              LV -P> JO
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    66
// (2)   p   = q                    LV -D> LV
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    67
// (3)   p.f = q                    JO -F> OF,  OF -D> LV
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    68
// (4)   p   = q.f                  JO -F> OF,  LV -D> OF
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    70
// In all these cases, p and q are local variables.  For static field
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    71
// references, we can construct a local variable containing a reference
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    72
// to the static memory.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
// C2 does not have local variables.  However for the purposes of constructing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
// the connection graph, the following IR nodes are treated as local variables:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
//     Phi    (pointer values)
10982
85bcf8ef9cc8 7059047: EA: can't find initializing store with several CheckCastPP
kvn
parents: 8319
diff changeset
    77
//     LoadP, LoadN
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    78
//     Proj#5 (value returned from callnodes including allocations)
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    79
//     CheckCastPP, CastPP
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
//
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    81
// The LoadP, Proj and CheckCastPP behave like variables assigned to only once.
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    82
// Only a Phi can have multiple assignments.  Each input to a Phi is treated
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
// as an assignment to it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
//
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    85
// The following node types are JavaObject:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
//
10982
85bcf8ef9cc8 7059047: EA: can't find initializing store with several CheckCastPP
kvn
parents: 8319
diff changeset
    87
//     phantom_object (general globally escaped object)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
//     Allocate
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
//     AllocateArray
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
//     Parm  (for incoming arguments)
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    91
//     CastX2P ("unsafe" operations)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
//     CreateEx
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
//     ConP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
//     LoadKlass
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
    95
//     ThreadLocal
10982
85bcf8ef9cc8 7059047: EA: can't find initializing store with several CheckCastPP
kvn
parents: 8319
diff changeset
    96
//     CallStaticJava (which returns Object)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
// AddP nodes are fields.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
// After building the graph, a pass is made over the nodes, deleting deferred
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
// nodes and copying the edges from the target of the deferred edge to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// source.  This results in a graph with no deferred edges, only:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
//    LV -P> JO
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
   105
//    OF -P> JO (the object whose oop is stored in the field)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
//    JO -F> OF
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// Then, for each node which is GlobalEscape, anything it could point to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
// is marked GlobalEscape.  Finally, for any node marked ArgEscape, anything
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
// it could point to is marked ArgEscape.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
class  Compile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
class  Node;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
class  CallNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
class  PhiNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
class  PhaseTransform;
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   118
class  PointsToNode;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
class  Type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
class  TypePtr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
class  VectorSet;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   123
class JavaObjectNode;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   124
class LocalVarNode;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   125
class FieldNode;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   126
class ArraycopyNode;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   127
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   128
class ConnectionGraph;
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   129
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   130
// ConnectionGraph nodes
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   131
class PointsToNode : public ResourceObj {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   132
  GrowableArray<PointsToNode*> _edges; // List of nodes this node points to
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   133
  GrowableArray<PointsToNode*> _uses;  // List of nodes which point to this node
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   134
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   135
  const u1           _type;  // NodeType
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   136
  u1                _flags;  // NodeFlags
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   137
  u1               _escape;  // EscapeState of object
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   138
  u1        _fields_escape;  // EscapeState of object's fields
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   139
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   140
  Node* const        _node;  // Ideal node corresponding to this PointsTo node.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   141
  const int           _idx;  // Cached ideal node's _idx
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   142
  const uint         _pidx;  // Index of this node
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   143
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  typedef enum {
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
   146
    UnknownType = 0,
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
   147
    JavaObject  = 1,
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
   148
    LocalVar    = 2,
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   149
    Field       = 3,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   150
    Arraycopy   = 4
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  } NodeType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  typedef enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    UnknownEscape = 0,
10982
85bcf8ef9cc8 7059047: EA: can't find initializing store with several CheckCastPP
kvn
parents: 8319
diff changeset
   155
    NoEscape      = 1, // An object does not escape method or thread and it is
85bcf8ef9cc8 7059047: EA: can't find initializing store with several CheckCastPP
kvn
parents: 8319
diff changeset
   156
                       // not passed to call. It could be replaced with scalar.
85bcf8ef9cc8 7059047: EA: can't find initializing store with several CheckCastPP
kvn
parents: 8319
diff changeset
   157
    ArgEscape     = 2, // An object does not escape method or thread but it is
85bcf8ef9cc8 7059047: EA: can't find initializing store with several CheckCastPP
kvn
parents: 8319
diff changeset
   158
                       // passed as argument to call or referenced by argument
85bcf8ef9cc8 7059047: EA: can't find initializing store with several CheckCastPP
kvn
parents: 8319
diff changeset
   159
                       // and it does not escape during call.
85bcf8ef9cc8 7059047: EA: can't find initializing store with several CheckCastPP
kvn
parents: 8319
diff changeset
   160
    GlobalEscape  = 3  // An object escapes the method or thread.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  } EscapeState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  typedef enum {
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   164
    ScalarReplaceable = 1,  // Not escaped object could be replaced with scalar
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   165
    PointsToUnknown   = 2,  // Has edge to phantom_object
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   166
    ArraycopySrc      = 4,  // Has edge from Arraycopy node
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   167
    ArraycopyDst      = 8   // Has edge to Arraycopy node
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   168
  } NodeFlags;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   171
  inline PointsToNode(ConnectionGraph* CG, Node* n, EscapeState es, NodeType type);
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   172
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   173
  uint        pidx()   const { return _pidx; }
952
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 348
diff changeset
   174
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   175
  Node* ideal_node()   const { return _node; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   176
  int          idx()   const { return _idx; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   177
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   178
  bool is_JavaObject() const { return _type == (u1)JavaObject; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   179
  bool is_LocalVar()   const { return _type == (u1)LocalVar; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   180
  bool is_Field()      const { return _type == (u1)Field; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   181
  bool is_Arraycopy()  const { return _type == (u1)Arraycopy; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   182
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   183
  JavaObjectNode* as_JavaObject() { assert(is_JavaObject(),""); return (JavaObjectNode*)this; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   184
  LocalVarNode*   as_LocalVar()   { assert(is_LocalVar(),"");   return (LocalVarNode*)this; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   185
  FieldNode*      as_Field()      { assert(is_Field(),"");      return (FieldNode*)this; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   186
  ArraycopyNode*  as_Arraycopy()  { assert(is_Arraycopy(),"");  return (ArraycopyNode*)this; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   187
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   188
  EscapeState escape_state() const { return (EscapeState)_escape; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   189
  void    set_escape_state(EscapeState state) { _escape = (u1)state; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   190
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   191
  EscapeState fields_escape_state() const { return (EscapeState)_fields_escape; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   192
  void    set_fields_escape_state(EscapeState state) { _fields_escape = (u1)state; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   193
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   194
  bool     has_unknown_ptr() const { return (_flags & PointsToUnknown) != 0; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   195
  void set_has_unknown_ptr()       { _flags |= PointsToUnknown; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   196
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   197
  bool     arraycopy_src() const { return (_flags & ArraycopySrc) != 0; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   198
  void set_arraycopy_src()       { _flags |= ArraycopySrc; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   199
  bool     arraycopy_dst() const { return (_flags & ArraycopyDst) != 0; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   200
  void set_arraycopy_dst()       { _flags |= ArraycopyDst; }
952
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 348
diff changeset
   201
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   202
  bool     scalar_replaceable() const { return (_flags & ScalarReplaceable) != 0;}
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   203
  void set_scalar_replaceable(bool v) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   204
    if (v)
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   205
      _flags |= ScalarReplaceable;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   206
    else
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   207
      _flags &= ~ScalarReplaceable;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   208
  }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   209
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   210
  int edge_count()              const { return _edges.length(); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   211
  PointsToNode* edge(int e)     const { return _edges.at(e); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   212
  bool add_edge(PointsToNode* edge)    { return _edges.append_if_missing(edge); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   213
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   214
  int use_count()             const { return _uses.length(); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   215
  PointsToNode* use(int e)    const { return _uses.at(e); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   216
  bool add_use(PointsToNode* use)    { return _uses.append_if_missing(use); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   217
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   218
  // Mark base edge use to distinguish from stored value edge.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   219
  bool add_base_use(FieldNode* use) { return _uses.append_if_missing((PointsToNode*)((intptr_t)use + 1)); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   220
  static bool is_base_use(PointsToNode* use) { return (((intptr_t)use) & 1); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   221
  static PointsToNode* get_use_node(PointsToNode* use) { return (PointsToNode*)(((intptr_t)use) & ~1); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   222
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   223
  // Return true if this node points to specified node or nodes it points to.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   224
  bool points_to(JavaObjectNode* ptn) const;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   225
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   226
  // Return true if this node points only to non-escaping allocations.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   227
  bool non_escaping_allocation();
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   228
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   229
  // Return true if one node points to an other.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   230
  bool meet(PointsToNode* ptn);
952
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 348
diff changeset
   231
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
#ifndef PRODUCT
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   233
  NodeType node_type() const { return (NodeType)_type;}
961
7fb3b13d4205 6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents: 953
diff changeset
   234
  void dump(bool print_state=true) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   239
class LocalVarNode: public PointsToNode {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   240
public:
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   241
  LocalVarNode(ConnectionGraph *CG, Node* n, EscapeState es):
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   242
    PointsToNode(CG, n, es, LocalVar) {}
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   243
};
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   244
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   245
class JavaObjectNode: public PointsToNode {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   246
public:
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   247
  JavaObjectNode(ConnectionGraph *CG, Node* n, EscapeState es):
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   248
    PointsToNode(CG, n, es, JavaObject) {
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   249
      if (es > NoEscape)
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   250
        set_scalar_replaceable(false);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   251
    }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   252
};
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   253
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   254
class FieldNode: public PointsToNode {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   255
  GrowableArray<PointsToNode*> _bases; // List of JavaObject nodes which point to this node
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   256
  const int   _offset; // Field's offset.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   257
  const bool  _is_oop; // Field points to object
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   258
        bool  _has_unknown_base; // Has phantom_object base
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   259
public:
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   260
  FieldNode(ConnectionGraph *CG, Node* n, EscapeState es, int offs, bool is_oop):
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   261
    PointsToNode(CG, n, es, Field),
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   262
    _offset(offs), _is_oop(is_oop),
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   263
    _has_unknown_base(false) {}
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   264
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   265
  int      offset()              const { return _offset;}
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   266
  bool     is_oop()              const { return _is_oop;}
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   267
  bool     has_unknown_base()    const { return _has_unknown_base; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   268
  void set_has_unknown_base()          { _has_unknown_base = true; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   269
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   270
  int base_count()              const { return _bases.length(); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   271
  PointsToNode* base(int e)     const { return _bases.at(e); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   272
  bool add_base(PointsToNode* base)    { return _bases.append_if_missing(base); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   273
#ifdef ASSERT
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   274
  // Return true if bases points to this java object.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   275
  bool has_base(JavaObjectNode* ptn) const;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   276
#endif
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   277
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   278
};
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   279
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   280
class ArraycopyNode: public PointsToNode {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   281
public:
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   282
  ArraycopyNode(ConnectionGraph *CG, Node* n, EscapeState es):
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   283
    PointsToNode(CG, n, es, Arraycopy) {}
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   284
};
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   285
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   286
// Iterators for PointsTo node's edges:
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   287
//   for (EdgeIterator i(n); i.has_next(); i.next()) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   288
//     PointsToNode* u = i.get();
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   289
class PointsToIterator: public StackObj {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   290
protected:
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   291
  const PointsToNode* node;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   292
  const int cnt;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   293
  int i;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   294
public:
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   295
  inline PointsToIterator(const PointsToNode* n, int cnt) : node(n), cnt(cnt), i(0) { }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   296
  inline bool has_next() const { return i < cnt; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   297
  inline void next() { i++; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   298
  PointsToNode* get() const { ShouldNotCallThis(); return NULL; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   299
};
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   300
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   301
class EdgeIterator: public PointsToIterator {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   302
public:
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   303
  inline EdgeIterator(const PointsToNode* n) : PointsToIterator(n, n->edge_count()) { }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   304
  inline PointsToNode* get() const { return node->edge(i); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   305
};
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   306
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   307
class UseIterator: public PointsToIterator {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   308
public:
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   309
  inline UseIterator(const PointsToNode* n) : PointsToIterator(n, n->use_count()) { }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   310
  inline PointsToNode* get() const { return node->use(i); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   311
};
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   312
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   313
class BaseIterator: public PointsToIterator {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   314
public:
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   315
  inline BaseIterator(const FieldNode* n) : PointsToIterator(n, n->base_count()) { }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   316
  inline PointsToNode* get() const { return ((PointsToNode*)node)->as_Field()->base(i); }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   317
};
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   318
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   319
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
class ConnectionGraph: public ResourceObj {
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   321
  friend class PointsToNode;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
private:
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   323
  GrowableArray<PointsToNode*>  _nodes; // Map from ideal nodes to
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   324
                                        // ConnectionGraph nodes.
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
   325
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   326
  GrowableArray<PointsToNode*>  _worklist; // Nodes to be processed
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   327
  VectorSet                  _in_worklist;
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   328
  uint                         _next_pidx;
4470
1e6edcab3109 6895383: JCK test throws NPE for method compiled with Escape Analysis
kvn
parents: 1055
diff changeset
   329
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   330
  bool            _collecting; // Indicates whether escape information
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   331
                               // is still being collected. If false,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   332
                               // no new nodes will be processed.
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
   333
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   334
  bool               _verify;  // verify graph
7122
23b82ce71b4e 6991188: C2 Crashes while compiling method
kvn
parents: 5914
diff changeset
   335
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   336
  JavaObjectNode* phantom_obj; // Unknown object
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   337
  JavaObjectNode*    null_obj;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   338
  Node*             _pcmp_neq; // ConI(#CC_GT)
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   339
  Node*              _pcmp_eq; // ConI(#CC_EQ)
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
   340
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   341
  Compile*           _compile; // Compile object for current compilation
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   342
  PhaseIterGVN*         _igvn; // Value numbering
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   343
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   344
  Unique_Node_List ideal_nodes; // Used by CG construction and types splitting.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
952
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 348
diff changeset
   346
  // Address of an element in _nodes.  Used when the element is to be modified
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   347
  PointsToNode* ptnode_adr(int idx) const {
952
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 348
diff changeset
   348
    // There should be no new ideal nodes during ConnectionGraph build,
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   349
    // growableArray::at() will throw assert otherwise.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   350
    return _nodes.at(idx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  }
952
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 348
diff changeset
   352
  uint nodes_size() const { return _nodes.length(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   354
  uint next_pidx() { return _next_pidx++; }
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   355
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   356
  // Add nodes to ConnectionGraph.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   357
  void add_local_var(Node* n, PointsToNode::EscapeState es);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   358
  void add_java_object(Node* n, PointsToNode::EscapeState es);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   359
  void add_field(Node* n, PointsToNode::EscapeState es, int offset);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   360
  void add_arraycopy(Node* n, PointsToNode::EscapeState es, PointsToNode* src, PointsToNode* dst);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   361
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   362
  // Compute the escape state for arguments to a call.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   363
  void process_call_arguments(CallNode *call);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   364
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   365
  // Add PointsToNode node corresponding to a call
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   366
  void add_call_node(CallNode* call);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   367
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   368
  // Map ideal node to existing PointsTo node (usually phantom_object).
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   369
  void map_ideal_node(Node *n, PointsToNode* ptn) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   370
    assert(ptn != NULL, "only existing PointsTo node");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   371
    _nodes.at_put(n->_idx, ptn);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   372
  }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   373
13886
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13391
diff changeset
   374
  // Utility function for nodes that load an object
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13391
diff changeset
   375
  void add_objload_to_connection_graph(Node *n, Unique_Node_List *delayed_worklist);
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   376
  // Create PointsToNode node and add it to Connection Graph.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   377
  void add_node_to_connection_graph(Node *n, Unique_Node_List *delayed_worklist);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   378
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   379
  // Add final simple edges to graph.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   380
  void add_final_edges(Node *n);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   381
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   382
  // Finish Graph construction.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   383
  bool complete_connection_graph(GrowableArray<PointsToNode*>&   ptnodes_worklist,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   384
                                 GrowableArray<JavaObjectNode*>& non_escaped_worklist,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   385
                                 GrowableArray<JavaObjectNode*>& java_objects_worklist,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   386
                                 GrowableArray<FieldNode*>&      oop_fields_worklist);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   387
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   388
#ifdef ASSERT
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   389
  void verify_connection_graph(GrowableArray<PointsToNode*>&   ptnodes_worklist,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   390
                               GrowableArray<JavaObjectNode*>& non_escaped_worklist,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   391
                               GrowableArray<JavaObjectNode*>& java_objects_worklist,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   392
                               GrowableArray<Node*>& addp_worklist);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   393
#endif
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   394
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   395
  // Add all references to this JavaObject node.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   396
  int add_java_object_edges(JavaObjectNode* jobj, bool populate_worklist);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   397
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   398
  // Put node on worklist if it is (or was) not there.
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   399
  inline void add_to_worklist(PointsToNode* pt) {
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   400
    PointsToNode* ptf = pt;
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   401
    uint pidx_bias = 0;
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   402
    if (PointsToNode::is_base_use(pt)) {
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   403
      // Create a separate entry in _in_worklist for a marked base edge
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   404
      // because _worklist may have an entry for a normal edge pointing
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   405
      // to the same node. To separate them use _next_pidx as bias.
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   406
      ptf = PointsToNode::get_use_node(pt)->as_Field();
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   407
      pidx_bias = _next_pidx;
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   408
    }
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   409
    if (!_in_worklist.test_set(ptf->pidx() + pidx_bias)) {
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   410
      _worklist.append(pt);
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   411
    }
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   412
  }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   413
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   414
  // Put on worklist all uses of this node.
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   415
  inline void add_uses_to_worklist(PointsToNode* pt) {
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   416
    for (UseIterator i(pt); i.has_next(); i.next()) {
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   417
      add_to_worklist(i.get());
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   418
    }
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   419
  }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   420
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   421
  // Put on worklist all field's uses and related field nodes.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   422
  void add_field_uses_to_worklist(FieldNode* field);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   423
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   424
  // Put on worklist all related field nodes.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   425
  void add_fields_to_worklist(FieldNode* field, PointsToNode* base);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   426
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   427
  // Find fields which have unknown value.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   428
  int find_field_value(FieldNode* field);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   429
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   430
  // Find fields initializing values for allocations.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   431
  int find_init_values(JavaObjectNode* ptn, PointsToNode* init_val, PhaseTransform* phase);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   432
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   433
  // Set the escape state of an object and its fields.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   434
  void set_escape_state(PointsToNode* ptn, PointsToNode::EscapeState esc) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   435
    // Don't change non-escaping state of NULL pointer.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   436
    if (ptn != null_obj) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   437
      if (ptn->escape_state() < esc)
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   438
        ptn->set_escape_state(esc);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   439
      if (ptn->fields_escape_state() < esc)
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   440
        ptn->set_fields_escape_state(esc);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   441
    }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   442
  }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   443
  void set_fields_escape_state(PointsToNode* ptn, PointsToNode::EscapeState esc) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   444
    // Don't change non-escaping state of NULL pointer.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   445
    if (ptn != null_obj) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   446
      if (ptn->fields_escape_state() < esc)
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   447
        ptn->set_fields_escape_state(esc);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   448
    }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   449
  }
11198
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 11189
diff changeset
   450
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   451
  // Propagate GlobalEscape and ArgEscape escape states to all nodes
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   452
  // and check that we still have non-escaping java objects.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   453
  bool find_non_escaped_objects(GrowableArray<PointsToNode*>& ptnodes_worklist,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   454
                                GrowableArray<JavaObjectNode*>& non_escaped_worklist);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   455
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   456
  // Adjust scalar_replaceable state after Connection Graph is built.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   457
  void adjust_scalar_replaceable_state(JavaObjectNode* jobj);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   458
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   459
  // Optimize ideal graph.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   460
  void optimize_ideal_graph(GrowableArray<Node*>& ptr_cmp_worklist,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   461
                            GrowableArray<Node*>& storestore_worklist);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   462
  // Optimize objects compare.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   463
  Node* optimize_ptr_compare(Node* n);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   464
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   465
  // Returns unique corresponding java object or NULL.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   466
  JavaObjectNode* unique_java_object(Node *n);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   467
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   468
  // Add an edge of the specified type pointing to the specified target.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   469
  bool add_edge(PointsToNode* from, PointsToNode* to) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   470
    assert(!from->is_Field() || from->as_Field()->is_oop(), "sanity");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   471
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   472
    if (to == phantom_obj) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   473
      if (from->has_unknown_ptr()) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   474
        return false; // already points to phantom_obj
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   475
      }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   476
      from->set_has_unknown_ptr();
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   477
    }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   478
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   479
    bool is_new = from->add_edge(to);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   480
    assert(to != phantom_obj || is_new, "sanity");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   481
    if (is_new) { // New edge?
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   482
      assert(!_verify, "graph is incomplete");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   483
      is_new = to->add_use(from);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   484
      assert(is_new, "use should be also new");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   485
    }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   486
    return is_new;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   487
  }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   488
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   489
  // Add an edge from Field node to its base and back.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   490
  bool add_base(FieldNode* from, PointsToNode* to) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   491
    assert(!to->is_Arraycopy(), "sanity");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   492
    if (to == phantom_obj) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   493
      if (from->has_unknown_base()) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   494
        return false; // already has phantom_obj base
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   495
      }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   496
      from->set_has_unknown_base();
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   497
    }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   498
    bool is_new = from->add_base(to);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   499
    assert(to != phantom_obj || is_new, "sanity");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   500
    if (is_new) {      // New edge?
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   501
      assert(!_verify, "graph is incomplete");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   502
      if (to == null_obj)
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   503
        return is_new; // Don't add fields to NULL pointer.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   504
      if (to->is_JavaObject()) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   505
        is_new = to->add_edge(from);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   506
      } else {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   507
        is_new = to->add_base_use(from);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   508
      }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   509
      assert(is_new, "use should be also new");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   510
    }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   511
    return is_new;
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   512
  }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   513
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   514
  // Add LocalVar node and edge if possible
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   515
  void add_local_var_and_edge(Node* n, PointsToNode::EscapeState es, Node* to,
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   516
                              Unique_Node_List *delayed_worklist) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   517
    PointsToNode* ptn = ptnode_adr(to->_idx);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   518
    if (delayed_worklist != NULL) { // First iteration of CG construction
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   519
      add_local_var(n, es);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   520
      if (ptn == NULL) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   521
        delayed_worklist->push(n);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   522
        return; // Process it later.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   523
      }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   524
    } else {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   525
      assert(ptn != NULL, "node should be registered");
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   526
    }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   527
    add_edge(ptnode_adr(n->_idx), ptn);
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12158
diff changeset
   528
 }
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   529
  // Helper functions
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12158
diff changeset
   530
  bool   is_oop_field(Node* n, int offset, bool* unsafe);
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   531
  static Node* get_addp_base(Node *addp);
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   532
  static Node* find_second_addp(Node* addp, Node* n);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  // offset of a field reference
238
803c80713999 6674588: (Escape Analysis) Improve Escape Analysis code
kvn
parents: 1
diff changeset
   534
  int address_offset(Node* adr, PhaseTransform *phase);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   537
  // Propagate unique types created for unescaped allocated objects
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   538
  // through the graph
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   539
  void split_unique_types(GrowableArray<Node *>  &alloc_worklist);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   541
  // Helper methods for unique types split.
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   542
  bool split_AddP(Node *addp, Node *base);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   544
  PhiNode *create_split_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *>  &orig_phi_worklist, bool &new_created);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   545
  PhiNode *split_memory_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *>  &orig_phi_worklist);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   547
  void  move_inst_mem(Node* n, GrowableArray<PhiNode *>  &orig_phis);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   548
  Node* find_inst_mem(Node* mem, int alias_idx,GrowableArray<PhiNode *>  &orig_phi_worklist);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   549
  Node* step_through_mergemem(MergeMemNode *mmem, int alias_idx, const TypeOopPtr *toop);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   552
  GrowableArray<MergeMemNode*>  _mergemem_worklist; // List of all MergeMem nodes
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  Node_Array _node_map; // used for bookeeping during type splitting
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
                        // Used for the following purposes:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
                        // Memory Phi    - most recent unique Phi split out
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
                        //                 from this Phi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
                        // MemNode       - new memory input for this node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
                        // ChecCastPP    - allocation that this is a cast of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
                        // allocation    - CheckCastPP of the allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  // manage entries in _node_map
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   563
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   564
  void  set_map(Node* from, Node* to)  {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   565
    ideal_nodes.push(from);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   566
    _node_map.map(from->_idx, to);
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   567
  }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   568
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   569
  Node* get_map(int idx) { return _node_map[idx]; }
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   570
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   571
  PhiNode* get_map_phi(int idx) {
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   572
    Node* phi = _node_map[idx];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    return (phi == NULL) ? NULL : phi->as_Phi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  // Notify optimizer that a node has been modified
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  void record_for_optimizer(Node *n) {
5914
8363e7e6915a 6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents: 5547
diff changeset
   578
    _igvn->_worklist.push(n);
11198
34c860ff41e3 7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents: 11189
diff changeset
   579
    _igvn->add_users_to_worklist(n);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
8319
aedb3bd871bc 7013538: Java memory leak with escape analysis
kvn
parents: 7397
diff changeset
   582
  // Compute the escape information
aedb3bd871bc 7013538: Java memory leak with escape analysis
kvn
parents: 7397
diff changeset
   583
  bool compute_escape();
4470
1e6edcab3109 6895383: JCK test throws NPE for method compiled with Escape Analysis
kvn
parents: 1055
diff changeset
   584
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
public:
5914
8363e7e6915a 6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents: 5547
diff changeset
   586
  ConnectionGraph(Compile *C, PhaseIterGVN *igvn);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
952
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 348
diff changeset
   588
  // Check for non-escaping candidates
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 348
diff changeset
   589
  static bool has_candidates(Compile *C);
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 348
diff changeset
   590
5914
8363e7e6915a 6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents: 5547
diff changeset
   591
  // Perform escape analysis
8363e7e6915a 6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents: 5547
diff changeset
   592
  static void do_analysis(Compile *C, PhaseIterGVN *igvn);
8363e7e6915a 6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents: 5547
diff changeset
   593
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   594
  bool not_global_escape(Node *n);
5914
8363e7e6915a 6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents: 5547
diff changeset
   595
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
#ifndef PRODUCT
12158
f24f2560da32 7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents: 11198
diff changeset
   597
  void dump(GrowableArray<PointsToNode*>& ptnodes_worklist);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7122
diff changeset
   600
27424
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   601
inline PointsToNode::PointsToNode(ConnectionGraph *CG, Node* n, EscapeState es, NodeType type):
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   602
  _edges(CG->_compile->comp_arena(), 2, 0, NULL),
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   603
  _uses (CG->_compile->comp_arena(), 2, 0, NULL),
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   604
  _node(n),
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   605
  _idx(n->_idx),
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   606
  _pidx(CG->next_pidx()),
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   607
  _type((u1)type),
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   608
  _escape((u1)es),
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   609
  _fields_escape((u1)es),
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   610
  _flags(ScalarReplaceable) {
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   611
  assert(n != NULL && es != UnknownEscape, "sanity");
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   612
}
77a7f4a2463b 8041984: CompilerThread seems to occupy all CPU in a very rare situation
kvn
parents: 13886
diff changeset
   613
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7122
diff changeset
   614
#endif // SHARE_VM_OPTO_ESCAPE_HPP