6073 Commits

Author SHA1 Message Date
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
Andrew Kelley
fdbb0fb7b9
Merge pull request #13744 from Vexu/stage2-fixes
Improve error messages, fix dependency loops
2022-12-03 00:42:11 -05:00
Veikka Tuominen
0e38cc16d5 Sema: fix comparisons between lazy and runtime values
Closes #12498
2022-12-03 00:09:23 +02:00
Jakub Konka
5eaacf1ce9 windows: use array of tmp bufs as backing store for input memory to ntdll 2022-12-02 12:24:15 -05:00
Jakub Konka
2823fcabd1
Merge pull request #13725 from mathetake/fixreaddir
wasi: fixes IterableDir.nextWasi for large directory
2022-12-01 17:30:00 +01:00
Veikka Tuominen
b7066b6024 add workaround for compiler bug 2022-12-01 14:48:09 +02:00
Ryan Liptak
c37afa2811 std.testing: Improve expectEqualBytes for large inputs and make expectEqualSlices use it
`expectEqualBytes` will now truncate the hexdump of each input to a maximum window of 256 bytes, which makes it safe to use for arbitrarily large inputs. Therefore, it can be used in `expectEqualSlices` when the type is u8.
2022-12-01 02:18:51 -05:00
Takeshi Yoneda
829bf5a03e wasi: fixes IterableDir.nextWasi for large directory
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-12-01 13:56:53 +09:00
Andrew Kelley
a943422672
Merge pull request #13717 from GethDW/option-fix
std.build.Builder: fix for Allocator changes
2022-11-30 19:43:51 -05:00
Ryan Liptak
34fa6a1e04 std.testing: Add expectEqualBytes that outputs hexdumps with diffs highlighted in red
The coloring is controlled by `std.debug.detectTTYConfig` so it will be disabled when appropriate.
2022-11-30 18:57:37 -05:00
Andrew Kelley
16caea38d1 std.ArrayList: fix shrinkAndFree
Fixes a regression introduced in
e35f297aeb993ec956ae80379ddf7f86069e109b.

Now there is test coverage for ArrayList.shrinkAndFree in the case when
resizing fails.
2022-11-30 15:42:59 -07:00
Andrew Kelley
c84bc3a06b std.os.test: disable flaky timerfd test
See tracking issue #13721
2022-11-30 15:18:35 -07:00
Veikka Tuominen
34f96c5fd0
Merge pull request #13719 from Vexu/debug
Improve debuggability of programs built by the self hosted compiler
2022-11-30 22:51:39 +02:00
Andrew Kelley
abd9089aa6 std.build: simpler fix to options implementation
Instead of messing with ArrayList and more logic, just unwrap the error
of toOwnedSlice().
2022-11-30 13:22:04 -07:00
GethDW
747f64b3fb std.build.Builder: fix for Allocator changes 2022-11-30 13:04:32 -07:00
Andrew Kelley
44ee1c885f std.os.windows.ReadLink: add missing alignment of local data buffer 2022-11-30 12:55:23 -07:00
Veikka Tuominen
e4fd9acc2a CLI: allow using --debug-compile-errors with zig build 2022-11-30 19:14:04 +02:00
Andrew Kelley
7f063b2c52 WasmAllocator: simplify thanks to new Allocator interface
Now it can refuse to resize when it would disturb the metadata tracking
strategy, resulting in smaller code size, a simpler implementation, and
less fragmentation.
2022-11-29 23:46:02 -07:00