16203 Commits

Author SHA1 Message Date
joachimschmidt557
edcebe7013
stage2 ARM: implement is_null and is_non_null for ptr-like optionals 2021-12-21 23:13:30 +01:00
Andrew Kelley
8b6ea9ffe7 C backend: implement ret_addr 2021-12-21 14:32:02 -07:00
Luuk de Gram
4cb2f11693 wasm-linker: Implement the --export-table and --import-table flags.
This implements the flags for both the linker frontend as well as the self-hosted linker.

Closes #5790
2021-12-21 12:38:50 -08:00
Ersikan
e15a267668 elf: Put constant data in the .rodata section
Allocate a new program header and a new section to accomodate the read-only data
section ".rodata".

Separate TextBlock into multiple TextBlockList, to separate decl in different
sections.

If a Decl is not a function, it is added to the .rodata section.
2021-12-21 11:33:12 -08:00
joachimschmidt557
44061cd760 stage2 ARM: Refactor airStore 2021-12-21 11:30:56 -08:00
Andrew Kelley
8df540aeef
Merge pull request #10370 from Snektron/stage2-inferred-error-sets-2
stage2: Make page_allocator work
2021-12-21 11:28:40 -08:00
ominitay
7e16bb36d8 Change ArgIterator.next() return type
Changes the return type of `ArgIterator.next()` from
`?(NextError![:0]u8)` to `NextError!?[:0]u8`.
2021-12-21 11:15:33 -08:00
John Schmidt
0d09b87c14 Langref: replace mentions of c_void with anyopaque 2021-12-21 11:13:21 -08:00
Robin Voetter
e106e18d96 stage2: @shlWithOverflow 2021-12-21 01:47:27 +01:00
Robin Voetter
964dbeb826 stage2: @subWithOverflow 2021-12-21 01:41:51 +01:00
Robin Voetter
58d67a6718 stage2: make anyopaque sized
While this is technically incorrect, proper handling of anyopaque, as well
as regular opaque, is probably best left until pointers to zero-sized types
having no bits is abolished.
2021-12-21 01:41:51 +01:00
Robin Voetter
c47ed0c912 stage2: @mulWithOverflow 2021-12-21 01:41:51 +01:00
Robin Voetter
ddd2ef822f stage2: @returnAddress() 2021-12-21 01:41:51 +01:00
Robin Voetter
2f7e98c129 stage2: also write addrspace to pointer typeinfo 2021-12-21 01:41:51 +01:00
Robin Voetter
f3d635b668 stage2: @addWithOverflow 2021-12-21 01:41:51 +01:00
Robin Voetter
28bcd7dbdd os: disable unexpected error tracing on stage 2 builds
The self-hosted compiler cannot yet deal with the print function that this
field enables. It is not critical, however, and allows us to remove formatting
from the list of neccesary features to implement to get the page allocator
working.
2021-12-21 01:41:50 +01:00
Robin Voetter
138f85bf25 stage2: only create inferred error sets for inferred error set functions 2021-12-21 01:41:50 +01:00
Robin Voetter
16bddecff9 stage2: allow @ptrToInt on anything that is a pointer at runtime
This in particular allows @ptrToInt on pointer-like optionals.
2021-12-21 01:41:50 +01:00
Robin Voetter
d5621504b0 stage2: save and restore parameters when resolving inline bodies
This caused zirParam instructions of parent blocks to be present in
inline analyzed blocks, and so function prototypes declared in the
inline blocks would also gain and add to the parameters in the
parent block.

Only block and block_inline are affected in this commit, as prototypes
and declarations are always generated in block_inline. This might need
to be resolved in a more general way at some point.
2021-12-21 01:41:50 +01:00
Robin Voetter
e18c3f3109 stage2: wrap function prototypes in an inline block.
Previously, function parameter instructions for function prototypes would be
generated in the parent block. This caused issues in blocks where multiple
prototypes would be generated in, such as the block for struct fields for
example. This change introduces an inline block around every prototype such
that all parameters for a prototype are confined to a unique block.
2021-12-21 01:41:50 +01:00
Robin Voetter
993197cd86 stage2: merged error sets in wrapErrorUnion 2021-12-21 01:41:50 +01:00
Robin Voetter
9d6c45f697 stage2: inferred error set coercion 2021-12-21 01:41:50 +01:00
Robin Voetter
a2958a4ede stage2: allow multiple inferred error sets per Fn
This allows the inferred error set of comptime and inline invocations to be
resolved separately from the inferred error set of the runtime version or other
comptime/inline invocations.
2021-12-21 01:41:50 +01:00
Robin Voetter
b2343e63bd stage2: move inferred error set state into func 2021-12-21 01:41:50 +01:00
Robin Voetter
cd733ceb85 stage2: replace ErrorSet and ErrorSetMerged arrays with hash maps 2021-12-21 01:41:50 +01:00
Andrew Kelley
ea913846c2 ci: add 0.9.0 to downloads json 2021-12-20 15:18:25 -07:00
Andrew Kelley
e3e6516d08 start the 0.10.0 release cycle 2021-12-20 13:13:48 -07:00
Andrew Kelley
a18bf7a7bf Release 0.9.0 0.9.0 2021-12-20 13:13:19 -07:00
joachimschmidt557
ecf0050a92 stage2 AArch64: Implement saving callee-saved registers 2021-12-19 23:24:44 -08:00
Kenta Iwasaki
5c7f2ab011 stage1: deal with BPF not supporting @returnAddress()
Make `@returnAddress()` return for the BPF target, as the BPF target for
the time being does not support probing for the return address. Stack
traces for the general purpose allocator for the BPF target is also set
to not be captured.
2021-12-19 23:22:05 -08:00
Lee Cannon
16b7535497
Allocator: allocBytes and reallocBytes (#10352)
Closes #10348
2021-12-19 01:58:13 -05:00
Andrew Kelley
80b21cef5a langref: fix tidy html error
regressed in 8468b544e8769b774e2e5988a58c51d991df999a
2021-12-18 23:57:00 -07:00
Andrew Kelley
07c03f85a8 zig test: fix test runner detection of tty
Before, `std.Progress` was printing unwanted stuff to stderr. Now, the
test runner's logic to detect whether we should print each test as a
separate line to stderr is properly activated.
2021-12-18 23:45:32 -07:00
Isaac Freund
9f9f215305
stage1, stage2: rename c_void to anyopaque (#10316)
zig fmt now replaces c_void with anyopaque to make updating
code easy.
2021-12-19 00:24:45 -05:00
bnprks
8468b544e8
Add Vector documentation (#10303)
* Create Vector language documentation

Main changes to docs:
1. Create brief documentation on Zig vector types with code example
2. Get rid of the SIMD sub-heading under the main Vectors heading,
and update links accordingly
3. Add an example to the `@shuffle` docs
2021-12-18 23:40:57 -05:00
Jakub Konka
a08137330c macho: handle -install_name option for dylibs/MachO
The status quo for the `build.zig` build system is preserved in
the sense that, if the user does not explicitly override
`dylib.setInstallName(...);` in their build script, the default
of `@rpath/libname.dylib` applies. However, should they want to
override the default behaviour, they can either:

1) unset it with

```dylib.setIntallName(null);```

2) set it to an explicit string with

```dylib.setInstallName("somename.dylib");```

When it comes to the command line however, the default is not to
use `@rpath` for the install name when creating a dylib. The user
will now be required to explicitly specify the `@rpath` as part
of the desired install name should they choose so like so:

1) with `build-lib`

```
zig build-lib -dynamic foo.zig -install_name @rpath/libfoo.dylib
```

2) with `cc`

```
zig cc -shared foo.c -o libfoo.dylib -Wl,"-install_name=@rpath/libfoo.dylib"
```
2021-12-18 17:55:53 -08:00
Jacob G-W
9a8fdbe0a0 plan9 linker: fix off by 1 error 2021-12-18 17:54:20 -08:00
Andrew Kelley
6adecdc58a init-exe template: build.zig: setTarget on the tests 2021-12-18 17:29:46 -07:00
fubark
88ea2cb757 Make Builder.spawnChildEnvMap public 2021-12-18 15:25:09 -08:00
joachimschmidt557
9892684d35 stage2 ARM: spill insts currently in compare flags if necessary 2021-12-18 15:23:25 -08:00
Jens Goldberg
5b29b4ffa6 Fix MIPS inline assembly clobbers 2021-12-18 14:42:01 -08:00
Andrew Kelley
6d04de706a Revert "std: optimize hash_map probe loop condition"
This reverts commit 11803a3a569205d640c7ec0b0aedba83f47a6e64.

Observations from the performance dashboard:
 * strictly worse in terms of CPU instructions
 * slightly worse wall time (but this can be noisy)
 * sometimes better, sometimes worse for branch predictions

Given that the commit was introducing complexity for optimization's
sake, these performance changes do not seem worth it.
2021-12-17 16:56:43 -07:00
sentientwaffle
11803a3a56 std: optimize hash_map probe loop condition
See https://github.com/ziglang/zig/pull/10337 for context.

In #10337 the `available` tracking fix necessitated an additional condition on the probe loop in both `getOrPut` and `getIndex` to prevent an infinite loop. Previously, this condition was implicit thanks to the guaranteed presence of a free slot.

The new condition hurts the `HashMap` benchmarks (https://github.com/ziglang/zig/pull/10337#issuecomment-996432758).

This commit removes that extra condition on the loop. Instead, when probing, first check whether the "home" slot is the target key — if so, return it. Otherwise, save the home slot's metadata to the stack and temporarily "free" the slot (but don't touch its value). Then continue with the original loop. Once again, the loop will be implicitly broken by the new "free" slot. The original metadata is restored before the function returns.

`getOrPut` has one additional gotcha — if the home slot is a tombstone and `getOrPut` misses, then the home slot is is written with the new key; that is, its original metadata (the tombstone) is not restored.

Other changes:

- Test hash map misses.
- Test using `getOrPutAssumeCapacity` to get keys at the end (along with `get`).
2021-12-17 15:21:41 -08:00
Andrew Kelley
e8b39960bb
Merge pull request #10342 from Arnavion/pq-comparefn-context
std.priority_{de,}queue: allow comparator to take context parameter
2021-12-17 14:34:32 -08:00
Felix "xq" Queißner
c1745b2896 Actually installs the implib for DLLs. 2021-12-17 14:31:59 -08:00
sentientwaffle
ef0566df78 std: count hash_map tombstones as available
When entries are inserted and removed into a hash map at an equivalent rate (maintaining a mostly-consistent total count of entries), it should never need to be resized. But `HashMapUnmanaged.available` does not presently count tombstoned slots as "available", so this put/remove pattern eventually panics (assertion failure) when `available` reaches `0`.

The solution implemented here is to count tombstoned slots as "available". Another approach (which hashbrown (b3eaf32e60/src/raw/mod.rs (L1455-L1542)) takes) would be to rehash all entries in place when there are too many tombstones. This is more complex but avoids an `O(n)` bad case when the hash map is full of many tombstones.
2021-12-16 19:11:53 -08:00
Lee Cannon
d54ba76e40 TracyAllocator: correct order of free and alloc 2021-12-16 19:09:57 -08:00
Samarth Hattangady
1fa5a1959d std.time.epoch: fix issue in documentation
std.time.epoch.DaySeconds.getHoursIntoDay said that hours goes from
0-11. should be 0-23.
2021-12-16 19:08:58 -08:00
Andrew Kelley
58f669dc8c
Merge pull request #10339 from ziglang/update-glibc
update glibc to 2.34
2021-12-16 13:16:14 -08:00
Andrew Kelley
9257669cd4 glibc: do not pass -DSHARED to any of the libc_nonshared.a sources
This essentially reverts 6a12dce207114842e2e49a3aeb18af01ab207f0b but it
leaves breadcrumbs in the source explaining why things are the way they
are.
2021-12-16 03:34:20 -07:00