Skip to content

Add a reusable StringPool for interning strings#12536

Merged
fitzgen merged 4 commits into
bytecodealliance:mainfrom
fitzgen:string-pool
Feb 6, 2026
Merged

Add a reusable StringPool for interning strings#12536
fitzgen merged 4 commits into
bytecodealliance:mainfrom
fitzgen:string-pool

Conversation

@fitzgen

@fitzgen fitzgen commented Feb 5, 2026

Copy link
Copy Markdown
Member

And make sure it handles allocation failure.

Depends on #12534 and #12535

@fitzgen fitzgen requested review from a team as code owners February 5, 2026 21:18
@fitzgen fitzgen requested review from alexcrichton and removed request for a team February 5, 2026 21:18
}

impl TryClone for Atom {
fn try_clone(&self) -> core::result::Result<Self, OutOfMemory> {

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 can be just Result instead of core::result::Result I think?


/// Strings in this pool. These must never be mutated or reallocated once
/// inserted.
strings: Vec<String>,

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.

Perhaps Box<str> instead of String to further emphasize the lack of reallocation + mutation?

Comment on lines +24 to +26
/// A map from each string in this pool (as an unsafe borrow from
/// `self.strings`) to its `Atom`.
map: HashMap<&'static str, Atom>,

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.

Given the self-borrowing nature here, this I think would be a good use case for ManuallyDrop and the destructor documents-via-code that strings is destroyed after map

@github-actions github-actions Bot added fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself labels Feb 5, 2026
@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown

Subscribe to Label Action

cc @fitzgen

Details This issue or pull request has been labeled: "fuzzing", "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: fuzzing

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@fitzgen fitzgen added this pull request to the merge queue Feb 6, 2026
Merged via the queue into bytecodealliance:main with commit 0c673b7 Feb 6, 2026
45 checks passed
@fitzgen fitzgen deleted the string-pool branch February 6, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants