Commit Graph

1790 Commits

Author SHA1 Message Date
Andrew Kelley 28071ac637 self-hosted translate-c emits a hello world AST
Also breaking std lib API change: the return value of
std.zig.parse returns `*ast.Tree` rather than `ast.Tree`.

See #1964
2019-04-26 15:43:36 -04:00
Andrew Kelley c82acdbb9e clean up test output
After 4df2f3d74f test names have the word "test" in them so the
redundant word is removed from test runner. Also move the prefix/suffix
to where it logically belongs in the fully qualified symbol name.
2019-04-26 15:10:13 -04:00
Andrew Kelley 17ffe166c2 add preliminary windows support to std.io.COutStream 2019-04-25 00:24:25 -04:00
Andrew Kelley 976080462c translate-c: a little closer to self-hosted implementation 2019-04-25 00:06:54 -04:00
Andrew Kelley 56e07622c6 Merge pull request #2312 from squeek502/heap-shrink-large-align
fix heap allocators when shrinking an object but growing its alignment
2019-04-24 23:44:28 -04:00
Shawn Landden 8ef7f6febb remove Shebang (#!) support
Closes:  #2165
2019-04-24 23:34:19 -04:00
vegecode 733c547a65 compiler-rt: Add missing import of test for comparesf2 2019-04-24 21:16:03 -04:00
vegecode 01168e1577 compiler-rt: add aeabi_dcmp, comparedf2 2019-04-24 21:15:39 -04:00
LemonBoy 374d16793f Go one instruction before the return address
The return address may not point to an area covered by the debug infos
so we hope for the best and decrement the address so that it points to
the caller instruction.
2019-04-23 10:05:46 +02:00
LemonBoy b095e33667 Fix silly typo 2019-04-23 09:57:57 +02:00
LemonBoy 57ec183c09 Fix reading of signed leb128 values 2019-04-23 09:57:22 +02:00
Ryan Liptak 8ce130de3c Bump up FixedBufferAllocator test memory to account for new tests 2019-04-22 02:25:57 -07:00
Ryan Liptak b3598163df std.heap.DirectAllocator: Fix aligned reallocs on Windows 2019-04-22 02:20:01 -07:00
daurnimator 211f0a2226 std: Add mem.nativeIntToBig and mem.nativeIntToLittle
To be used where `htons`, `htonl`, etc. would be used in C.
It's useful to have a function that returns a number directly for use in initialisers.
2019-04-21 14:04:01 -04:00
Ryan Liptak 66020856b2 fix heap allocators when shrinking an object but growing its alignment 2019-04-20 23:56:39 -07:00
vegecode bb25f212b3 compiler-rt: add aeabi_fcmp, comparesf2 2019-04-21 00:12:21 -04:00
tgschultz 22f5e5fd3e Fixes DirectAllocator Windows implementation to call HeapFree when new_size == 0 2019-04-20 14:04:09 -04:00
Andrew Kelley 9b83fe6b4c fixup and zig fmt 2019-04-20 13:48:38 -04:00
Andrew Kelley 907a7068ce Merge branch 'dwarfy' of https://github.com/LemonBoy/zig into LemonBoy-dwarfy 2019-04-20 13:32:59 -04:00
LemonBoy c2542bb7b7 Recover symbol infos from DWARF sections 2019-04-20 10:35:39 +02:00
Ryan Liptak 1030cc97ca fix DirectAllocator not unmapping unused pages on large alignments
Fixes #2306
2019-04-20 02:21:42 -04:00
Raul Leal d44d2784e6 zig-fmt: allow comptime blocks in containers (#2308)
* zig-fmt: allow comptime blocks in containers
* add test for comptime block in container
2019-04-19 15:27:42 -04:00
LemonBoy 0286be127e Fix parseFormValueConstant
Signed/unsigned confusion made the code fail an assertion sometimes.
2019-04-19 19:59:14 +02:00
Andrew Kelley 89763c9a0d stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.

Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.

Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.

Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.

As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).

This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.

This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.

See #1964
2019-04-16 19:12:20 -04:00
Andrew Kelley 4c03746926 Revert "DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory."
This reverts commit 71bb8cd537.

This broke the CI on Windows.
2019-04-16 19:11:37 -04:00
Andrew Kelley 52caf311bb Merge pull request #2286 from shritesh/wasm_alloc
WasmAllocator: WebAssembly Memory Allocator
2019-04-16 13:27:56 -04:00
Shritesh Bhattarai 0c28a18d96 WasmAllocator: cleanup 2019-04-16 12:23:45 -05:00
Sahnvour 71bb8cd537 DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory. 2019-04-16 13:18:21 -04:00
Shritesh Bhattarai 4235982fe6 fmt wasm_allocator 2019-04-16 01:42:11 -05:00
Shritesh Bhattarai aa3f31ac0a wasm: add WasmAllocator 2019-04-16 01:40:16 -05:00
Shritesh Bhattarai f2119f9961 wasm: WasmAllocator that uses fixed 64kb pages 2019-04-15 21:21:46 -05:00
Andrew Kelley 0a280b6062 update std.os.page_size for WebAssembly 2019-04-15 21:20:41 -04:00
Shritesh Bhattarai f5d84250a3 wasi: switch to "standard" wasi_unstable module fn 2019-04-15 18:44:33 -04:00
Shritesh Bhattarai 22960a5fdf wasi: better comments 2019-04-13 22:45:31 -05:00
Shritesh Bhattarai a2d8f03092 support extern "wasi" functions 2019-04-13 22:28:58 -05:00
Shritesh Bhattarai 93528be6b1 wasi: sigabrt at panic 2019-04-13 21:54:50 -05:00
Shritesh Bhattarai fe9cd0b4bc wasi: use __wasi_proc_exit instead of posix.exit 2019-04-13 21:36:53 -05:00
Shritesh Bhattarai 72bcd5a4a5 WIP: hello world 2019-04-13 15:15:39 -05:00
Andrew Kelley 3ce024dd85 A bunch of fixes for the DWARF parser (#2254)
* Correct parsing of DWARF line_info section

* Fix reading of udata/sdata encoded attributes

* Add definition for DW_AT_alignment

Even though it's been standardized in DWARF5 some compilers produce it
anyway for DWARF4 infos too.

* Fix reading of reference attributes

* Distinguish between absolute/relative addresses
2019-04-11 14:34:13 -04:00
Matthew Iannucci 27cd830ec8 Add initial support for iOS targets (#2237)
* Add iOS C int sizes... try to hack in iOS DebugInfo

* Get rid of ios link check for now

* Remove macos linkversion check
2019-04-11 13:15:17 -04:00
LemonBoy 51eb4ebec1 Distinguish between absolute/relative addresses 2019-04-11 15:41:42 +02:00
LemonBoy 38492b2ea4 Fix reading of reference attributes 2019-04-11 10:36:15 +02:00
LemonBoy 29ec409b52 Add definition for DW_AT_alignment
Even though it's been standardized in DWARF5 some compilers produce it
anyway for DWARF4 infos too.
2019-04-11 10:36:15 +02:00
LemonBoy 795b3e9b68 Fix reading of udata/sdata encoded attributes 2019-04-11 10:36:15 +02:00
Marc Tiehuis 78af62a19a Pack big.Int sign and length fields
This effectively takes one-bit from the length field and uses it as the
sign bit. It reduces the size of an Int from 40 bits to 32 bits on a
64-bit arch.

This also reduces std.Rational from 80 bits to 64 bits.
2019-04-11 19:36:35 +12:00
Marc Tiehuis 87d8ecda46 Fix math.big.Int divN/gcdLehmer and fuzz-test failures 2019-04-11 19:36:35 +12:00
Marc Tiehuis 30788a98b1 Handle zero-limb trailing div case in big.Int 2019-04-11 19:36:35 +12:00
Marc Tiehuis d3e1f32362 Small fixes for big.Rational and corrections for gcdLehmer
The int div code still causes some edge cases to fail right now.
2019-04-11 19:36:35 +12:00
Marc Tiehuis b3ecdfd7bf Fix big.Int toString maybe-null allocator 2019-04-11 19:36:35 +12:00
Marc Tiehuis 5f4fcd5030 Add initial big.Rational type 2019-04-11 19:36:35 +12:00