EscapeAnalysis

Version 1 by john.rose
on May 15, 2009 14:11.

compared with
Current by k_v_n
on May 15, 2009 17:04.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (28)

View page history
h3. Escape Analysis
_(To do: Format this nicely.)_

{noformat}
From: Vladimir Kozlov
Date: May 15, 2009 1:47:21 PM PDT
_C2 implemented implements the flow-insensitive escape analysis algorithm described in:
 
{noformat}
[Choi99] Jong-Deok Shoi, Manish Gupta, Mauricio Seffano,
Vugranam C. Sreedhar, Sam Midkiff,
"Escape Analysis for Java", Procedings of ACM SIGPLAN
OOPSLA Conference, November 1, 1999
{noformat}
 
The analysis requires construction of a "connection graph" (CG) for the method being analyzed. The nodes of the connection graph are:
the method being analyzed. The nodes of the connection graph are:
 
{noformat}
- Java objects (JO)
- Local variables (LV)
- Fields of an object (OF), these also include array elements
{noformat}
 
C2 does not have local variables. However for the purposes of constructing the connection graph, the following IR nodes are treated as local variables:
the connection graph, the following IR nodes are treated as local variables:
 
{noformat}
Phi (pointer values)
LoadP, LoadN
CheckCastPP, CastPP, EncodeP, DecodeN
Return (GlobalEscape)
{noformat}
 
The LoadP, Proj and CheckCastPP behave like variables assigned to only once. Only a Phi can have multiple assignments. Each input to a Phi is treated as an assignment to it.
Only a Phi can have multiple assignments. Each input to a Phi is treated
as an assignment to it.

The following node types are JavaObject:
{noformat}
top()
Allocate
LoadKlass, LoadNKlass (GlobalEscape)
ThreadLocal (ArgEscape)
{noformat}

AddP nodes are fields.
After building the graph, a pass is made over the nodes, deleting deferred nodes and copying the edges from the target of the deferred edge to the source. This results in a graph with no deferred edges, only:
nodes and copying the edges from the target of the deferred edge to the
source. This results in a graph with no deferred edges, only:
 
{noformat}
LV -P> JO
OF -P> JO (the object whose oop is stored in the field)
JO -F> OF
{noformat}
 
It After that escape analysis makes a pass over the nodes and determines nodes escape state:
 
GlobalEscape - An object escapes the method and thread
(stored into a static field or stored into
a field of an escaped object or returned
as the result of the current method).
* GlobalEscape - An object escapes the method and thread (stored into a static field or stored into a field of an escaped object or returned as the result of the current method).
* ArgEscape - An object passed as argument or referenced by argument but not globally escape during a call (by analyzing the bytecode of called method).
argument but not globally escape during a call
(by analyzing the bytecode of called method).
* NoEscape - A scalar replaceable object.
 
After escape analysis C2 eliminates scalar replaceable object allocations and associated locks. C2 also eliminates locks for all non globally escaping objects. C2 does NOT replace a heap allocation with a stack allocation for non globally escaping objects.
allocations and associated locks. C2 also eliminates locks for all
non globally escaping objects. C2 does NOT replace a heap allocation
with a stack allocation for non globally escaping objects.
{noformat}

The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact