Skip to content

Implement Kotzmann VEE'05 connection graph escape analysis for arrays#6

Draft
Copilot wants to merge 9 commits intomasterfrom
copilot/implement-escape-analysis-for-arrays
Draft

Implement Kotzmann VEE'05 connection graph escape analysis for arrays#6
Copilot wants to merge 9 commits intomasterfrom
copilot/implement-escape-analysis-for-arrays

Conversation

Copy link

Copilot AI commented Feb 4, 2026

Implements intraprocedural escape analysis following Kotzmann & Mössenböck's VEE'05 approach for array allocations in ZJIT HIR.

Changes

Three-level escape classification

  • NoEscape: Local-only (scalar replacement candidate)
  • ArgEscape: Returned/passed to callees (limited optimization)
  • GlobalEscape: Heap escape via ivars/globals (no optimization)

Connection graph implementation

  • Nodes track allocation sites with escape states
  • Points-to edges model array element relationships (ArrayAref/ArrayAset)
  • Phantom nodes handle unknown references conservatively
  • Fixed-point propagation (typically 2-5 iterations, max 100)

Analysis phases

  1. Build connection graph from array allocations
  2. Add edges: method calls→ArgEscape, ivar stores→GlobalEscape, returns→ArgEscape
  3. Propagate states through points-to relationships
  4. Extract final classifications

Integration with existing infrastructure

  • Leverages LocalArray effect for DCE of NoEscape arrays
  • Compatible with PatchPoint deoptimization
  • Returns HashMap<InsnId, EscapeState> for future optimizations

Example

// Array never leaves method - NoEscape
def local_only
  arr = [1, 2, 3]
  arr.length
end

// Array returned to caller - ArgEscape  
def returns_array
  [1, 2, 3]
end

// Array stored to heap - GlobalEscape
def stores_array
  @arr = [1, 2, 3]
end

Paper: https://www.usenix.org/legacy/events/vee05/full_papers/p111-kotzmann.pdf


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 4, 2026 03:18
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
… improve comments

Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add lightweight escape analysis for arrays in ZJIT HIR Implement lightweight escape analysis for arrays in ZJIT HIR Feb 4, 2026
Copilot AI requested a review from tekknolagi February 4, 2026 03:28
Copilot AI and others added 4 commits February 4, 2026 03:50
…n graphs

Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
…eoptimization docs

Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
…improve comments

Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Copilot AI changed the title Implement lightweight escape analysis for arrays in ZJIT HIR Implement Kotzmann VEE'05 connection graph escape analysis for arrays Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants