Commit Graph

764 Commits

Author SHA1 Message Date
Andrew Kelley f1f998e071 improve cmpxchg
* remove @cmpxchg, add @cmpxchgWeak and @cmpxchgStrong
   - See explanations in the langref.
 * add operand type as first parameter
 * return type is ?T where T is the operand type

closes #461
2018-04-18 12:16:42 -04:00
Alexandros Naskos 253ecd5c11 Added ReleaseSmall mode 2018-04-16 03:26:10 +03:00
Andrew Kelley b9360640ce add @atomicLoad builtin
See #174
2018-04-15 18:12:00 -04:00
Andrew Kelley a8d794215e exit with error code instead of panic for file not found 2018-04-15 15:22:07 -04:00
Andrew Kelley b5459eb987 add @sqrt built-in function
See #767
2018-04-15 13:26:58 -04:00
Andrew Kelley 1999f0daad fix undefined behavior triggered by fn inline test
LLVM destroys the string that we use to test if LLVM deleted the
inlined function.

Also fixed forgetting to initialize a buffer in std lib path detection.
2018-04-13 11:10:17 -04:00
Andrew Kelley e85a10e9f5 async tcp server proof of concept 2018-04-09 00:52:45 -04:00
Andrew Kelley ee1a4f4c1d error return traces work with async return case 2018-04-08 17:44:29 -04:00
Andrew Kelley 9e98ea552d fix calling convention at callsite of zig-generated fns 2018-04-08 16:40:59 -04:00
Andrew Kelley ada441157f put the error return addresses in the coro frame 2018-04-08 16:04:48 -04:00
Andrew Kelley e4083b7391 codegen: fix not putting llvm allocas together 2018-04-08 16:04:48 -04:00
Andrew Kelley d26905c102 error return traces for the early return case
it would work but LLVM is not correctly spilling the addresses.

See #821
2018-04-08 16:04:48 -04:00
Ben Noordhuis 8980281184 fix llvm assert on version string with git sha
LLVM's CodeViewDebug pass misparses the version string when it contains
a git revision so stop doing that.  This only affected Windows builds.

closes #898
2018-04-06 00:31:55 +02:00
Marc Tiehuis 2e5115b068 Add run compiler command
'zig run file.zig' builds a file and stores the artifacts in the global
cache. On successful compilation the binary is executed.

'zig run file.zig -- a b c' does the same, but passes the arguments a,
b and c as runtime arguments to the program. Everything after an '--' are
treated as runtime arguments.

On a posix system, a shebang can be used to run a zig file directly. An
example shebang would be '#!/usr/bin/zig run'. You may not be able pass
extra compile arguments currently as part of the shebang. Linux for example
treats all arguments after the first as a single argument which will result
in an 'invalid command'.

Currently there is no customisability for the cache path as a compile
argument. For a posix system you can use `TMPDIR=. zig run file.zig` to
override, in this case using the current directory for the run cache.

The input file is always recompiled, even if it has changed. This is
intended to be cached but further discussion/thought needs to go into
this.

Closes #466.
2018-04-01 17:03:06 +12:00
Andrew Kelley b01c50d6fa find libc and zig std lib at runtime
this removes the following configure options:
 * ZIG_LIBC_LIB_DIR
 * ZIG_LIBC_STATIC_LIB_DIR
 * ZIG_LIBC_INCLUDE_DIR
 * ZIG_DYNAMIC_LINKER
 * ZIG_EACH_LIB_RPATH
 * zig's reliance on CMAKE_INSTALL_PREFIX

these options are still available as command line options, however,
the default will attempt to execute the system's C compiler to
collect system defaults for these values.

closes #870
2018-03-30 17:10:54 -04:00
Andrew Kelley aa2995ee39 fix invalid codegen for error return traces across suspend points
See #821

Now the code works correctly, but error return traces are missing
the frames from coroutines.
2018-03-24 22:07:12 -04:00
Andrew Kelley 897e783763 add promise->T syntax parsing
closes #857
2018-03-24 19:25:53 -04:00
Andrew Kelley 18af2f9a27 fix async fns with inferred error sets
closes #856
2018-03-24 18:28:32 -04:00
Andrew Kelley b1c07c0ea9 move error ret tracing codegen to zig ir
progress towards #821
2018-03-24 18:28:32 -04:00
Marc Tiehuis 3d1732ef6c Fix OpqaueType usage in exported c functions
We prefer `struct typename`. If a typedef is required, this must be done
manually after generation.
2018-03-23 20:27:11 +13:00
Andrew Kelley 7f7823e23c fix casting a function to a pointer causing compiler crash
closes #777
2018-03-13 19:15:20 -04:00
Andrew Kelley 84e952c230 fix await multithreaded data race
coro return was reading from a value that coro await was
writing to. that wasn't how it was designed to work, it
was an implementation mistake.

this commit also has some work-in-progress code for fixing
error return traces across suspend points.
2018-03-10 01:38:40 -05:00
Andrew Kelley 60b2031831 improvements to stack traces
* @panic generates an error return trace
 * printing an error return trace no longer interferes with
   normal stack traces.
 * instead of ignore_frame_count, we look at the return address
   when you call panic, and that's the first stack trace function
   makes stack traces much cleaner - the error return trace
   flows gracefully into the stack trace
2018-03-10 01:38:40 -05:00
Andrew Kelley eff3530dfa var is no longer a pseudo-type, it is syntax
closes #779
2018-03-06 18:31:31 -05:00
Andrew Kelley 101b7745c4 add optnone noinline to async functions
this works around LLVM optimization assertion failures.
https://bugs.llvm.org/show_bug.cgi?id=36578

closes #800
2018-03-02 13:40:03 -05:00
Andrew Kelley a7c87ae1e4 fix not casting result of llvm.coro.promise 2018-03-01 10:23:47 -05:00
Andrew Kelley 253d988e7c implementation of await
but it has bugs
2018-03-01 03:28:13 -05:00
Andrew Kelley 8429d4ceac implement coroutine resume 2018-02-28 22:18:48 -05:00
Andrew Kelley c622766156 async function fulfills promise atomically 2018-02-28 21:48:20 -05:00
Andrew Kelley 807a5e94e9 add atomicrmw builtin function 2018-02-28 21:19:51 -05:00
Andrew Kelley ad2a29ccf2 break the data dependencies that llvm coro transforms cant handle
my simple coro test program builds now

see #727
2018-02-28 16:47:13 -05:00
Andrew Kelley 026aebf2ea another workaround for llvm coroutines
this one doesn't work either
2018-02-28 04:01:22 -05:00
Andrew Kelley d243453862 Revert "llvm coroutine workaround: sret functions return sret pointer"
This reverts commit 132e604aa3.

this workaround didn't work either
2018-02-27 17:47:18 -05:00
Andrew Kelley 138d6f9093 revert workaround for alloc and free as coro params
reverts 4ac6c4d6bf

the workaround didn't work
2018-02-27 17:46:13 -05:00
Andrew Kelley 132e604aa3 llvm coroutine workaround: sret functions return sret pointer 2018-02-27 17:12:53 -05:00
Andrew Kelley 6e2a67724c Revert "another llvm workaround for getelementptr"
This reverts commit c2f5634fb3.

It doesn't work. With this, LLVM moves the allocate fn call
to after llvm.coro.begin
2018-02-27 14:58:02 -05:00
Andrew Kelley c2f5634fb3 another llvm workaround for getelementptr 2018-02-27 14:57:49 -05:00
Andrew Kelley 4ac6c4d6bf workaround llvm coro transformations
by making alloc and free functions be parameters to async
functions instead of using getelementptr in the DynAlloc block

See #727
2018-02-26 21:14:15 -05:00
Andrew Kelley 3e86fb500d implement coroutine suspend
see #727
2018-02-26 02:46:21 -05:00
Andrew Kelley 83f8906449 codegen for coro_resume instruction
See #727
2018-02-25 17:34:05 -05:00
Andrew Kelley 4eac75914b codegen for coro_free instruction
See #727
2018-02-25 16:46:01 -05:00
Andrew Kelley d2d2ba10e9 codegen for coro_end instruction
See #727
2018-02-25 16:40:00 -05:00
Andrew Kelley 0cf327eb17 codegen for coro_suspend instruction
See #727
2018-02-25 16:29:07 -05:00
Andrew Kelley d0f2eca106 codegen for coro_begin instruction
See #727
2018-02-25 16:22:19 -05:00
Andrew Kelley 79f1ff574b codegen for coro_alloc_fail instruction
See #727
2018-02-25 16:15:14 -05:00
Andrew Kelley bced3fb64c codegen for get_implicit_allocator instruction
See #727
2018-02-25 16:05:10 -05:00
Andrew Kelley 93cbd4eeb9 codegen for coro_alloc and coro_size instructions
See #727
2018-02-25 15:20:31 -05:00
Andrew Kelley 9f6c5a20de codegen for coro_id instruction
See #727
2018-02-25 15:10:29 -05:00
Andrew Kelley 7567448b91 codegen for cancel
See #727
2018-02-25 14:47:58 -05:00
Andrew Kelley 05bf666eb6 codegen for calling an async function
See #727
2018-02-25 02:47:31 -05:00