aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime
AgeCommit message (Collapse)Author
8 daysAdd RP2350 support (#4459)Patricio Whittingslow
machine/rp2350: add support * add linker scripts for rp2350 * add bootloader * begin melding rp2040 and rp2350 APIs * add UART * add rp2350 boot patching * Fix RP2350 memory layout (#4626) * Remove rp2040-style second stage bootloader. * Add 'minimum viable' IMAGE_DEF embedded block * Create a pico2 specific target * Implement rp2350 init, clock, and uart support * Merge rp2 reset code back together * Separate chip-specific clock definitions * Clear pad isolation bit on rp2350 * Init UART in rp2350 runtime * Correct usb/serial initialization order * Implement jump-to-bootloader * test: add pico2 to smoketests --------- Signed-off-by: deadprogram <[email protected]> Co-authored-by: Matthew Mets <[email protected]> Co-authored-by: Matt Mets <[email protected]> Co-authored-by: deadprogram <[email protected]>
8 daysfix: add build tags to ensure that tkey target has stubs for ↵deadprogram
runtime/interrupt package Signed-off-by: deadprogram <[email protected]>
10 daysruntime: make channels parallelism-safeAyke van Laethem
12 daystargets: add implementation for Tillitis TKey device (#4631)Ron Evans
* initial implementation for Tillitis TKey device * add UART implementation for TKey * add Pin interface implementation for TKey touch sensor * add RNG interface implementation for TKey * add helpful machine package functions to return identifiers such as name and version for TKey * use built-in timer for sleep timing on TKey * modify UART implementation for TKey to implement Serialer interface * implement BLAKE2s ROM function call for TKey device * handle abort by triggering TKey device fault using illegal instruction to halt CPU * simplify TKey implementation by inheriting from existing riscv32 target * return error for trying to configure invalid baudrates on UART * add tkey to builder test * be very specific for features passed to LLVM for specific config in use for TKey * handle feedback items from TKey device code review Signed-off-by: deadprogram <[email protected]>
2024-12-04fix: allow nintendoswitch target to compiledeadprogram
Signed-off-by: deadprogram <[email protected]>
2024-12-04runtime: remove CondAyke van Laethem
I don't think this is used anywhere right now, and it would need to be updated to work with multithreading. So instead of fixing it, I think we can remove it. My original intention was to have something like this that could be used in the machine package, but since this is in the runtime package (and the runtime package imports the machine package on baremetal) it can't actually be used that way. I checked the TinyGo repo and the drivers repo, and `runtime.Cond` isn't used anywhere except in that one test.
2024-12-01mips: fix a bug when scanning the stackAyke van Laethem
Previously the assembler was reordering this code: jal tinygo_scanstack move $a0, $sp Into this: jal tinygo_scanstack nop move $a0, $sp So it was "helpfully" inserting a branch delay slot, even though this was already being taken care of. Somehow this didn't break, but it does break in the WIP threading branch (https://github.com/tinygo-org/tinygo/pull/4559) where this bug leads to a crash.
2024-12-01runtime: lock output in print/printlnAyke van Laethem
This ensures that calls to print/println happening in different threads are not interleaved. It's a task.PMutex, so this should only change things when threading is used. This matches the Go compiler, which does the same thing: https://godbolt.org/z/na5KzE7en The locks are not recursive, which means that we need to be careful to not call `print` or `println` inside a runtime.print* implementation, inside putchar (recursively), and inside signal handlers. Making them recursive might be useful to do in the future, but it's not really necessary.
2024-12-01runtime: make signals parallelism-safeAyke van Laethem
2024-11-30runtime: implement GoexitAyke van Laethem
This is needed for full support for the testing package
2024-11-27runtime: use uint32 for the channel state and select indexAyke van Laethem
This uses uint32 instead of uint64. The reason for this is that uint64 atomic operations aren't universally available (especially on 32-bit architectures). We could also use uintptr, but that seems needlessly complicated: it's unlikely real-world programs will use more than a billion select states (2^30).
2024-11-22runtime: prepare the leaking GC for concurrent operationsAyke van Laethem
This uses the task.PMutex parallel-only-mutex type to make the leaking GC parallelism safe. The task.PMutex type is currently a no-op but will become a real mutex once we add true parallelism.
2024-11-21runtime: fix regression introduced by merging conflicting PRsAyke van Laethem
2024-11-20runtime: implement race-free signals using futexesAyke van Laethem
This requires an API introduced in MacOS 11. I think that's fine, since the version before that (MacOS 10.15) is EOL since 2022. Though if needed, we could certainly work around it by using an older and slightly less nice API.
2024-11-20runtime: use SA_RESTART when registering a signalAyke van Laethem
This really is the only sane way to register a signal. If this flag is not set, many syscalls will return EINTR (and not complete their operation) which will be a massive source of hard-to-debug bugs.
2024-11-20runtime: rewrite channel implementationAyke van Laethem
This rewrite simplifies the channel implementation considerably, with 34% less LOC. Perhaps the most important change is the removal of the channel state, which made sense when we had only send and receive operations but only makes things more compliated when multiple select operations can be pending on a single channel. I did this rewrite originally to make it possible to make channels parallelism-safe. The current implementation is not parallelism-safe, but it will be easy to make it so (the main additions will be a channel lock, a global select lock, and an atomic compare-and-swap in chanQueue.pop).
2024-11-20runtime: move scheduler code aroundAyke van Laethem
This moves all scheduler code into a separate file that is only compiled when there's a scheduler in use (the tasks or asyncify scheduler, which are both cooperative). The main goal of this change is to make it easier to add a new "scheduler" based on OS threads. It also fixes a few subtle issues with `-gc=none`: - Gosched() panicked. This is now fixed to just return immediately (the only logical thing to do when there's only one goroutine). - Timers aren't supported without a scheduler, but the relevant code was still present and would happily add a timer to the queue. It just never ran. So now it exits with a runtime error, similar to any blocking operation.
2024-11-20cgo: support errno value as second return parameterAyke van Laethem
Making this work on all targets was interesting but there's now a test in place to make sure this works on all targets that have the CGo test enabled (which is almost all targets).
2024-11-19windows: don't return, exit via exit(0) insteadAyke van Laethem
This fixes a bug where output would not actually be written to stdout before exiting the process, leading to a flaky Windows CI. Exiting using `exit(0)` appears to fix this. For some background, see: https://github.com/tinygo-org/tinygo/pull/4589
2024-11-18runtime: heapptr only needs to be initialized onceAyke van Laethem
There is no need to initialize it twice.
2024-11-18linux: add runtime.fcntl functionleongross
This is needed for the internal/syscall/unix package. Signed-off-by: leongross <[email protected]>
2024-11-15compiler, runtime: move constants into shared packageAyke van Laethem
Use a single package for certain constants that must be the same between the compiler and the runtime. While just using the same values in both places works, this is much more obvious and harder to mess up. It also avoids the need for comments pointing to the other location the constant is defined. And having it in code makes it possible for IDEs to analyze the source. In the future, more such constants and maybe algorithms can be added.
2024-11-14runtime: optimize findHeadAyke van Laethem
This is similar to https://github.com/tinygo-org/tinygo/pull/3899, but smaller and hopefully just as efficient. Thanks to @HattoriHanzo031 for starting this work, benchmarking, and for improving the performance of the code even further.
2024-11-08wasm: correctly return from run() in wasm_exec.jsAyke van Laethem
Instead of hanging forever, it should return the exit code from os.Exit.
2024-11-08wasm: support `//go:wasmexport` functions after a call to `time.Sleep`Ayke van Laethem
This fixes a bug where `//go:wasmexport` functions would not be allowed anymore after a call to `time.Sleep` (when using `-buildmode=default`).
2024-11-07runtime: remove unnecessary check for negative sleepTicks durationAyke van Laethem
This is now fixed for every target in the previous commit. Also see: https://github.com/tinygo-org/tinygo/pull/4239
2024-11-07runtime: don't call sleepTicks with a negative durationAyke van Laethem
There are rare cases where this can happen, see for example https://github.com/tinygo-org/tinygo/issues/4568
2024-11-01runtime/trace: stub all public methodsJoonas Bergius
Signed-off-by: Joonas Bergius <[email protected]>
2024-10-25runtime: bump markStackSizeDamian Gryski
Every time we overflow the stack, we have to do a full rescan of the heap. Making this larger means fewer overflows and thus fewer secondary+ heap scans.
2024-10-24runtime: add gc layout info for some basic typesDamian Gryski
2024-10-23runtime: add support for os/signalAyke van Laethem
This adds support for enabling and listening to signals on Linux and MacOS.
2024-10-19runtime: use unsafe.Slice for leveldb codeDamian Gryski
2024-10-19runtime: use unsafe.Slice in tsip codeDamian Gryski
2024-10-19runtime: remove minSched hack for wasmAyke van Laethem
I am not entirely sure what it's doing (it seems related to js.FuncOf), but tests still seem to pass when this code is removed. So let's remove it.
2024-10-18runtime: disallow defer in interruptsAyke van Laethem
This often doesn't work because there might not be a current task to push the defer frame to. It will instead show an unhelpful nil pointer dereference panic. We could make this work with a separate defer stack for interrupts (as if they were newly started goroutines) but that is difficult with multiple interrupts happening at the same time (we shouldn't jump to a previous interrupt in `panic()`!). So instead, disable defer altogether in interrupts and adjust panic/recover accordingly.
2024-10-18wasm: add //go:wasmexport support to js/wasmAyke van Laethem
This adds support for //go:wasmexport with `-target=wasm` (in the browser). This follows the //go:wasmexport proposal, meaning that blocking functions are not allowed. Both `-buildmode=default` and `-buildmode=c-shared` are supported. The latter allows calling exported functions after `go.run()` has returned.
2024-10-18runtime: implement newcoro, coroswitch to support package iterElias Naur
2024-10-09runtime: add HeapAlloc to gc_leakingDamian Gryski
2024-10-07runtime: track Memstats.HeapAlloc for gc_blocksDamian Gryski
2024-10-07Added mstats fieldsBCG
2024-10-04compiler, runtime: enable go:wasmexport for wasip2 (#4499)Randy Reddig
* compiler: prefer go:wasmexport over go:export * runtime, targets/wasip2: enable -buildmode=c-shared for wasip2 * runtime: rename import from wasi_run to wasiclirun (PR feedback)
2024-10-04wasm: add `//go:wasmexport` support (#4451)Ayke
This adds support for the `//go:wasmexport` pragma as proposed here: https://github.com/golang/go/issues/65199 It is currently implemented only for wasip1 and wasm-unknown, but it is certainly possible to extend it to other targets like GOOS=js and wasip2.
2024-10-02runtime: seed fastrand() with hardware randomnessDamian Gryski
2024-10-02runtime: add maps.cloneDamian Gryski
Fixes #4382
2024-10-02runtime: fix building with -tags=runtime_memhash_tsipDamian Gryski
2024-10-02runtime: make map iteration less definedDamian Gryski
Fixes #3726
2024-09-17Cgo add cbytes implementation (rebased version of #3318) (#4470)leongross
cgo: added CBytes implementation
2024-09-06wasip2: do not export the _start functionAyke van Laethem
It seems to have been replaced with the Component Model `run` function.
2024-09-04stub runtime_{Before,After}Exec for linkageRoger Standridge
2024-09-04darwin: replace custom syscall package with Go native syscall packageAyke van Laethem
This required a few compiler and runtime tricks to work, but I ran a bunch of tests and it seems fine. (CI will of course do more exhaustive testing). The main benefit here is that we don't need to maintain the darwin version of the syscall package, and reduce extra risks for bugs (because we reuse the well-tested syscall package). For example, Go 1.23 needed a bunch of new constants in the syscall package. That would have been avoided if we had used the native syscall package on MacOS.