escape.hpp revision 0
0N/A * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A// Adaptation for C2 of the escape analysis algorithm described in: 0N/A// [Choi99] Jong-Deok Shoi, Manish Gupta, Mauricio Seffano, Vugranam C. Sreedhar, 0N/A// Sam Midkiff, "Escape Analysis for Java", Procedings of ACM SIGPLAN 0N/A// OOPSLA Conference, November 1, 1999 0N/A// The flow-insensitive analysis described in the paper has been implemented. 0N/A// The analysis requires construction of a "connection graph" (CG) for the method being 0N/A// analyzed. The nodes of the connection graph are: 0N/A// - Java objects (JO) 0N/A// - Local variables (LV) 0N/A// - Fields of an object (OF), these also include array elements 0N/A// The CG contains 3 types of edges: 0N/A// - PointsTo (-P>) {LV,OF} to JO 0N/A// - Deferred (-D>) from {LV, OF} to {LV, OF} 0N/A// - Field (-F>) from JO to OF 0N/A// The following utility functions is used by the algorithm: 0N/A// PointsTo(n) - n is any CG node, it returns the set of JO that n could 0N/A// The algorithm describes how to construct the connection graph in the following 4 cases: 0N/A// Case Edges Created 0N/A// (1) p = new T() LV -P> JO 0N/A// (2) p = q LV -D> LV 0N/A// (3) p.f = q JO -F> OF, OF -D> LV 0N/A// (4) p = q.f JO -F> OF, LV -D> OF 0N/A// In all these cases, p and q are local variables. For static field references, we can 0N/A// construct a local variable containing a reference to the static memory. 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) 0N/A// Proj (value returned from callnodes including allocations) 0N/A// The LoadP, Proj and CheckCastPP behave like variables assigned to only once. Only 0N/A// a Phi can have multiple assignments. Each input to a Phi is treated 0N/A// as an assignment to it. 0N/A// The following note types are JavaObject: 0N/A// Parm (for incoming arguments) 0N/A// AddP nodes are fields. 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// 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 bool _unique_type;
// For allocated objects, this node may be a unique type 0N/A Node*
_node;
// Ideal node corresponding to this PointsTo node 0N/A bool _hidden_alias;
// this node is an argument to a function which may return it 0N/A // creating a hidden alias 0N/A // count of outgoing edges 0N/A // node index of target of outgoing edge "e" 0N/A // type of outgoing edge "e" 0N/A // add a edge of the specified type pointing to the specified target 0N/A // remove an edge of the specified type pointing to the specified target 0N/A // still being collected. If false, no new 0N/A // nodes will be processed 0N/A // pointer values loaded from a field which 0N/A // has not been set are assumed to point to 0N/A // address of an element in _nodes. Used when the element is to be modified 0N/A // expand _nodes array 0N/A // offset of a field reference 0N/A // compute the escape state for arguments to a call 0N/A // compute the escape state for the return value of a call 0N/A // compute the escape state of a Phi. This may be called multiple 0N/A // times as new inputs are added to the Phi. 0N/A // compute the escape state of an ideal node. 0N/A // walk the connection graph starting at the node corresponding to "n" and 0N/A // add the index of everything it could point to, to "ptset". This may cause 0N/A // Phi's encountered to get (re)processed (which requires "phase".) 0N/A // Edge manipulation. The "from_i" and "to_i" arguments are the 0N/A // node indices of the source and destination of the edge 0N/A // Add an edge to node given by "to_i" from any field of adr_i whose offset 0N/A // matches "offset" A deferred edge is added if to_i is a LocalVar, and 0N/A // a pointsto edge is added if it is a JavaObject 0N/A // Add a deferred edge from node given by "from_i" to any field of adr_i whose offset 0N/A // Remove outgoing deferred edges from the node referenced by "ni". 0N/A // Any outgoing edges from the target of the deferred edge are copied 0N/A // Used for the following purposes: 0N/A // Memory Phi - most recent unique Phi split out 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 // Propagate unique types created for unescaped allocated objects 0N/A // through the graph 0N/A // manage entries in _node_map 0N/A // Notify optimizer that a node has been modified 0N/A // Node: This assumes that escape analysis is run before 0N/A // PhaseIterGVN creation 0N/A // Set the escape state of a node 0N/A // bypass any casts and return the node they refer to 0N/A // Get Compile object for current compilation. 0N/A // record a Phi for later processing. 0N/A // process a node and fill in its connection graph node 0N/A // All nodes have been recorded, compute the escape information 0N/A // escape state of a node