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

7 коммитов

Автор SHA1 Сообщение Дата
Nia Waldvogel
ecd8c2d902 transform (coroutines): fix memory corruption for tail calls that reference stack allocations
This change fixes a bug in which `alloca` memory lifetimes would not extend past the suspend of an asynchronous tail call.
This would typically manifest as memory corruption, and could happen with or without normal suspending calls within the function.
2021-09-21 20:08:30 +02:00
Ayke van Laethem
3d13f9cfe1 transform: show better error message in coroutines lowering
A common error is when someone tries to export a blocking function. This
is not possible with the coroutines scheduler. Previously, it resulted
in an error like this:

    panic: trying to make exported function async: messageHandler

With this change, the error is much better and shows where it comes from
exactly:

    /home/ayke/tmp/export-async.go:8: blocking operation in exported function: messageHandler

    traceback:
    messageHandler
            /home/ayke/tmp/export-async.go:9:5
    main.foo
            /home/ayke/tmp/export-async.go:15:2
    runtime.chanSend
            /home/ayke/src/github.com/tinygo-org/tinygo/src/runtime/chan.go:494:12

This should make it easier to identify and fix the problem. And it
avoids a compiler panic, which is a really bad way of showing
diagnostics.
2021-03-05 14:42:43 +01:00
Nia Weiss
d424b3d7ea add missing return pointer restore for regular coroutine tail calls
This fixes an issue where a normal suspending call followed by a plain tail call would result in the tail return value being written to the return pointer of the normal suspending call.
This is fixed by saving the return pointer at the start of the function and restoring it before initiating a plain tail call.
2020-11-01 08:32:55 +01: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
Jaden Weiss
62e78c0a26 runtime (gc): add garbage collector that uses an external allocator 2020-03-30 14:35:29 +02:00
Ayke van Laethem
9d3de55229 compiler: move Optimizer function to transform package
This refactor is a prerequisite to much larger refactors in the
compiler.
2020-03-21 15:45:25 +01:00
Jaden Weiss
6a50f25a48 refactor coroutine lowering and tasks 2020-03-17 12:16:10 +01:00