Граф коммитов

1498 коммитов

Автор SHA1 Сообщение Дата
sago35
5ed0f67e1c
sam: fix ROM / RAM size on atsamd51j20 2020-05-07 23:04:10 +02:00
sago35
8ce3cfad40 flash: fix getDefaultPort() fails on Windows locales such as Japan 2020-05-07 22:47:45 +02:00
Ayke van Laethem
904fa852f6 transform: fix debug information in func lowering pass
This commit fixes errors like the following:

    inlinable function call in a function with debug info must have a !dbg location
      call void @runtime.nilPanic(i8* undef, i8* null)
    inlinable function call in a function with debug info must have a !dbg location
      %24 = call fastcc %runtime._interface @"(*github.com/vugu/vugu/domrender.JSRenderer).render$1"(%"github.com/vugu/vugu.VGNode"** %19, i32 %22, i32 %23, i8* %15, i8* undef)
    error: optimizations caused a verification failure

Not all instructions had a debug location, which apparently caused
issues for the inliner.
2020-05-07 08:24:14 +02:00
Ayke van Laethem
d0b2585e82 main: update go-llvm to fix macOS build problem 2020-05-05 08:11:20 +02:00
Ayke van Laethem
23e88bfb15 arm: allow nesting in DisableInterrupts and EnableInterrupts
This finally fixes a TODO left in the code.
2020-04-29 18:25:16 +02:00
Ayke van Laethem
6389e45d99 all: replace ReadRegister with AsmFull inline assembly
This makes AsmFull more powerful (by supporting return values) and
avoids a compiler builtin.
2020-04-29 18:25:16 +02:00
Ayke van Laethem
9342e73ae1 builder: fix picolibc include path
Previously we used --sysroot to set the sysroot explicitly.
Unfortunately, this flag is not used directly by Clang to set the
include path (<sysroot>/include) but is instead interpreted by the
toolchain code. This means that even when the toolchain is explicitly
set (using the --sysroot parameter), it may still decide to use a
different include path such as <sysroot>/usr/include (such as on
baremetal aarch64).

This commit uses the Clang-internal -internal-isystem flag which sets
the include directory directly (as a system include path). This should
be more robust.

The reason the --sysroot parameter has so far worked is that all
existing targets happened to add <sysroot>/include as an include path.

The relevant Clang code is here:
https://github.com/llvm/llvm-project/blob/release/9.x/clang/lib/Driver/Driver.cpp#L4693-L4739
So far, RISC-V is handled by RISCVToolchain, Cortex-M targets by
BareMetal (which seems to be specific to ARM unlike what the name says)
and aarch64 fell back to Generic_ELF.
2020-04-29 15:41:08 +02:00
Ayke van Laethem
fc4857e98c runtime: avoid recursion in printuint64 function
This function is called from runtime.printitf, which is called from
runtime._panic, and is therefore the leaf function of many call paths.
This makes analyzing stack usage very difficult.

Also forwarding printuint32 to printuint64 as it reduces code size in
the few examples I've tested. Printing numbers is not often done so it
doesn't matter if it's a bit slow (the serial connection is probably
slower anyway).
2020-04-26 17:19:07 +02:00
Yannis Huber
f66492a338 Fix return address in scheduler 2020-04-26 16:58:02 +02:00
Jaden Weiss
445fd37bef main: update version for beginning of v0.14 development cycle 2020-04-26 16:57:24 +02:00
Ayke van Laethem
a9ba6ebad9 main: version 0.13.1
This release fixes a few bugs introduced in the previous 0.13.0 release.
2020-04-21 17:02:43 +02:00
Ayke van Laethem
565ff99c31 gba: always use ARM mode instead of Thumb mode
This results in bigger code size, but it works around a bug in the
linker.

The issue starts with the problem that libraries (picolibc, compiler-rt)
were compiled as ARM and the rest as Thumb. This causes some blx
instructions to be inserted by the linker to call into these libraries.

Ideally we should fix the libraries to use Thumb mode instead, but that
requires some more extensive changes (including fixes to compiler-rt)
and it's just way easier to use ARM mode everywhere.
2020-04-21 15:40:52 +02:00
Jaden Weiss
ceeba528e7 runtime: copy stack scan assembly for GBA
The GC stack scanning code was implemented in the Cortex-M assembly, which meant that it was not available on the GBA which is pre-cortex.
This change adds a copy of the relevant code into a new asembly file which is used on the GBA.
2020-04-21 10:28:42 +02:00
Ayke van Laethem
16c2d84c49 compiler: add parameter names to IR
This makes viewing the IR easier because parameters have readable names.

This also makes it easier to write compiler tests (still a work in
progress), that work in LLVM 9 and LLVM 10, as LLVM 10 started printing
value names for unnamed parameters.
2020-04-21 08:54:39 +02:00
Ayke van Laethem
f00bb63330 runtime: do not put scheduler and GC code in the same section
This allows dead code elimination and avoids linker errors with
-scheduler=leaking.
2020-04-20 21:32:29 +02:00
Ayke van Laethem
efdb2e852e main: version 0.13.0 2020-04-13 17:48:30 +02:00
Ron Evans
bb540df2d1 flash: retry 3 times when attempting to reset the serial port
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-04-13 16:18:48 +02:00
suzuki-koya
e181199305 compiler/llvm.go: fix typo 2020-04-13 16:07:35 +02:00
Ayke van Laethem
7b2377586f compiler: unexport some exported symbols
Some symbols (constants/types/methods) were exported while they are an
implementation detail. To keep the public API clean, unexport them.
2020-04-13 09:24:57 +02:00
Elliott Sales de Andrade
471cb4cfd7 wasm_exec: Implement syscall/js.valueDelete.
This is only useful on Go 1.14, and is a port of:
60f271358f
2020-04-13 08:47:34 +02:00
Elliott Sales de Andrade
5706b062e9 wasm_exec: Add copyBytesToGo.
This is basically just a copy of copyBytesToJS, but with arguments
reversed.
2020-04-13 08:47:34 +02:00
Elliott Sales de Andrade
4347496623 wasm_exec: Cross-port exit with code 1 change.
This cross-ports the following commit:
9eef964800
2020-04-13 08:47:34 +02:00
Jaden Weiss
9c78f7039d runtime (chan): fix blocking select on a nil channel
Previously, a blocking select on a nil channel would result in a nil panic inside the channel runtime code.
This change fixes the nil checks so that the select works as intended.
2020-04-13 08:28:24 +02:00
Jaden Weiss
9890c760cf transform (func-lowering): remove specializations from function value lowering and fix lowering of a function value of an unimplemented type
Previously, the function value lowering pass had special cases for when there were 0 or 1 function implementations.
However, the results of the pass were incorrect in both of these cases.
This change removes the specializations and fixes the transformation.

In the case that there was a single function implementation, the compiler emitted a select instruction to obtain the function pointer.
This selected between null and the implementing function pointer.
While this was technically correct, it failed to eliminate indirect function calls.
This prevented discovery of these calls by the coroutine lowering pass, and caused async function calls to be passed through unlowered.
As a result, the generated code had undefined behavior (usually resulting in a segfault).

In the case of no function implementations, the lowering code was correct.
However, the lowering code was not run.
The discovery of function signatures was accomplished by scanning implementations, and when there were no implementations nothing was discovered or lowered.

For maintainability reasons, I have removed both specializations rather than fixing them.
This substantially simplifies the code, and reduces the amount of variation that we need to worry about for testing purposes.
The IR now generated in the cases of 0 or 1 function implementations can be efficiently simplified by LLVM's optimization passes.
Therefore, there should not be a substantial regression in terms of performance or machine code size.
2020-04-12 22:43:43 +02:00
Elliott Sales de Andrade
0a8bfc57ef all: support Go 1.14 2020-04-12 18:41:34 +02:00
Ayke van Laethem
5674c35e14 wasm: backport "garbage collect references to JavaScript values"
See commit:
54e6ba6724

Warning: this will drop support for Go 1.13 for WebAssembly targets!
I have modified the integration tests to specifically blacklist Go 1.13
instead of whitelisting any other version, to avoid accidentally not
testing WebAssembly.
2020-04-12 18:41:34 +02:00
Ayke van Laethem
0f9038ad2e wasm: remove _callbackShutdown
It doesn't seem to be used.

This commit is somewhat related to this commit:
6dd70fc5e3
Most of the things don't port over nicely.
2020-04-12 18:41:34 +02:00
Elliott Sales de Andrade
343bb42644 cgo: normalize test results
This makes the result consistent across Go versions, by running a regex
on the CGo output that wraps all single-line functions in a consistent
way.

Originally written by Elliott Sales de Andrade and modified by Ayke van
Laethem.
2020-04-12 18:41:34 +02:00
Jaden Weiss
bb5f7534e5 transform (coroutines): remove map iteration from coroutine lowering pass
The coroutine lowering pass had issues where it iterated over maps, sometimes resulting in non-deterministic output.
This change removes many of the maps and ensures that the transformations are deterministic.
2020-04-12 16:54:40 +02:00
Ron Evans
3862d6e8a2 docs: update README to have all currently supported boards
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-04-12 09:00:06 +02:00
Ayke van Laethem
5ef8c89937 reelboard: add SoftDevice target reelboard-s140v7
Unfortunately, `tinygo flash` doesn't work here. You have to merge the
SoftDevice and the application hex with a mergehex tool and flash that
to the board.
2020-04-11 10:56:58 +02:00
Ayke van Laethem
2078b042a4 nrf: add lib/nrfx/mdk to include dirs
This directory is needed for nrf.h and other headers that are used by
the SoftDevice. It is definitely needed for nrf52840 for example, but
I've also added it to the nrf51 as it will likely also require adding
this directory.
2020-04-11 10:56:58 +02:00
Ayke van Laethem
9e453a5a29 builder: work around a bug in ld.lld in LLVM 10
See comment in the commit for details. It works around a bug that's been
reported here: https://bugs.llvm.org/show_bug.cgi?id=45336

This is a separate commit so it can easily be reverted if/when this
patch is backported to the LLVM 10 stable branch.
2020-04-09 20:23:51 +02:00
Ayke van Laethem
a08d3aa1dd ci: run tests in LLVM9 + LLVM10 2020-04-09 20:23:51 +02:00
Ayke van Laethem
0afd42c439 main: switch to LLVM 10
This commit also adds a bit of version independence, in particular for
external commands. It also adds the LLVM version to the `tinygo version`
command, which might help while debugging.
2020-04-09 20:23:51 +02:00
Ayke van Laethem
584e94ce2f transform: allow updating tests with -update flag
This should make it much easier to update existing tests.
2020-04-09 20:23:51 +02:00
Jaden Weiss
5308e8903e compiler: pass interface typecode through defer frames
Previously, the typecode was passed via a direct reference, which results in invalid IR when the defer is not reached in all return paths.
It also results in incorrect behavior if the defer is in a loop, causing all defers to use the typecode of the last iteration.
2020-04-09 15:02:09 +02:00
Jaden Weiss
e077e35386 runtime (gc): split marking into two phases 2020-04-09 14:13:10 +02:00
Jaden Weiss
4a6fba7e3a runtime (gc): remove recursion from "conservative" GC 2020-04-09 14:13:10 +02:00
Ayke van Laethem
012c4a02c9 machine: switch to modern interrupt registration method
This saves about 112 bytes in flash and 288 bytes in RAM when the UART
is not used.
2020-04-07 17:53:52 +02:00
Ayke van Laethem
dd0fb1dd9a arm: use -fomit-frame-pointer
The frame pointer was already omitted in the object files that TinyGo
emits, but wasn't yet omitted in the C files it compiles. Omitting the
frame pointer is good for code size (and perhaps performance).

The frame pointer was originally used for printing stack traces in a
debugger. However, advances in DWARF debug info have made it largely
unnecessary (debug info contains enough information now to recover the
frame pointer even without an explicit frame pointer register). In fact,
GDB has been able to produce backtraces in TinyGo compiled code for a
while now while it didn't include a frame pointer.
2020-04-07 16:17:10 +02:00
Ayke van Laethem
639ec1e6ee builder: make sure -fshort-enums is used consistently
The main change is in building the libraries, where -fshort-enums was
passed on RISC-V while other C files weren't compiled with this setting.

Note: the test already passed before this change, but it seems like a
good idea to explicitly test for enum size consistency.
There is also not a particular reason not to pass -fshort-enums on
RISC-V. Perhaps it's better to do it there too (on baremetal targets
that don't have to worry about binary compatibility).
2020-04-07 16:17:10 +02:00
Ayke van Laethem
8333c171f4 hifive1-qemu: fix compile error and add smoke test
This probably got broken with this PR:
https://github.com/tinygo-org/tinygo/pull/976
2020-04-07 16:17:10 +02:00
Ayke van Laethem
b8f5627c9f machine: move errors.New calls to globals
Calling errors.New in an error path causes a heap allocation at an
already unfortunate moment. It is more efficient to create these error
values in globals and return these constant globals. If these errors are
not used (because the related code was optimized out), the globals will
also be optimized out.
2020-04-07 13:24:26 +02:00
Jaden Weiss
9f8715c143 runtime (gc): scan callee-saved registers while marking stack 2020-04-07 11:50:50 +02:00
Ayke van Laethem
cbaa58a2d9 all: change //go:export to //export
This is the kind that is used in Go (actually CGo) for exporting
functions. I think it's best to use //export instead of our custom
//go:export pragma, for consistency (they are equivalent in TinyGo).
Therefore I've updated all instances to the standard format (except for
two that are updated in https://github.com/tinygo-org/tinygo/pull/1024).

No smoke tests changed (when comparing the output hash), except for some
wasm tests that include DWARF debug info and tend to be flaky anyway.
2020-04-05 16:16:57 +02:00
Ayke van Laethem
46345aade6 compiler: optimize comparing interface values against nil
This is a very common case. Avoiding a runtime.interfaceEqual call leads
to a very big reduction in code size in some cases (while it doesn't
affect many other examples). A number of driver smoke tests are reduced
by about 4kB just with this optimization.

I found this issue while looking into automatically calculating the
required amount of stack space for goroutines. The
runtime.interfaceEqual function is recursive, so it is best avoided.
2020-04-04 22:47:21 +02:00
Ayke van Laethem
f06d7d1bd6 builder: run tools (clang, ...) as separate processes
This is necessary because LLVM defines many options in global variables
that are modified when invoking Clang. In particular, LLVM 10 seems to
have a bug in which it always sets the -pgo-warn-misexpect flag. Setting
it multiple times (over various cc1 invocations) results in an error:

    clang (LLVM option parsing): for the --pgo-warn-misexpect option: may only occur zero or one times!

This is fixed by running the Clang invocation in a new `tinygo`
invocation.

Because we've had issues with lld in the past, also run lld in a
separate process so similar issues won't happen with lld in the future.
2020-04-03 12:41:44 +02:00
Ayke van Laethem
407149e323 compiler: add debug info to goroutine start wrappers 2020-04-03 08:12:18 +02:00
Ron Evans
5d539df216 machine/atsamd21,atsamd51: clear the USB packet size before setting it again when sending
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-04-02 11:09:24 -04:00