mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 20:39:05 +00:00
* `IncrementalGraph(.client).File` packs its fields in a specific way to save space, but it makes the struct hard to use and error-prone (e.g., untagged unions with tags stored in a separate `flags` struct). This PR changes `File` to have a human-readable layout, but adds methods to convert it to and from `File.Packed`, a packed version with the same space efficiency as before. * Reduce the need to pass the dev allocator to functions (e.g., `deinit`) by storing it as a struct field via the new `DevAllocator` type. This type has no overhead in release builds, or when `AllocationScope` is disabled. * Use owned pointers in `PackedMap`. * Use `bun.ptr.Shared` for `PackedMap` instead of the old `bun.ptr.RefPtr`. * Add `bun.ptr.ScopedOwned`, which is like `bun.ptr.Owned`, but can store an `AllocationScope`. No overhead in release builds or when `AllocationScope` is disabled. * Reduce redundant allocators in `BundleV2`. * Add owned pointer conversions to `MutableString`. * Make `AllocationScope` behave like a pointer, so it can be moved without invalidating allocations. This eliminates the need for self-references. * Change memory cost algorithm so it doesn't rely on “dedupe bits”. These bits used to take advantage of padding but there is now no padding in `PackedMap`. * Replace `VoidFieldTypes` with `useAllFields`; this eliminates the need for `voidFieldTypesDiscardHelper`. (For internal tracking: fixes STAB-1035, STAB-1036, STAB-1037, STAB-1038, STAB-1039, STAB-1040, STAB-1041, STAB-1042, STAB-1043, STAB-1044, STAB-1045) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
31 lines
1.3 KiB
Zig
31 lines
1.3 KiB
Zig
//! The `ptr` module contains smart pointer types that are used throughout Bun.
|
|
pub const Cow = @import("./ptr/Cow.zig").Cow;
|
|
|
|
pub const CowSlice = @import("./ptr/CowSlice.zig").CowSlice;
|
|
pub const CowSliceZ = @import("./ptr/CowSlice.zig").CowSliceZ;
|
|
pub const CowString = CowSlice(u8);
|
|
|
|
pub const owned = @import("./ptr/owned.zig");
|
|
pub const Owned = owned.Owned; // owned pointer allocated with default allocator
|
|
pub const DynamicOwned = owned.Dynamic; // owned pointer allocated with any allocator
|
|
pub const MaybeOwned = owned.maybe.MaybeOwned; // owned or borrowed pointer
|
|
pub const ScopedOwned = owned.scoped.ScopedOwned; // uses `AllocationScope`
|
|
|
|
pub const shared = @import("./ptr/shared.zig");
|
|
pub const Shared = shared.Shared;
|
|
pub const AtomicShared = shared.AtomicShared;
|
|
|
|
pub const ref_count = @import("./ptr/ref_count.zig");
|
|
/// Deprecated; use `Shared(*T)`.
|
|
pub const RefCount = ref_count.RefCount;
|
|
/// Deprecated; use `AtomicShared(*T)`.
|
|
pub const ThreadSafeRefCount = ref_count.ThreadSafeRefCount;
|
|
/// Deprecated; use `Shared(*T)`.
|
|
pub const RefPtr = ref_count.RefPtr;
|
|
|
|
pub const TaggedPointer = @import("./ptr/tagged_pointer.zig").TaggedPointer;
|
|
pub const TaggedPointerUnion = @import("./ptr/tagged_pointer.zig").TaggedPointerUnion;
|
|
|
|
/// Deprecated; use `Shared(*T).Weak`.
|
|
pub const WeakPtr = @import("./ptr/weak_ptr.zig").WeakPtr;
|