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