9824 Commits

Author SHA1 Message Date
emekoi
68be229917 added custom format method for WindowsVersion 2020-07-05 22:43:10 +00:00
Jonathan Marler
27c1e0b453 Fix issue 5757: increase branch quota for formatting enums 2020-07-05 22:27:50 +00:00
Andrew Kelley
dcca5cf1a9
Merge pull request #5797 from xackus/intcast-runtime-safety
stage1: `@intcast` runtime safety for unsigned -> signed of same bit count
2020-07-05 22:24:25 +00:00
Andrew Kelley
289eab9177
Merge pull request #5786 from ziglang/std-hash-map
reimplement std.HashMap
2020-07-05 21:12:20 +00:00
Andrew Kelley
3a89f214aa update more HashMap API usage 2020-07-05 21:11:42 +00:00
Andrew Kelley
3c8b13d998 std hash map: do the pow2 improvement again
it's a noticeable speedup
2020-07-05 21:11:42 +00:00
Andrew Kelley
632acffcbd update std lib to new hash map API 2020-07-05 21:11:42 +00:00
Andrew Kelley
b3b6ccba50 reimplement std.HashMap
* breaking changes to the API. Some of the weird decisions from before
   are changed to what would be more expected.
   - `get` returns `?V`, use `getEntry` for the old API.
   - `put` returns `!void`, use `fetchPut` for the old API.
 * HashMap now has a comptime parameter of whether to store hashes with
   entries. AutoHashMap has heuristics on whether to set this parameter.
   For example, for integers, it is false, since equality checking is
   cheap, but for strings, it is true, since equality checking is
   probably expensive.
 * The implementation has a separate array for entry_index /
   distance_from_start_index. Entries no longer has holes; it is an
   ArrayList, and iteration is simpler and more cache coherent.
   This is inspired by Python's new dictionaries.
 * HashMap is separated into an "unmanaged" and a "managed" API. The
   unmanaged API is where the actual implementation is; the managed API
   wraps it and provides a more convenient API, storing the allocator.
 * Memory usage: When there are less than or equal to 8 entries, HashMap
   now incurs only a single pointer-size integer as overhead, opposed to
   using an ArrayList.
 * Since the entries array is separate from the indexes array, the holes
   in the indexes array take up less room than the holes in the entries
   array otherwise would. However the entries array also allocates
   additional capacity for appending into the array.
 * HashMap now maintains insertion order. Deletion performs a "swap
   remove". It's now possible to modify the HashMap while iterating.
2020-07-05 21:11:42 +00:00
xackus
b8553b4813 compiler-rt: fix bugs uncovered by previous commit 2020-07-05 20:44:08 +02:00
xackus
51f8c306d9 stage1: add missing runtime safety for @intCast unsigned -> signed of same bit count 2020-07-05 17:58:21 +02:00
pfg
4a63189bf1 stage2: add and @as tests 2020-07-04 15:30:17 -07:00
pfg
d4456d92f5 stage2: builtin @as 2020-07-04 15:16:46 -07:00
pfg
1d52438bd5 stage2: InfixOp add 2020-07-04 15:16:46 -07:00
joachimschmidt557
0ae1157e45 std.mem.dupe is deprecated, move all references in std
Replaced all occurences of std.mem.dupe in stdlib with
Allocator.dupe/std.mem.dupeZ -> Allocator.dupeZ
2020-07-04 21:40:06 +03:00
heidezomp
672b4d5c24 zig build --help: Consistent capitalization/punctuation 2020-07-04 13:00:53 +00:00
pfg
65aac13257 don't try to find config_h if it's not needed 2020-07-04 12:50:37 +00:00
Andrew Kelley
70dca0a0c6
Merge pull request #5779 from ziglang/stage1-hash-map
stage1 HashMap: store hash & do robin hood hashing
2020-07-03 17:11:54 +00:00
Andrew Kelley
f281b928d9 cmake: add -DZIG_WORKAROUND_POLLY_SO
to work around #4799 until a newer llvm version is released.
2020-07-03 04:48:48 +00:00
Andrew Kelley
72cd11dd60 Merge branch 'timotheecour-pr_fix_4799'
closes #5092
2020-07-03 04:43:21 +00:00
Andrew Kelley
14e07e9a72 clean up readme 2020-07-03 04:43:05 +00:00
Timothee Cour
9a7f05378f fix https://github.com/ziglang/zig/issues/4799 2020-07-03 04:40:25 +00: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
Jakub Konka
e7d02eae4d
Update lib/std/fs/test.zig
Co-authored-by: Joachim Schmidt <joachim.schmidt557@outlook.com>
2020-07-02 20:54:57 +02:00
Ian Simonson
70cc1751ca Translate-c fix rhs not cast on array access
Closes #5671. Checks if the rhs is integral and of
differing or the same signedness. If they are different
does an @intCast to the lhs type
2020-07-02 14:05:12 +00:00
Jakub Konka
b5badd1122 Fix memory corruption in Dir.Iterator test 2020-07-02 10:35:44 +02:00
Jakub Konka
64bd134818 Add Dir.Iterator tests
This commit adds some `std.fs.Dir.Iterator` tests.
2020-07-02 10:35:44 +02: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
Andrew Kelley
6f98ef09e3
Merge pull request #5717 from squeek502/fs-dir-file-ops
Add tests for using file operations on directories
2020-07-01 23:20:50 +00:00
Andrew Kelley
d2a4e5e226
Merge pull request #5749 from kubkon/wasi-notcapable
[libstd]: handle ENOTCAPABLE in WASI
2020-07-01 23:12:26 +00:00
Alexandros Naskos
30ae7f7573 Corrected default value field initialization in std.zeroInit 2020-07-01 23:09:08 +00:00
Chris Watson
b8d5b3e611 Add documentation for @src() builtin 2020-07-01 22:22:30 +00:00
CodeMyst
7eed220924 in docs removed "path can be absolute" for imports 2020-07-01 22:12:44 +00:00
Andrew Kelley
f69875d85c build: -Dlib-files-only prevents self-hosted compiler from being built
closes #5756
2020-07-01 21:57:04 +00:00
Jakub Konka
8306826d53 Map ENOTCAPABLE into error.AccessDenied instead of error.NotCapable
This is direct result of review comments left by andrewrk and
daurnimator. It makes sense to map `ENOTCAPABLE` into a more generic
`error.AccessDenied`.
2020-06-30 18:21:38 +02:00
Jakub Konka
5bc99dd7e8 Fix more compilation errors 2020-06-29 21:42:11 +02:00
Jakub Konka
b96882c57a Fix compilation errors 2020-06-29 18:09:22 +02:00
Jakub Konka
bf8bf528c6 Handle ENOTCAPABLE in WASI
This commit adds `error.NotCapable` enum value and makes sure that
every applicable WASI syscall that can return `ENOTCAPABLE` errno
remaps it to `error.NotCapable.
2020-06-29 17:10:01 +02:00
Jonathan Marler
67e97a1f0f ArenaAllocator: use full capacity 2020-06-29 05:12:30 -04:00
Jonathan Marler
35e8876c23 Revert "arena_allocator: refactor and use full capacity"
This reverts commit e120b07a524f1accd4975f5206018c61c4be9345.
2020-06-29 05:12:30 -04:00
Andrew Kelley
1eed0cf0f3 zig fmt and delete unused type 2020-06-28 19:45:10 -04:00
Andrew Kelley
aa92446365 stage2: implement function parameters
In codegen.zig, the std.Target.Cpu.Arch is now generally available as a
comptime value where needed. This is a tradeoff that causes the compiler
binary to be more bloated, but gives us higher performance, since the
optimizer can optimize per architecture (which is usually how compilers
are designed anyway, with different code per-architecture), and it also
allows us to use per-architecture types, such as a Register enum that is
specific to the comptime-known architecture.

Adds abiSize method to Type.
2020-06-28 19:45:10 -04:00
Jonathan Marler
e120b07a52 arena_allocator: refactor and use full capacity 2020-06-28 18:40:15 -04:00
Jonathan Marler
c2eead9629 Fix issue 5741, use after free 2020-06-28 18:05:18 -04:00
Ryan Liptak
74c245aea9 Disable wasi 'readFileAlloc on a directory' assertion for now 2020-06-28 13:56:00 -07:00
Jonathan Marler
374e3e42e0 WasmPageAllocator: fix bug not aligning allocations 2020-06-28 14:25:39 -04: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
Andrew Kelley
ac6bf53069
stage2: clean up test harness, implement symbol collision detection (#5708)
* Clean up test harness
* Stage2/Testing: Add convenience wrappers
* Add a `compiles` wrapper case
* fix incremental compilation after error
* exported symbol collision detection
* function redefinition detection for Zig code
* handle missing function names
* Stage2/Testing: Simplify incremental compilation tests
* Stage2/Testing: Update documentation
* Stage2/TestHarness: Improve progress reporting
* Disable test
* Improve Tranform failure output
2020-06-27 21:54:11 -04:00
Noam Preil
80b70470c0
Stage2/Module: Add symbol -> export lookup table 2020-06-27 21:50:59 -04:00
Noam Preil
ffca1569d1
Return instead of branch 2020-06-27 21:39:39 -04:00