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