11304 Commits

Author SHA1 Message Date
John Schmidt
ec445fb6b8 Improve error messages for break type coercion 2023-03-21 15:09:42 +02:00
mlugg
f9b5829508 Sema: implement @export for arbitrary values 2023-03-21 15:04:39 +02:00
Xavier Bouchoux
898e4473e8 CBE: implement aggregateInit() for array of array case.
fixes `error(compilation): clang failed with stderr: error: array type 'uint32_t[10]' (aka 'unsigned int[10]') is not assignable`
2023-03-21 14:56:04 +02:00
Veikka Tuominen
f7204c7f37
Merge pull request #15028 from Vexu/compile-errors
Sema: improve error message of field access of wrapped type
2023-03-21 14:55:36 +02:00
Jacob Young
c58b5732f3 x86_64: implement @byteSwap and @bitReverse 2023-03-21 08:49:54 +01:00
Jacob Young
f316cb29cc x86_64: implement atomic and fence ops 2023-03-21 08:49:54 +01:00
Jacob Young
3f4569bf18 codegen: fix backend breakage due to optional layout change 2023-03-21 08:49:54 +01:00
Jacob Young
6c453dd806 x86_64: implement some slice ops 2023-03-21 08:49:54 +01:00
Jacob Young
958c8e1ce9 x86_64: implement @popCount for older processors
This fixes the behavior tests when compiled for baseline.
2023-03-21 08:49:54 +01:00
Jacob Young
f95faac5ae x86_64: (re)implement optional ops
Note that this commit also changes the layout of optional for all
other backends using `src/codegen.zig` without updating them!
2023-03-21 08:49:54 +01:00
Jacob Young
24f0900ecb x86_64: implement some error union ops 2023-03-21 08:49:54 +01:00
Jacob Young
bbd05e2d97 x86_64: improve codegen for neg and not 2023-03-21 08:49:54 +01:00
Jacob Young
80427796df x86_64: implement @returnAddress and @frameAddress 2023-03-21 08:49:54 +01:00
Jacob Young
53ec2a955e x86_64: implement clz, ctz, and popCount 2023-03-21 08:49:54 +01:00
Jacob Young
edd63f9aba x86_64: reimplement inline memcpy and memset 2023-03-21 08:49:54 +01:00
Jacob Young
c865c8fb2a x86_64: implement float division intrinsics 2023-03-21 08:49:54 +01:00
Jacob Young
b6eebb709f x86_64: fix OBO
These loops were skipping over the top stack entry, and there's already
a function that does this correctly.
2023-03-21 08:49:54 +01:00
Jacob Young
30e1daa746 x86_64: implement basic float ops 2023-03-21 08:49:54 +01:00
Jacob Young
29e6aedc95 x86_64: implement min and max as commutative binary ops 2023-03-21 08:49:54 +01:00
Veikka Tuominen
e70a0b2a6b Value: implement reinterpreting enum field index as integer
Closes #15019
2023-03-21 03:31:03 +02:00
Veikka Tuominen
82133cd992 Sema: improve error message of field access of wrapped type
Closes #15027
2023-03-21 00:34:12 +02:00
Veikka Tuominen
9d9815fb9c Value: handle comparisons of runtime_values
Closes #15004
2023-03-21 00:34:12 +02:00
Veikka Tuominen
773b1c4c5c llvm: fix lowering packed union initiated to zero-bit value
Closes #14980
2023-03-21 00:34:12 +02:00
Jakub Konka
9a203fa789
Merge pull request #14986 from ziglang/macos-hcs
Upstream macOS hot-code swapping PoC
2023-03-19 21:22:40 +01:00
Ganesan Rajagopal
30aeb41a19 Fix linker segfault adding rpath to sharedlib
If the shared library is a relative path, dirname will return null causing a segfault. In the case I debugged, the current directory was already in RPATH so just ignoring this case seems a reasonable fix. After this fix "make" and "make test" pass for mimalloc.

Closes #13766
2023-03-19 17:42:27 +01:00
Jakub Konka
6874b29308 macho: fix 32bit build 2023-03-19 17:13:38 +01:00
Luuk de Gram
c26cbd561c
Merge pull request #14998 from Luukdegram/shared-mem
wasm-linker: Implement shared-memory
2023-03-19 15:43:06 +01:00
Luuk de Gram
322ace70f9
Merge pull request #14838 from Luukdegram/bss-fix
wasm-linker: fix storing atoms in the correct segment
2023-03-19 15:42:39 +01:00
Jakub Konka
f026939a40 macho: enable hot update state only when on compatible host 2023-03-19 09:45:05 +01:00
Jakub Konka
6f15eedff1 darwin: put posix spawn constants in POSIX_SPAWN struct 2023-03-18 21:54:05 +01:00
Jakub Konka
0aab3bda12 macho: add wrappers for attaching/detaching from HCS process 2023-03-18 21:53:46 +01:00
Jakub Konka
37192bcdcb macos: HCS PoC working 2023-03-18 21:53:36 +01:00
Jakub Konka
f1e25cf43e macho: add hot-code swapping poc 2023-03-18 21:53:26 +01:00
Jakub Konka
e35c8a2fd6 link: use std.os.ptrace wrapper on linux 2023-03-18 21:52:52 +01:00
Jakub Konka
2ac8d90df0
Merge pull request #14935 from ziglang/fix-macos-build2
link: move macOS kernel inode cache invalidation to MachO linker
2023-03-18 21:45:21 +01:00
Luuk de Gram
4e0d7154b1
wasm-linker: implement __wasm_init_memory & flag
Implements the __wasm_init_memory and __wasm_init_memory_flag synthetic
function and symbol.

The former will initialize all passive segments during runtime. For the
bss section we will fill it with zeroes, whereas the other segments
will simply be initialized only.

The latter stores the offset into the linear data section, after all
heap memory that is part of the Wasm module. Any memory initialized
at runtime starts from this offset.
2023-03-18 20:13:30 +01:00
Luuk de Gram
09d6938df9
wasm: add atomics opcodes and refactoring
This adds the atomic opcodes for the Threads proposal to the
WebAssembly specification: https://github.com/WebAssembly/threads

PrefixedOpcode has been renamed to MiscOpcode as there's multiple
types of prefixed opcodes. This naming is similar to other tools
such as LLVM. As we now use the 0xFE prefix, we moved the
function_index MIR instruction as it was occupying the same value.
This commit includes renaming all related opcodes.
2023-03-18 20:13:30 +01:00
Luuk de Gram
9fce1df4cd
wasm-linker: implement runtime TLS relocations 2023-03-18 20:13:30 +01:00
Luuk de Gram
9d13c2257d
wasm-linker: implement TLS initialization function
Implements the TLS initialization function. This is a synthetic function
created by the linker. This will only be created when shared-memory is
enabled. This function will be called during thread creation, if there's
any TLS symbols, which will initialize the TLS segment using the
bulk-memory feature.
2023-03-18 20:13:30 +01:00
Luuk de Gram
ff28c8b600
wasm-linker: create TLS symbols
Initialize TLS symbols when shared-memory is enabled. Those symbols
will be called by synthetic functions created by the linker. (TODO).
2023-03-18 20:13:30 +01:00
Luuk de Gram
00af3a79ae
wasm-linker: emit 'data count' & segment flags
When linking with shared-memory enabled, we must ensure to emit
the "data count" section as well as emit the correct segment flags
to tell the runtime/loader that each segment is passive. This is
required as we don't emit the offsets for such segments but instead
initialize each segment (for each thread) during runtime.
2023-03-18 20:13:29 +01:00
Luuk de Gram
fb9d3cd50e
wasm-linker: feature verifiction for shared-mem
When the user enables shared-memory, we must ensure the linked objects
have the 'atomics' and 'bulk-memory' features allowed.
2023-03-18 20:13:29 +01:00
Luuk de Gram
09abd53da7
wasm-linker: refactor Limits and add flags
Rather than adding the flags "on-demand" during limits writing,
we now properly parse them and store the flags within the limits
itself. This also allows us to store whether we're using shared-
memory or not. Only when the correct flag is set will we set the
max within `Limits` or else we will leave it `undefined`.
2023-03-18 20:13:29 +01:00
Luuk de Gram
b0024c4884
wasm-linker: basic TLS support
Linker now parses segments with regards to TLS segments. If the name
represents a TLS segment but does not contain the TLS flag, we set it
manually as the object file is created using an older compiler (LLVM).

For now we panic when we find a TLS relocation and implement those
later.
2023-03-18 20:13:25 +01:00
square
887abd0f33 delete --prominent-compile-errors from help 2023-03-18 20:13:52 +02:00
Jakub Konka
46171bf6c8 macho+zld: clean up how to interface with link.zig and openPath() 2023-03-18 19:05:06 +01:00
Luuk de Gram
bddf138e72
wasm-link: fix storing decls in the right segment
When a decl is `undefined` is must be stored in the data segment when
the build mode is safe. For unsafe optimize modes, it must be stored
in the bss segment instead.

For mutable decls where the atom contains all zeroes, it must always
be stored in the bss segment. All other values will result in the
atom being stored in the data segment.
2023-03-18 16:12:42 +01:00
Jakub Konka
ee705e3ac7 macho+zld: clean up opening and closing of file descriptors 2023-03-18 09:32:29 +01:00
mlugg
71e873703f Sema: make @returnAddress return 0 at comptime
See also #14938.

Resolves: #14931
2023-03-17 15:55:02 -04:00
Jacob Young
cfcd6698cd main: add debug option to dump unoptimized llvm ir 2023-03-17 01:57:14 -04:00