authorgravatar for sahnvour@pm.meSahnvour <sahnvour@pm.me> 2019-05-08 18:14:35+02:00
committergravatar for sahnvour@pm.meSahnvour <sahnvour@pm.me> 2019-05-11 16:41:13+02:00
logcd537f822b0b60e00eff34c4e11c43f718705699
treebc81ed81420324b6184453cec452d5b9ed4aed57
parenta2d5b0fabe13d28075963e06b4bc6040888542af

Use unprotected heap when in single_threaded mode.


1 files changed, 2 insertions(+), 1 deletions(-)

std/heap.zig+2-1
...@@ -280,7 +280,8 @@ pub const HeapAllocator = switch (builtin.os) {...@@ -280,7 +280,8 @@ pub const HeapAllocator = switch (builtin.os) {
280 const amt = n + alignment + @sizeOf(usize);280 const amt = n + alignment + @sizeOf(usize);
281 const optional_heap_handle = @atomicLoad(?HeapHandle, &self.heap_handle, builtin.AtomicOrder.SeqCst);281 const optional_heap_handle = @atomicLoad(?HeapHandle, &self.heap_handle, builtin.AtomicOrder.SeqCst);
282 const heap_handle = optional_heap_handle orelse blk: {282 const heap_handle = optional_heap_handle orelse blk: {
283 const hh = os.windows.HeapCreate(0, amt, 0) orelse return error.OutOfMemory;283 const options = if (builtin.single_threaded) os.windows.HEAP_NO_SERIALIZE else 0;
284 const hh = os.windows.HeapCreate(options, amt, 0) orelse return error.OutOfMemory;
284 const other_hh = @cmpxchgStrong(?HeapHandle, &self.heap_handle, null, hh, builtin.AtomicOrder.SeqCst, builtin.AtomicOrder.SeqCst) orelse break :blk hh;285 const other_hh = @cmpxchgStrong(?HeapHandle, &self.heap_handle, null, hh, builtin.AtomicOrder.SeqCst, builtin.AtomicOrder.SeqCst) orelse break :blk hh;
285 _ = os.windows.HeapDestroy(hh);286 _ = os.windows.HeapDestroy(hh);
286 break :blk other_hh.?; // can't be null because of the cmpxchg287 break :blk other_hh.?; // can't be null because of the cmpxchg