Andrew Kelley
8699cdc3df
InternPool: fix UAF in getCoercedInt and add u16 int value encoding
2023-06-10 20:42:29 -07:00
mlugg
2ffef605c7
Replace uses of Value.zero, Value.one, Value.negative_one
...
This is a bit nasty, mainly because Type.onePossibleValue is now
errorable, which is a quite viral change.
2023-06-10 20:42:29 -07:00
Andrew Kelley
4c3c605e5f
InternPool: add getCoercedInt to avoid copy in Sema
2023-06-10 20:42:29 -07:00
mlugg
c1ca16d779
wip: progress towards compiling tests
2023-06-10 20:42:29 -07:00
Andrew Kelley
9d9e1a2991
InternPool: implement indexToKey and equality for int values
2023-06-10 20:42:29 -07:00
Andrew Kelley
6c713b40f7
InternPool: add an encoding for arrays with sentinels
2023-06-10 20:42:29 -07:00
Andrew Kelley
75900ec1b5
stage2: move integer values to InternPool
2023-06-10 20:42:29 -07:00
Andrew Kelley
73720b6975
Sema: update onePossibleValue for InternPool
2023-06-10 20:42:29 -07:00
Andrew Kelley
f7bd42785b
LLVM backend: update integer constant lowering for InternPool
2023-06-10 20:42:29 -07:00
Andrew Kelley
27d641eb35
stage2: fix interned integer value printing
2023-06-10 20:42:29 -07:00
Andrew Kelley
6350aabf9d
InternPool: fix bug in addLimbsExtraAssumeCapacity
2023-06-10 20:42:29 -07:00
Andrew Kelley
9626811725
Sema: add typeHasOnePossibleValue logic for InternPool
2023-06-10 20:42:29 -07:00
Andrew Kelley
31aee50c1a
InternPool: add a slice encoding
...
This uses the data field to reference its pointer field type, which
allows for efficient and infallible access of a slice type's pointer
type.
2023-06-10 20:42:29 -07:00
Andrew Kelley
08e9763951
stage2: add missing comptimeOnly logic for InternPool
2023-06-10 20:42:28 -07:00
Andrew Kelley
80bf5af345
fix AIR printing of interned constants
2023-06-10 20:42:28 -07:00
Andrew Kelley
3e6dd0da7a
stage2: add tmp_hack_arena for the InternPool transition
...
Temporarily used for some unfortunate allocations made by backends that
need to construct pointer types that can't be represented by the
InternPool. Once all types are migrated to be stored in the InternPool,
this can be removed.
2023-06-10 20:42:28 -07:00
Andrew Kelley
ce3cffbd5a
fill out more InternPool Type methods
...
particularly, printing types
2023-06-10 20:42:28 -07:00
Andrew Kelley
0471638734
InternPool: add a dump function
...
So we can see stats
2023-06-10 20:42:28 -07:00
Andrew Kelley
9ec0017f46
stage2: migrate many pointer types to the InternPool
2023-06-10 20:42:28 -07:00
Andrew Kelley
70a4b76aca
std.builtin.AddressSpace: allocate one more bit to this enum
2023-06-10 20:42:28 -07:00
Andrew Kelley
2f05b1482a
Sema: update core comptime detection logic to be InternPool aware
...
* Add some assertions to make sure instructions are not none. I tested
all these with master branch as well and made sure the behavior tests
still passed with the assertions intact (along with a handful of
callsite updates).
* Fix Sema.resolveMaybeUndefValAllowVariablesMaybeRuntime not noticing
that interned values are comptime-known. This was causing all kinds
of chaos.
* Fix print_air writeType calling tag() without checking for ip_index
2023-06-10 20:42:28 -07:00
Andrew Kelley
ac07ddadeb
InternPool: enhance integer values
...
The Key struct now has a Storage tagged union which can store a u64,
i64, or big int.
This is needed so that indexToKey can be implemented for integers stored
compactly in the data structure.
2023-06-10 20:42:28 -07:00
Andrew Kelley
75cf06c187
std.mem.alignForwardGeneric: manually inline the assertions
...
This matches more directly the documentation comments, and makes it more
obvious what went wrong when an assertion fails.
2023-06-10 20:42:28 -07:00
Andrew Kelley
41cdcd5486
stage2: add a few more Value checks for InternPool
2023-06-10 20:42:28 -07:00
Andrew Kelley
6ab8b6f8b2
stage2: move undef, unreach, null values to InternPool
2023-06-10 20:42:28 -07:00
Andrew Kelley
773fabf361
InternPool: add the missing pointer data
2023-06-10 20:42:28 -07:00
Andrew Kelley
5e636643d2
stage2: move many Type encodings to InternPool
...
Notably, `vector`.
Additionally, all alternate encodings of `pointer`, `optional`, and
`array`.
2023-06-10 20:42:27 -07:00
Andrew Kelley
9d422bff18
stage2: move all integer types to InternPool
2023-06-10 20:40:04 -07:00
Andrew Kelley
85c69c5194
Type.isSlice: make it InternPool aware
2023-06-10 20:40:04 -07:00
Andrew Kelley
fb16ad3add
Type: update to use InternPool for some methods
2023-06-10 20:40:04 -07:00
Andrew Kelley
ca3cf93b21
stage2: move most simple values to InternPool
2023-06-10 20:40:04 -07:00
Andrew Kelley
836d8a1f64
stage2: move most simple types to InternPool
2023-06-10 20:40:04 -07:00
Andrew Kelley
bcd4bb8afb
stage2: move named int types to InternPool
2023-06-10 20:40:04 -07:00
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