Commit Graph

1981 Commits

Author SHA1 Message Date
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
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
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 e120b07a52.
2020-06-29 05:12:30 -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
0cfe8e5d6f
Merge pull request #5064 from marler8997/newAllocator
new allocator interface
2020-06-27 18:21:00 -04:00
Jonathan Marler
a728436992 new allocator interface after Andrew Kelley review 2020-06-27 08:57:35 -06:00
Ryan Liptak
626b5eccab Move fs-specific tests from os/test.zig to fs/test.zig
The moved tests do not use `std.os` directly and instead use `std.fs` functions, so it makes more sense for them to be in `fs/test.zig`
2020-06-27 10:17:08 +00:00
Ryan Liptak
12aca758c6 Dir.deleteFile: Fix symlink behavior when translating EPERM to EISDIR 2020-06-26 17:12:02 -07:00
Ryan Liptak
505bc9817a Implement Dir.deleteFile in terms of deleteFileZ/deleteFileW
Reduces duplicate code, consistent with other fn/fnZ/fnW implementations
2020-06-26 16:08:26 -07:00
Ryan Liptak
14c3c47fb7 fs.deleteFile: Translate to error.IsDir when appropriate on POSIX systems
Linux deviates from POSIX and returns EISDIR while other POSIX systems return EPERM. To make all platforms consistent in their errors when calling deleteFile on a directory, we have to do a stat to translate EPERM (AccessDenied) to EISDIR (IsDir).
2020-06-26 16:00:43 -07:00
Jonathan Marler
dc9648f868 new allocator interface 2020-06-26 13:34:48 -06:00
Ryan Liptak
0e3d74df8a Add tests for using file operations on directories 2020-06-26 00:06:23 -07:00
Andrew Kelley
e820678ca1
Merge pull request #5588 from tgschultz/leb128-output
LEB128 overhaul and output
2020-06-25 19:10:31 -04:00
Andrew Kelley
061c8be049
Merge pull request #5684 from squeek502/fs-file-dir-ops
Add tests for using directory operations on files
2020-06-25 19:08:30 -04:00
data-man
77bb2dc094 Use writer in benchmarks 2020-06-25 19:07:25 -04:00
Ryan Liptak
dcdbb7006c Add tests for using directory operations on files 2020-06-25 03:49:58 -07:00
Ryan Liptak
f50ed94174 Windows: Fix fs.Dir.openDir not handling STATUS_NOT_A_DIRECTORY
Now correctly returns error.NotDir
2020-06-25 03:49:58 -07:00
Andrew Kelley
41c6cc9001
Merge pull request #5677 from kubkon/fstatat
[libstd]: implement fstatat in WASI plus fix on macOS
2020-06-25 00:01:38 -04:00
Andrew Kelley
d337469e44
Merge pull request #5583 from ziglang/zig-ast-to-zir
self-hosted: hook up Zig AST to ZIR
2020-06-24 22:37:58 -04:00
Code Hz
7875649c24 Pdb.openFile use []const u8 instead of []u8 2020-06-24 22:27:30 -04:00
Andrew Kelley
20b4a2cf2c self-hosted: add compare output test for new AST->ZIR code 2020-06-24 21:28:42 -04:00
Andrew Kelley
e42b7702eb Merge remote-tracking branch 'origin/master' into zig-ast-to-zir 2020-06-24 15:36:59 -04:00
Jakub Konka
d40e367b73 Reformat using if-else where appropriate 2020-06-24 21:00:21 +02:00
Jakub Konka
c63b23d684 Use fstatat on macOS (otherwise uses 32bit) 2020-06-24 21:00:21 +02:00
Jakub Konka
be78b7b648 Implement fstatat targeting WASI
Also, add more informative `@compileError` in a few `std.os` functions
that would otherwise yield a cryptic compile error when targeting
WASI. Finally, enhance docs in a few places and add test case for
`fstatat`.
2020-06-24 21:00:21 +02:00
Alexandros Naskos
50b70bd77f @asyncCall now requires an argument tuple 2020-06-24 14:07:39 +03:00
Jakub Konka
5fed725e0a
Remove some leftover debugging checks 2020-06-23 23:59:32 +02:00
Jakub Konka
66e5205047 Refactor PreopenList.find()
This commit generalizes `std.fs.wasi.PreopenList.find(...)` allowing
search by `std.fs.wasi.PreopenType` union type rather than by dir
name. In the future releases of WASI, it is expected to have more
preopen types (or capabilities) than just directories. This commit
aligns itself with that vision.

This is a potentially breaking change. However, since `std.fs.wasi.PreopenList`
wasn't made part of any Zig release yet, I think we should be OK
to introduce those changes without pointing to any deprecations.
2020-06-23 21:54:36 +02:00
Andrew Kelley
6938245fcc Merge remote-tracking branch 'origin/master' into zig-ast-to-zir 2020-06-22 23:22:17 -04:00
Andrew Kelley
78c6d39cd4
Merge pull request #5667 from cartr/windows-arguments-unclosed-quote
In std.process.ArgIteratorWindows, don't treat unclosed quotes like they're escaped
2020-06-22 20:07:43 -04:00
Jakub Konka
923c0feda1 Add std.fs.File.readAllAlloc tests
This commit adds some unit tests for `std.fs.File.readAllAlloc`
function. It also updates the docs of `Reader.readNoEof`
which were outdated, and swaps `inStream()` for  `reader()` in
`File.readAllAlloc` with the former being deprecated.
2020-06-22 20:03:21 -04:00
Andrew Kelley
6ff6ac866d
Merge pull request #5666 from kubkon/symlinkat-readlinkat
[libstd]: enhance std.os.{symlinkat, readlinkat} coverage
2020-06-22 20:02:27 -04:00
Andrew Kelley
44bd0a2670
Merge pull request #5662 from shtanton/meta-cast
Adds std.meta.cast and uses it to simplify translate-c
2020-06-22 19:54:30 -04:00
prime31
65ef74e2cd
try allocation of pointer type when parsing (#5665)
* `try` allocation of pointer type when parsing

* fixes pointer destroy compile error
2020-06-22 17:30:02 +03:00
Carter Sande
7cb41a415a ArgIteratorWindows: simplify quote state tracking 2020-06-22 03:03:30 -07:00
Carter Sande
8faa85ac19 ArgIteratorWindows: don't treat unclosed quotes like they're escaped 2020-06-22 03:03:20 -07:00