5685 Commits

Author SHA1 Message Date
Andrew Kelley
85ffb8f18f disable 2 failing behavior tests with x86 backend 2023-04-28 13:29:39 -07:00
Andrew Kelley
73d3fb9883 C backend: fix ptr comparison of array ptrs when one is null-terminated 2023-04-28 13:24:43 -07:00
Andrew Kelley
a67dec1c9f disable not yet passing new behavior tests from this branch 2023-04-28 13:24:42 -07:00
Andrew Kelley
9295355985 LLVM backend: optimize memset with comptime-known element
When the element is comptime-known, we can check if it has a repeated
byte representation. In this case, `@memset` can be lowered with the
LLVM intrinsic rather than with a loop.
2023-04-28 13:24:42 -07:00
Andrew Kelley
00b690540e llvm backend: fix lowering of memset
The bitcast of ABI size 1 elements was problematic for some types.
2023-04-28 13:24:42 -07:00
Andrew Kelley
fd6200eda6
Merge pull request #15431 from kcbanner/fix_decl_value_arena
sema: Rework Decl.value_arena to fix another memory corruption issue
2023-04-28 11:43:57 -07:00
Andrew Kelley
011bc59e8a
Merge pull request #15435 from jacobly0/x86_64-frame
x86_64: add frame indices
2023-04-27 15:45:01 -07:00
Andrew Kelley
aa3405aabc
Merge pull request #15474 from Luukdegram/wasm-atomics
wasm: implement atomic instructions
2023-04-27 08:26:35 -07:00
xEgoist
1a455b2dd8 test: Fix windows_spawn tmp directory cleanup
On Windows, a directory that's set as the current working directory is
not allowed to be removed. This can cause error on `deleteTree` if the
CWD is set to the file to be removed and will cause `error.FileBusy`.
However, due to `tmp.cleanup()` ignoring the errors, the folder removal error will
be ignored. The only test violating this is `windows_spawn`. As a
solution, setting the parent directory to be the CWD before deletion
will allow the cleanup to pass.
2023-04-27 11:01:02 +03:00
kcbanner
2b592d7e3c sema: Rework Decl.value_arena to fix another memory corruption issue
This fixes a bug where resolveStructLayout to was promoting from stale
value_arena state which was then overwrriten when another ArenaAllocator
higher in the call stack saved its state back. This resulted in the memory
for struct_obj.optmized_order overlapping existing allocations.

My initial fix in c7067ef wasn't sufficient, as it only checked if the struct being
resolved had the same owner as the current sema instance. However, it's
possible for resolveStructLayout to be called when the sema instance
has a different owner, but the struct decl's value_arena is currently in
use higher up in the callstack.

This change introduces ValueArena, which holds the arena state as well as tracks
if an arena has already been promoted from it. This allows callers to use the
value_arena storage without needing to be aware of another user of this same storage
higher up in the call stack.
2023-04-27 01:11:57 -04:00
Jakub Konka
bc69d5a00f macho: invalidate GOT/stub relocs after segment shift in memory 2023-04-26 19:08:38 -04:00
Jacob Young
b5b0b55582 x86_64: fix tlv references 2023-04-26 19:05:17 -04:00
Jacob Young
a8842b6cbf cases: disable broken backends
Disable backends that don't support the new liveness format.
2023-04-26 19:05:17 -04:00
Jacob Young
894406b9d3 behavior: update passing cbe tests 2023-04-26 19:05:17 -04:00
Andrew Kelley
3c66850e42
Merge pull request #15278 from ziglang/memcpy-memset
change semantics of `@memcpy` and `@memset`
2023-04-26 10:01:54 -07:00
kcbanner
b55b8e7745 add support for .field_ptr in elemValueAdvanced
This fixes a crash when @compileLog is passed a slice backed by an aggregate field at comptime.
2023-04-26 17:31:42 +03:00
Casey Banner
bc4d9f3aa9
translate-c: fix codegen when C source has variables named the same as mangling prefixes
If the C code had variables that were named the same as the prefixes used
for name mangling, such as "tmp" or "ref", then the codegen would generate
incorrect code in some cases. This was because these aliases were immediately
visible to expressions that actually needed to use the original name.

I introduced the concept of reserving aliases without enabling them. An alias
that isn't enabled isn't visible to expression translation, but is still
reserved so that sub-expressions generate aliases that don't overlap.

Add test cases to cover the cases that would break before this change.

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-04-26 17:30:46 +03:00
Luuk de Gram
1d97181703
wasm: enable atomics behavior tests 2023-04-26 16:28:41 +02:00
Andrew Kelley
13101295b9
Merge pull request #15454 from jacobly0/cbe-extern
cbe: implement `@extern`
2023-04-25 23:48:03 -07:00
kcbanner
295b8ca467 sema: add error for coercing a slice to an anyopaque pointer 2023-04-26 00:53:09 +03:00
Andrew Kelley
1ba72bcf9a update test cases for new memcpy/memset semantics 2023-04-25 11:23:41 -07:00
Andrew Kelley
58fabbc903 x86_64 backend: support @memset with slices 2023-04-25 11:23:41 -07:00
Andrew Kelley
881e931ee1 x86_64 backend: implement @memset for element ABI size > 1
* make memset and memset_safe guarantee that if the length is
   comptime-known then it will be nonzero.
2023-04-25 11:23:41 -07:00
Andrew Kelley
7c56145a76 add behavior test for @memset on slices
and avoid new language feature in std.ArrayList for now, until x86_64
self-hosted backend can implement it.
2023-04-25 11:23:41 -07:00
Andrew Kelley
482a0f648c Sema: implement comptime @memcpy 2023-04-25 11:23:41 -07:00
Andrew Kelley
83a7303bbf Sema: implement comptime @memset 2023-04-25 11:23:41 -07:00
Andrew Kelley
057c950093 LLVM backend: support non-byte-sized memset
Also introduce memset_safe AIR tag and support it in C backend and LLVM
backend.
2023-04-25 11:23:41 -07:00
Andrew Kelley
a5c910adb6 change semantics of @memcpy and @memset
Now they use slices or array pointers with any element type instead of
requiring byte pointers.

This is a breaking enhancement to the language.

The safety check for overlapping pointers will be implemented in a
future commit.

closes #14040
2023-04-25 11:23:40 -07:00
Jacob Young
a1fcb51692 cbe: fix mutability issues with builtin test_functions 2023-04-25 13:42:10 -04:00
Andrew Kelley
a2fe81a639
Merge pull request #15421 from Vexu/fixes
Runtime safety improvements
2023-04-24 16:23:03 -07:00
Andrew Kelley
ef0a02081d
Merge pull request #15290 from mlugg/feat/builtin-in-comptime
Add `@inComptime` builtin
2023-04-24 12:54:12 -07:00
Andrew Kelley
dc94729643 CI: disable compiling std lib C backend test with clang
Unfortunately this requires about 8G of RAM for clang to compile
and our Windows CI runners do not have this much.
2023-04-24 11:58:45 -07:00
Andrew Kelley
39644fb277 Revert "tests: add a maxrss for compiling std lib C backend .c file"
This reverts commit c75e11bf6aa67f2ca62b9b6677d134592777bfec.

Caused this problem on some machines:
"this step declares an upper bound of 9126805504 bytes of memory,
exceeding the available 7515721728 bytes of memory".

Instead the next commit will disable std lib tests with the C backend on
Windows.
2023-04-24 11:51:46 -07:00
Ian Johnson
2be347a2c8 Sema: allow method calls on optional pointers 2023-04-24 09:35:54 +03:00
Andrew Kelley
c75e11bf6a tests: add a maxrss for compiling std lib C backend .c file
I observed clang taking 8G to compile the output from the std lib tests
using the C backend. This commit should make the Windows CI stop failing
due to OOM.
2023-04-23 22:24:13 -07:00
Andrew Kelley
2dbcc03fb8
Merge pull request #15405 from Luukdegram/wasm
wasm: implement more runtime safety checks
2023-04-23 15:39:36 -07:00
mlugg
35d82d31be Add @inComptime builtin
Resolves: #868
2023-04-23 13:16:42 -07:00
kcbanner
42ee364e7b translate-c: support brace-enclosed string initializers (c++20 9.4.2.1) 2023-04-23 21:45:08 +03:00
zooster
bc8e1e1de4
Improvements to docs and text
* docs(std.math): elaborate on difference between absCast and absInt

* docs(std.rand.Random.weightedIndex): elaborate on likelihood

I think this makes it easier to understand.

* langref: add small reminder

* docs(std.fs.path.extension): brevity

* docs(std.bit_set.StaticBitSet): mention the specific types

* std.debug.TTY: explain what purpose this struct serves

This should also make it clearer that this struct is not supposed to provide unrelated terminal manipulation functionality such as setting the cursor position or something because terminals are complicated and we should keep this struct simple and focused on debugging.

* langref(package listing): brevity

* langref: explain what exactly `threadlocal` causes to happen

* std.array_list: link between swapRemove and orderedRemove

Maybe this can serve as a TLDR and make it easier to decide.

* PrefetchOptions.locality: clarify docs that this is a range

This confused me previously and I thought I can only use either 0 or 3.

* fix typos and more

* std.builtin.CallingConvention: document some CCs

* langref: explain possibly cryptic names

I think it helps knowing what exactly these acronyms (@clz and @ctz) and
abbreviations (@popCount) mean.

* variadic function error: add missing preposition

* std.fmt.format docs: nicely hyphenate

* help menu: say what to optimize for

I think this is slightly more specific than just calling it
"optimizations". These are speed optimizations. I used the word
"performance" here.
2023-04-23 21:06:21 +03:00
Veikka Tuominen
f1e43d1f4f Sema: emit cast to null panics for function pointers
Closes #14676
2023-04-23 19:09:14 +03:00
Veikka Tuominen
c3b30a0fd0 enable passing test
Closes #12360
2023-04-23 12:29:58 +03:00
Luuk de Gram
27a41413f7
wasm: enable @intToError test 2023-04-22 21:16:23 +02:00
Andrew Kelley
21aa55d34e
Merge pull request #15356 from jacobly0/cbe-std-tests
cbe: enable CI for std tests
2023-04-22 11:04:36 -07:00
Borja Clemente
bd801dc489
std: GPA deinit return an enum instead of a bool 2023-04-22 14:09:44 +03:00
Jacob Young
d56c6c7791 cbe: implement 128-bit atomics support
* Disable 128-bit atomics for x86_64 generic (currently also baseline)
   because they require heavy abi agreement to correctly lower.
   ** This is a breaking change **
 * Enable 128-bit atomics for aarch64 in Sema since it just works.
2023-04-21 16:36:31 -04:00
Jacob Young
6b23a7b61a behavior: enable a bunch of disabled tests 2023-04-21 16:36:31 -04:00
Jacob Young
871d29b1a4 std: add more missing windows libraries when running tests 2023-04-21 16:36:31 -04:00
Jacob Young
ee9ef86d89 test: exclude the last warning from cbe tests 2023-04-21 16:36:31 -04:00
Jacob Young
a1ed4bd796 cbe: fix remaining aarch64 issues 2023-04-21 16:36:31 -04:00
Jacob Young
d98974e826 cbe: fix issues with atomic floats
Since the Zig language documentation claims support for `.Min` and
`.Max` in `@atomicRmw` with floats, allow in Sema and implement for both
the llvm and C backends.
2023-04-21 16:36:30 -04:00