23824 Commits

Author SHA1 Message Date
Andrew Kelley
d65b42e07c
Merge pull request #15481 from ziglang/use-mem-intrinsics
actually use the new memory intrinsics
2023-04-29 00:19:55 -07:00
Andrew Kelley
fa200ca0ca update zig1.wasm
This is needed because bug fixes to the C backend are required in order
to actually update the standard library and compiler sources to use the
new `@memcpy` and `@memset` semantics.
2023-04-28 13:29:39 -07:00
Andrew Kelley
85ffb8f18f disable 2 failing behavior tests with x86 backend 2023-04-28 13:29:39 -07:00
Andrew Kelley
e3bb06a984 std.Build.RunStep: show test name on process termination
This is a small change to help when reading failure logs which makes the
"exited with code 1" and similar message include the test name.

Further enhancements could do the following:
 * even if one unit test crashes the process, the parent process
   continues running the other unit tests
 * ability to test for expected panics (#1356)
 * timeouts on individual tests
2023-04-28 13:29:39 -07:00
Andrew Kelley
fee318c44d Sema: fix airMemset for comptime slices 2023-04-28 13:24:43 -07:00
Andrew Kelley
6931f6c5be Sema: fix false negative Value.isComptimePtr for slices 2023-04-28 13:24:43 -07:00
Andrew Kelley
624c3069b4 std.os.windows: fix overlapping copy 2023-04-28 13:24:43 -07:00
Andrew Kelley
0794e48b91 update a couple more callsites to @memset 2023-04-28 13:24:43 -07:00
Andrew Kelley
cb9e8b0d01 C backend: take advantage of Assignment abstraction in airMemset 2023-04-28 13:24:43 -07:00
Andrew Kelley
42973d73e6 compiler: use @memcpy instead of std.mem.copy 2023-04-28 13:24:43 -07:00
Andrew Kelley
125221cce9 std: update to use @memcpy directly 2023-04-28 13:24:43 -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
6261c13731 update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
Andrew Kelley
57ea6207d3 std.ArrayList: mark the appendNTimes methods inline
The previous commit introduced an optimization to the LLVM backend that
makes `@memset` lower more optimally when the element is comptime-known
and has a repeating byte pattern.

By making these functions inline, if the element parameter is
comptime-known at the callsite, it will be comptime-known in the
`@memset` call, causing more use of the LLVM `memset` intrinsic rather
than an inline for loop when using the LLVM backend.

This affects, for example, std.crypto.argon2, which calls
appendNTimesAssumeCapacity with a `[128]u64` as the element. This is now
lowered with a single `memset` call.
2023-04-28 13:24:43 -07:00
Andrew Kelley
82fc360613 stage2: avoid panicking for unimplemented compiler code
Prevents the compiler from crashing when using `@memset` on extern
unions, for example.
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
36df2a83fc C backend: fix memset for structs and arrays 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
51adbf472b llvm backend: fix memset with byref element value 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
Jacob Young
8c52c6ec6c std: prevent the possibility of deadlocks in some threaded tests 2023-04-27 08:24:32 -07:00
Tw
131b328c10 translate-c: deduplicate global declaration
Fix #15456

Signed-off-by: Tw <weii.tan>
2023-04-27 11:13:16 +03:00
朕与将军解战袍
363269a2a9
fix incorrect struct definition 2023-04-27 11:10:38 +03: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
15dafd16e6 sema: add prev to ValueArena to allow freeing previous arenas when new ones are created during re-analysis
In semaDecl, it was possible for a new ArenaAllocators state to replace an existing one that
hadn't been freed yet. Instead of the ref_count (which was made redundant by adding
the allocator parameter to `release`), I now store a pointer to the previous arena, if one exists.

This allows a recursive deinit to happen when the last arena created is destroyed.
2023-04-27 01:11:57 -04: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
Andrew Kelley
396bd51c48 enable debugging infrastructure when using C backend
Thanks to @jacobly0's recent enhancements to the C backend, this stuff
works now.
2023-04-26 20:56:21 -07:00
Andrew Kelley
afbcad9939
Merge pull request #15452 from mlugg/zig-cbe-opt
CBE: minor optimizations to output source
2023-04-26 17:09:04 -07:00
Jakub Konka
f56054d129 coff: invalidate GOT relocs after segment shift in memory 2023-04-26 19:08:38 -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
eff0e6a726 x86_64: fix rem/mod behavior and hazards 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
Jacob Young
1f18b53589 x86_64: fix some floating point encoding errors 2023-04-26 19:05:17 -04:00
Jacob Young
26d4f9b69e x86_64: add frame indices
This allows abstract references to the stack frame which enables:
 * deferred frame layout until after the function has been processed
 * frame compaction (sorting by alignment)
 * being able to overalign the stack
 * references that change based on an overaligned stack
 * moving callee saved spills to the usual part (smaller code size)
 * shared call frame (avoids stack adjustments before and after calls)
2023-04-26 19:05:17 -04:00
Jan Philipp Hafer
f618398b24 compiler_rt: document ARM status
This commit documents the status of Run-time ABI 2022Q3 for ARM excluding
C++ helper functions.
2023-04-26 15:32:05 -07:00
Meghan
66da64d77c
std.http: fix name of Status field to better match RFC name (#15455)
.header_fields_too_large -> .request_header_fields_too_large
2023-04-26 14:02:55 -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
Loris Cro
d0311e28b3 autodoc: fix sidebar regression and other minor bugs 2023-04-26 18:20:41 +02:00
Loris Cro
b294bff1a8
Autodoc: new decl search system (#15475)
New search system is based on a Radix Tree. The Radix Tree contains a shallow list of all decl names (ie no paths), plus some suffixes, split by following the official style guide (eg "HashMapUnmanaged" also produces "MapUnmanaged" and "Unmanaged", same with snake_case and camelCase names).

Additionally, the search system uses the decl graph data to recognize hierarchical relationships between decls, allowing you to zero on a target namespace for search. As an example "fs create" will score highe all things related to the creation of files and directories inside of `std.fs`, while still showing (but with lower score) matches from `std.Bulild`. 

As another example "fs windows" will prioritize windows-related results in `std.fs`, while "windows fs" will prioritize fs-related results in `std.windows`.
2023-04-26 18:17:20 +02: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
Luuk de Gram
b26a46d05b
wasm: support pointers in cmpxchg 2023-04-26 16:28:41 +02:00
Luuk de Gram
7c09e09457
wasm: implement atomic stores 2023-04-26 16:28:41 +02:00
Luuk de Gram
0e3303ccd9
wasm: implement @fence
Uses the `atomic.fence` instruction for multi-thread-enabled builds
where the `atomics` feature is enabled for the wasm32 target.
In all other cases, this lowers to a nop.
2023-04-26 16:28:41 +02:00