4206 Commits

Author SHA1 Message Date
Jakub Konka
3f0a3cea6e Fix builtins to return and accept u32 instead of i32 2020-06-09 00:22:34 -04:00
Jakub Konka
8ffa8ed9a8 Expose full llvm intrinsic 2020-06-09 00:22:34 -04:00
Jakub Konka
601e831f1d Add builtin for llvm.wasm.memory.grow.i32 intrinsic
This will allow the developer to request additional memory pages
from the runtime to be allocated for the Wasm app. Typical usage:

```zig
var wasm_pages = @wasmMemorySize();
@wasmMemoryGrow(1);
@import("std").debug.assert((wasm_pages + 1) == @wasmMemorySize());
```
2020-06-09 00:22:17 -04:00
Jakub Konka
ce3f0077cf Add builtin for llvm.wasm.memory.size.i32 instrinsic
This will allow the developer to poll the runtime for currently
allocated memory in the number of Wasm pages. Typical usage:

```zig
var wasm_pages = @wasmMemorySize();
@import("std").debug.assert(wasm_pages > 0);
```
2020-06-09 00:22:17 -04:00
Andrew Kelley
9ee98f103b
Merge pull request #5539 from mikdusan/issue5474
stage1: fix constness in some corner cases
2020-06-09 00:12:57 -04:00
Jakub Konka
0ff5d7b24e Add option for overriding the stack size
This commit adds a `--stack [size]` link-time option to zig compiler
allowing the user to override the default stack size set for the
specified executable/library format. This is currently limited to
ELF, COFF and Wasm however (i.e., Mach-O is excluded).
2020-06-08 17:44:06 -04:00
Jakub Konka
cde7c75676 Increase default Wasm stack to 1MB
This commit increases the default Wasm stack to 1MB from the default
of 1 Wasm page which equal 64KB. This seems like a reasonable default
size while at the same time not overly large. Also, Rust lang seems
to be favouring this default as well: [rust-lang#50083].

[rust-lang#50083]: https://github.com/rust-lang/rust/pull/50083
2020-06-08 17:29:14 -04:00
xackus
0d40cb6255 stage1: fix crash on slice byte reinterpretation 2020-06-08 17:19:06 -04:00
Michael Dusan
c0c9d11d8c
stage1: fix constness in some corner cases
- for one-possible-value types, ir_analyze_struct_field_ptr()
  no longer hardcodes const/volatile

- when slicing arrays, ir_analyze_instruction_slice()
  no longer consults ConstValSpecialStatic

closes #5474
2020-06-05 00:49:57 -04:00
Veikka Tuominen
eb687810cf
Merge pull request #4976 from xackus/std-lib-docs
std lib docs: fix null and int values
2020-06-01 14:50:05 +03:00
xackus
250dd9ac21 stage1: fix unresolved inferred error sets 2020-05-31 15:04:34 +02:00
foobles
51682717d7 Support equality comparison for optional to non-optional (?T ==/!= T)
extracted function ir_try_evaluate_bin_op_const
extracted type_is_self_comparable function
renamed ir_try_evaluate_bin_op_const to ir_try_evaluate_bin_op_cmp_const
implemented analysis of ?T == T
added ir_set_cursor_at_end_and_append_basic_block_gen
use build_br_gen and ir_set_cursor_at_end_and_append_block_gen
added ir_append_basic_block_gen
removed include of all_types in ir.cpp
extracted compile-time and runtime evaluation of cmp_optional_non_optional to separate functions

closes #5390
closes #1332
2020-05-29 18:46:09 -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
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
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
foobles
cb6bc5bdb5
Add caller location tracking for asserts (ir_assert, src_assert, ir_assert_gen) (#5393) 2020-05-26 12:55:31 -04: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
Andrew Kelley
c432811d96 fix regression in compile errors 2020-05-23 20:27:09 -04:00
Andrew Kelley
140dc2f43e stage1: fix false positive redeclared variable compile error 2020-05-20 23:13:02 -04:00
Alexandros Naskos
400a91e1c6 Add TypeOf resolution of dereferences and struct fields of undefined values 2020-05-18 19:15:44 +03:00
Andrew Kelley
16f100b82e
Merge pull request #5307 from ziglang/self-hosted-incremental-compilation
rework self-hosted compiler for incremental builds
2020-05-17 13:53:27 -04:00
Andrew Kelley
9a22c8b6ca
Merge pull request #5057 from xackus/opaque-param
stage1: fix assert fail on opaque fn ptr param
2020-05-17 12:48:56 -04:00
Noam Preil
03ed9e4173 Fix compilation with GCC 5 2020-05-17 12:18:53 -04:00
Andrew Kelley
69a5f0d797 Merge remote-tracking branch 'origin/master' into self-hosted-incremental-compilation 2020-05-16 01:26:18 -04:00
Vexu
b2f16d4484
fix infinite loop with mismatced bracket 2020-05-15 23:50:47 +03:00
Vexu
ac319b2734
remove useless nosuspend parsing
nosuspend cannot be used in a type expression and
all other use casesare covered by PrimaryExpr
2020-05-14 11:19:14 +03:00
Andrew Kelley
fda0eef9fb clear progress indicator before printing errors 2020-05-12 16:43:50 -04:00
Vexu
29b3be4f2f
Merge pull request #5319 from Vexu/float-fix
Fix intToFloat on comptime_floats
2020-05-12 15:20:03 +03:00
Vexu
0847b47bf8
fix @intToFloat on comptime_floats 2020-05-12 00:24:09 +03:00
xackus
204f8daeed stage1: detect underflow in bigint_fits_in_bits 2020-05-11 14:06:37 +02:00
Vexu
f2d3266075
Merge pull request #4932 from Qix-/fix-private-access
Fix private access
2020-05-08 18:21:15 +03:00
Josh Junon
4a5c58dd35
fix private member checking for non-canonical invocations (fixes #4909) 2020-05-08 14:26:13 +03:00
xackus
2c9effc101 stage1: handle all cases of invalid struct field default value 2020-05-07 16:39:16 -04:00
Tadeo Kondrak
7ada59f873
remove nakedcc/stdcallcc/async fn/extern fn fnproto 2020-05-05 09:37:28 -06:00
Andrew Kelley
e6955688ac
Merge pull request #5272 from tadeokondrak/noasync-to-nosuspend
Noasync to nosuspend
2020-05-05 11:21:02 -04:00
Tadeo Kondrak
b957dc29a4
Rename noasync to nosuspend in C++ compiler 2020-05-05 05:17:34 -06:00
Vexu
f127dee474
Merge pull request #5267 from Vexu/const-call
Fix missing compile error on call assigned to const
2020-05-04 21:45:15 +03:00
Vexu
adc444ceeb
fix missing compile error on call assigned to const 2020-05-04 14:28:58 +03:00
xackus
887bf8ba93 stage1: remove unneeded switch 2020-05-04 06:51:51 +02:00
xackus
0db9e90e8f stage1: fix assert fail on opaque fn ptr param 2020-05-04 06:51:37 +02:00
data-man
c8b4cc2ff9 Include dbg.h to third-party libs 2020-05-02 18:29:02 -04:00
Tadeo Kondrak
a62e9bc8e5
Implement @Type for ErrorSet 2020-05-02 14:39:32 -06:00
Tadeo Kondrak
ca6db2d008
Implement @Type() for EnumLiteral and FnFrame 2020-05-02 14:39:28 -06:00
Tadeo Kondrak
1696e943ac
Implement @typeInfo for @Frame()
Closes https://github.com/ziglang/zig/issues/3066
2020-05-02 14:39:27 -06:00
Andrew Kelley
428065da30
Merge pull request #5243 from niacat/kern-arand
Avoid reading from /dev/urandom on NetBSD
2020-05-02 04:16:24 -04:00
Michael Dusan
09d6dc1ce6
stage1: cleanup
- remove unused IrInstSrcOptionalUnwrapPtr.initializing
2020-05-01 18:01:21 -04:00
nia
74ad315360 In init_rand avoid reading from /dev/urandom on NetBSD/FreeBSD
Use the KERN_ARND sysctl instead.
2020-05-01 17:23:27 +01:00
Tadeo Kondrak
249938dde0
Validate vector types for @Vector 2020-04-28 00:24:45 -06:00
Tadeo Kondrak
45f4a1124f implement @Type() for more types 2020-04-27 14:37:18 -04:00
George Roman
a17eb15e11 Add missing state to C object cache 2020-04-27 12:21:48 -04:00