Add alignment feature flag

This commit is contained in:
Jarred Sumner
2023-05-07 01:04:38 -07:00
parent 25eecc3e07
commit 243847f992
3 changed files with 10 additions and 0 deletions

View File

@@ -166,3 +166,5 @@ pub const boundary_based_chunking = true;
/// https://github.com/mitsuhiko/source-map-rfc/blob/proposals/debug-id/proposals/debug-id.md
/// https://github.com/source-map/source-map-rfc/pull/20
pub const source_map_debug_id = true;
pub const alignment_tweak = true;

View File

@@ -79,6 +79,10 @@ const CAllocator = struct {
}
fn alloc(_: *anyopaque, len: usize, log2_align: u8, _: usize) ?[*]u8 {
if (comptime FeatureFlags.alignment_tweak) {
return alignedAlloc(len, log2_align);
}
const alignment = @as(usize, 1) << @intCast(Allocator.Log2Align, log2_align);
return alignedAlloc(len, alignment);
}

View File

@@ -230,6 +230,10 @@ pub const Arena = struct {
var this = bun.cast(*mimalloc.Heap, arena);
// if (comptime Environment.allow_assert)
// ArenaRegistry.assert(.{ .heap = this });
if (comptime FeatureFlags.alignment_tweak) {
return alignedAlloc(this, len, log2_align);
}
const alignment = @as(usize, 1) << @intCast(Allocator.Log2Align, log2_align);
return alignedAlloc(