6102 Commits

Author SHA1 Message Date
Luuk de Gram
c6d654f73b
wasm: implement the 'splat' instruction part 1
This implements `airSplat` for the native WebAssembly backend when
the features 'simd128' or 'relaxed-simd' are enabled. The commit
supports splat where the value lives in the linear memory segment,
as well as on the stack. This saves a lot of instruction cost.
When it detects the element type is not 8, 16, 32 or 64 bits,
the backend will instead use the same strategy as if the features
where disabled.
2022-12-12 17:42:00 +01:00
Luuk de Gram
5a6b6992d8
std: Add Wasm SIMD opcodes and value type
This adds the opcodes for both the simd128 and relaxed-simd features.
Those instructions are required by the self-hosted WebAssembly
backend. Additionally, this also adds the new `v128` Valtype which
is required to represent a 128bit simd value. SIMD values that do
not have exactly 128 bits will be represented differently.
2022-12-12 17:41:56 +01:00
yujiri8
d36cd49f0b
zig fmt: remove c_void -> anyopaque rewrite
TODO comments said to remove this
2022-12-12 10:46:28 +01:00
Jan Philipp Hafer
8a27df5355 std.os.linux: fix timerfd test
Remove timerfd timeout and fix timerfd_settime flag.
CI tests should not rely on timings to succeed.

Closes #13721.
2022-12-12 10:58:54 +02:00
Ronald Chen
959c10c5e5 std: added std.mem.window 2022-12-12 07:07:56 +02:00
Ronald Chen
4d23721395 std: implement subsetOf and supersetOf for EnumMultiset 2022-12-12 06:23:56 +02:00
Ronald Chen
552ecc286a std: implement subsetOf and supersetOf for DynamicBitSet 2022-12-12 06:23:56 +02:00
Andrew Kelley
e3ef01c6c7 disable failing windows std lib tests
See tracking issues #13892 and #13893
2022-12-11 12:48:18 -07:00
Andrew Kelley
59bd296328 std.build.InstallRawStep: fix compilation on wasm32-wasi 2022-12-11 12:48:17 -07:00
Andrew Kelley
dd4ca88ca7 std: fix compile error bitrot
These were revealed in an earlier commit in this branch that removed a
workaround disabling Windows std lib files from being tested.
2022-12-11 12:48:17 -07:00
Andrew Kelley
d1ad126e34 std.build.OptionsStep: fix regressed tests 2022-12-11 12:48:17 -07:00
Andrew Kelley
dd547f06c6 std.build: extract steps to separate files
There are intended to be no functional changes in this commit.
2022-12-11 12:48:17 -07:00
Pyrolistical
cd9af0f286
std: add EnumMultiSet 2022-12-11 19:10:54 +02:00
Mikael Berthe
05890a12f5 std: Update ArrayList documentation
Calling `deinit` might still be required after using `toOwnedSlice` now.
2022-12-11 17:42:26 +02:00
Jakub Konka
0214d2d745 Remove incorrect assertion in readMachODebugInfo panicking during panic
This fixes a class of bugs on macOS where a segfault happening in
a loaded dylib with no debug info would cause a panic in the panic
handler instead of simply noting that the dylib has no valid debug
info via `error.MissingDebugInfo`. An example could be code linking
some system dylib and causing some routine to segfault on say invalid
pointer value, which should normally cause Zig to print an incomplete
stack trace anchored at the currently loaded image and backtrace all
the way back to the Zig binary with valid debug info. Currently, in
a situation like this we would trigger a panic within a panic.
2022-12-11 13:46:57 +01:00
Ronald Chen
a792e13fc0 std: added pure fns to EnumSet 2022-12-11 03:46:08 -05:00
Takeshi Yoneda
78ea270cc6
wasi: fixes os.isatty on type mismatch (#13813) 2022-12-11 03:44:38 -05:00
Andrew Kelley
f1f17dc1c7
Merge pull request #13810 from r00ster91/old
Re-enable many previously failing tests and add test coverage
2022-12-10 15:07:51 -05:00
Andrew Kelley
023b597ab4
Merge pull request #13370 from r00ster91/newascii
std.ascii: remove LUT and deprecations
2022-12-10 14:53:41 -05:00
Josh
a6a141bbe9 fix doc comments in bitset types 2022-12-10 14:32:24 -05:00
r00ster91
3370d58956 aarch64: reenable tests that are no longer regressed
Closes #12013
Closes #10627
Closes #12027
2022-12-10 12:34:34 +01:00
r00ster91
75f8c04d6d behavior: add test coverage for slicing zero length array field of struct
Closes #11787
2022-12-10 12:33:17 +01:00
Veikka Tuominen
9d93b2ccf1 Eliminate BoundFn type from the language
Closes #9484
2022-12-09 20:37:18 -07:00
r00ster91
a01993e908 std.fmt escape functions: reflect printability of space in test 2022-12-09 21:57:17 +01:00
r00ster91
45650f7003 std.ascii: more tests 2022-12-09 21:57:17 +01:00
r00ster91
0162a0868c isHex, isAlphanumeric: prong reorder
On x86 interestingly I can see a reduction in codesize by 1 instruction with this.
While not necessarily faster, it might still reduce codesize a bit and this ordering is also more logical
because it follows ASCII table order. Rust's std uses this ordering too.
See https://zig.godbolt.org/z/PqodY8YqY for the difference.
2022-12-09 21:57:17 +01:00
r00ster91
19dbc5805c fix(perf): remove LUT
This makes it so that we no longer use a LUT (Look-Up Table):
* The code is much simpler and easier to understand now.
* Using a LUT means we rely on a warm cache.
  Relying on the cache like this results in inconsistent performance and in many cases codegen will be worse.
  Also as @topolarity once pointed out, in some cases while it seems like the code may branch, it actually doesn't:
  https://github.com/ziglang/zig/pull/11629#issuecomment-1213641429
* Other languages' standard libraries don't do this either.
  JFF I wanted to see what other languages codegen compared to us now:
  https://rust.godbolt.org/z/Te4ax9Edf, https://zig.godbolt.org/z/nTbYedWKv
  So we are pretty much on par or better than other languages now.
2022-12-09 21:57:17 +01:00
r00ster91
626e02a429 docs: minor improvements 2022-12-09 21:57:17 +01:00
r00ster91
6b7d9b34e8 api(std.ascii): remove deprecated decls 2022-12-09 21:57:17 +01:00
Frank Denis
c49e4d534f
Improve and remove duplicate doNotOptimizeAway() implementations (#13790)
* Improve and remove duplicate doNotOptimizeAway() implementations

We currently have two doNotOptimizeAway() implementations, one in
std.math and the other one in std.mem.

Maybe we should deprecate one. In the meantime, the std.math one
now just calls the std.mem one.

In a comptime environment, just ignore the value. Previously,
std.mem.doNotOptimizeAway() did not work at comptime.

If the value fits in a CPU register, just tell the compiler we
need that value to be computed, without clobbering anything else.

Only clobber all possibly escaped memory on pointers or large arrays.

Add tests by the way since we didn't had any (we had, but only
indirect ones).
2022-12-09 18:22:50 +01:00
Ryan Liptak
71c82393eb std.testing: Fully absorb expectEqualBytes into expectEqualSlices
- In #13720, expectEqualBytes was added as a standalone function
- In #13723, expectEqualSlices was made to use expectEqualBytes when the type was u8
- In this commit, expectEqualSlices has fully absorbed expectEqualBytes, and expectEqualBytes itself has been removed

For non-`u8` types, expectEqualSlices will now work similarly to expectEqualBytes (highlighting diffs in red), but will use a full line for each index and therefore will only print a maximum of 16 indexes.
2022-12-09 04:36:27 -05:00
r00ster91
7826e28bd3 Re-apply: "std.ComptimeStringMap: use tuple types"
096d3efae5fcaa5640f4acb2f9be2d7f93f7fdb2 was not the cause of the
CI failure.
2022-12-08 22:21:46 +02:00
Andrew Kelley
225ed65ed2 Revert "std.ComptimeStringMap: use tuple types"
This reverts commit 096d3efae5fcaa5640f4acb2f9be2d7f93f7fdb2.

This commit is not passing a very important CI test that was recently
added.
2022-12-08 02:23:17 -08:00
Andrew Kelley
d69e97ae16
Merge pull request #13806 from Vexu/stage2-fixes
misc fixes and improvements
2022-12-07 21:35:02 -05:00
Veikka Tuominen
6039554b26 tokenizer: detect null bytes before EOF
Closes #13811
2022-12-08 00:16:30 +02:00
r00ster91
096d3efae5 std.ComptimeStringMap: use tuple types
This is now possible due to #13627.
2022-12-07 14:56:55 +02:00
Veikka Tuominen
92f1a29c40 AstGen: make @compileError operand implicitly comptime
This matches the language reference.
2022-12-07 14:48:24 +02:00
Andrew Kelley
53a9ee699a
Merge pull request #13799 from ziglang/close-stage1-issues
close stage1 issues
2022-12-07 03:06:10 -05:00
Frank Denis
14416b522e
Revert "std.crypto.aes: use software implementation in comptime context (#13792)" (#13798)
This reverts commit d4adf4420071397d993bac629a9da27b33c67ca3.

Unfortunately, this is not the right place to check if AES functions
are being used at comptime or not.
2022-12-07 03:49:20 +00:00
Andrew Kelley
50eb7983cd remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Andrew Kelley
b7b905d227 add behavior test for while(true) not needing else unreachable
closes #707
2022-12-06 17:57:27 -07:00
Andrew Kelley
e7d28344fa
Merge pull request #13560 from ziglang/wasi-bootstrap
Nuke the C++ implementation of Zig from orbit using WASI
2022-12-06 18:52:39 -05:00
Frank Denis
d4adf44200
std.crypto.aes: use software implementation in comptime context (#13792)
Hardware-accelerated AES requires inline assembly code, which
cannot work at comptime.
2022-12-06 22:48:19 +00:00
Andrew Kelley
823d1e7087 add std.heap.wasm_allocator 2022-12-06 12:27:28 -07:00
Andrew Kelley
e73170f972 std: fix WASI regressions
This branch largely reverts 58f961f4cb9875bbce3070969438ecf08f392c9f. I
would like to revisit the proposal to modify the standard library in
this way and think more carefully about it before adding isAbsolute()
checks everywhere.
2022-12-06 12:15:05 -07:00
Jacob Young
906120bc2c std.fmt: more descriptive names for impl functions
This is a workaround for a limitation of the C backend.
2022-12-06 12:15:04 -07:00
Andrew Kelley
9cb06f3b8b fix merge conflicts from master branch 2022-12-06 12:15:04 -07:00
Andrew Kelley
55ca43a04c std.wasm: add Opcode.prefixed and make PrefixedOpcode nonexhaustive 2022-12-06 12:15:04 -07:00
Andrew Kelley
6b0d773266 std: clean up imports in a couple files 2022-12-06 12:15:04 -07:00
Andrew Kelley
d5312d53a0 WASI: remove absolute path emulation from std lib
Instead of checking for absolute paths and current working directories
in various file system operations, there is one simple solution: allow
overriding `std.fs.cwd` on WASI.

os.realpath is back to causing a compile error when used on WASI. This
caused a compile error in the Sema handling of `@src()`. The compiler
should never call realpath, so the commit that made this change is
reverted (95ab942184427e7c9b840d71f4d093931e3e48fb). If this breaks
debug info, a different strategy is needed to solve it other than using
realpath.

I also removed the preopens code and replaced it with something much
simpler. There is no longer any global state in the standard library.

Additionally-
 * os.openat no longer does an unnecessary fstat on WASI when O.WRONLY
   is not provided.
 * os.chdir is back to causing a compile error on WASI.
2022-12-06 12:15:04 -07:00