Commit Graph

24319 Commits

Author SHA1 Message Date
Andrew Kelley 4cd8a40b3b stage2: move float types to InternPool 2023-06-10 20:40:03 -07:00
Andrew Kelley aa1bb5517d InternPool: implement isSinglePointer 2023-06-10 20:40:03 -07:00
Andrew Kelley e77dede87e InternPool: implement typePtrOrOptionalPtrTy 2023-06-10 20:40:03 -07:00
Andrew Kelley 264292f430 InternPool: implement resolveTypeFields 2023-06-10 20:40:03 -07:00
Andrew Kelley cdf6acba96 InternPool: implement hasWellDefinedLayout for simple_type 2023-06-10 20:40:03 -07:00
Andrew Kelley d1887ab1dd InternPool: implement hasRuntimeBitsAdvanced for simple_type 2023-06-10 20:40:03 -07:00
Andrew Kelley b125063dcf InternPool: implement typeHasOnePossibleValue for simple_type 2023-06-10 20:40:03 -07:00
Andrew Kelley 50f33734c6 stage2: isGenericPoison InternPool awareness 2023-06-10 20:40:03 -07:00
Andrew Kelley 00f82f1c46 stage2: add interned AIR tag
This required additionally passing the `InternPool` into some AIR
methods.

Also, implement `Type.isNoReturn` for interned types.
2023-06-10 20:40:03 -07:00
Andrew Kelley c7e84ddb72 InternPool: flesh out some of the implementations
* hashing
 * equality
 * encoding
2023-06-10 20:40:03 -07:00
Andrew Kelley cac60a05a7 std.builtin: give some enums integer types 2023-06-10 20:40:03 -07:00
Andrew Kelley 9aec2758cc stage2: start the InternPool transition
Instead of doing everything at once which is a hopelessly large task,
this introduces a piecemeal transition that can be done in small
increments at a time.

This is a minimal changeset that keeps the compiler compiling. It only
uses the InternPool for a small set of types.

Behavior tests are not passing.

Air.Inst.Ref and Zir.Inst.Ref are separated into different enums but
compile-time verified to have the same fields in the same order.

The large set of changes is mainly to deal with the fact that most Type
and Value methods now require a Module to be passed in, so that the
InternPool object can be accessed.
2023-06-10 20:40:03 -07:00
mlugg 1e7dcaa3ae Sema: resolve peer vector types before comparison
Resolves: #15732
2023-06-10 21:41:49 +03:00
Jacob G-W c842deea75 os/plan9: fix order of register setting in syscall1
We need to set rbp last because the arguments are stored on the
stack. If we clobber rbp first, then we will get a segfault when
trying to access the function arguments.

I believe I had already done this with the other syscall* functions,
but not with syscall1, so this allows single argument syscalls like
close to work.
2023-06-10 11:36:32 +03:00
mlugg 34d44e0c1c Sema: emit error on @intToPtr with slice dest type
Resolves: #15967
2023-06-10 11:12:35 +03:00
mlugg bf4b43a2f7 AstGen: handle ref_table for params
This is kind of similar to 1a4b0d9. In this case, we need to handle
ref_table when appending the body of param instructions.

Resolves: #15952
2023-06-10 07:18:05 +03:00
Veikka Tuominen 2094d98694 Merge pull request #15980 from squeek502/walker-fixes
A few `IterableDir.Walker`/`Iterator` fixes
2023-06-10 05:09:34 +03:00
sentientwaffle f04e65bc09 std.hash_map: fetchRemove increment available
To avoid leaking slots, `fetchRemove` must increment `available` (when the "fetch" succeeds).

Without the `available += 1`, the added test `"std.hash_map repeat fetchRemove"` fails with

    run test std-x86-linux-none-Debug: error: thread 432734 panic: integer overflow
    .../zig/lib/std/hash_map.zig:1365:28: 0x6471d5 in getOrPutAssumeCapacityAdapted__anon_47495 (test)
            self.available -= 1;
                           ^
    .../zig/lib/std/hash_map.zig:1308:62: 0x616950 in getOrPutAssumeCapacityContext (test)
            const result = self.getOrPutAssumeCapacityAdapted(key, ctx);
                                                             ^

Alternatively, `fetchRemove` could call `removeByIndex`, though that would entail calling `header()` twice instead of once.
2023-06-10 02:24:35 +03:00
Loris Cro 99fe2a23c0 Merge pull request #15950 from der-teufel-programming/autodoc-quickfixes
autodoc: Fix rendering of some values in main.js
2023-06-09 09:35:45 -07:00
Ryan Liptak af835111fa Allow recovering from Walker.next errors without continually hitting the same error
Before this commit, if Walker.next errored with e.g. `error.AccessDenied` and the caller did something like `while (true) { walker.next() catch continue; }`, then the directory that errored with AccessDenied would be continually iterated in each `next` call and error every time with AccessDenied.

After this commit, the directory that errored will be popped off the stack before the error is returned, meaning that in the subsequent `next` call, it won't be retried and the Walker will continue with whatever directories remain on its stack.

For a real example, before this commit, walking `/proc/` on my system would infinitely loop due to repeated AccessDenied errors on the same directory. After this commit, I am able to walk `/proc/` on my system fully (skipping over any directories that are unable to be iterated).
2023-06-08 02:16:15 -07:00
Ryan Liptak 7555085e63 Directory iteration: handle EACCES returned from getdents64
This can occur for directories that the user does not have the necessary permissions to be able to iterate.
2023-06-08 02:16:15 -07:00
Ryan Liptak 2f188290e2 Use iterateAssumeFirstIteration in Walker.next to avoid unnecessary lseek calls
Since we are opening each directory for iteration, we know that we don't need to reset the cursor's directory before iterating. Using `iterateAssumeFirstIteration` skips the cursor resetting which eliminates an `lseek` syscall for every directory opened on non-Windows platforms.

This doesn't seem to actually matter much for performance (1.01 ± 0.02 times faster when walking /home/ on my system) but avoiding unnecessary syscalls is always nice anyway.
2023-06-08 02:16:15 -07:00
Marc Tiehuis 00ff653576 reimplement wyhash v4.1 (#15969) 2023-06-07 19:27:17 -07:00
Josh Wolfe cb7040154e std: fix parseInt for single-digit signed minInt (#15966) 2023-06-07 10:34:25 -04:00
David Gonzalez Martin c16d4ab9e4 llvm: stop generating FPU code if there is no FPU
Fixes https://github.com/ziglang/zig/issues/14465

For aarch64, LLVM was crashing because Zig commands it to generate FPU code
even when there is no FPU present. This commit implements the necessary checks
to avoid this undesired situation and aarch64 can be compiled again with
no FPU.
2023-06-06 18:30:56 +00:00
Frank Denis 9ee0a706da crypto.bcrypt: allow very large passwords to be pre-hashed (#15955)
crypto.bcrypt: allow very large passwords to be pre-hashed

bcrypt has a slightly annoying limitation: passwords are limited
to 72 characters. In the original implementation, additional characters
are silently ignored.

When they care, applications adopt different strategies to work around
this, in incompatible ways.

Ideally, large passwords should be pre-hashed using a hash function that
hinders GPU attackers, and the hashed function should not be deterministic
in order to defeat shucking attacks.

This change improves the developer experience by adding a very explicit
`silently_truncate_password` option, that can be set to `false` in
order to do that automatically, and consistently across Zig applications.

By default, passwords are still truncated, so this is not a breaking
change.

Add some inline documentation for our beloved autodoc by the way.
2023-06-06 09:08:57 +02:00
Jakub Konka 7e0a02ee25 macos+libc: add zlib.h,sys/paths.h,netinet/{ip.h,udp.h} 2023-06-04 16:37:53 +02:00
Krzysztof Wolicki ad6e106f52 autodoc: Fix rendering of some values in main.js 2023-06-04 11:05:53 +00:00
Andrew Kelley 629f0d23b5 Merge pull request #15579 from squeek502/mem-delimiters
Split `std.mem.split` and `tokenize` into `sequence`, `any`, and `scalar` versions
2023-06-03 13:51:02 -07:00
dweiller 3add9d8257 std.c: fix return type of recv/recvfrom on windows
Windows defines `recv` and `recvfrom` to return a value of type `int`,
rather than a pointer-sized signed integer, and so should use `c_int`
rather than `isize` for their return types.
2023-06-03 13:45:52 -07:00
xEgoist ff57a264ad Build: fix producesPdbFile logic (#15756)
Fixes bug causing ReleaseSmall to fail on Windows.

Due to the change in default behavior of ReleaseSmall, debug info are
stripped by default. However because `Compile.create` still defaults to
null, `producesPdbFile` will report true for
`lib/std/Build/Step/InstallArtifact.zig` causing it to fail on copying a
file that does not exist. This commit change the default of strip
depending on `optimize`.
2023-06-03 16:45:08 -04:00
DraagrenKirneh 105078519a fix missing insertion of module to all_modules on first download 2023-06-03 13:40:28 -07:00
Eric Joldasov 5c6f111379 std.io.reader.Reader: add streamUntilDelimiter
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-03 13:38:23 -07:00
mlugg 1a4b0d9790 AstGen: handle ref_table for errdefer captures
Resolves: #15861
2023-06-03 13:36:44 -07:00
Andrew Kelley 77b40d6ecb Merge pull request #15927 from truemedian/http-bugs
std.http: fix infinite read loop, deduplicate connection code, add TlsAlert errors
2023-06-03 13:36:07 -07:00
Andrew Kelley 9461ed5037 Merge pull request #15900 from Snektron/spirv-pool
SPIR-V Intern Pool
2023-06-02 12:17:02 -07:00
Frank Denis 879f0b9cee Fix std.hash benchmarks (#15917) 2023-06-02 20:08:28 +02:00
Nameless 23ccff9cce std.http.Server: collapse BufferedConnection into Connection 2023-06-01 13:44:00 -05:00
Nameless 0e5e6cb10c std.http: add TlsAlert descriptions so that they can at least be viewed in err return traces 2023-06-01 13:43:55 -05:00
Nameless 8136123aa7 std.http.Client: collapse BufferedConnection into Connection 2023-06-01 13:43:23 -05:00
Luuk de Gram 3faf376b08 Merge pull request #15919 from Luukdegram/wasm-behavior-tests 2023-06-01 19:42:04 +02:00
Evin Yulo 6c2f374556 Use the word 'base' consistently instead of 'radix' 2023-06-01 00:02:16 +03:00
Evin Yulo 3085e2af41 add missing note "operation is runtime due to this operand" 2023-05-31 19:18:36 +03:00
Luuk de Gram 1042deb86f enable passing behavior tests 2023-05-31 18:04:33 +02:00
Luuk de Gram ebfd3450d9 codegen: Write padding bytes for unions
Previously we did not write any missing padding bytes after the smallest
field (either tag or payload, depending on alignment). This resulted in
writing too few bytes and not matching the full abisize of the union.
2023-05-31 18:04:33 +02:00
Luuk de Gram 7e10cf4fbe wasm: shl_with_overflow ensure rhs is coerced
Both operands must have the same Wasm type before we are allowed
to perform any binary operation on the values.
2023-05-31 18:04:33 +02:00
Luuk de Gram e36cc0ce8f wasm: union_init support packed unions 2023-05-31 18:04:33 +02:00
Luuk de Gram 128814f9bf wasm: aggregate_init store sentinel for arrays 2023-05-31 18:04:32 +02:00
Luuk de Gram 969f921162 wasm: ptr_elem_val use pointer type for local
When storing the address after calculating the element's address,
ensure it's stored in a local with the correct type. Previously it
would incorrectly use the element's type, which could be a float for
example and therefore generate invalid WebAssembly code.

This change also introduces a more robust `store` function.
2023-05-31 18:04:32 +02:00
Luuk de Gram ffa89d3b83 wasm: UnwrapErrUnionPayloadPtr ensure ptr ret
When the paylaod is zero-sized we must ensure a valid pointer
is still returned for the ptr variation of the instruction. This,
because it's valid to have a pointer to a zero-sized value.
In such a case, we simply return the operand.
2023-05-31 18:04:32 +02:00