aboutsummaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
2021-05-28Revert "scheduler: task.Data made 64bit to avoid overflow"deadprogram
This reverts commit fd8938c6346010979992986b2a1b512449e5c866.
2021-05-28scheduler: task.Data made 64bit to avoid overflowKenneth Bell
2021-05-28stm32: Use TIM for runtime clockKenneth Bell
2021-05-28stm32f103 (bluepill): add pwmKenneth Bell
2021-05-28stm32f7: add pwmKenneth Bell
2021-05-28stm32l4: add pwmKenneth Bell
2021-05-28stm32l0: add pwmKenneth Bell
2021-05-28stm32l5: add pwmKenneth Bell
2021-05-28stm32: add pwm for f4 seriesKenneth Bell
2021-05-27Do not disable interrupts on abortYurii Soldak
Allows panic messages to be printed fully into serial console
2021-05-26compiler: skip context parameter when starting regular goroutineAyke van Laethem
Do not store the context parameter (which is used for closures and function pointers) in the goroutine start parameter bundle for direct functions that don't need a context parameter. This avoids storing the (undef) context parameter and thus makes the IR to start a new goroutine simpler in most cases. This reduces code size in the channel.go and goroutines.go tests. Surprisingly, all test cases (when compiled with -target=microbit) have a changed binary, I haven't investigated why but I suppose the codegen is slightly different for the runtime.run function (which starts the main goroutine).
2021-05-26compiler: do not emit nil checks for loading closure variablesAyke van Laethem
Closure variables are allocated in a parent function and are thus never nil. Don't do a nil check before reading or modifying the value. This commit results in a slight reduction in code size in some test cases: calls.go, channel.go, goroutines.go, json.go, sort.go - presumably wherever closures are used.
2021-05-26compiler: add support for running a builtin in a goroutineAyke van Laethem
Not sure why you would ever do this, but it appears to be allowed by the Go specification and previously TinyGo would crash with an unhelpful error message when you would do this. I don't see any practical use of it. The implementation simply runs the builtin directly.
2021-05-26compiler: add tests for starting a goroutineAyke van Laethem
This commit adds a test for both WebAssembly and Cortex-M targets (which use a different way of goroutine lowering) to show how they lower goroutines. It makes it easier to show how the output changes in future commits.
2021-05-26main: rename goroutine testsAyke van Laethem
While LLVM coroutines are one implementation of goroutines, it is not the only one. Therefore, rename the tests to 'goroutines' to better describe what they're for.
2021-05-26compiler: refactor goroutine codeAyke van Laethem
Move the code from the compiler.go file to the goroutine.go file, which is a more appropriate place. This keeps all the goroutine related code in one file, to make it easier to find.
2021-05-26docker: update dev dockerfile to Go 1.16deadprogram
Signed-off-by: deadprogram <[email protected]>
2021-05-25cmsis-svd: update with latest to sync with upstream repodeadprogram
Signed-off-by: deadprogram <[email protected]>
2021-05-25Support chained interrupt handlersKenneth Bell
Multiple calls to interrupt.New are permitted with handlers called sequentially in undefined order.
2021-05-23os: add FileMode constants from Go 1.16sago35
2021-05-22reflect: implement AppendSliceAyke van Laethem
This implementation of AppendSlice simply calls through to the version used in the runtime: runtime.sliceAppend.
2021-05-22reflect: use SliceHeader and StringHeader variant for internal useAyke van Laethem
These variants uses an unsafe.Pointer instead of uintptr so that the pointer/non-pointer fields match those of real slices and strings. This may be necessary in the future once we switch to a precise garbage collector.
2021-05-21cgo: implement prefix parsingAyke van Laethem
This implements expressions such as "-5" and "-5 - 2", in other words, negative numbers.
2021-05-21cgo: parse binary operatorsAyke van Laethem
This follows the Pratt parser design.
2021-05-21cgo: create skeleton of a Pratt parserAyke van Laethem
This converts the existing const parser to the basics of a Pratt parser, following the book "Writing An Interpreter In Go" by Thorsten Ball. It doesn't really do anything interesting yet, it simply converts the existing code (with existing tests) to the new structure.
2021-05-20Add a stub for os.ReadDir()Federico G. Schwindt
This is needed by crypto/x509 in some configuration. Related to #1888.
2021-05-20Add support for net.IPFederico G. Schwindt
2021-05-20interp: ignore inline assembly in markExternalAyke van Laethem
The markExternal function is used when a global (function or global variable) is somehow run at runtime. All the other globals it refers to are from then on no longer known at compile time, so can't be used by the interp package anymore. This can also include inline assembly. While it is possible to modify globals that way, it is only possible to modify exported globals: similar to calling an undefined function (in C for example).
2021-05-19ci: disable building some optional Clang componentsAyke van Laethem
This commit disables the Clang static analyzer and ARCMigrate components of Clang. These aren't used at the moment in TinyGo so don't need to be enabled. This reduces the build by 200 files (2909 -> 2709). The idea comes from here (via LLVM weekly): https://www.cambus.net/speedbuilding-llvm-clang-in-5-minutes/
2021-05-14version: update TinyGo version to 0.19.0-devsago35
2021-05-13machine: define Serial as the default outputAyke van Laethem
Previously, the machine.UART0 object had two meanings: - it was the first UART on the chip - it was the default output for println These two meanings conflict, and resulted in workarounds like: - Defining UART0 to refer to the USB-CDC interface (atsamd21, atsamd51, nrf52840), even though that clearly isn't an UART. - Defining NRF_UART0 to avoid a conflict with UART0 (which was redefined as a USB-CDC interface). - Defining aliases like UART0 = UART1, which refer to the same hardware peripheral (stm32). This commit changes this to use a new machine.Serial object for the default serial port. It might refer to the first or second UART depending on the board, or even to the USB-CDC interface. Also, UART0 now really refers to the first UART on the chip, no longer to a USB-CDC interface. The changes in the runtime package are all just search+replace. The changes in the machine package are a mixture of search+replace and manual modifications. This commit does not affect binary size, in fact it doesn't affect the resulting binary at all.
2021-05-13machine: make UART objects pointer receiversAyke van Laethem
This means that machine.UART0, machine.UART1, etc are of type *machine.UART, not machine.UART. This makes them easier to pass around and avoids surprises when they are passed around by value while they should be passed around by reference. There is a small code size impact in some cases, but it is relatively minor.
2021-05-13machine: make USBCDC global a pointerAyke van Laethem
Make the USBCDC use a pointer receiver everywhere. This makes it easier to pass around the object in the future. This commit sometimes changes code size, but not significantly (a few bytes) and usually in a positive way. My eventual goal is the following: - Declare `machine.USB` (or similar, name TBD) as a pointer receiver for the USB-CDC interface. - Let `machine.UART0` always point to an UART, never actually to a USBCDC object. - Define `machine.Serial`, which is either a real UART or an USB-CDC, depending on the board. This way, if you want a real UART you can use machine.UARTx and if you just want to print to the default serial port, you can use machine.Serial. This change does have an effect on code size and memory consumption. There is often a small reduction (-8 bytes) in RAM consumption and an increase in flash consumption.
2021-05-12Update README.mdv0.18.0sago35
2021-05-12main: version 0.18.0Ayke van Laethem
2021-05-11wasm: scan globals conservativelyAyke van Laethem
Make the GC globals scan phase conservative instead of precise on WebAssembly. This reduces code size at the risk of introducing some false positives. This is a stopgap measure to mitigate an issue with the precise scanning of globals that doesn't track all pointers. It works for regular globals but globals created in the interp package don't always have a type and therefore may be missed by the AddGlobalsBitmap pass. The same issue is present on Linux and macOS, but is not as noticeable there.
2021-05-11compiler: only check for default stack size with tasks schedulerAyke van Laethem
With -scheduler=none, there are no goroutines so there is no stack size anywhere. Therefore, don't check whether the default stack size is set.
2021-05-10Discover USB ports onlyYurii Soldak
This will ignore f.ex. bluetooth
2021-05-10atsame5x: add support for CANsago35
2021-05-09runtime: use the tasks scheduler instead of coroutinesAyke van Laethem
This results in smaller and likely more efficient code. It does require some architecture specific code for each architecture, but I've kept the amount of code as small as possible.
2021-05-09compiler: use wasm for testsAyke van Laethem
The next commit will change the implementation of func values on Linux as a result of switching to a task-based scheduler. To keep the compiler/testdata/func.go test working as expected, switch to WebAssembly tests.
2021-05-08runtime: remove the asyncScheduler constantAyke van Laethem
There is no reason to specialize this per chip as it is only ever used for JavaScript. Not only that, it is causing confusion and is yet another quirk to learn when porting the runtime to a new microcontroller.
2021-05-08runtime: improve timers on nrf, and samd chipsAyke van Laethem
This commit improves the timers on various microcontrollers to better deal with counter wraparound. The result is a reduction in RAM size of around 12 bytes and a small effect (sometimes positive, sometimes negative) on flash consumption. But perhaps more importantly: getting the current time is now interrupt-safe (it previously could result in a race condition) and the timer will now be correct when the timer isn't retrieved for a long duration. Before this commit, a call to `time.Now` more than 8 minutes after the previous call could result in an incorrect time. For more details, see: https://www.eevblog.com/forum/microcontrollers/correct-timing-by-timer-overflow-count/msg749617/#msg749617
2021-05-06main: match `go test` outputAyke van Laethem
This commit makes the output of `tinygo test` similar to that of `go test`. It changes the following things in the process: * Running multiple tests in a single command is now possible. They aren't paralellized yet. * Packages with no test files won't crash TinyGo, instead it logs it in the same way the Go toolchain does.
2021-05-06Add -llvm-features parameterFederico G. Schwindt
With this is possible to enable e.g., SIMD in WASM using -llvm-features +simd128. Multiple features can be specified separated by comma, e.g., -llvm-features +simd128,+tail-call With help from @deadprogram and @aykevl.
2021-05-06compiler: openocd commands in tinygo command lineKenneth Bell
2021-05-06machine: move PinMode to central locationAyke van Laethem
It is always implemented exactly the same way (as an uint8) so there is no reason to implement it in each target separately. This also makes it easier to add some documentation to it.
2021-05-06atsamd21: remove special handling for SPI-24mhzsago35
2021-05-05wasi: do not crash if argc is 0Dan Kegel
Instead, leave args at its default value (which provides a fake argv[0] as it has for a long time). linux and mac do not seem affected. Fixes #1862 (tinygo apps after v0.17.0-113-g7b761fa crash if run without argv[0])
2021-05-05unix: use conservative GC by defaultAyke van Laethem
This commit does two things: 1. It makes it possible to grow the heap on Linux and MacOS by allocating 1GB of virtual memory on startup and then slowly using it as necessary, when running out of available heap space. 2. It switches the default GC to be the conservative GC (previously extalloc). This is good for consistency with other platforms that all use this same GC. This makes the extalloc GC unused by default.