ワンクリックで
escape-analysis
Determine if objects escape their defining scope to enable stack allocation and optimization.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Determine if objects escape their defining scope to enable stack allocation and optimization.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Implement abstract machines for defining and executing operational semantics of programming languages.
Implements alias and points-to analysis for pointer programs. Use for: (1) Optimizing compilers, (2) Verifying memory safety, (3) Program understanding, (4) Parallelization.
Define program meaning through logical assertions and proof rules (Hoare logic).
Transforms closures to explicit environments. Use when: (1) Implementing functional languages, (2) Building compilers, (3) Understanding closures.
Implements common subexpression elimination (CSE). Use when: (1) Building compilers, (2) Optimizing code, (3) Program analysis.
Implements general dataflow analysis framework. Use when: (1) Building compilers, (2) Static analysis tools, (3) Program verification.
| name | escape-analysis |
| description | Determine if objects escape their defining scope to enable stack allocation and optimization. |
| version | 1.0.0 |
| tags | ["analysis","optimization","memory","oopsla"] |
| difficulty | advanced |
| languages | ["java","rust","python"] |
| dependencies | ["alias-and-points-to-analysis","interprocedural-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.
| 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 |
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| 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 |
| Approach | Pros | Cons |
|---|---|---|
| Intraprocedural | Fast | Misses interprocedural escapes |
| Interprocedural | More precise | Expensive |
| Flow-sensitive | Most precise | Very expensive |
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 |
✅ Good: Catches all escapes, enables significant optimization ⚠️ Warning: Conservative (many false positives) ❌ Bad: Misses escapes, causes runtime errors
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 |
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 |
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 |