escape-analysis
Skill17 starsChanged 9 months agoApache-2.0View on GitHub
Determine if objects escape their defining scope to enable stack allocation and optimization.
In this repository98 other files it gives its agents.
- abstract-interpretation-engineSkill
- abstract-machineSkill
- acsl-annotation-assistantSkill
- actor-model-implementerSkill
- algebraic-effectsSkill
- alias-and-points-to-analysisSkill
- axiomatic-semanticsSkill
- bidirectional-type-checkingSkill
- bisimulation-checkerSkill
- capability-systemSkill
- closure-converterSkill
- common-subexpression-eliminatorSkill
- concurrency-verifierSkill
- constant-propagation-passSkill
- contextual-equivalenceSkill
- control-flow-analysisSkill
- coq-proof-assistantSkill
- cps-transformerSkill
- dafny-verifierSkill
- dataflow-analysis-frameworkSkill
- dead-code-eliminatorSkill
- defunctionalizationSkill
- denotational-semantics-builderSkill
- dependent-type-implementerSkill
- dsl-embeddingSkill
- effect-handlers-implementerSkill
- effect-systemSkill
- effect-type-systemSkill
- existential-typesSkill
- ffi-designerSkill
- fuzzer-generatorSkill
- gadt-implementerSkill
- garbage-collector-implementerSkill
- graalvm-truffle-implementerSkill
- gradual-typing-implementerSkill
- higher-order-abstract-syntaxSkill
- hoare-logic-verifierSkill
- incremental-computationSkill
- information-flow-analyzerSkill
- inline-expanderSkill
- interprocedural-analysisSkill
- invariant-generatorSkill
- jit-compiler-builderSkill
- lambda-calculus-interpreterSkill
- language-server-protocolSkill
- lean-proverSkill
- lexer-generatorSkill
- linear-type-implementerSkill
- liveness-analysisSkill
- llvm-backend-generatorSkill
- lock-free-data-structureSkill
- loop-optimizerSkill
- loop-termination-proverSkill
- macro-expanderSkill
- memory-allocatorSkill
- message-passing-systemSkill
- mlir-dialect-designerSkill
- model-checkerSkill
- module-systemSkill
- monad-transformerSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
Lock Elision: Remove unnecessary synchronization
- Distinctive: line 43
Run after inlining for best results
- Distinctive: line 45
Use for lock elision in synchronized code
- Distinctive: line 47
Consider object size for stack allocation
- Distinctive: line 85
When allocation cost is negligible
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Escape Analysis
Escape analysis determines whether objects allocated in a method can be accessed outside that method. This enables optimizations like stack allocation, lock elision, and scalar replacement.
When to Use This Skill
- Optimizing memory allocation
- Eliminating unnecessary synchronization
- Enabling scalar replacement
- Building JIT compilers
- Reducing GC pressure
What This Skill Does
- Escape Detection: Identify objects that escape their scope
- Interprocedural Analysis: Track escapes through method calls
- Stack Allocation: Allocate non-escaping objects on stack
- Lock Elision: Remove unnecessary synchronization
- Scalar Replacement: Replace objects with scalar variables
Key Concepts
| Concept | Description |
| Escape | Object accessible outside its creating method |
| No Escape | Object stays local, can be stack-allocated |
| Arg Escape | Object escapes via method parameter |
| Global Escape | Object escapes via return or static field |
| Scalar Replacement | Replace object with individual fields |
Tips
- Run after inlining for best results
- Combine with points-to analysis for precision
- Use for lock elision in synchronized code
- Profile to identify optimization opportunities
- Consider object size for stack allocation
Common Use Cases
- Stack allocation optimization
- Lock elision (remove unnecessary synchronized)
- Scalar replacement of aggregates
- Reducing GC pressure
- JVM JIT optimization
Related Skills
alias-and-points-to-analysis- Foundation for points-to and alias analysisinterprocedural-analysis- Method-level analysisgarbage-collector-implementer- Uses escape infoinline-expander- Exposes more escape opportunities
Canonical References
| Reference | Why It Matters |
| Choi, Gupta, Serrano, Sreedhar, Midkiff, "Escape Analysis for Java" (OOPSLA 1999) | IBM connection graph approach |
| Blanchet, "Escape Analysis for Java: Theory and Practice" (TOPLAS 2003) | Formal correctness proof |
| Kotzmann et al., "Design of the Java HotSpot Client Compiler" (OOPSLA 2008) | Production implementation |
Tradeoffs and Limitations
Approach Tradeoffs
| Approach | Pros | Cons |
| Intraprocedural | Fast | Misses interprocedural escapes |
| Interprocedural | More precise | Expensive |
| Flow-sensitive | Most precise | Very expensive |
When NOT to Use This Skill
- Programs with minimal object allocation
- When allocation cost is negligible
- For single-use scripts
Limitations
- Requires whole-program analysis for full precision
- Reflection can cause unexpected escapes
- Native code can cause unknown escapes
Assessment Criteria
A high-quality implementation should have:
| Criterion | What to Look For |
| Soundness | Never miss an escape |
| Precision | Minimize false positives |
| Efficiency | Reasonable compile time |
| Optimization | Enable real speedups |
Quality Indicators
✅ Good: Catches all escapes, enables significant optimization ⚠️ Warning: Conservative (many false positives) ❌ Bad: Misses escapes, causes runtime errors
Research Tools & Artifacts
Real-world escape analysis implementations:
| Tool | Why It Matters |
| Java HotSpot | Production escape analysis in JVM |
| J9 JVM | IBM's JVM escape analysis |
| GraalVM | Truffle-based escape analysis |
| V8 | JavaScript escape analysis |
| CLR | .NET escape analysis |
Key Papers
- Choi et al.: Original escape analysis paper
- Blanchet: Escape analysis improvements
Research Frontiers
Current escape analysis research:
| Direction | Key Papers | Challenge |
| Concurrency | "Escape Analysis for Concurrency" | Thread escape |
| Partial escape | "Partial Escape Analysis" | Some fields escape |
| Escape in ML | "Escape Analysis for ML" | Functional escape |
Hot Topics
- Escape for parallelism: Enabling parallelism
- Escape for memory: Stack allocation decisions
Implementation Pitfalls
Common escape analysis bugs:
| Pitfall | Real Example | Prevention |
| Reflection | Class.forName escapes | Model reflection |
| Native | JNI causes escapes | Conservative |
| Threads | Thread.start escapes | Thread analysis |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

