diff options
author | 2023-05-07 01:04:38 -0700 | |
---|---|---|
committer | 2023-05-07 01:04:38 -0700 | |
commit | 243847f992c4e01aedcdd7a05f40d4be20cf8fa9 (patch) | |
tree | 2762a81d6638b26cacba7f7472e3db384e96d6fc | |
parent | 25eecc3e07531fd18a42fa809dc22050987449a5 (diff) | |
download | bun-243847f992c4e01aedcdd7a05f40d4be20cf8fa9.tar.gz bun-243847f992c4e01aedcdd7a05f40d4be20cf8fa9.tar.zst bun-243847f992c4e01aedcdd7a05f40d4be20cf8fa9.zip |
Add alignment feature flag
-rw-r--r-- | src/feature_flags.zig | 2 | ||||
-rw-r--r-- | src/memory_allocator.zig | 4 | ||||
-rw-r--r-- | src/mimalloc_arena.zig | 4 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/feature_flags.zig b/src/feature_flags.zig index c7a2f4819..dbc7914ea 100644 --- a/src/feature_flags.zig +++ b/src/feature_flags.zig @@ -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; diff --git a/src/memory_allocator.zig b/src/memory_allocator.zig index 0362f39c0..391446f5e 100644 --- a/src/memory_allocator.zig +++ b/src/memory_allocator.zig @@ -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); } diff --git a/src/mimalloc_arena.zig b/src/mimalloc_arena.zig index 23a9f4762..d0d0bbeab 100644 --- a/src/mimalloc_arena.zig +++ b/src/mimalloc_arena.zig @@ -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( |