Use low alignment bits instead of truncating high pointer bits

Changed PackedNext implementation to preserve ARM TBI/PAC/MTE pointer metadata:
- Store full usize pointer with auto_delete flag in LOW alignment bit (not high bit)
- ConcurrentTask is 8-byte aligned (contains u64 Task), so low bit is guaranteed zero
- Use enum(usize) { zero = 0, _ } for type safety and clean initialization syntax
- All atomic operations use usize (instead of u64) with @intFromEnum/@enumFromInt
- Masks: AUTO_DELETE_MASK=0x1, POINTER_MASK=~0x1

Benefits:
- Preserves all high pointer metadata (ARM pointer authentication, tagging, etc.)
- Uses guaranteed-zero low alignment bits instead of truncating address space
- Type-safe enum wrapper prevents accidental misuse
- Clean .zero initialization syntax
This commit is contained in:
Claude Bot
2025-11-03 03:18:20 +00:00
parent 063a5a9775
commit bd90052694
5 changed files with 54 additions and 40 deletions

View File

@@ -27,7 +27,7 @@ export fn Bun__queueJSCDeferredWorkTaskConcurrently(jsc_vm: *VirtualMachine, tas
var loop = jsc_vm.eventLoop();
const concurrent_task = ConcurrentTask.new(.{
.task = Task.init(task),
.next = .{},
.next = .zero,
});
concurrent_task.next.setAutoDelete(true);
loop.enqueueTaskConcurrent(concurrent_task);