Conversation
a3d9401 to
8824695
Compare
commit: |
🌿 Interactive Playground and Documentation PreviewA preview deployment has been built for this pull request. Try out the changes live in the interactive playground: 🌱 Grown from commit ✅ Preview deployment has been cleaned up. |
946680a to
85defcf
Compare
This was referenced Mar 4, 2026
marcoroth
added a commit
that referenced
this pull request
Mar 4, 2026
This pull request introduces arena allocation for the lexer and parser, replacing "per-object" `malloc`/`free` calls with bulk allocation from a memory arena. All allocated AST nodes, tokens, and internal strings are placed into a single arena that is freed in one shot after the parse tree has been converted to the binding's native objects. The arena is accessed through `hb_allocator_T`, a vtable-based allocator abstraction introduced in #1287. This pull request switches the default backend from `malloc` to `hb_arena_T` across all bindings and the CLI. The `malloc` backend remains available as a fallback. The intent is to validate the arena approach in production and then, once confident, simplify the abstraction away and use `hb_arena_T` directly. The `hb_allocator_T` interface was extended with a `destroy` function pointer and a high-level `hb_allocator_init(allocator, type)` constructor that takes an `hb_allocator_type_T` enum (`HB_ALLOCATOR_ARENA`, `HB_ALLOCATOR_MALLOC`). A separate `hb_allocator_init_with_size` variant accepts a custom initial arena size for edge cases. The default arena size is controlled by a compile-time `HB_ALLOCATOR_DEFAULT_ARENA_SIZE` flag. The extract API (`herb_extract`, `herb_extract_ruby_*`, `herb_extract_html_*`) was also updated to accept an `hb_allocator_T*`. Depends on #1287
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request extracts a
hb_allocator_Tfor providing an interface for allocating memory in the lexer and parser. In this pull request we implement both amalloc-based and ahb_arena_T-based allocator.Additionally, this updates all call-sites and functions to accept a new allocator that can later be swapped to use the
hb_arena_T-based allocator in #726.