Commit Graph

29894 Commits

Author SHA1 Message Date
David Rubin
09e9812086
riscv: vectors part 2 2024-07-14 23:02:34 -07:00
David Rubin
571aa694fd
riscv: vectors part 1 2024-07-14 23:02:34 -07:00
David Rubin
f2301ba896
simd: correct suggestVectorLength
* the file's doc-comment was misleading and did not focus on the correct aspect of SIMD

* added cpu flag awareness to `suggestVectorLengthForCpu` in order to provide a more accurate vector length
2024-07-14 23:02:33 -07:00
David Rubin
3e73f37d0a
riscv: implement @fence 2024-07-14 23:02:33 -07:00
David Rubin
7a02878f4e
riscv: truncate airStructFieldVal result 2024-07-14 23:02:33 -07:00
David Rubin
27ceb4ae37
riscv implement @sqrt for f32/f64 2024-07-14 23:02:32 -07:00
David Rubin
0460572899
riscv: @atomicRmw
Now we generate debug undefined constants when the user asks for them to dedup across the function decl. This takes 2 instructions instead of 7 in the RISC-V backend.

TODO, we need to dedupe across function decl boundaries.
2024-07-14 23:02:32 -07:00
David Rubin
ea084e9519
riscv: @atomicLoad and @atomicStore 2024-07-14 23:02:29 -07:00
Andrew Kelley
445bd7a06f build runner: update watch caption to include subprocesses 2024-07-14 22:27:51 -07:00
Andrew Kelley
987f63208e build runner: handle compiler subprocess failures gracefully
Compilation errors now report a failure on rebuilds triggered by file
system watches.

Compiler crashes now report failure correctly on rebuilds triggered by
file system watches.

The compiler subprocess is restarted if a broken pipe is encountered on
a rebuild.
2024-07-14 22:17:29 -07:00
Andrew Kelley
f6c1b71c22 build system: update std.Progress.Node for long-lived children 2024-07-14 21:38:55 -07:00
Andrew Kelley
f33395ce6a std.Progress: add getIpcFd and have_ipc API
This makes advanced use cases possible such as a long-lived child
process whose progress node gets re-attached to a different parent.
2024-07-14 21:38:16 -07:00
Andrew Kelley
716b128a24 frontend: add -fincremental, -fno-incremental flag
Remove --debug-incremental

This flag is also added to the build system. Importantly, this tells
Compile step whether or not to keep the compiler running between
rebuilds. It defaults off because it is currently crashing
zirUpdateRefs.
2024-07-14 21:18:09 -07:00
Andrew Kelley
abf8955951 make zig compiler processes live across rebuilds
Changes the `make` function signature to take an options struct, which
additionally includes `watch: bool`. I intentionally am not exposing
this information to configure phase logic.

Also adds global zig cache to the compiler cache prefixes.

Closes #20600
2024-07-14 19:51:16 -07:00
Andrew Kelley
d404d8a363
Merge pull request #20593 from jacobly0/more-races
InternPool: fix more races
2024-07-14 17:32:51 -07:00
bing
464537db62
std.crypto.ff: fix typo in montgomery boolean documentation (#20624) 2024-07-14 15:34:02 +02:00
Andrew Kelley
bd7b2cc4b4
Merge pull request #20620 from kcbanner/fixup_msvc_bootstrap
Fixes for bootrapping with MSVC
2024-07-13 22:42:04 -07:00
Krzysztof Wolicki
fba618a6c9 Fix handling of --save-exact=name in fetch 2024-07-13 22:39:53 -07:00
Ryan Liptak
d48251d0f0 ArgIteratorWindows.init: Take []const u16 slice instead of multi-item pointer
Now that we use the PEB to get the precise length of the command line string, there's no need for a multi-item pointer/sliceTo call. This provides a minor speedup:

    Benchmark 1 (153 runs): benchargv-before.exe
      measurement          mean ± σ            min … max           outliers         delta
      wall_time          32.7ms ±  429us    32.1ms … 36.9ms          1 ( 1%)        0%
      peak_rss           6.49MB ± 5.62KB    6.46MB … 6.49MB         14 ( 9%)        0%
    Benchmark 2 (157 runs): benchargv-after.exe
      measurement          mean ± σ            min … max           outliers         delta
      wall_time          31.9ms ±  236us    31.4ms … 32.7ms          4 ( 3%)        -  2.4% ±  0.2%
      peak_rss           6.49MB ± 4.77KB    6.46MB … 6.49MB         14 ( 9%)          +  0.0% ±  0.0%
2024-07-13 18:37:49 -07:00
Ryan Liptak
1a62cfffa7 Replace GetCommandLineW with PEB access, delete GetCommandLine bindings 2024-07-13 18:19:19 -07:00
Ryan Liptak
1418c8a5d4 ArgIteratorWindows: Store last emitted code unit instead of checking the last 6 emitted bytes
Previously, to ensure args were encoded as well-formed WTF-8 (i.e. no encoded surrogate pairs), the code unit would be encoded and then the last 6 emitted bytes would be checked to see if they were a surrogate pair, and this was done for any emitted code unit (although this was not necessary, it should have only been done when emitting a low surrogate).

After this commit, we still want to ensure well-formed WTF-8, but, to do so, the last emitted code point is stored, meaning we can just directly check that the last code unit is a high surrogate and the current code unit is a low surrogate to determine if we have a surrogate pair.

This provides some performance benefit over and above a "use the same strategy as before but only check when we're emitting a low surrogate" implementation:

    Benchmark 1 (111 runs): benchargv-master.exe
      measurement          mean ± σ            min … max           outliers         delta
      wall_time          45.2ms ±  532us    44.5ms … 49.4ms          2 ( 2%)        0%
      peak_rss           6.49MB ± 3.94KB    6.46MB … 6.49MB         10 ( 9%)        0%
    Benchmark 2 (154 runs): benchargv-storelast.exe
      measurement          mean ± σ            min … max           outliers         delta
      wall_time          32.6ms ±  293us    32.2ms … 34.2ms          8 ( 5%)        - 27.8% ±  0.2%
      peak_rss           6.49MB ± 5.15KB    6.46MB … 6.49MB         15 (10%)          -  0.0% ±  0.0%
    Benchmark 3 (131 runs): benchargv-onlylow.exe
      measurement          mean ± σ            min … max           outliers         delta
      wall_time          38.4ms ±  257us    37.9ms … 39.6ms          5 ( 4%)        - 15.1% ±  0.2%
      peak_rss           6.49MB ± 5.70KB    6.46MB … 6.49MB          9 ( 7%)          -  0.0% ±  0.0%
2024-07-13 18:19:19 -07:00
gooncreeper
ee6a52b40f
std.ArrayList.unusedCapacitySlice: Return unaligned slice (#20490) 2024-07-14 00:56:29 +00:00
Ryan Liptak
10914dc310 ArgIteratorWindows: Clarify buffer length comment 2024-07-13 17:48:08 -07:00
kcbanner
c318710653 zig.h: expand zig_msvc_atomic_load_ into version for relaxed, acquire, and seq_cst 2024-07-13 19:45:45 -04:00
Marc Tiehuis
944c6d40ce std.fmt.formatFloat: skip f80 round-trip tests on x86_64 windows 2024-07-14 11:19:34 +12:00
Harrison McCarty
8ff01f78f3 std.fmt.parseFloat: add f80 formatFloat support 2024-07-14 11:19:34 +12:00
kcbanner
373e53d7c5 Compile: Pass the default --zig-lib-dir along to child processes
main: print the self_exe_path when `findZigLibDirFromSelfExe` fails in all cases
2024-07-13 19:04:55 -04:00
Ryan Liptak
959d227d13 ArgIteratorWindows: Reduce allocated memory by parsing the WTF-16 string directly
Before this commit, the WTF-16 command line string would be converted to WTF-8 in `init`, and then a second buffer of the WTF-8 size + 1 would be allocated to store the parsed arguments. The converted WTF-8 command line would then be parsed and the relevant bytes would be copied into the argument buffer before being returned.

After this commit, only the WTF-8 size of the WTF-16 string is calculated (without conversion) which is then used to allocate the buffer for the parsed arguments. Parsing is then done on the WTF-16 slice directly, with the arguments being converted to WTF-8 on-the-fly.

This has a few (minor) benefits:

- Cuts the amount of memory allocated by ArgIteratorWindows in half (or better)
- Makes the total amount of memory allocated by ArgIteratorWindows predictable, since, before, the upfront `wtf16LeToWtf8Alloc` call could end up allocating more-memory-than-necessary temporarily due to its internal use of an ArrayList. Now, the amount of memory allocated is always exactly `calcWtf8Len(cmd_line) + 1`.
2024-07-13 14:48:17 -07:00
kcbanner
bc28454b43 zig.h: replace _InterlockedExchangeAdd with a plain volatile load
This was causing zig2.exe to crash during bootstrap, because there was an atomic
load of read-only memory, and the attempt to write to it as part of the (idempotent)
atomic exchange was invalid.

Aligned reads (of u32 / u64) are atomic on x86 / x64, so this is replaced with an
optimization-proof load (`__iso_volatile_load8*`) and a reordering barrier.
2024-07-13 17:46:24 -04:00
kcbanner
11534aa34d zcu: fixup incorrect pass-by-value of Zcu 2024-07-13 13:44:39 -07:00
Andrew Kelley
d8c1c9ea6e frontend: report correct paths for C objects
oops, the src_path field of CObject is not relative to the module
owner's root directory.
2024-07-13 02:13:03 -07:00
Jacob Young
ad55fb7a20 Compilation: restore saveState 2024-07-13 04:47:38 -04:00
Jacob Young
2ff49751aa Compilation: introduce work stages for better work distribution 2024-07-13 04:47:38 -04:00
Jacob Young
a1053e8e1d InternPool: add and use a mutate mutex for each list
This allows the mutate mutex to only be locked during actual grows,
which are rare. For the lists that didn't previously have a mutex, this
change has little effect since grows are rare and there is zero
contention on a mutex that is only ever locked by one thread.  This
change allows `extra` to be mutated without racing with a grow.
2024-07-13 04:47:38 -04:00
Jacob Young
d72a8db2db update zig1.wasm
This allows using atomics on packed structs in the compiler.
2024-07-13 04:47:38 -04:00
Jacob Young
9f8e4ddf25 Builder: fix llvm ir syntax 2024-07-13 04:04:14 -04:00
Krzysztof Wolicki
30ef0ed054 Args including and after -- get passed to build runner directly 2024-07-13 00:02:46 -07:00
Andrew Kelley
1d20ff11d7
Merge pull request #20580 from ziglang/watch
introduce file system watching features to the zig build system
2024-07-12 16:56:17 -07:00
Andrew Kelley
5efcc2e9e7 build runner: refactor fs watch logic for OS abstraction
Makes the build runner compile successfully for non-linux targets;
printing an error if you ask for --watch rather than making build
scripts fail to compile.
2024-07-12 14:20:20 -07:00
Andrew Kelley
f77b43dad3 zig build: add a --debug-target CLI flag
it's not advertised in the usage and only available in debug builds of
the compiler. Makes it easier to test changes to the build runner that
might affect targets differently.
2024-07-12 14:19:17 -07:00
Andrew Kelley
4f9a8b6843 update build system unit test
need to add another field to initialize now
2024-07-12 11:00:52 -07:00
xtex
0d79aa0176
std.Build.Step.Run: support prefixed artifact args
Just like how addPrefixedFileArg and addPrefixedDirectoryArg works, we can make it for artifacts.

Signed-off-by: Bingwu Zhang <xtexchooser@duck.com>
2024-07-12 11:06:06 +02:00
YANG Xudong
3bf0d2e516
std: Add loongarch support for coff. (#20583)
* std: Add loongarch support for coff.

See: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#machine-types

* Update toCoffMachine.
2024-07-12 00:47:32 -07:00
Tau
2b99b04285 Fix right shift on negative BigInts
Closes #17662.
2024-07-12 00:46:03 -07:00
Jacob Young
3ad81c40c0 Zcu: allow atomic operations on packed structs
Same validation rules as the backing integer would have.
2024-07-12 00:43:38 -07:00
Andrew Kelley
67e3e4989d Compilation: fix rebase conflict 2024-07-12 00:18:29 -07:00
Andrew Kelley
5a34e6c3e6 frontend: add file system inputs for incremental cache mode
These are also used for whole cache mode in the case that any compile
errors are emitted.
2024-07-12 00:15:11 -07:00
Andrew Kelley
a3c20dffae integrate Compile steps with file watching
Updates the build runner to unconditionally require a zig lib directory
parameter. This parameter is needed in order to correctly understand
file system inputs from zig compiler subprocesses, since they will refer
to "the zig lib directory", and the build runner needs to place file
system watches on directories in there.

The build runner's fanotify file watching implementation now accounts
for when two or more Cache.Path instances compare unequal but ultimately
refer to the same directory in the file system.

Breaking change: std.Build no longer has a zig_lib_dir field. Instead,
there is the Graph zig_lib_directory field, and individual Compile steps
can still have their zig lib directories overridden. I think this is
unlikely to break anyone's build in practice.

The compiler now sends a "file_system_inputs" message to the build
runner which shares the full set of files that were added to the cache
system with the build system, so that the build runner can watch
properly and redo the Compile step. This is implemented for whole cache
mode but not yet for incremental cache mode.
2024-07-12 00:14:08 -07:00
Andrew Kelley
fd4d366009 std.Build.Cache.Path: fix the format method
This function previously wrote a trailing directory separator, but
that's not correct if the path refers to a file.
2024-07-12 00:14:08 -07:00
Andrew Kelley
818f9cb5a0 std.Build.Step.ObjCopy: remove random bytes from cache hash
The cache hash already has the zig version in there, so it's not really
needed.
2024-07-12 00:14:08 -07:00