Commit Graph

90 Commits (69b90e0681bb42980eeb8364e50686a1f9702eb5)

Author SHA1 Message Date
Sahnvour 987c209b40 heap: make one global instance of DirectAllocator
it is now stateless, so the de/init are not necessary anymore
2019-06-22 14:10:53 -04:00
daurnimator b0648bfbd3
std.heap.ArenaAllocator: use singly linked list 2019-06-10 15:41:40 +10:00
daurnimator ed41d10a06
std: existing LinkedList is actually a TailQueue 2019-06-10 15:41:40 +10:00
Andrew Kelley 129714d077
more fixes for windows and wasi 2019-05-27 01:35:58 -04:00
Andrew Kelley 6be79d79aa
fixes for Windows and WASI 2019-05-27 00:48:56 -04:00
Andrew Kelley 0c6ab61b22
tests passing on linux 2019-05-26 23:35:26 -04:00
Andrew Kelley 2b42e910bf
behavior tests passing on Linux 2019-05-26 19:56:37 -04:00
Andrew Kelley 2f040a23c8
clean up references to os 2019-05-26 18:32:44 -04:00
Andrew Kelley 7cb6279ac0
clean up references to posix 2019-05-26 18:32:44 -04:00
Shawn Landden 1fdb24827f
breaking changes to all bit manipulation intrinsics
* `@clz`, `@ctz`, `@popCount`, `@bswap`, `@bitreverse` now
   have a type parameter
 * rename @bitreverse to @bitReverse
 * rename @bswap to @byteSwap

Closes #2119
Closes #2120
2019-05-16 16:37:58 -04:00
Sahnvour cd537f822b Use unprotected heap when in single_threaded mode. 2019-05-11 16:41:13 +02:00
Sahnvour a2d5b0fabe Implement Windows' DirectAllocator on top of VirtualAlloc and VirtualFree. 2019-05-11 16:41:13 +02:00
Sahnvour d665948dcf Duplicate windows's DirectAllocator as HeapAllocator, which it is in reality. 2019-05-08 18:19:36 +02:00
Andrew Kelley 70a9ee3dd6
Merge branch 'stdlib-32b' of https://github.com/LemonBoy/zig into LemonBoy-stdlib-32b 2019-05-04 14:46:35 -04:00
LemonBoy b612512bb5 std: Remove some assumptions about the host platform
The stdlib is now 32-bit friendly.
2019-05-04 08:44:26 +02:00
Shritesh Bhattarai f86b8e4535 WasmAllocator: compileError on non-wasm arch 2019-05-03 16:21:33 -04:00
Andrew Kelley 4b6f350369
DirectAllocator: move if > 0 condition above @memcpy
Minor improvement to 3c13aa17 as noted by daurnimator
2019-04-29 13:48:15 -04:00
Shawn Landden 3c13aa178b std.heap: do not excessively call mmap, and munmap in direct allocator 2019-04-29 13:47:24 -04:00
Ryan Liptak afc33f00ee heap: fixup style of realloc memory copies 2019-04-25 13:41:19 -07:00
Ryan Liptak 57f545eed8 std.heap.DirectAllocator: reduce the amount of redundant memcpy calls on Windows
Previously the memory would be copied to a different aligned address in some cases where the old offset could have been used. This fixes it so that it will always try to use the old offset when possible, and only uses a different offset if the old one is truly invalid (not aligned or not enough space to store the alloc at the old offset).
2019-04-25 13:35:45 -07:00
Ryan Liptak 8ce130de3c Bump up FixedBufferAllocator test memory to account for new tests 2019-04-22 02:25:57 -07:00
Ryan Liptak b3598163df std.heap.DirectAllocator: Fix aligned reallocs on Windows 2019-04-22 02:20:01 -07:00
Ryan Liptak 66020856b2 fix heap allocators when shrinking an object but growing its alignment 2019-04-20 23:56:39 -07:00
tgschultz 22f5e5fd3e Fixes DirectAllocator Windows implementation to call HeapFree when new_size == 0 2019-04-20 14:04:09 -04:00
Ryan Liptak 1030cc97ca fix DirectAllocator not unmapping unused pages on large alignments
Fixes #2306
2019-04-20 02:21:42 -04:00
Andrew Kelley 4c03746926
Revert "DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory."
This reverts commit 71bb8cd537.

This broke the CI on Windows.
2019-04-16 19:11:37 -04:00
Andrew Kelley 52caf311bb
Merge pull request #2286 from shritesh/wasm_alloc
WasmAllocator: WebAssembly Memory Allocator
2019-04-16 13:27:56 -04:00
Shritesh Bhattarai 0c28a18d96 WasmAllocator: cleanup 2019-04-16 12:23:45 -05:00
Sahnvour 71bb8cd537 DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory. 2019-04-16 13:18:21 -04:00
Shritesh Bhattarai 4235982fe6 fmt wasm_allocator 2019-04-16 01:42:11 -05:00
Shritesh Bhattarai aa3f31ac0a wasm: add WasmAllocator 2019-04-16 01:40:16 -05:00
Shritesh Bhattarai f2119f9961 wasm: WasmAllocator that uses fixed 64kb pages 2019-04-15 21:21:46 -05:00
Andrew Kelley 01fb421031 fix regressions on Windows from previous commit 2019-03-15 18:57:07 -04:00
Andrew Kelley 9c13e9b7ed
breaking changes to std.mem.Allocator interface API
Before, allocator implementations had to provide `allocFn`,
`reallocFn`, and `freeFn`.

Now, they must provide only `reallocFn` and `shrinkFn`.
Reallocating from a zero length slice is allocation, and
shrinking to a zero length slice is freeing.

When the new memory size is less than or equal to the
previous allocation size, `reallocFn` now has the option
to return `error.OutOfMemory` to indicate that the allocator
would not be able to take advantage of the new size.

For more details see #1306. This commit closes #1306.

This commit paves the way to solving #2009.

This commit also introduces a memory leak to all coroutines.
There is an issue where a coroutine calls the function and it
frees its own stack frame, but then the return value of `shrinkFn`
is a slice, which is implemented as an sret struct. Writing to
the return pointer causes invalid memory write. We could work
around it by having a global helper function which has a void
return type and calling that instead. But instead this hack will
suffice until I rework coroutines to be non-allocating. Basically
coroutines are not supported right now until they are reworked as
in #1194.
2019-03-15 17:57:21 -04:00
Andrew Kelley d633dcd07a
remove the valgrind integration with std.mem.Allocator
See #1837
2019-03-11 13:34:51 -04:00
Andrew Kelley 5362ca204f
Merge branch 'valgrind' of https://github.com/daurnimator/zig into daurnimator-valgrind 2019-03-11 13:27:04 -04:00
Andrew Kelley e402455704
rename std lib files to new convention 2019-03-02 16:46:04 -05:00
daurnimator d68ae35c11
std: when a FixedBufferAllocator is initialised, set the buffer to undefined 2019-02-20 16:52:23 +11:00
Maya Rashish bc10382ec1 Add NetBSD support
Mostly picking the same paths as FreeBSD.
We need a little special handling for crt files, as netbsd uses its
own (and not GCC's) for those, with slightly different names.
2019-02-17 09:17:34 +02:00
Andrew Kelley c2db077574
std.debug.assert: remove special case for test builds
Previously, std.debug.assert would `@panic` in test builds,
if the assertion failed. Now, it's always `unreachable`.

This makes release mode test builds more accurately test
the actual code that will be run.

However this requires tests to call `std.testing.expect`
rather than `std.debug.assert` to make sure output is correct.

Here is the explanation of when to use either one, copied from
the assert doc comments:

Inside a test block, it is best to use the `std.testing` module
rather than assert, because assert may not detect a test failure
in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert
is the correct function to use.

closes #1304
2019-02-08 18:23:38 -05:00
John Schmidt be6d022257 Make ThreadSafeFixedBufferAllocator alias FixedBufferAllocator when --single-threaded
Fixes #1910
2019-02-07 23:21:37 -05:00
Andrew Kelley b1775ca168
thread local storage working for linux x86_64 2019-02-06 13:48:04 -05:00
Andrew Kelley dfbc063f79
`std.mem.Allocator.create` replaced with better API
`std.mem.Allocator.createOne` is renamed to `std.mem.Allocator.create`.

The problem with the previous API is that even after copy elision,
the initalization value passed as a parameter would always be a copy.
With the new API, once copy elision is done, initialization
functions can directly initialize allocated memory in place.

Related:
 * #1872
 * #1873
2019-02-03 16:13:28 -05:00
Andrew Kelley b883bc873d
breaking API changes to all readInt/writeInt functions & more
* add `@bswap` builtin function. See #767
 * comptime evaluation facilities are improved to be able to
   handle a `@ptrCast` with a backing array.
 * `@truncate` allows "truncating" a u0 value to any integer
   type, and the result is always comptime known to be `0`.
 * when specifying pointer alignment in a type expression,
   the alignment value of pointers which do not have addresses
   at runtime is ignored, and always has the default/ABI alignment
 * threw in a fix to freebsd/x86_64.zig to update syntax from
   language changes
 * some improvements are pending #863

closes #638
closes #1733

std lib API changes
 * io.InStream().readIntNe renamed to readIntNative
 * io.InStream().readIntLe renamed to readIntLittle
 * io.InStream().readIntBe renamed to readIntBig
 * introduced io.InStream().readIntForeign
 * io.InStream().readInt has parameter order changed
 * io.InStream().readVarInt has parameter order changed
 * io.InStream().writeIntNe renamed to writeIntNative
 * introduced io.InStream().writeIntForeign
 * io.InStream().writeIntLe renamed to writeIntLittle
 * io.InStream().writeIntBe renamed to writeIntBig
 * io.InStream().writeInt has parameter order changed
 * mem.readInt has different parameters and semantics
 * introduced mem.readIntNative
 * introduced mem.readIntForeign
 * mem.readIntBE renamed to mem.readIntBig and different API
 * mem.readIntLE renamed to mem.readIntLittle and different API
 * introduced mem.readIntSliceNative
 * introduced mem.readIntSliceForeign
 * introduced mem.readIntSliceLittle
 * introduced mem.readIntSliceBig
 * introduced mem.readIntSlice
 * mem.writeInt has different parameters and semantics
 * introduced mem.writeIntNative
 * introduced mem.writeIntForeign
 * mem.writeIntBE renamed to mem.readIntBig and different semantics
 * mem.writeIntLE renamed to mem.readIntLittle and different semantics
 * introduced mem.writeIntSliceForeign
 * introduced mem.writeIntSliceNative
 * introduced mem.writeIntSliceBig
 * introduced mem.writeIntSliceLittle
 * introduced mem.writeIntSlice
 * removed mem.endianSwapIfLe
 * removed mem.endianSwapIfBe
 * removed mem.endianSwapIf
 * added mem.littleToNative
 * added mem.bigToNative
 * added mem.toNative
 * added mem.nativeTo
 * added mem.nativeToLittle
 * added mem.nativeToBig
2018-12-12 20:35:04 -05:00
Andrew Kelley 9493738e54
Merge branch 'freebsd-up' of https://github.com/myfreeweb/zig into freebsd2 2018-11-19 17:24:41 -05:00
Jimmi Holst Christensen 8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00
Andrew Kelley 2b395d4ede
remove @minValue,@maxValue; add std.math.minInt,maxInt
closes #1466
closes #1476
2018-10-26 15:01:51 -04:00
Greg V 7a3f0a55d9 Add freebsd to more things 2018-10-20 15:15:01 +03:00
Jimmi Holst Christensen 378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00
Andrew Kelley c06a61e9bf
remove `this`. add `@This()`.
closes #1283
2018-09-13 16:34:33 -04:00