-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change!: use arena allocation for AST, IR and interned strings
- Loading branch information
Showing
35 changed files
with
1,949 additions
and
2,235 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! Arena allocator. | ||
//! | ||
//! This modules provides [`Arena`], an arena allocator that can be used to | ||
//! allocate values in heap that will all be freed at once when the [`Arena`] | ||
//! object is dropped. | ||
/// Arena allocator. | ||
/// | ||
/// See the [module-level documentation](self) for more information. | ||
pub struct Arena { | ||
bump: bumpalo::Bump, | ||
} | ||
|
||
impl Default for Arena { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl Arena { | ||
pub fn new() -> Self { | ||
Self { | ||
bump: bumpalo::Bump::new(), | ||
} | ||
} | ||
|
||
pub fn alloc<T: Copy>(&self, value: T) -> &T { | ||
self.bump.alloc(value) | ||
} | ||
|
||
pub fn alloc_slice<T: Copy>(&self, slice: &[T]) -> &[T] { | ||
self.bump.alloc_slice_copy(slice) | ||
} | ||
|
||
pub fn alloc_str(&self, value: &str) -> &str { | ||
self.bump.alloc_str(value) | ||
} | ||
} |
Oops, something went wrong.