32699 Commits

Author SHA1 Message Date
Andrew Kelley
c8e807c44e std.heap.GeneralPurposeAllocator: use for loops in leak check 2025-02-06 14:23:23 -08:00
Andrew Kelley
b14a350430 std.heap.GeneralPurposeAllocator: reduce page size to 512K
and fix compilation on 32-bit targets
2025-02-06 14:23:23 -08:00
Andrew Kelley
00b723dc9d std.heap.WasmAllocator: update to new Allocator API 2025-02-06 14:23:23 -08:00
Andrew Kelley
82b5a1d313 std.heap.GeneralPurposeAllocator: implement resize and remap 2025-02-06 14:23:23 -08:00
Andrew Kelley
0e0f0c9625 std.heap.GeneralPurposeAllocator: check canary in free 2025-02-06 14:23:23 -08:00
Andrew Kelley
8ff7481e82 std.heap.GeneralPurposeAllocator: inline small allocation metadata
Put the small allocation metadata directly into the (large) pages
allocated.
2025-02-06 14:23:23 -08:00
Andrew Kelley
1a6d87d699 std.heap.ThreadSafeAllocator: update to new Allocator API 2025-02-06 14:23:23 -08:00
Andrew Kelley
36e9b0f026 std.mem.Allocator: keep the undefined memset
Reversal on the decision: the Allocator interface is the correct place
for the memset to undefined because it allows Allocator implementations
to bypass the interface and use a backing allocator directly, skipping
the performance penalty of memsetting the entire allocation, which may
be very large, as well as having valuable zeroes on them.

closes #4298
2025-02-06 14:23:23 -08:00
Andrew Kelley
2c5113f6d1 std.os.linux.mmap: remove logic that does not belong here 2025-02-06 14:23:23 -08:00
Andrew Kelley
601f632c27 std.heap.GeneralPurposeAllocator: fix large alloc accounting
when mremap relocates an allocation
2025-02-06 14:23:23 -08:00
Andrew Kelley
becd16859d std.hash_map: placeholder for doc comments 2025-02-06 14:23:23 -08:00
Andrew Kelley
f1717777a2 std.heap: delete LoggingAllocator and friends
I don't think these belong in std, at least not in their current form.

If someone wants to add these back I'd like to review the patch before
it lands.

Reverts 629e2e784495dd8ac91493fa7bb11e1772698e42
2025-02-06 14:23:23 -08:00
Andrew Kelley
0d8166be3f std: update to new Allocator API 2025-02-06 14:23:23 -08:00
Andrew Kelley
a4d4e086c5 introduce std.posix.mremap and use it
in std.heap.page_allocator
2025-02-06 14:23:23 -08:00
Andrew Kelley
a0b2a18648 std.testing.FailingAllocator: flatten namespace 2025-02-06 14:23:23 -08:00
Andrew Kelley
7eeef5fb2b std.mem.Allocator: introduce remap function to the interface
This one changes the size of an allocation, allowing it to be relocated.
However, the implementation will still return `null` if it would be
equivalent to

new = alloc
memcpy(new, old)
free(old)

Mainly this prepares for taking advantage of `mremap` which I thought
would be a bigger deal but apparently is only available on Linux. Still,
we should use it on Linux.
2025-02-06 14:23:23 -08:00
Andrew Kelley
dd2fa4f75d std.heap.GeneralPurposeAllocator: runtime-known page size
no longer causes compilation failure.

This also addresses the problem of high map count causing OOM by
choosing a page size of 2MiB for most targets when the page_size_max is
smaller than this number.
2025-02-06 14:23:23 -08:00
Andrew Kelley
b23662feeb std.heap.WasmAllocator: use @splat syntax
preferred over array multiplication where possible.
2025-02-06 14:23:23 -08:00
Andrew Kelley
91f41bdc70 std.heap.PageAllocator: restore high alignment functionality
This allocator now supports alignments greater than page size, with the
same implementation as it used before.

This is a partial revert of ceb0a632cfd6a4eada6bd27bf6a3754e95dcac86.

It looks like VirtualAlloc2 has better solutions to this problem,
including features such as MEM_RESERVE_PLACEHOLDER and MEM_LARGE_PAGES.
This possibility can be investigated as a follow-up task.
2025-02-06 14:23:23 -08:00
Andrew Kelley
5c63884539 add std.mem.Alignment API 2025-02-06 14:23:23 -08:00
Andrew Kelley
4913de3c88 GeneralPurposeAllocator: minimal fix
This keeps the implementation matching master branch, however,
introduces a compile error that applications can work around by
explicitly setting page_size_max and page_size_min to match their
computer's settings, in the case that those values are not already
equal.

I plan to rework this allocator in a follow-up enhancement with the goal
of reducing total active memory mappings.
2025-02-06 14:23:23 -08:00
Andrew Kelley
95a0474dc6 revert GPA to before this branch 2025-02-06 14:23:23 -08:00
Andrew Kelley
284de7d957 adjust runtime page size APIs
* fix merge conflicts
* rename the declarations
* reword documentation
* extract FixedBufferAllocator to separate file
* take advantage of locals
* remove the assertion about max alignment in Allocator API, leaving it
  Allocator implementation defined
* fix non-inline function call in start logic

The GeneralPurposeAllocator implementation is totally broken because it
uses global state but I didn't address that in this commit.
2025-02-06 14:23:23 -08:00
Archbirdplus
439667be04 runtime page size detection
heap.zig: define new default page sizes
heap.zig: add min/max_page_size and their options
lib/std/c: add miscellaneous declarations
heap.zig: add pageSize() and its options
switch to new page sizes, especially in GPA/stdlib
mem.zig: remove page_size
2025-02-06 14:23:23 -08:00
Matthew Lugg
43e52ec5c5
Merge pull request #22777 from mlugg/some-bugs
Fix a bunch of frontend bugs
2025-02-06 22:19:25 +00:00
Jacob Young
6afc5770d3 wasm: disable failing tests 2025-02-06 17:02:54 -05:00
Jacob Young
c2718c4803 x86_64: rewrite float @mod 2025-02-06 16:14:53 -05:00
Jacob Young
288d3062d0 x86_64: avoid comparing different transcendental function impls 2025-02-06 16:14:53 -05:00
Jacob Young
96ed1a2b46 x86_64: remove cases that are impossible to lower 2025-02-06 16:14:53 -05:00
Jacob Young
fa9b0fa6d3 x86_64: rewrite most of the remaining float ops 2025-02-06 16:14:53 -05:00
Jacob Young
39119088f9 x86_64: rewrite vector @truncate 2025-02-06 16:14:53 -05:00
Jacob Young
c58e60a042 x86_64: rewrite scalar @truncate 2025-02-06 16:14:53 -05:00
Hugo Beauzée-Luyssen
edee702a7f
generic glibc: guard pidfd_spawn(p) declarations 2025-02-06 18:00:45 +01:00
Hugo Beauzée-Luyssen
9d85c79f2f
generic glibc: guard pidfd function declarations
They were introduced in 2.36 & 2.39
2025-02-06 18:00:44 +01:00
Hugo Beauzée-Luyssen
e716d13555
generic glibc: guard definitions of functions introduced in 2.36 2025-02-06 18:00:43 +01:00
Frank Denis
b0ed602d5d
crypto/phc-encoding: forbid parameters named 'v' (#22569)
The spec is ambiguous, and it's too late to change it.

So the most reasonable thing to do in order to avoid generating
strings that could be parsed differently by other implementations
is to forbid parameters named "v" at compile-time.

See https://github.com/P-H-C/phc-string-format/issues/8
2025-02-06 16:37:42 +01:00
John Benediktsson
1c07eacc7f std.process: adding hasNonEmptyEnvVar() and using for NO_COLOR 2025-02-06 15:00:48 +01:00
David Rubin
eb72f26e28
std.c: add HINT to macos MAP 2025-02-06 01:17:49 -08:00
Hugo Beauzée-Luyssen
5d2584e53e
generic glibc: guard statx declaration
It was added in glibc 2.28
2025-02-06 10:08:12 +01:00
Hugo Beauzée-Luyssen
fdef5c564d
generic glibc: guard close_range declaration
It is only available starting from glibc 2.34
2025-02-06 10:08:12 +01:00
mlugg
62e251dcaa incremental: codegen types which are recreated
Unfortunately, I can't easily add a test for this, because the repro
depends on some details of DWARF layout; but I've confirmed that it
fixes a bug repro on another branch.
2025-02-06 08:21:19 +00:00
mlugg
5d935e1137
behavior: add test for old bug
Resolves: #18435
2025-02-06 01:23:27 +00:00
mlugg
75ec7d863e
Sema: add missing validateRuntimeValue calls
Resolves: #13791
2025-02-06 01:11:10 +00:00
Alex Rønne Petersen
1a1389c513
Merge pull request #19614 from jedisct1/wasi-libc-update
Update wasi-libc to d03829489904d38c624f6de9983190f1e5e7c9c5
2025-02-06 02:10:08 +01:00
mlugg
164700740b
behavior: add test for old bug
Resolves: #13013
2025-02-06 00:52:03 +00:00
mlugg
6bd92a21b7
behavior: add test for old bug
Resolves: #2289
2025-02-06 00:51:59 +00:00
mlugg
b21becb2a6
incremental: fix crash when introducing syntax error
Clearing the analysis roots was very clever and all, but not actually
valid. We need to avoid *any* reference to the analysis errors if there
were any fatal files, and that includes sorting the errors!

Resolves: #22774
2025-02-05 22:00:55 +00:00
mlugg
3031d81387
Sema: fix @typeInfo of function with generic return type and IES
Resolves: #20088
2025-02-05 21:26:04 +00:00
mlugg
5317d88414
Sema: fix @errorCast with error unions
Resolves: #20169
2025-02-05 21:17:40 +00:00
mlugg
fbbf34e563
Sema: disable runtime safety checks in comptime blocks
Sometimes we emit runtime instructions in comptime scopes. These
instructions will be discarded, but they allow comptime blocks to
contain intermediate runtime-known values, which is necessary for
expressions like `runtime_array.len` to work.

Since we will always throw away these runtime instructions, including
safety checks is a time waste at best and trips an assertion at worst!

Resolves: #20064
2025-02-05 21:17:40 +00:00