Skip to content

Research custom pointer implementation for boa gc#91

Merged
nekevss merged 3 commits into
boa-dev:mainfrom
shruti2522:custom-ptr
Jul 9, 2026
Merged

Research custom pointer implementation for boa gc#91
nekevss merged 3 commits into
boa-dev:mainfrom
shruti2522:custom-ptr

Conversation

@shruti2522

Copy link
Copy Markdown
Contributor

Related to #86

@shruti2522 shruti2522 changed the title Research custom pointer implementation for boa Research custom pointer implementation for boa gc Jun 17, 2026

@nekevss nekevss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty good write up. I'm actually super excited to see this concept in action. Can you extend it with some actual example code?

It would be worth attempting to create a new allocator that relies on a custom pointer and implement some level of heap serialization.


// private

// TODO(perf): O(n) scan; replace with a sorted index at scale.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this as a linear O(n) scan for the prototype since pools will be small. For production, we should probably replace this with a sorted index or a direct chunk map for O(1) lookups

}

// overflow guard
if slot_count as u64 > super::MAX_SLOT_IDX as u64 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added explicit guards against slot_count arithmetic overflows and corrupt live_count data here. Since we are reading raw bytes from disk, we might want to throw a fuzzer at this deserializer in a follow up PR

@nekevss nekevss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepting this as is, because I think the work here is interesting.

I'm not sure that the tradeoff of not being able to deref is worth it, so we may not continue much further down this route for now. I think a custom pointer type would still be incredibly useful but we may have to reevaluate how it may affect the API.

@nekevss nekevss merged commit 592903f into boa-dev:main Jul 9, 2026
4 checks passed
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