zig/lib/std
mlugg 9c3670fc93
compiler: implement analysis-local comptime-mutable memory
This commit changes how we represent comptime-mutable memory
(`comptime var`) in the compiler in order to implement the intended
behavior that references to such memory can only exist at comptime.

It does *not* clean up the representation of mutable values, improve the
representation of comptime-known pointers, or fix the many bugs in the
comptime pointer access code. These will be future enhancements.

Comptime memory lives for the duration of a single Sema, and is not
permitted to escape that one analysis, either by becoming runtime-known
or by becoming comptime-known to other analyses. These restrictions mean
that we can represent comptime allocations not via Decl, but with state
local to Sema - specifically, the new `Sema.comptime_allocs` field. All
comptime-mutable allocations, as well as any comptime-known const allocs
containing references to such memory, live in here. This allows for
relatively fast checking of whether a value references any
comptime-mtuable memory, since we need only traverse values up to
pointers: pointers to Decls can never reference comptime-mutable memory,
and pointers into `Sema.comptime_allocs` always do.

This change exposed some faulty pointer access logic in `Value.zig`.
I've fixed the important cases, but there are some TODOs I've put in
which are definitely possible to hit with sufficiently esoteric code. I
plan to resolve these by auditing all direct accesses to pointers (most
of them ought to use Sema to perform the pointer access!), but for now
this is sufficient for all realistic code and to get tests passing.

This change eliminates `Zcu.tmp_hack_arena`, instead using the Sema
arena for comptime memory mutations, which is possible since comptime
memory is now local to the current Sema.

This change should allow `Decl` to store only an `InternPool.Index`
rather than a full-blown `ty: Type, val: Value`. This commit does not
perform this refactor.
2024-03-25 14:49:41 +00:00
..
Build Build.Cache: fix UAF during unhit 2024-03-24 18:28:16 +00:00
c fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
compress compress.xz: remove unnecessary variable 2024-03-13 18:43:36 +01:00
crypto Change std.os.exit to std.process.exit 2024-03-22 15:01:02 +02:00
dwarf extract std.posix from std.os 2024-03-19 11:45:09 -07:00
fmt fix comptime float formatting 2024-03-24 10:23:48 +02:00
fs std: promote tests to doctests 2024-03-21 14:11:46 -07:00
hash extract std.posix from std.os 2024-03-19 11:45:09 -07:00
heap extract std.posix from std.os 2024-03-19 11:45:09 -07:00
http extract std.posix from std.os 2024-03-19 11:45:09 -07:00
io std.io: remove BufferedTee 2024-03-20 21:05:35 -07:00
json std.json: update tests to match new floating point formatting 2024-03-09 17:03:05 +13:00
math Update frexp.zig (#19370) 2024-03-21 18:08:52 -04:00
mem mem: explicit dupe and dupeZ error on Allocator 2023-09-07 21:56:57 +03:00
meta std: promote tests to doctests 2024-03-21 14:11:46 -07:00
net std.net, std.http: simplify 2024-02-23 02:37:11 -07:00
os std: promote tests to doctests 2024-03-21 14:11:46 -07:00
posix extract std.posix from std.os 2024-03-19 11:45:09 -07:00
Random extract std.posix from std.os 2024-03-19 11:45:09 -07:00
sort lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
tar std.tar: use doctest 2024-03-11 12:25:03 +01:00
Target std.Target.Query: avoid using builtin.target.abi 2024-02-02 20:43:01 -07:00
testing std: enable FailingAllocator to fail on resize 2023-09-06 19:06:32 +03:00
Thread bsd: followup to std.posix extraction from std.os 2024-03-20 14:06:35 -07:00
time std: promote tests to doctests 2024-03-21 14:11:46 -07:00
tz
unicode
valgrind std: promote tests to doctests 2024-03-21 14:11:46 -07:00
zig compiler: implement analysis-local comptime-mutable memory 2024-03-25 14:49:41 +00:00
array_hash_map.zig std.array_hash_map: remove meta context verification 2024-03-21 19:40:56 -07:00
array_list.zig Remove redundant test name prefixes now that test names are fully qualified 2024-02-26 15:18:31 -08:00
ascii.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
atomic.zig bsd: debitrot AtomicOrder renames 2024-03-15 02:28:50 -04:00
base64.zig improve documentation in std 2024-03-10 18:13:30 -07:00
bit_set.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
BitStack.zig
bounded_array.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
buf_map.zig lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
buf_set.zig Change many test blocks to doctests/decltests 2024-02-26 15:18:31 -08:00
Build.zig std.Build.addTest: add doc comments 2024-03-21 14:02:58 -07:00
builtin.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00
c.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00
child_process.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
coff.zig lib/std/coff: add ImportHeader, and Relocation metadata 2024-03-22 15:12:11 +01:00
compress.zig improve documentation in std 2024-03-10 18:13:30 -07:00
comptime_string_map.zig Remove redundant test name prefixes now that test names are fully qualified 2024-02-26 15:18:31 -08:00
crypto.zig Merge pull request #19239 from jedisct1/ml-kem 2024-03-11 18:48:08 -07:00
debug.zig add std.debug.inValgrind 2024-03-21 14:35:08 -07:00
dwarf.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00
dynamic_library.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00
elf.zig improve documentation in std 2024-03-10 18:13:30 -07:00
enums.zig compiler: implement analysis-local comptime-mutable memory 2024-03-25 14:49:41 +00:00
fifo.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
fmt.zig compiler: implement analysis-local comptime-mutable memory 2024-03-25 14:49:41 +00:00
fs.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
gpu.zig std: add gpu namespace 2024-02-05 11:55:14 +03:30
hash.zig XXH3 Implementation for Zig STD (#17530) 2023-10-17 13:55:01 -05:00
hash_map.zig std.hash_map: fix pointer lock safety false positive 2024-03-20 17:14:52 -07:00
heap.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00
http.zig std.http.Server: expose arbitrary HTTP headers 2024-02-23 02:58:02 -07:00
Ini.zig
io.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
json.zig x86_64: pass more tests 2023-10-25 04:28:30 -04:00
leb128.zig Dwarf: improve x86_64 backend debug info 2023-11-12 03:21:52 -05:00
linked_list.zig Revert "std.SinglyLinkedList: add sort function" 2023-11-24 22:33:50 -07:00
log.zig Buffer the logging function 2024-02-09 14:02:57 -08:00
macho.zig std.macho: add segment flags 2024-01-24 12:48:12 +01:00
math.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
mem.zig std.mem.indexOfSentinel: valgrind integration 2024-03-21 15:01:57 -07:00
meta.zig compiler: implement analysis-local comptime-mutable memory 2024-03-25 14:49:41 +00:00
multi_array_list.zig std.builtin: make container layout fields lowercase 2024-03-11 07:09:07 -07:00
net.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00
once.zig std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
os.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
packed_int_array.zig std.builtin.Endian: make the tags lower case 2023-10-31 21:37:35 -04:00
pdb.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00
posix.zig std: don't do BYOS at the POSIX API layer 2024-03-20 00:38:44 -07:00
priority_dequeue.zig Remove redundant test name prefixes now that test names are fully qualified 2024-02-26 15:18:31 -08:00
priority_queue.zig Remove redundant test name prefixes now that test names are fully qualified 2024-02-26 15:18:31 -08:00
process.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
Progress.zig std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
Random.zig Fixup filename casing 2024-02-08 15:39:28 +01:00
RingBuffer.zig std.RingBuffer: use sliceAt/sliceFirst in read*AssumeLength 2024-03-10 18:17:23 +11:00
segmented_list.zig Remove redundant test name prefixes now that test names are fully qualified 2024-02-26 15:18:31 -08:00
SemanticVersion.zig Change many test blocks to doctests/decltests 2024-02-26 15:18:31 -08:00
simd.zig improve documentation in std 2024-03-10 18:13:30 -07:00
sort.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
start.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00
start_windows_tls.zig
std.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00
tar.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
Target.zig compiler: implement analysis-local comptime-mutable memory 2024-03-25 14:49:41 +00:00
testing.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
Thread.zig Merge pull request #19348 from jedisct1/wasi-threads-compfix 2024-03-21 15:13:15 -07:00
time.zig std: promote tests to doctests 2024-03-21 14:11:46 -07:00
treap.zig Remove redundant test name prefixes now that test names are fully qualified 2024-02-26 15:18:31 -08:00
tz.zig std.builtin.Endian: make the tags lower case 2023-10-31 21:37:35 -04:00
unicode.zig compiler: implement analysis-local comptime-mutable memory 2024-03-25 14:49:41 +00:00
Uri.zig http: fix fetching a github release 2024-02-26 20:11:43 -08:00
valgrind.zig Fix simple doc mistakes. (#17624) 2023-10-21 21:24:55 +00:00
wasm.zig Remove redundant test name prefixes now that test names are fully qualified 2024-02-26 15:18:31 -08:00
zig.zig extract std.posix from std.os 2024-03-19 11:45:09 -07:00