Commit Graph

6022 Commits

Author SHA1 Message Date
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
Andrew Kelley 931261752d rename a couple variables 2022-11-29 23:46:02 -07:00
Andrew Kelley e2e60f5ff9 std.heap.WasmAllocator: redo
The previous version had a fatal flaw: it did ensureCapacity(1) on the
freelist when allocating, but I neglected to consider that you could
free() twice in a row. Silly!

This strategy allocates an intrusive freelist node with every
allocation, big or small. It also does not have the problems with resize
because in this case we can push the upper areas of freed stuff into the
corresponding freelist.
2022-11-29 23:46:02 -07:00
Andrew Kelley 3dcea95ffe std.heap.WasmAllocator: implement resizing 2022-11-29 23:46:02 -07:00
Andrew Kelley d4a1ae474a std.heap.WasmAllocator: resize in place without force shrinking 2022-11-29 23:46:02 -07:00
Andrew Kelley 0c0c70ee82 std.heap.WasmAllocator: large allocations 2022-11-29 23:46:02 -07:00
Andrew Kelley 3ea04ed64c introduce std.heap.WasmAllocator
fast allocator for WebAssembly

eventually this is intended to be merged into
`std.heap.GeneralPurposeAllocator`
2022-11-29 23:46:02 -07:00
Andrew Kelley 9f8c19210b std.heap: extract PageAllocator, WasmPageAllocator 2022-11-29 23:46:02 -07:00
Andrew Kelley f466667888 stage2: fix crash on comptime lazy @ctz and @clz 2022-11-29 23:30:38 -07:00
Andrew Kelley ceb0a632cf std.mem.Allocator: allow shrink to fail
closes #13535
2022-11-29 23:30:38 -07:00
Andrew Kelley b8473ae7d3 Merge pull request #13693 from Vexu/safety
Safety panic improvements & some bug fixes
2022-11-29 19:59:55 -05:00
Jakub Konka 648579b330 libstd: skip problematic tests on aarch64-windows 2022-11-30 00:26:40 +01:00
Veikka Tuominen e60db701d1 Sema: add option to disable formatted panics
Closes #13174
2022-11-29 21:44:08 +02:00
Veikka Tuominen 17ff002bc0 Sema: improve safety panic for access of inactive union field 2022-11-29 21:44:08 +02:00
Jakub Konka 9d0ea0e3f1 arm: implement CPU feature detection by parsing system registers
Also add an incomplete table implementing instruction fusions according
to official optimisation programming manuals.
2022-11-29 19:24:42 +01:00
Jakub Konka 988fff260e windows: map CP 40xx registry values to system ID registers 2022-11-29 19:24:42 +01:00
Jakub Konka 152202da77 windows: if detecting CPU feature set and model fails, use generic with overrides 2022-11-29 19:24:42 +01:00
Veikka Tuominen 6337c04244 Sema: improve panic for slice start index being greater than end index
Closes #13689
2022-11-29 15:47:02 +02:00
Veikka Tuominen 34be5784a3 parser: disallow defer and variable declaration as else branch
Closes #13658
2022-11-29 15:47:02 +02:00
Jakub Konka d3b1cdf508 Merge pull request #13659 from ziglang/arm-win-cpu-features
windows: add native CPU and features detection for Armv8 chips
2022-11-28 21:36:56 +01:00
Ryan Liptak 4e078941d0 os.windows.OpenFile: Add USER_MAPPED_FILE as a possible error
Ran into this when using a program that uses CreateFileMapping and then trying to call `std.fs.createFile` on the mapped file. More info can be found here:

https://stackoverflow.com/questions/41844842/when-error-1224-error-user-mapped-file-occurs

Before:

```
error.Unexpected NTSTATUS=0xc0000243
C:\Users\Ryan\Programming\Zig\zig\lib\std\os\windows.zig:138:40: 0x7ff74e957466 in OpenFile (test.exe.obj)
        else => return unexpectedStatus(rc),
                                       ^
```

After:

```
FAIL (AccessDenied)
C:\Users\Ryan\Programming\Zig\zig\lib\std\os\windows.zig:137:30: 0x7ff7f5b776ea in OpenFile (test.exe.obj)
        .USER_MAPPED_FILE => return error.AccessDenied,
                             ^
```
2022-11-28 18:56:11 +01:00
zooster a27bfae036 std.Thread.Futex.PosixImpl.Address.from: fix alignment type
Fixes #13673
2022-11-28 18:49:33 +02:00
Jakub Konka 2528189101 windows: fix signature of kernel32.RegOpenKeyExW to use *HKEY 2022-11-28 17:09:03 +01:00
Jakub Konka 7bf12b1197 arm: move cpu model table into system/arm.zig
Now we can reuse the table between CPU model parsers on Linux and
Windows.

Use similar parsing structure for Windows as we do for Linux. On
Windows, we rely on two entries in the registry per CPU core:
`CP 4000` and `Identifier`. Collating the data from the two allows
us recreating most of the `/proc/cpuinfo` data natively on Windows.
Additionally, we still allow for overwriting any CPU features as flagged
by pulling the feature data embedded in `SharedUserData`.
2022-11-28 17:07:35 +01:00
Jakub Konka 7fbd2955fa windows: pull QWORD and SZ identifiers from registry in one syscall
At the same time, do not assume the values necessarily exist, and
use defaults as markers for the lack of keys in the registry.
2022-11-28 17:07:34 +01:00
Jakub Konka d64d7aaac7 windows: drive the registry helper with actual value set for reg entries 2022-11-28 17:07:34 +01:00
Jakub Konka 57bda6524b windows: make registry helper generic over value types 2022-11-28 17:07:34 +01:00
Jakub Konka 49ce86bddf windows: fix logic for pulling info for each core 2022-11-28 17:07:34 +01:00
Jakub Konka f348fbc024 windows: revert changes to definition of HKEY 2022-11-28 17:07:34 +01:00
Jakub Konka 7473ef98e9 windows: implement simplistic CPU model parser 2022-11-28 17:07:34 +01:00
Jakub Konka 7ea2c7fbcd windows: use RtlQueryRegistryValues to query reg in a single syscall 2022-11-28 17:07:34 +01:00
Jakub Konka 153afed877 windows: impl some primitives for getting registry keys 2022-11-28 17:07:34 +01:00
Jakub Konka e74b6f0a4b windows: detect couple more aarch64 CPU features 2022-11-28 17:07:34 +01:00
Jakub Konka 29aafdcd55 windows: detect native CPU features for aarch64 SoCs 2022-11-28 17:07:34 +01:00
Jakub Konka 6edf9127fe windows: add missing enum values for ProcessorFeatures enumeration 2022-11-28 17:07:34 +01:00
Jakub Konka 625415d738 windows: add zig impl of IsProcessorFeaturePresent syscall 2022-11-28 17:07:34 +01:00
Jakub Konka 1eac3c57ec windows: add processor feature enumeration 2022-11-28 17:07:33 +01:00
Jacob Young d9a51648e6 std.big.int.Mutable: fix set(@as(DoubleLimb, 0))
Previously, this would set len to 1 but fail to initialize any limbs.
2022-11-28 07:40:09 -05:00
notcancername f98aac9db4 document std.heap.StackFallbackAllocator 2022-11-28 14:31:57 +02:00
Andrew Kelley 3ae4931dc1 CLI: more careful resolution of paths
In general, we prefer compiler code to use relative paths based on open
directory handles because this is the most portable. However, sometimes
absolute paths are used, and sometimes relative paths are used that go
up a directory.

The recent improvements in 81d2135ca6
regressed the use case when an absolute path is used for the zig lib
directory mixed with a relative path used for the root source file. This
could happen when, for example, running the standard library tests, like
this:

stage3/bin/zig test ../lib/std/std.zig

This happened because the zig lib dir was inferred to be an absolute
directory based on the zig executable directory, while the root source
file was detected as a relative path. There was no common prefix and so
it was not determined that the std.zig file was inside the lib
directory.

This commit adds a function for resolving paths that preserves relative
path names while allowing absolute paths, and converting relative
upwards paths (e.g. "../foo") to absolute paths. This restores the
previous functionality while remaining compatible with systems such as
WASI that cannot deal with absolute paths.
2022-11-28 01:23:39 -05:00
Frank Denis 7411be3c9e std.crypto.edwards25519: add a rejectLowOrder() function (#13668)
Does what the name says: rejects generators of low-order groups.

`clearCofactor()` was previously used to do it, but for e.g.
cofactored signature verification, we don't need the result of an
actual multiplication. Only check that we didn't end up with a
low-order point, which is a faster operation.
2022-11-28 00:34:13 +01:00
bfredl 0196010b0c linux.bpf: expose map_get_next_key
Returning a bool allows to conveniently use it as the condition
of a while loop.

Also remove restriction that ST cannot be double-word.
While imm is only 32-bit, this value is extended into a 64-bit
memory location.
2022-11-27 02:07:49 -05:00
Igor Anić 87a14f2b03 stdlib: remove flaky test
fixes ziglang#13660
2022-11-27 01:46:06 -05:00
Andrew Kelley d5e41bf15b disable spuriously failing std lib test case
see tracking issue #13660
2022-11-26 14:54:56 -07:00
Cody Tapscott a0af3c7a19 std.os: Fix std.os.chdir for WASI
Test coverage was lacking for chdir() on WASI, allowing this to
regress.

This change makes os.chdir() compile again, and improves the test
logic to use our standard CWD support for WASI.
2022-11-26 22:06:15 +02:00
Matt Chudleigh f61c5f3f52 Bug fix: Prevent uninitialized parse nodes
If a parse node is reserved but never set the node remains
uninitialized and can crash tools doing a linear scan of the nodes
(like ZLS) when switching on the tag.
2022-11-26 18:06:39 +02:00
Andrew Kelley 30eb2a1753 Merge pull request #13627 from Vexu/tuple-decls
Implement tuple type declarations
2022-11-25 18:06:09 -05:00
Andrew Kelley 972c040241 Merge pull request #13611 from Snektron/spirv-assembler
spirv: assembler
2022-11-24 17:48:39 -05:00
Frank Denis feb806a212 std.crypto.ed25519 incremental signatures: hash the fallback noise (#13643)
If the noise parameter was null, we didn't use any noise at all.

We unconditionally generated random noise (`noise2`) but didn't use it.

Spotted by @cryptocode, thanks!
2022-11-24 12:13:37 +01:00
Andrew Kelley 1d7faf30f9 Merge pull request #13577 from ianic/issue-12877
stdlib: fix condition variable broadcast FutexImpl
2022-11-23 16:24:55 -05:00