6090 Commits

Author SHA1 Message Date
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
Andrew Kelley
4e2a960b52 std.fs: fix openDirAbsolute
These functions had a compile error since the introduction of
IterableDir.
2022-12-06 12:15:04 -07:00
Andrew Kelley
28514476ef remove -fstage1 option
After this commit, the self-hosted compiler does not offer the option to
use stage1 as a backend anymore.
2022-12-06 12:15:04 -07:00
Pyrolistical
bf316e5506 std: added eql to DynamicBitSet and DynamicBitSetUnmanaged 2022-12-06 21:09:33 +02:00
Frank Denis
397881fefb treshold -> threshold 2022-12-05 19:25:10 -05:00
Jason Phan
97827d6d38
std.fmt.formatInt: Use an optimized path for decimals
It enables faster decimal-to-string conversions for values in the range
[0, 100).
2022-12-05 22:58:45 +02:00
Pyrolistical
9e74e4c1f8 std: added pure functions to StaticBitSet
The following functions were added to both IntegerBitSet and ArrayBitSet:
fn eql(self: Self, other: Self) bool
fn subsetOf(self: Self, other: Self) bool
fn supersetOf(self: Self, other: Self) bool
fn complement(self: Self) Self
fn unionWith(self: Self, other: Self) Self
fn intersectWith(self: Self, other: Self) Self
fn xorWith(self: Self, other: Self) Self
fn differenceWith(self: Self, other: Self) Self
2022-12-05 21:06:10 +02:00
nc
a7cb5027ae std.atomic.Queue: fix unget implementation and add doc 2022-12-05 17:01:56 +02:00
Martin Wickham
b1c4227763 Allow const ArrayLists to be cloned 2022-12-05 04:36:10 -05:00
Frank Denis
4be1bb4aac
std.crypto benchmark: don't use a relative path to import std (#13772) 2022-12-05 04:44:14 +00:00
Andrew Kelley
954019983d std: add move() functions to hash maps 2022-12-04 15:57:40 -07:00
Veikka Tuominen
e361740669
Merge pull request #13142 from mllken/gzip-safety
gzip: add missing header fields and bounds for header parsing
2022-12-04 14:32:25 +02:00
Gregory Oakes
8d17e90fcd std: add a special case for empty structs in meta.FieldEnum.
Empty structs would previously result in a compilation error.
2022-12-04 14:22:16 +02:00