Commit Graph

9293 Commits

Author SHA1 Message Date
Jonathan S
0674b51453 In getCwdAlloc, geometrically allocate larger buffers to find an appropriate size. 2020-05-29 18:27:39 -04:00
Jonathan S
ab3931fa95 Prefer Files to paths in std.debug. Additionally [breaking] add a flags parameter to openSelfExe and stop exporting openElfDebugInfo.
This should save a call to readlink in openSelfDebugInfo and support executables in overlong paths on Linux.
2020-05-29 18:27:39 -04:00
Jonathan S
631633b252 Document and reduce usage of MAX_PATH_BYTES, lifting arbitrary buffer size requirements 2020-05-29 18:23:06 -04:00
Veikka Tuominen
4c8b937fb0
Merge pull request #5184 from alexnask/typeof_extern_call
Extern functions are now evaluated to undefined values at comptime in TypeOf calls.
2020-05-30 01:11:22 +03:00
Andrew Kelley
65c3833ec2
Merge pull request #5388 from kubkon/wasi-args-iter
Add ArgIteratorWasi and integrate it with ArgIterator
2020-05-29 15:55:14 -04:00
Noam Preil
e9f344dcd4 Add include dirs to translate-c (close #5098) 2020-05-29 13:39:16 -04:00
Noam Preil
3b4e29f1ad [CI] Use ninja on Azura and Drone 2020-05-29 13:34:15 -04:00
Noam Preil
834e8ac2dc [Stage2/Codegen] Extract REX 2020-05-29 13:33:09 -04:00
Jakub Konka
6e347e6180 Fix args iterator test 2020-05-29 17:12:19 +02:00
Jakub Konka
6f48842ddb Make ArgIterator.init() a compile error in WASI
Given that the previous design would require the use of a default
allocator to have `ArgIterator.init()` work in WASI, and since in
Zig we're trying to avoid default allocators, I've changed the design
slightly in that now `init()` is a compile error in WASI, and instead
in its message it points to `initWithAllocator(*mem.Allocator)`.
The latter by virtue of requiring an allocator as an argument can
safely be used in WASI as well as on other OSes (where the allocator
argument is simply unused). When using `initWithAllocator` it is then
natural to remember to call `deinit()` after being done with the
iterator. Also, to make use of this, I've also added `argsWithAllocator`
function which is equivalent to `args` minus the requirement of supplying
an allocator and being fallible.

Finally, I've also modified the WASI only test `process.ArgWasiIterator`
to test all OSes.
2020-05-29 10:48:03 +02:00
Jakub Konka
f1a4e1a70f Add ArgIteratorWasi and integrate it with ArgIterator
This commit pulls WASI specific implementation of args extraction
from the runtime from `process.argsAlloc` and `process.argsFree`
into a new iterator struct `process.ArgIteratorWasi`. It also
integrates the struct with platform-independent `process.ArgIterator`.
2020-05-29 10:48:03 +02:00
data-man
dc4fea983d Use tuples in multiTrait 2020-05-28 23:10:44 -04:00
Dmitry Atamanov
0328537ca6
Support stringify for vectors (#5441)
* use array's pointer
2020-05-28 23:10:16 -04:00
Walter Mays
8630ae7523 Remove reliance on hashing algorithm for iterator reset test. 2020-05-28 23:09:21 -04:00
Andrew Kelley
1e0de896b8
Merge pull request #5452 from squeek502/comptime-string-map
Add std.ComptimeStringMap based on the tokenizer optimization in #5442
2020-05-28 23:06:40 -04:00
Timon Kruiper
6e89692d81 C ABI: Add C support for passing structs of floats to an extern function
Currently this does not handle returning these structs yet.

Related: #1481
2020-05-28 22:56:33 -04:00
Andrew Kelley
34101127c6
Merge pull request #5463 from kubkon/link-issue-wasm-vector
Link issue to the failing test case: miscompiled Vector in wasm
2020-05-28 22:55:07 -04:00
Andrew Kelley
dadc4327e1 Merge branch 'stage2-vaddr-alloc' 2020-05-28 22:45:59 -04:00
Andrew Kelley
5d77fede89 remove debug log statements 2020-05-28 22:43:16 -04:00
Andrew Kelley
0bd89979fd stage2: handle deletions and better dependency resolution
* Deleted decls are deleted; unused decls are also detected as deleted.
   Cycles are not yet detected.
 * Re-analysis is smarter and will not cause a re-analysis of dependants
   when only a function body is changed.
2020-05-28 22:42:13 -04:00
Jakub Konka
4f24ab9cfc Fix skipping condition (skip when wasm32) 2020-05-29 00:06:26 +02:00
Jakub Konka
3dbe376c77 Link issue to the failing test case targeting wasm 2020-05-28 23:32:17 +02:00
Andrew Kelley
3eed7a4dea stage2: first pass at recursive dependency resolution 2020-05-28 12:19:00 -04:00
Andrew Kelley
c7ca1fe6f7 self-hosted: introduce a virtual address allocation scheme
The binary file abstraction changed its struct named "Decl" to
"TextBlock" and it now represents an allocated slice of memory in
the .text section. It has two new fields: prev and next, making it
a linked list node. This allows a TextBlock to find its neighbors.

The ElfFile struct now has free_list and last_text_block fields.
Doc comments for free_list are reproduced here:

A list of text blocks that have surplus capacity. This list can have false
positives, as functions grow and shrink over time, only sometimes being added
or removed from the freelist.

A text block has surplus capacity when its overcapacity value is greater than
minimum_text_block_size * alloc_num / alloc_den. That is, when it has so
much extra capacity, that we could fit a small new symbol in it, itself with
ideal_capacity or more.

Ideal capacity is defined by size * alloc_num / alloc_den.

Overcapacity is measured by actual_capacity - ideal_capacity. Note that
overcapacity can be negative. A simple way to have negative overcapacity is to
allocate a fresh text block, which will have ideal capacity, and then grow it
by 1 byte. It will then have -1 overcapacity.

The last_text_block keeps track of the end of the .text section.

Allocation, freeing, and resizing decls are all now more sophisticated,
and participate in the virtual address allocation scheme. There is no
longer the possibility for virtual address collisions.
2020-05-27 15:23:27 -04:00
Veikka Tuominen
2ae9e06363
Merge pull request #5448 from Vexu/translate-c
Translate-c use correct scope in for loop condition
2020-05-27 17:00:31 +03:00
Vexu
cd5b7b9e1d
translate-c: use correct scope in for loop condition 2020-05-27 14:14:17 +03:00
Ryan Liptak
3cac0a5614 Not sure how a tab snuck in there 2020-05-26 23:26:19 -07:00
Ryan Liptak
b683498ae8 Use ComptimeStringMap in std.meta.stringToEnum when feasible 2020-05-26 23:10:13 -07:00
Ryan Liptak
dfafafac7b std.ComptimeStringMap: Add support for void value type (i.e. a set) 2020-05-26 23:10:12 -07:00
Ryan Liptak
62cfc68d2f Use std.ComptimeStringMap in the C tokenizer 2020-05-26 23:10:08 -07:00
Ryan Liptak
a9dd79d293 Use std.ComptimeStringMap in zig's tokenizer
Should have no performance change, the implementation was just made generic/re-usable
2020-05-26 21:36:58 -07:00
Ryan Liptak
0865e5d360 Add std.ComptimeStringMap 2020-05-26 21:34:55 -07:00
Jakub Konka
e61e8c94be Reenable zig parser tests disabled targeting Wasm
I'm not sure why I disabled them when landing extended Wasm/WASI
support, but they pass the parser tests just fine now, so I'm gonna
go ahead and re-enable them.
2020-05-26 21:01:54 -04:00
Andrew Kelley
ba41a9d5d7 different strategy for tokenizing keywords
throughput: 279 MiB/s => 347 MiB/s
2020-05-26 18:59:49 -04:00
data-man
b6e1670d2b Use ccache (optionally) 2020-05-26 16:04:40 -04:00
Walter Mays
e1186c88ea Remove unimplemented init call from ArrayListUnmanaged. 2020-05-26 15:59:56 -04:00
Andrew Kelley
ef42ef9ce8
Merge pull request #5440 from kubkon/align-fn-error-wasm
Make align expr on fns a compile error in Wasm
2020-05-26 15:49:19 -04:00
Dmitry Atamanov
dd62f63c04
fmt padding correction (#5403)
* Make .Left as default
2020-05-26 20:53:51 +03:00
Walter Mays
19a04d8ebd
Add writeToSlice method to SegmentedList. (#5405) 2020-05-26 13:04:25 -04:00
foobles
cb6bc5bdb5
Add caller location tracking for asserts (ir_assert, src_assert, ir_assert_gen) (#5393) 2020-05-26 12:55:31 -04:00
Andrew Kelley
57b78fff73 Merge branch 'daurnimator-pretty-print-non-exhaustive-enums'
closes #4693
2020-05-26 12:15:37 -04:00
Andrew Kelley
62fefe8648 std.fmt: non-exhaustive enums: avoid the loop when it's not necessary 2020-05-26 12:15:08 -04:00
daurnimator
5cdeac3b0e std: in fmt, use tag names of non-exhaustive enums when available 2020-05-26 12:00:33 -04:00
daurnimator
292d515e91 std: allow specifiying enums to be formatted as numbers 2020-05-26 12:00:33 -04:00
Jakub Konka
08b0cae777 Add matching compile error test 2020-05-26 18:00:08 +02:00
Jakub Konka
015c899297 Make align expr on fns a compile error in Wasm
In Wasm, specifying alignment of function pointers makes little sense
since function pointers are in fact indices to a Wasm table, therefore
any alignment check on those is invalid. This can cause unexpected
behaviour when checking expected alignment with `@ptrToInt(fn_ptr)`
or similar. This commit proposes to make `align` expressions a
compile error when compiled to Wasm architecture.

Some references:
[1] [Mozilla: WebAssembly Tables](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format#WebAssembly_tables)
[2] [Sunfishcode's Wasm Ref Manual](https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#indirect-call)
2020-05-26 17:17:32 +02:00
data-man
d10e407977 More vector support in std.meta 2020-05-26 10:56:29 -04:00
Alexandros Naskos
d88db4d34b Changed test name to reflect it only fixes #4328 2020-05-26 12:36:02 +03:00
Veikka Tuominen
4b8077ea8e
Merge pull request #5383 from Vexu/fix
Fix missing compile error on while/for missing block
2020-05-26 11:13:09 +03:00
Andrew Kelley
49f3defe5b Merge branch 'leroycep-feature-cache-hash-zig'
closes #4635
2020-05-25 21:04:10 -04:00