Escape Analysis #931
galderz
started this conversation in
Design discussions
Replies: 1 comment 4 replies
-
Very cool work, nice job @galderz!
Is there a way for other plugins to determine whether any given
Why is that? Wouldn't one of the previous rules account for any If the rules err on the side of deciding a value is non-escaping when it actually is, then the optimization will produce incorrect code and cannot be enabled.
What do the phantom nodes represent? The fact that a value has escaped? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Escape Analysis is implemented according to IBM's Stack Allocation and Synchronization Optimizations for Java Using Escape Analysis paper. The code follows the flow insensitive algorithm within the paper, which is the simplest version to implement.
The implementation works through the intra-method and inter-method analysis to build connection graphs representing allocations, connections to these, and their escape state. The possible values for escape state are: global, argument or not escape. Allocations that do not escape can be stack allocated:
Runnable
,ThreadGroup
andThread
, which are initially marked as global.The intra-method and inter-method analysis work this way:
I've added a visitor for producing connection graphs, which visualizes New instances and nodes that link to them. Along with colour coding to identify no, argument or global escaping nodes, it helps visualize the internal connection graph. Two sets of graphs are produced, one for each of the escape analysis phases: intra-method and inter-method (see paper for more details).
Escape analysis, and the related optimizations, are enabled by default. A command line flag is available,
--no-escape-analysis
, to disable it, e.g. useful when diagnosing problem root causes. The--gen-graph
flag has been enhanced to control generation of dot files for connection graphs.Future work:
Other options considered:
Beta Was this translation helpful? Give feedback.
All reactions