4206 Commits

Author SHA1 Message Date
Vexu
a1e78d0b06
add is_tuple field to struct typeinfo
part of #4335
2020-07-17 00:15:34 +03:00
haze
82562b205f
On darwin, only add the self exe to the cache hash for compiler id (#5880)
Now that Big Sur does not have system libraries on the filesystem, zig can no longer read them and add them to the cache hash for the compiler id.
This changes it so that only the first library path returned by os_self_exe_shared_libs is added to the cache hash under Darwin. I looked into methods on getting the system version to keep parity with older versions, but @fengb reported that this works on Catalina (a version behind Big Sur)

Signed-off-by: Haze Booth <isnt@haze.cool>
2020-07-15 22:37:04 -04:00
Andrew Kelley
a7c3cec65f follow up from previous commit for generic methods 2020-07-14 15:29:07 -07:00
Andrew Kelley
4696cd3e09 fix ability to call methods on enums with pointer-to-self
closes #3218
2020-07-14 14:38:40 -07:00
Vexu
dff1ac1089 check for invalid sentinel when creating pointer with @Type 2020-07-13 00:29:53 +00:00
Vexu
bfe9d4184f fix alignment parsing in stage1 2020-07-12 07:35:34 +00:00
Vexu
be1507a7af
update compile error tests and some doc comments 2020-07-12 00:54:07 +03:00
Vexu
8110639c79
add 'anytype' to stage1 and langref 2020-07-11 17:41:33 +03:00
Vexu
2e037fd827 use correct cast function when doing @floatCast at comptime 2020-07-11 11:36:28 +03:00
Andrew Kelley
02619edf41 Revert "use correct cast function when doing @floatCast at comptime"
This reverts commit 2e1bdd0d14f490a80bbed3ee0e0479a908715d33.

Test failures
2020-07-09 23:24:21 -07:00
Vexu
2e1bdd0d14
use correct cast function when doing @floatCast at comptime
Closes #5832
2020-07-09 21:25:55 +03:00
Vexu
5667a21b1e fix missing check on extern variables with no type 2020-07-08 03:09:41 +00:00
xackus
51f8c306d9 stage1: add missing runtime safety for @intCast unsigned -> signed of same bit count 2020-07-05 17:58:21 +02:00
Andrew Kelley
22f0a103c3 stage1 HashMap: linear scan for < 16 entries 2020-07-03 03:50:35 +00:00
Andrew Kelley
df2c27eb48 stage1 HashMap: store hash & do robin hood hashing
This adds these two fields to a HashMap Entry:

uint32_t hash
uint32_t distance_from_start_index

Compared to master branch, standard library tests compiled 8.4% faster
and took negligible (0.001%) more memory to complete. The amount of
memory used is still down from before 8b82c4010480 which moved indexes
to be stored separately from entries.

So, it turns out, keeping robin hood hashing plus separating indexes
did result in a performance improvement. What happened previously is
that the gains from separating indexes balanced out the losses from
removing robin hood hashing, resulting in a wash.

This also serves as an inspiration for adding a benchmark to
std.AutoHashMap and improving the implementation.
2020-07-02 22:38:55 +00:00
Andrew Kelley
8b82c40104 stage1: reimplement HashMap
The indexes are stored separately using an array of
uint8_t, uint16_t, uint32_t, or size_t, depending on the number of
entries in the map.

Entries only contain a key and a value, no longer have
distance_from_start_index or is_used.

In theory this should be both faster and use less memory.

In practice it seems to have little to no effect. For the standard
library tests, vs master branch, the time had no discernable
difference, and it shaved off only 13 MiB of peak rss usage.
2020-07-02 04:53:26 +00:00
Shawn Anastasio
8574861ca0 Implement required ABI bits for powerpc{,64,64le} 2020-07-01 16:12:27 -05:00
antlilja
dcc406deff Add new error message for unreachable else prongs
* Adds error message for types: enum, int and bool
* Adds compile error tests
2020-07-01 16:09:36 +02:00
Andrew Kelley
581d16154b
Merge pull request #5696 from alexnask/async_call_tuple
@asyncCall now takes arguments as a tuple instead of varargs
2020-06-28 01:00:58 -04:00
arbrk1
78d8931647
Fix issue #5618 (#5685)
* fix issue #5618

* A test for the issue #5618 added.
Also inserted a comma in the neighboring test to make it more zigfmt-friendly.
2020-06-24 23:58:50 -04:00
Alexandros Naskos
2fde8249b7 Fixed crash when resolving peer types of *[N:s]const T and [*:s]const T 2020-06-24 23:58:02 -04:00
Andrew Kelley
e42b7702eb Merge remote-tracking branch 'origin/master' into zig-ast-to-zir 2020-06-24 15:36:59 -04:00
Alexandros Naskos
129a4fb251 Copy union const values correctly 2020-06-24 15:21:58 -04:00
antlilja
fd50696359 Store else node in IrInstSrcCheckSwitchProngs
* Remove have_else_prong (bool)
* Add else_prong (AstNode*)
2020-06-24 17:36:24 +02:00
Alexandros Naskos
eefcd04462 Small fixes, fixed tests, added test for argument tuple type 2020-06-24 16:56:24 +03:00
Alexandros Naskos
50b70bd77f @asyncCall now requires an argument tuple 2020-06-24 14:07:39 +03:00
Andrew Kelley
3aab6012c4 Revert "building mingw-w64 for windows ARM looks in lib64/lib32 for .def files"
This reverts commit 93f0bcb649087b5db5cfcba5de5faaaf59047751.

This is not correct (from #mingw-w64 IRC):

<andrewrk> is there no .def file for ntdll on arm 64 bit?
<andrewrk> or does mingw-w64-crt/lib64/ntdll.def apply to both x86_64
and aarch64?
<wbs> andrewrk: there's none at the moment (as apps rarely link directly
against ntdll, and I didn't want to guess needlessly around that one
originally when I added arm64 support, before I actually had a real
arm64 windows device)
<wbs> andrewrk: but I guess I could/should complete that now
<wbs> (if you need one right now, the libarm32 one probably is the
closest match)
2020-06-24 02:08:08 -04:00
Andrew Kelley
93f0bcb649 building mingw-w64 for windows ARM looks in lib64/lib32 for .def files 2020-06-24 01:59:19 -04:00
antlilja
0de35af98b Add duplicate checking for switch on types
* Add compile error tests
2020-06-23 15:17:04 -04:00
Andrew Kelley
6938245fcc Merge remote-tracking branch 'origin/master' into zig-ast-to-zir 2020-06-22 23:22:17 -04:00
xackus
d907f574e0 stage1: fix concat of sliced str literals 2020-06-21 14:57:12 -04:00
Robin Voetter
8696e52a3d
Make unary minus for unsigned types a compile error (#5654)
* Make unary minus for unsigned types a compile error

* Add unreachable when generating unsigned negate
2020-06-21 14:55:44 -04:00
Andrew Kelley
c70633eacd
Merge pull request #5203 from tadeokondrak/@type-for-even-more-types
implement @typeInfo for Frame and implement @Type for Frame, EnumLiteral, and ErrorSet
2020-06-18 21:25:03 -04:00
Andrew Kelley
5ea0f589c9
Merge pull request #5625 from antlilja/master
Improve support for f128 and comptime_float operations
2020-06-18 20:32:43 -04:00
Andrew Kelley
355319fb67 zig cc: add missing cxxabi include path 2020-06-18 18:17:26 -04:00
Andrew Kelley
46b57748a5 stage1: stop emitting memset to undefined when safety is off 2020-06-18 17:12:56 -04:00
Andrew Kelley
7e58c56ca7 self-hosted: implement Decl lookup
* Take advantage of coercing anonymous struct literals to struct types.
 * Reworks Module to favor Zig source as the primary use case.
   Breaks ZIR compilation, which will have to be restored in a future commit.
 * Decl uses src_index rather then src, pointing to an AST Decl node
   index, or ZIR Module Decl index, rather than a byte offset.
 * ZIR instructions have an `analyzed_inst` field instead of Module
   having a hash table.
 * Module.Fn loses the `fn_type` field since it is redundant with
   its `owner_decl` `TypedValue` type.
 * Implement Type and Value copying. A ZIR Const instruction's TypedValue
   is copied to the Decl arena during analysis, which allows freeing the
   ZIR text instructions post-analysis.
 * Don't flush the ELF file if there are compilation errors.
 * Function return types allow arbitrarily complex expressions.
 * AST->ZIR for function calls and return statements.
2020-06-18 17:12:56 -04:00
Andrew Kelley
4a38799631 make file and fn_name fields of SourceLocation also null-terminated
One of the main motivating use cases for this language feature is
tracing/profiling tools, which expect null-terminated strings for these
values. Since the data is statically allocated, making them
additionally null-terminated comes at no cost.

This prevents the requirement of compile-time code to convert to
null-termination, which could increase the compilation time of
code with tracing enabled.

See #2029
2020-06-18 17:09:10 -04:00
Vexu
a5379aa3ee
implement @src 2020-06-18 21:11:09 +03:00
antlilja
1157ee1307 Improve builtin op support for f128/comptime_float
* Add support for fabs, floor, ceil, trunc and round
* Add behavior tests
2020-06-17 17:35:45 +02:00
Andrew Kelley
593db7e8d0
Merge pull request #5608 from alexnask/windows_utf16_dir
Use PathSpace and wide FS calls on windows in stage1
2020-06-16 18:26:02 -04:00
Jakub Konka
04c3fae720 Remove obsolete branch in ir_analyze_cast
Branch handling `*[N]T` to `E![]T` is already handled in a more complete
branch handling `*[N]T` to `[]T` *and* `*[N]T` to `E![]T` so it seems
safe to remove this one.
2020-06-16 18:24:45 -04:00
Andrew Kelley
2bb3e1aff4 stage1: implement type coercion of anon struct literal to struct
closes #3672
2020-06-15 16:52:18 -04:00
Alexandros Naskos
2c8a3aaf85 Use _wfopen instead of fopen on windows 2020-06-15 22:21:01 +03:00
Alexandros Naskos
242246f793 UTF16 create process, utf8->utf16 fix 2020-06-15 21:51:53 +03:00
Alexandros Naskos
c34bdff4bb Use more wide functions on windows 2020-06-15 18:38:41 +03:00
Alexandros Naskos
3b0b56b81a Switched more Windows FS calls to their wide versions 2020-06-15 16:15:10 +03:00
Alexandros Naskos
037c72fe67 Convert paths to UTF-16 before calling CreateDirectory on windows 2020-06-15 15:52:59 +03:00
Jakub Konka
52b97eeef1 Return u32 in @wasmMemorySize instead of i32 2020-06-09 00:22:34 -04:00
Jakub Konka
057d97c093 Return should be i32 due to error signaling in memory.grow
Also, fix tests.
2020-06-09 00:22:34 -04:00