escape.hpp revision 3619
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This code is free software; you can redistribute it and/or modify it
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * under the terms of the GNU General Public License version 2 only, as
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * published by the Free Software Foundation.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This code is distributed in the hope that it will be useful, but WITHOUT
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * version 2 for more details (a copy is included in the LICENSE file that
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * accompanied this code).
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You should have received a copy of the GNU General Public License version
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 2 along with this work; if not, write to the Free Software Foundation,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or visit www.oracle.com if you need additional information or have any
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * questions.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross// Adaptation for C2 of the escape analysis algorithm described in:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// [Choi99] Jong-Deok Shoi, Manish Gupta, Mauricio Seffano,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// Vugranam C. Sreedhar, Sam Midkiff,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// "Escape Analysis for Java", Procedings of ACM SIGPLAN
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// OOPSLA Conference, November 1, 1999
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// The flow-insensitive analysis described in the paper has been implemented.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// The analysis requires construction of a "connection graph" (CG) for
b1352070d318187b41b088da3533692976f3f225Alan Wright// the method being analyzed. The nodes of the connection graph are:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// - Java objects (JO)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// - Local variables (LV)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// - Fields of an object (OF), these also include array elements
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// The CG contains 3 types of edges:
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States// - PointsTo (-P>) {LV, OF} to JO
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States// - Deferred (-D>) from {LV, OF} to {LV, OF}
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States// - Field (-F>) from JO to OF
7b59d02d2a384be9a08087b14defadd214b3c1ddjb// The following utility functions is used by the algorithm:
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// PointsTo(n) - n is any CG node, it returns the set of JO that n could
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// point to.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// The algorithm describes how to construct the connection graph
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// in the following 4 cases:
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// Case Edges Created
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// (1) p = new T() LV -P> JO
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// (2) p = q LV -D> LV
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// (3) p.f = q JO -F> OF, OF -D> LV
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// (4) p = q.f JO -F> OF, LV -D> OF
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// In all these cases, p and q are local variables. For static field
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// references, we can construct a local variable containing a reference
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// to the static memory.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// C2 does not have local variables. However for the purposes of constructing
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// the connection graph, the following IR nodes are treated as local variables:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// Phi (pointer values)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// LoadP, LoadN
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// Proj#5 (value returned from callnodes including allocations)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// CheckCastPP, CastPP
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross// The LoadP, Proj and CheckCastPP behave like variables assigned to only once.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross// Only a Phi can have multiple assignments. Each input to a Phi is treated
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross// as an assignment to it.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// The following node types are JavaObject:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// phantom_object (general globally escaped object)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// Allocate
7b59d02d2a384be9a08087b14defadd214b3c1ddjb// AllocateArray
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// Parm (for incoming arguments)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// CastX2P ("unsafe" operations)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// CreateEx
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// LoadKlass
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as// ThreadLocal
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// CallStaticJava (which returns Object)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// AddP nodes are fields.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// After building the graph, a pass is made over the nodes, deleting deferred
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// nodes and copying the edges from the target of the deferred edge to the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// source. This results in a graph with no deferred edges, only:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// LV -P> JO
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// OF -P> JO (the object whose oop is stored in the field)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// JO -F> OF
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// Then, for each node which is GlobalEscape, anything it could point to
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// is marked GlobalEscape. Finally, for any node marked ArgEscape, anything
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States// it could point to is marked ArgEscape.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw// ConnectionGraph nodes
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb GrowableArray<PointsToNode*> _edges; // List of nodes this node points to
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw GrowableArray<PointsToNode*> _uses; // List of nodes which point to this node
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb Node* const _node; // Ideal node corresponding to this PointsTo node.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw typedef enum {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb typedef enum {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw NoEscape = 1, // An object does not escape method or thread and it is
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // not passed to call. It could be replaced with scalar.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ArgEscape = 2, // An object does not escape method or thread but it is
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // passed as argument to call or referenced by argument
7b59d02d2a384be9a08087b14defadd214b3c1ddjb // and it does not escape during call.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb GlobalEscape = 3 // An object escapes the method or thread.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb typedef enum {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb ScalarReplaceable = 1, // Not escaped object could be replaced with scalar
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb PointsToNode(Compile *C, Node* n, EscapeState es, NodeType type):
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw bool is_JavaObject() const { return _type == (u1)JavaObject; }
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as bool is_LocalVar() const { return _type == (u1)LocalVar; }
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb bool is_Arraycopy() const { return _type == (u1)Arraycopy; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw JavaObjectNode* as_JavaObject() { assert(is_JavaObject(),""); return (JavaObjectNode*)this; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw LocalVarNode* as_LocalVar() { assert(is_LocalVar(),""); return (LocalVarNode*)this; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FieldNode* as_Field() { assert(is_Field(),""); return (FieldNode*)this; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ArraycopyNode* as_Arraycopy() { assert(is_Arraycopy(),""); return (ArraycopyNode*)this; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw EscapeState escape_state() const { return (EscapeState)_escape; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void set_escape_state(EscapeState state) { _escape = (u1)state; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw EscapeState fields_escape_state() const { return (EscapeState)_fields_escape; }
7b59d02d2a384be9a08087b14defadd214b3c1ddjb void set_fields_escape_state(EscapeState state) { _fields_escape = (u1)state; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw bool has_unknown_ptr() const { return (_flags & PointsToUnknown) != 0; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void set_has_unknown_ptr() { _flags |= PointsToUnknown; }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross bool arraycopy_src() const { return (_flags & ArraycopySrc) != 0; }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross void set_arraycopy_src() { _flags |= ArraycopySrc; }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross bool arraycopy_dst() const { return (_flags & ArraycopyDst) != 0; }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross void set_arraycopy_dst() { _flags |= ArraycopyDst; }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross bool scalar_replaceable() const { return (_flags & ScalarReplaceable) != 0;}
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross int edge_count() const { return _edges.length(); }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross PointsToNode* edge(int e) const { return _edges.at(e); }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross bool add_edge(PointsToNode* edge) { return _edges.append_if_missing(edge); }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross int use_count() const { return _uses.length(); }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross PointsToNode* use(int e) const { return _uses.at(e); }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross bool add_use(PointsToNode* use) { return _uses.append_if_missing(use); }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Mark base edge use to distinguish from stored value edge.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross bool add_base_use(FieldNode* use) { return _uses.append_if_missing((PointsToNode*)((intptr_t)use + 1)); }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross static bool is_base_use(PointsToNode* use) { return (((intptr_t)use) & 1); }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross static PointsToNode* get_use_node(PointsToNode* use) { return (PointsToNode*)(((intptr_t)use) & ~1); }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Return true if this node points to specified node or nodes it points to.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Return true if this node points only to non-escaping allocations.
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as // Return true if one node points to an other.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb GrowableArray<PointsToNode*> _bases; // List of JavaObject nodes which point to this node
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb FieldNode(Compile *C, Node* n, EscapeState es, int offs, bool is_oop):
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw bool has_unknown_base() const { return _has_unknown_base; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void set_has_unknown_base() { _has_unknown_base = true; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw PointsToNode* base(int e) const { return _bases.at(e); }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw bool add_base(PointsToNode* base) { return _bases.append_if_missing(base); }
7b59d02d2a384be9a08087b14defadd214b3c1ddjb // Return true if bases points to this java object.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// Iterators for PointsTo node's edges:
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// for (EdgeIterator i(n); i.has_next(); i.next()) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb// PointsToNode* u = i.get();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw const int cnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw inline PointsToIterator(const PointsToNode* n, int cnt) : node(n), cnt(cnt), i(0) { }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw inline void next() { i++; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw PointsToNode* get() const { ShouldNotCallThis(); return NULL; }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw inline EdgeIterator(const PointsToNode* n) : PointsToIterator(n, n->edge_count()) { }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw inline PointsToNode* get() const { return node->edge(i); }
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb inline UseIterator(const PointsToNode* n) : PointsToIterator(n, n->use_count()) { }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw inline PointsToNode* get() const { return node->use(i); }
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb inline BaseIterator(const FieldNode* n) : PointsToIterator(n, n->base_count()) { }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw inline PointsToNode* get() const { return ((PointsToNode*)node)->as_Field()->base(i); }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw GrowableArray<PointsToNode*> _nodes; // Map from ideal nodes to
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // ConnectionGraph nodes.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw GrowableArray<PointsToNode*> _worklist; // Nodes to be processed
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb bool _collecting; // Indicates whether escape information
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // is still being collected. If false,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // no new nodes will be processed.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw Compile* _compile; // Compile object for current compilation
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw Unique_Node_List ideal_nodes; // Used by CG construction and types splitting.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Address of an element in _nodes. Used when the element is to be modified
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb // There should be no new ideal nodes during ConnectionGraph build,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // growableArray::at() will throw assert otherwise.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb // Add nodes to ConnectionGraph.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void add_local_var(Node* n, PointsToNode::EscapeState es);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void add_java_object(Node* n, PointsToNode::EscapeState es);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void add_field(Node* n, PointsToNode::EscapeState es, int offset);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void add_arraycopy(Node* n, PointsToNode::EscapeState es, PointsToNode* src, PointsToNode* dst);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb // Compute the escape state for arguments to a call.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Add PointsToNode node corresponding to a call
7b59d02d2a384be9a08087b14defadd214b3c1ddjb // Map ideal node to existing PointsTo node (usually phantom_object).
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb // Create PointsToNode node and add it to Connection Graph.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb void add_node_to_connection_graph(Node *n, Unique_Node_List *delayed_worklist);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb // Add final simple edges to graph.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb // Finish Graph construction.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb bool complete_connection_graph(GrowableArray<PointsToNode*>& ptnodes_worklist,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void verify_connection_graph(GrowableArray<PointsToNode*>& ptnodes_worklist,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Add all references to this JavaObject node.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int add_java_object_edges(JavaObjectNode* jobj, bool populate_worklist);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as // Put node on worklist if it is (or was) not there.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Put on worklist all uses of this node.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Put on worklist all field's uses and related field nodes.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Put on worklist all related field nodes.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void add_fields_to_worklist(FieldNode* field, PointsToNode* base);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Find fields which have unknown value.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Find fields initializing values for allocations.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross int find_init_values(JavaObjectNode* ptn, PointsToNode* init_val, PhaseTransform* phase);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Set the escape state of an object and its fields.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void set_escape_state(PointsToNode* ptn, PointsToNode::EscapeState esc) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Don't change non-escaping state of NULL pointer.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross void set_fields_escape_state(PointsToNode* ptn, PointsToNode::EscapeState esc) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross // Don't change non-escaping state of NULL pointer.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Propagate GlobalEscape and ArgEscape escape states to all nodes
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as // and check that we still have non-escaping java objects.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb bool find_non_escaped_objects(GrowableArray<PointsToNode*>& ptnodes_worklist,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Adjust scalar_replaceable state after Connection Graph is built.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void adjust_scalar_replaceable_state(JavaObjectNode* jobj);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb // Optimize ideal graph.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void optimize_ideal_graph(GrowableArray<Node*>& ptr_cmp_worklist,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Optimize objects compare.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Returns unique corresponding java object or NULL.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Add an edge of the specified type pointing to the specified target.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw assert(!from->is_Field() || from->as_Field()->is_oop(), "sanity");
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return false; // already points to phantom_obj
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Add an edge from Field node to its base and back.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return false; // already has phantom_obj base
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States bool is_new = from->add_base(to);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States assert(!_verify, "graph is incomplete");
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (to == null_obj)
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown return is_new; // Don't add fields to NULL pointer.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Add LocalVar node and edge if possible
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void add_local_var_and_edge(Node* n, PointsToNode::EscapeState es, Node* to,
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (delayed_worklist != NULL) { // First iteration of CG construction
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return; // Process it later.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Helper functions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // offset of a field reference
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Propagate unique types created for unescaped allocated objects
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // through the graph
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void split_unique_types(GrowableArray<Node *> &alloc_worklist);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Helper methods for unique types split.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw PhiNode *create_split_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, bool &new_created);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw PhiNode *split_memory_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void move_inst_mem(Node* n, GrowableArray<PhiNode *> &orig_phis);
7b59d02d2a384be9a08087b14defadd214b3c1ddjb Node* find_inst_mem(Node* mem, int alias_idx,GrowableArray<PhiNode *> &orig_phi_worklist);
3db3f65c6274eb042354801a308c8e9bc4994553amw Node* step_through_mergemem(MergeMemNode *mmem, int alias_idx, const TypeOopPtr *toop);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw GrowableArray<MergeMemNode*> _mergemem_worklist; // List of all MergeMem nodes
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw Node_Array _node_map; // used for bookeeping during type splitting
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Used for the following purposes:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Memory Phi - most recent unique Phi split out
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // from this Phi
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // MemNode - new memory input for this node
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // ChecCastPP - allocation that this is a cast of
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // allocation - CheckCastPP of the allocation
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // manage entries in _node_map
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb // Notify optimizer that a node has been modified
7b59d02d2a384be9a08087b14defadd214b3c1ddjb // Compute the escape information
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Check for non-escaping candidates
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw // Perform escape analysis
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw static void do_analysis(Compile *C, PhaseIterGVN *igvn);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw void dump(GrowableArray<PointsToNode*>& ptnodes_worklist);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#endif // SHARE_VM_OPTO_ESCAPE_HPP