38 Commits
Author SHA1 Message Date
Alexander Medvednikov fca9fad345 compiler: deprecate isize and usize in favor of int and uint (#31113) 2026-10-25 14:43:23 +03:00
Alexander Medvednikov 8fc0a2605e dlmalloc: fix mmap flags on macOS and the BSDs, and the broken bin paths (#30790)
The nix system allocator passed Linux's MAP_ANONYMOUS (0x20) on every
platform. On macOS and the BSDs MAP_ANON is 0x1000, so mmap got a file
mapping of fd -1, failed, and malloc always returned nil. It now uses
the C constants, as builtin/closure does. Trimming a segment on Linux
called mremap, which glibc declares only with _GNU_SOURCE, so clang and
gcc 14 rejected the generated C and V retried with V 0.5.2; it now
unmaps the tail with munmap on every system, as it did on macOS.

On Linux the port also diverged from upstream dlmalloc. left_bits was
written (x << 1) | (~(x << 1)) + 1, and since V gives | and + the same
precedence it was 0 for every input, so tmalloc_large never moved on to
a larger tree bin and the small-bin path disabled in #13120 read an
uninitialized bin. insert_large_chunk had the same trap in its child
index, putting every chunk under child[1], and tested the child slot's
address instead of its contents, so a second size in a tree bin
dereferenced nil. tmalloc_small started from the whole size of the
first chunk instead of its remainder, the disabled small-bin path gave
its remainder the request size, sys_alloc set a prepended segment's
size instead of growing it, add_segment compared a fencepost's contents
with the segment end instead of its address, and realloc did not free
the block it moved away from. With these fixed the small-bin path
matches upstream again and is enabled. The unused Chunk.prev() now
subtracts prev_foot.

The test checks left_bits, Chunk.prev and the tree descent directly,
and runs an allocate/write/realloc/free stress with pattern, overlap,
alignment and chunk header checks, over mmap and over an arena that
hands out regions above, below and away from the previous ones, so
every sys_alloc path runs on every platform.
2026-10-17 20:19:40 +03:00
Alexander Medvednikov 16d06d1e93 vlib: fix library bodies that no longer type-check (#30783)
The checker ignores errors in library bodies that no program code
calls, so these stayed hidden until a program reached them. A probe
that reports every library body error, run on every vlib module for
macOS, Linux, Windows and FreeBSD, found five.

v.mir: #30531 rewrote `typ.elem_type > 0` to `typ.elem_type_text() >
0`, which does not exist on ssa.Type, so mir.lower_from_ssa and
Module.type_size/type_align did not compile. Restore the comparison.

dlmalloc: `left_bits(1 << idx)` passed an int to a u32 parameter, so
every program calling dlmalloc.malloc failed to compile. Shift a u32
one instead.

sokol.sapp: the X11 drop list parser compared a char with rune
literals, so sapp's internal Linux test did not compile. Read the
characters as u8.

fasthttp: accept_loop stores its &Server parameter in each IocpConn,
which the checker rejects unless Server is @[heap], as it already is on
Linux and BSD. Mark the Windows Server @[heap] too, so a program that
calls Server.run directly compiles on Windows.

builtin.overflow: the __builtin_*_overflow declarations used the V1
`any` type, so the gcc/clang branches did not type-check. Declare them
as C variadic functions; the generated C is unchanged.

Add internal tests for v.mir and dlmalloc, which had none, so `v test`
type-checks every body of both modules from now on.
2026-10-17 18:41:37 +03:00
Alexander Medvednikov 58c7231793 all: vfmt 2026-09-17 10:47:56 +03:00
Alexander Medvednikov ee3ef57ffd json2: move module out of x and migrate vlib (#27759) 2026-07-13 18:53:00 +03:00
Alexander Medvednikov 0832a68bd7 all: fix add checker error when non-explicitly downcasting integers internally (fixes #23695) 2026-04-24 03:05:57 +03:00
Alexander Medvednikov e2e5cf8db5 all: super_batch3 fixes 2026-04-13 04:18:00 +03:00
kbkpbot a87a4d73b9 all: replace int with i32 in fn C.name(x int) int declarations (#26522) 2026-02-07 07:46:34 +02:00
Delyan Angelov b4b860cb1f tests: fix all warnings for v test-all on linux 2025-05-19 16:16:53 +03:00
Delyan Angelov 615e74d341 vlib: reduce false positive matches for /// , cleanup commented code 2025-03-08 17:47:13 +02:00
Noa Santo ae22bcfad9 dlmalloc: add missing public method doc comments (#23866) 2025-03-05 14:22:17 +02:00
yuyi e97036a25b v: remove the automatic passing of structs with more than 8 fields by reference (related #17159) (#22547) 2024-10-17 11:04:23 +03:00
yuyi 008aaad999 fmt: remove the prefixed module name of const names, that are in the same module (related #22183) (#22185) 2024-09-10 11:25:56 +03:00
yuyi c51d30bf53 fmt: fix alignment of struct init fields (#22025) 2024-08-11 09:11:24 +03:00
yuyi ddb6685d8a fmt: fix and simplify align of struct fields (#21995) 2024-08-05 20:23:39 +03:00
Delyan Angelov 0963069b98 dlmalloc: fix notice for ambiguous expression with both >> and & (#21539) 2024-05-21 01:56:54 +03:00
Delyan Angelov 6752ce8914 builtin,dlmalloc: fixes for v vlib/v/gen/c/coutput_test.v for gcc14.1, which is stricter 2024-05-19 17:18:48 +03:00
Turiiya 1a35a783f1 breaking,checker: disallow initializing private struct fields outside structs module (#21183) 2024-04-12 13:53:02 +03:00
Turiiya f77bb32044 all: fix typos (#21089) 2024-03-25 12:18:27 +02:00
Alexander Medvednikov f09826e928 all: unwrap const() blocks 2023-11-25 10:02:51 +03:00
Joe C 757929392e all: update attributes to use new syntax 2023-11-15 16:16:01 +11:00
yuyi 55ca8d8d8e fmt: align the custom values of the enum fields (#19331) 2023-09-12 14:44:38 +03:00
Delyan Angelov 5bb02b3dd7 tools: fix some noise in the output of v test-all 2023-08-03 23:19:14 +03:00
Swastik Baranwal 3d99f1f2c2 checker: disallow struct int to ptr outside unsafe (#17923) 2023-04-13 07:38:21 +02:00
Delyan Angelov 725456cde0 ci: fix warnings in v -cc gcc -keepc -freestanding -o bel vlib/os/bare/bare_example_linux.v 2023-01-06 14:55:01 +02:00
shove 8b962f8446 checker: fix nested struct reference type field initialized check. (fix: #15741) (#15752) 2022-09-15 07:59:31 +03:00
Delyan Angelov ed43bfc469 ci: fix dlmalloc again (workaround vfmt) 2022-07-21 21:21:20 +03:00
Delyan Angelov e29f6d1393 markused: fix ./v -skip-unused -cc gcc -keepc -freestanding -o bel vlib/os/bare/bare_example_linux.v 2022-07-21 21:18:33 +03:00
Delyan Angelov d9fe2edc41 ci: fix failing build-module-docs (because of unsafe { unsafe { nil } }) 2022-07-21 21:11:43 +03:00
Alexander Medvednikov 9099594a49 all: wrap up unsafe { nil } (p. 3) 2022-07-21 21:01:30 +03:00
Alexander Medvednikov caa0c2f153 vfmt: voidptr(0) => unsafe { nil } (p.1) 2022-07-21 20:46:01 +03:00
Delyan Angelov 5e0899853b dlmalloc: fix warning about fixed arrays of references, by using unsafe{} 2022-07-16 16:37:20 +03:00
yuyi c160ba2a8d checker: stricter mutable reference check (fix #14803) (#14805) 2022-06-21 13:23:21 +03:00
playX 65eb383cfd dlmalloc: add a temporary workaround for a segfault (#13120) 2022-01-10 15:54:23 +02:00
playX ac7e79ffd2 dlmalloc: fix WASM codegen bug (#13090) 2022-01-08 08:40:23 +02:00
playX 287331bc19 builtin: add builtin/wasm_bare (#13078) 2022-01-07 13:16:06 +02:00
playX ec91de3504 builtin: use dlmalloc for -freestanding (#13054) 2022-01-06 14:10:37 +02:00
playX 70a0aab72b vlib: add a dlmalloc module (#12974) 2022-01-05 18:17:47 +02:00