Skip to content

Perf main round2#21

Merged
wolfy-j merged 58 commits intomainfrom
perf-main-round2
Feb 21, 2026
Merged

Perf main round2#21
wolfy-j merged 58 commits intomainfrom
perf-main-round2

Conversation

@wolfy-j
Copy link
Contributor

@wolfy-j wolfy-j commented Feb 21, 2026

This pull request refactors and optimizes the binding and dominator analysis code in the compiler. The main themes are improved memory efficiency for symbol binding, more robust and scalable dominator computation, and enhanced API flexibility for binding table initialization. The changes include splitting local symbol storage for single/multi-name declarations, adding size hints for binding tables, memoizing captured symbols, and updating dominator computation to use slices and handle edge cases more safely.

Binding Table and Symbol Storage Improvements:

  • Split local symbol storage in BindingTable into localSymbolSingle (for single-name locals) and localSymbolsMulti (for multi-name locals), reducing memory allocations and simplifying access. Added new methods for setting, querying, and retrieving local symbols. [1] [2]
  • Added size hints to binding table initialization (NewBindingTableWithHint) and binder creation (NewBinderWithDeclHint), allowing more efficient map allocation for large functions. [1] [2]
  • Updated binder logic to use declaration count hints when binding functions, including recursive counting of declarations in statements and expressions.

API and Internal Consistency Enhancements:

  • Replaced usage of the old localSymbols map with the new split maps throughout binder logic, updating all relevant methods and usages. [1] [2] [3] [4] [5]
  • Updated tests to check initialization of new binding table fields.

Captured Symbol Memoization:

  • Added a thread-safe cache for captured symbols per function in BindingTable, improving performance for repeated queries. [1] [2] [3]

Dominator Analysis Refactoring:

  • Refactored dominator computation to use slices for point-indexed storage, added interface checks for optimized graph access, and improved robustness for edge cases (invalid points, empty graphs). [1] [2] [3] [4]
  • Replaced sort with slices.SortFunc for deterministic sorting of dominator tree children, and introduced new types for dense dominator info. [1] [2] [3]

These changes collectively make the binding and analysis phases more efficient, scalable, and maintainable (1200% perf imporovement).

@wolfy-j wolfy-j merged commit a2706e3 into main Feb 21, 2026
@wolfy-j wolfy-j deleted the perf-main-round2 branch March 3, 2026 22:15
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.

1 participant