Commit Graph

21337 Commits

Author SHA1 Message Date
Andrew Kelley
8f079bad1f langref: acknowledge design flaw in the self-hosted compiler
See tracking issue #13724
2022-12-01 00:38:02 -07:00
Andrew Kelley
9f9f1aadc7 CI: add aarch64-linux-debug job and flatten dirs 2022-12-01 00:37:47 -07:00
Ryan Liptak
c37afa2811 std.testing: Improve expectEqualBytes for large inputs and make expectEqualSlices use it
`expectEqualBytes` will now truncate the hexdump of each input to a maximum window of 256 bytes, which makes it safe to use for arbitrarily large inputs. Therefore, it can be used in `expectEqualSlices` when the type is u8.
2022-12-01 02:18:51 -05:00
Andrew Kelley
a943422672
Merge pull request #13717 from GethDW/option-fix
std.build.Builder: fix for Allocator changes
2022-11-30 19:43:51 -05:00
Andrew Kelley
94e751ad01
Merge pull request #13718 from Luukdegram/wasm-packed
stage2: Wasm - Implement packed structs
2022-11-30 19:29:26 -05:00
Ryan Liptak
34fa6a1e04 std.testing: Add expectEqualBytes that outputs hexdumps with diffs highlighted in red
The coloring is controlled by `std.debug.detectTTYConfig` so it will be disabled when appropriate.
2022-11-30 18:57:37 -05:00
Jacob Young
cf7a4de7f1 zig.h: fix disastrous typo 2022-11-30 15:48:44 -07:00
Andrew Kelley
16caea38d1 std.ArrayList: fix shrinkAndFree
Fixes a regression introduced in
e35f297aeb.

Now there is test coverage for ArrayList.shrinkAndFree in the case when
resizing fails.
2022-11-30 15:42:59 -07:00
Andrew Kelley
c84bc3a06b std.os.test: disable flaky timerfd test
See tracking issue #13721
2022-11-30 15:18:35 -07:00
Veikka Tuominen
34f96c5fd0
Merge pull request #13719 from Vexu/debug
Improve debuggability of programs built by the self hosted compiler
2022-11-30 22:51:39 +02:00
Andrew Kelley
b1793c2b52 add test coverage for zig build CLI and options API 2022-11-30 13:22:43 -07:00
Andrew Kelley
abd9089aa6 std.build: simpler fix to options implementation
Instead of messing with ArrayList and more logic, just unwrap the error
of toOwnedSlice().
2022-11-30 13:22:04 -07:00
GethDW
747f64b3fb std.build.Builder: fix for Allocator changes 2022-11-30 13:04:32 -07:00
Luuk de Gram
090deae41d
wasm: enable behavior tests for packed structs 2022-11-30 21:01:09 +01:00
Andrew Kelley
44ee1c885f std.os.windows.ReadLink: add missing alignment of local data buffer 2022-11-30 12:55:23 -07:00
Veikka Tuominen
fb4a5ccdee llvm: make debuggers actually usable
`@llvm.dbg.value` is absolutely useless, adding a temporary alloca
to store the constant in will make it actually show up in debuggers.
The effect on performance should be minimal since there is only one
store and it the change is not applied to ReleaseSafe builds.

```zig
fn foo(a: u32, b: []const u8, c: bool, d: enum { yes, no }) void {
    _ = a; _ = b; _ = c; _ = d;
}
```
before:
```
Breakpoint 1, a.foo (a=<optimized out>, b=..., c=<optimized out>, d=<optimized out>) at a.zig:18
18          _ = d;
```
after:
```
Breakpoint 1, a.foo (a=1, b=..., c=false, d=yes) at a.zig:15
15          _ = a; _ = b; _ = c; _ = d;
(gdb) p b
$1 = {ptr = 0x20854f <a.main.anon_3888> "bar", len = 3}
```
2022-11-30 19:33:03 +02:00
Veikka Tuominen
e4fd9acc2a CLI: allow using --debug-compile-errors with zig build 2022-11-30 19:14:04 +02:00
Veikka Tuominen
fba33ee58c Sema: print line column and path when using --debug-compile-errors 2022-11-30 19:12:05 +02:00
Luuk de Gram
3933a4bac5
codegen: support generating packed structs 2022-11-30 17:56:02 +01:00
Luuk de Gram
df7ddb475e
wasm: Fix pointer to field of packed struct
When requesting a pointer to a field of a packed struct (of which is
not byte-aligned), we simply provide the address of the packed struct
itself.
2022-11-30 17:56:02 +01:00
Luuk de Gram
6924f21bbd
wasm: support non-natural alignment in load/store
This implements support for loading and storing where the lhs is
of pointer type with host_size != 0. e.g. when loading a specific
field from a packed struct with a non-byte alignment such as (0:1:3).
2022-11-30 17:56:02 +01:00
Luuk de Gram
a7ad1212cb
wasm: airAggregateInit - Support packed structs
This allows the Wasm backend to construct an instance of a packed
struct during runtime. We first allocate a local, and then
shift+or each field's value into the result local. We then finally
return this result local as value.

The commit also fixes a type-issue in `airElemVal` where we used
the element type instead of a pointer type to store the value's
address into.
2022-11-30 17:56:02 +01:00
Luuk de Gram
a314e86772
wasm: support passing packed struct over C-ABI
This also adds support loading a runtime pointer from a packed struct.
Also, this commit improves many utility functions such as `trunc` and
`intcast` to also support non-integer types such as booleans.
2022-11-30 17:56:02 +01:00
Luuk de Gram
4af5bbde53
wasm: airStructFieldPtr - Support packed structs
Simplifies the airStructFieldPtr(index) functions to only obtain the
correct struct type and field index, which is then passed into the
structFieldPtr function. This function now calculates the byte-offset
of the field's address and returns a new `WValue` with this offset.
This means we only have to do this calculation in a single function,
and no longer have to duplicate any logic. This also handles both
regular (tagged) unions and packed unions.
2022-11-30 17:56:01 +01:00
Luuk de Gram
eb2caf9390
wasm: airStructFieldVal - Support packed structs
This implements loading a field from a packed struct, regardless of
its field's type. This means it supports pointers, floats and
integers. The commit also extracts the logic from airTrunc into its
own `trunc` function so it can be re-used.
2022-11-30 17:56:01 +01:00
Luuk de Gram
7cf442cabc
wasm: Support bitcasting between floats and ints 2022-11-30 17:56:01 +01:00
Luuk de Gram
2be0d5bbca
wasm: add support packed structs in lowerConstant
When lowering constants of packed structs, which are smaller than 65
bits, we lower the value to an integer rather than store it in the
constant data section. This allows us to use an immediate value,
for quick loads and stores.
2022-11-30 17:56:01 +01:00
Andrew Kelley
71038c42f5
Merge pull request #13513 from ziglang/faster-wasm-gpa
WebAssembly-only fast allocator
2022-11-30 01:46:37 -05:00
Andrew Kelley
7f063b2c52 WasmAllocator: simplify thanks to new Allocator interface
Now it can refuse to resize when it would disturb the metadata tracking
strategy, resulting in smaller code size, a simpler implementation, and
less fragmentation.
2022-11-29 23:46:02 -07:00
Andrew Kelley
931261752d rename a couple variables 2022-11-29 23:46:02 -07:00
Andrew Kelley
e2e60f5ff9 std.heap.WasmAllocator: redo
The previous version had a fatal flaw: it did ensureCapacity(1) on the
freelist when allocating, but I neglected to consider that you could
free() twice in a row. Silly!

This strategy allocates an intrusive freelist node with every
allocation, big or small. It also does not have the problems with resize
because in this case we can push the upper areas of freed stuff into the
corresponding freelist.
2022-11-29 23:46:02 -07:00
Andrew Kelley
3dcea95ffe std.heap.WasmAllocator: implement resizing 2022-11-29 23:46:02 -07:00
Andrew Kelley
d4a1ae474a std.heap.WasmAllocator: resize in place without force shrinking 2022-11-29 23:46:02 -07:00
Andrew Kelley
0c0c70ee82 std.heap.WasmAllocator: large allocations 2022-11-29 23:46:02 -07:00
Andrew Kelley
3ea04ed64c introduce std.heap.WasmAllocator
fast allocator for WebAssembly

eventually this is intended to be merged into
`std.heap.GeneralPurposeAllocator`
2022-11-29 23:46:02 -07:00
Andrew Kelley
9f8c19210b std.heap: extract PageAllocator, WasmPageAllocator 2022-11-29 23:46:02 -07:00
Andrew Kelley
e35f297aeb
Merge pull request #13666 from ziglang/allocator-interface
std.mem.Allocator: allow shrink to fail
2022-11-30 01:44:34 -05:00
Andrew Kelley
f466667888 stage2: fix crash on comptime lazy @ctz and @clz 2022-11-29 23:30:38 -07:00
Andrew Kelley
ceb0a632cf std.mem.Allocator: allow shrink to fail
closes #13535
2022-11-29 23:30:38 -07:00
Andrew Kelley
deda6b5146 LLVM: fix canElideLoad behavior with loops
closes #13546
2022-11-30 00:20:49 -05:00
Andrew Kelley
b8473ae7d3
Merge pull request #13693 from Vexu/safety
Safety panic improvements & some bug fixes
2022-11-29 19:59:55 -05:00
Jakub Konka
648579b330 libstd: skip problematic tests on aarch64-windows 2022-11-30 00:26:40 +01:00
Jakub Konka
37a9b78bc1
Merge pull request #13701 from ziglang/arm-win-more-features
Improve aarch64 feature detection based on the readouts from privileged system registers
2022-11-30 00:20:38 +01:00
Loris Cro
52e1be9c68 Revert "ci: add markers for collapsing log sections in GH web UI"
This reverts commit 6028adda4b.
2022-11-29 22:55:04 +01:00
Loris Cro
6028adda4b ci: add markers for collapsing log sections in GH web UI 2022-11-29 22:03:30 +01:00
Veikka Tuominen
b2b1d421c3 Sema: add missing failWithBadMemberAccess to zirExport
The assumption that AstGen would error only holds when exporting
a identifier not a namespace member.
2022-11-29 21:44:08 +02:00
Veikka Tuominen
4b0ef6a409 Sema: make non-existent field error point to field name
Closes #13698
2022-11-29 21:44:08 +02:00
Veikka Tuominen
6f5a438946 AstGen: unstack block scope when creating opaque type
Closes #13697
2022-11-29 21:44:08 +02:00
Veikka Tuominen
e60db701d1 Sema: add option to disable formatted panics
Closes #13174
2022-11-29 21:44:08 +02:00
Veikka Tuominen
ed73429926 Sema: explain why parameter must be declared comptime
Closes #13692
2022-11-29 21:44:08 +02:00