Commit Graph

47 Commits (2c9ed664dd771ebb96f02ede84dd1ce7b6d58e44)

Author SHA1 Message Date
Andrew Kelley e3ae2cfb52 add std.event.RwLock and a few more std changes
* add std.event.RwLock and std.event.RwLocked
 * std.debug.warn does its printing locked
 * add std.Mutex, however it's currently implemented as a spinlock
 * rename std.event.Group.cancelAll to std.event.Group.deinit and change
   the docs and assumptions.
 * add std.HashMap.clone
2018-08-01 16:26:37 -04:00
Andrew Kelley cc45527333 introduce std.event.fs for async file system functions
only works on linux so far
2018-07-30 13:44:36 -04:00
Andrew Kelley 09304aab77 fix cancel and await semantics 2018-07-29 23:25:40 -04:00
Andrew Kelley 3f4d0ecd7e Merge remote-tracking branch 'origin/master' into m-n-threading 2018-07-09 17:14:42 -04:00
Andrew Kelley 05f1ea33d2 ZIG_DEBUG_COLOR=1 overrides tty detection for runtime stack traces 2018-07-09 12:12:37 -04:00
Andrew Kelley ced3aae3b2 cleaner output from zig build when there are compile errors 2018-07-07 20:31:50 -04:00
Andrew Kelley eb326e1553 M:N threading
* add std.atomic.QueueMpsc.isEmpty
 * make std.debug.global_allocator thread-safe
 * std.event.Loop: now you have to choose between
   - initSingleThreaded
   - initMultiThreaded
 * std.event.Loop multiplexes coroutines onto kernel threads
 * Remove std.event.Loop.stop. Instead the event loop run() function
   returns once there are no pending coroutines.
 * fix crash in ir.cpp for calling methods under some conditions
 * small progress self-hosted compiler, analyzing top level declarations
 * Introduce std.event.Lock for synchronizing coroutines
 * introduce std.event.Locked(T) for data that only 1 coroutine should
   modify at once.
 * make the self hosted compiler use multi threaded event loop
 * make std.heap.DirectAllocator thread-safe

See #174

TODO:
 * call sched_getaffinity instead of hard coding thread pool size 4
 * support for Windows and MacOS
 * #1194
 * #1197
2018-07-07 00:32:19 -04:00
Andrew Kelley e891f9cd9d zig fmt 2018-06-20 17:16:27 -04:00
kristopher tate 71db8df548 std: update stdlib to match updated allocator create signature; ref #733 2018-06-21 00:40:21 +09:00
Andrew Kelley 7912061226 remove integer and float casting syntax
* add `@intCast`
 * add `@floatCast`
 * add `@floatToInt`
 * add `@intToFloat`

See #1061
2018-06-17 02:57:07 -04:00
Andrew Kelley 3ee4d23ebd posix read can return error.IsDir 2018-06-16 19:54:16 -04:00
Andrew Kelley 77678b2cbc
breaking syntax change: orelse keyword instead of ?? (#1096)
use the `zig-fmt-optional-default` branch to have zig fmt
automatically do the changes.

closes #1023
2018-06-10 01:13:51 -04:00
Andrew Kelley fc6446702e clean up std.ArrayList
* add `std.debug.assertError`
 * `std.ArrayList` update everything to follow `self` convention
 * rename `std.ArrayList.set` to `std.ArrayList.setOrError`
 * add `std.ArrayList.set` which asserts

Before 1.0.0 we might remove some of this API, because you can use
`toSlice()` for everything, but it's ok to add these functions as
an experiment before then.
2018-06-09 12:03:11 -04:00
Andrew Kelley fcbb7426fa use * for pointer type instead of &
See #770

To help automatically translate code, see the
zig-fmt-pointer-reform-2 branch.

This will convert all & into *. Due to the syntax
ambiguity (which is why we are making this change),
even address-of & will turn into *, so you'll have
to manually fix thes instances. You will be guaranteed
to get compile errors for them - expected 'type', found 'foo'
2018-05-31 17:28:07 -04:00
Andrew Kelley b184ae5ca5 run zig fmt on some of the codebase
See #1003
2018-05-26 23:00:29 -04:00
Andrew Kelley a35b366eb6 [breaking] delete ptr deref prefix op
start using zig-fmt-pointer-reform branch build of zig fmt
to fix code to use the new syntax

all of test/cases/* are processed, but there are more left
to be done - all the std lib used by the behavior tests
2018-04-30 20:35:54 -04:00
Andrew Kelley caefaf781e std.debug: dumpStackTrace & friends use DirectAllocator
this has the downside of failing to print a stack trace
when the system is out of memory (maybe we could add a
FallbackAllocator which tries DirectAllocator and falls
back on the 200KB preallocated buffer).

but for the more common use case when the system is not
out of memory, but the debug info cannot fit in
std.debug.global_allocator, now stack traces will work.

this is the case for the self hosted compiler.
2018-04-16 03:17:15 -04:00
Andrew Kelley 3b3649b86f refactor stack trace code to remove global state 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 61a02d9d1e omit pad zeroes in debug stack traces 2018-03-10 01:38:40 -05:00
Andrew Kelley 56645c1701 std.debug.dwarf supports line number version 4
fixes stack traces for llvm6 generated zig programs
2018-03-02 16:26:22 -05:00
Andrew Kelley de5c0c9f40 Merge remote-tracking branch 'origin/master' into async 2018-03-01 20:47:35 -05:00
Andrew Kelley 807a5e94e9 add atomicrmw builtin function 2018-02-28 21:19:51 -05:00
Ben Noordhuis 2b35615ffb fix memory leak in std.debug.openSelfDebugInfo() 2018-02-19 23:11:11 +01:00
Ben Noordhuis ab48934e9c add support for stack traces on macosx
Add basic address->symbol resolution support.  Uses symtab data from the
MachO image, not external dSYM data; that's left as a future exercise.

The net effect is that we can now map addresses to function names but
not much more.  File names and line number data will have to wait until
a future pull request.

Partially fixes #434.
2018-02-19 23:11:11 +01:00
Andrew Kelley ca597e2bfb std.zig.parser understands try. zig fmt respects a double line break. 2018-02-14 23:00:53 -05:00
Andrew Kelley 4a4ea92cf3 remove std.heap.IncrementingAllocator
Use std.heap.FixedBufferAllocator combined with
std.heap.DirectAllocator instead.

std.mem.FixedBufferAllocator is moved to std.heap.FixedBufferAllocator
2018-02-12 02:44:31 -05:00
Andrew Kelley 46aa416c48 std.os and std.io API update
* move std.io.File to std.os.File
 * add `zig fmt` to self hosted compiler
 * introduce std.io.BufferedAtomicFile API
 * introduce std.os.AtomicFile API
 * add `std.os.default_file_mode`
 * change FileMode on posix from being a usize to a u32
 * add std.os.File.mode to return mode of an open file
 * std.os.copyFile copies the mode from the source file instead of
   using the default file mode for the dest file
 * move `std.os.line_sep` to `std.cstr.line_sep`
2018-02-10 21:02:24 -05:00
Andrew Kelley a2bd9f8912 std lib: modify allocator idiom
Before we accepted a nullable allocator for some stuff like
opening files. Now we require an allocator.

Use the mem.FixedBufferAllocator pattern if a bound on the amount
to allocate is known.

This also establishes the pattern that usually an allocator is the
first argument to a function (possibly after "self").

fix docs for std.cstr.addNullByte

self hosted compiler:
 * only build docs when explicitly asked to
 * clean up main
 * stub out zig fmt
2018-02-09 18:27:50 -05:00
Andrew Kelley 6940212ecb error sets: fix peer resolution of error unions 2018-02-05 17:42:13 -05:00
Andrew Kelley b7bc259093 make OutStream and InStream take an error set param 2018-02-05 07:38:24 -05:00
Andrew Kelley 893f1088df error sets - peer resolution for error unions 2018-02-05 01:49:14 -05:00
Andrew Kelley b8f59e14cd *WIP* error sets - correctly resolve inferred error sets 2018-02-02 18:13:32 -05:00
Andrew Kelley 39d5f44863 *WI* error sets - basic support working 2018-02-02 14:26:14 -05:00
Andrew Kelley 5f518dbeb9 *WIP* error sets converting std lib 2018-01-31 22:48:40 -05:00
Andrew Kelley 5161d70620 *WIP* error sets 2018-01-31 01:51:31 -05:00
Andrew Kelley 3671582c15 syntax: functions require return type. remove `->`
The purpose of this is:

 * Only one way to do things
 * Changing a function with void return type to return a possible
   error becomes a 1 character change, subtly encouraging
   people to use errors.

See #632

Here are some imperfect sed commands for performing this update:

remove arrow:

```
sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig")
```

add void:

```
sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig")
```

Some cleanup may be necessary, but this should do the bulk of the work.
2018-01-25 04:10:11 -05:00
Andrew Kelley b3a6faf13e replace %defer with errdefer
See #632

now we have 1 less sigil
2018-01-23 23:08:09 -05:00
Andrew Kelley 6ec9933fd8 fix getting debug info twice in default panic handler 2018-01-15 16:26:13 -05:00
Andrew Kelley 7b57454cc1 clean up error return tracing
* error return tracing is disabled in release-fast mode
 * add @errorReturnTrace
 * zig build API changes build return type from `void` to `%void`
 * allow `void`, `noreturn`, and `u8` from main. closes #535
2018-01-15 00:01:02 -05:00
Andrew Kelley 971a6fc531 fix duplicate stack trace code 2018-01-14 10:19:21 -05:00
Andrew Kelley 32ea6f54e5 *WIP* proof of concept error return traces 2018-01-12 02:12:11 -05:00
Andrew Kelley 632d143bff replace `a %% b` with `a catch b`
See #632

better fits the convention of using keywords for control flow
2018-01-07 17:28:20 -05:00
Andrew Kelley 66717db735 replace `%return` with `try`
See #632

better fits the convention of using keywords for control flow
2018-01-07 16:53:13 -05:00
Andrew Kelley 2a25398c86 fix segfault when passing union enum with sub byte...
...field to const slice parameter

we use a packed struct internally to represent a const array
of disparate union values, and needed to update the internal
getelementptr instruction to recognize that.

closes #664
2017-12-24 04:11:58 -05:00
Josh Wolfe fb96c3e73e debug needs to export FailingAllocator 2017-12-23 21:47:13 -07:00
Andrew Kelley 4183c6f1a5 move std/debug.zig to a subdirectory
self hosted compiler parser tests do some fuzz testing
2017-12-23 22:15:48 -05:00