Commit Graph

648 Commits

Author SHA1 Message Date
Ayke van Laethem d27cfb1585 WIP shadow-stack based mark/sweep collector 2019-01-17 21:01:15 +01:00
Ayke van Laethem e6e561100a WIP refactor GC 2019-01-17 20:52:15 +01:00
Ayke van Laethem 95e18f36d0 main: compile and run a program directly
Do not try to use the ExectutionEngine of Go, instead compile the
program in the conventional way and run the binary.

This fixes some code duplication that causes slight (but problematic)
misbehavior between `tinygo build` and `tinygo run`.
2019-01-16 17:06:34 +01:00
Ron Evans 9ac2f39acc tools/gen-device-svd: handle case with nested registers that have same address to avoid duplicates
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-15 11:00:56 +01:00
Wèi Cōngruì 2ba7a438c2 loader: remove redundant gateway function 2019-01-15 06:40:57 +00:00
Ayke van Laethem b88180f8e6 runtime: remove ctx param from stub code
This was necessary before, when only some functions had a context
parameter. Now this is not necessary anymore because all functions
(independent of signature) have a context paramter at the end so the
signature always automatically matches.
2019-01-14 20:56:42 +01:00
Ayke van Laethem c840757352 compiler/interface: fix comparison with error value 2019-01-14 20:56:05 +01:00
Ron Evans b4dd2dbf60 docs: change links in README and remove old ReadTheDocs pages to point to TinyGo.org site
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-13 20:29:45 +01:00
Ron Evans 8d1284cfe7 generator: generate device wrappers for Atmel SAM family
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-13 18:59:56 +01:00
Ron Evans b8c326d710 machine/stm32f103xx: implmentation for I2C interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-10 16:10:25 +01:00
j7b fad4a735e6 tools: use env to search path for python3 2019-01-08 12:52:47 -08:00
Ayke 107fccb288 all: add support for more architectures and GOOS/GOARCH (#118)
This commit does two things:

  * It adds support for the GOOS and GOARCH environment variables. They
    fall back to runtime.GO* only when not available.
  * It adds support for 3 new architectures: 386, arm, and arm64. For
    now, this is Linux-only.
2019-01-05 11:46:25 +01:00
Konstantin Yegupov f44dff6f59 compiler: allow slicing arrays of a named type 2019-01-04 15:55:57 +01:00
Ayke 873c1c3b4d Reduce code size for AVR (#116)
* all: add support for specifying target CPU in target config
* avr: specify the chip name in the target CPU

This reduces code size by a large margin. For examples/blinky, it
reduces code size from 1360 to 1266 when compiling for the Arduino Uno
(94 bytes, or ~7%).
2019-01-04 14:58:35 +01:00
Konstantin Yegupov a8dd82538e all: add flag to enable i64 parameters in WebAssembly 2019-01-03 18:09:33 +01:00
Ron Evans dccfae485c machine/stm32f103xx: support for SPI interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-31 14:59:07 +01:00
Ron Evans f71e1bcf03 machine/stm32f103xx: implementation of RTC/TIM based timers
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-31 14:39:05 +01:00
kyegupov fb8dcde2f9 runtime: update link to original Go hashmap source code 2018-12-31 13:33:18 +01:00
Ayke van Laethem 18b16fc151 compiler: run some optimizations after interface lowering
By running these interprocedural optimizations after interface lowering,
in particular the heap-to-stack transformation pass, interfaces can be
zero cost in some more cases.

For example, say you have the following interface:

    type Writer interface {
        Write([]byte) (int, error)
    }

and you do something with it:

    func foo(w io.Writer) {
        w.Write([]byte("foo"))
    }

this commit enables escape analysis across interface boundaries, which
means that the Write call does not cause an allocation if all
implementations of io.Writer do not let the slice escape. This enables
broader uses of interfaces, as they are now a zero-cost abstraction in
more cases.
2018-12-22 19:06:01 +01:00
Ayke van Laethem 5a15d4162d compiler: add optsize function attr to reduce binary size
This is also added by Clang at -Oz and results in slightly smaller
binaries.
2018-12-22 18:58:43 +01:00
Ron Evans 5ff5873fe6 machine/microbit: add default pin mappings for SPI bus
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-22 17:20:40 +01:00
Ron Evans 47b667a4b8 machine/stm32: add support for stm32f103xx UART
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-18 17:17:18 +01:00
Johan Brandhorst a830451426 Dockerfile, README, docs: Remove entrypoint
This was causing more trouble than it was helping,
so lets remove it.
2018-12-17 20:41:33 +01:00
Ron Evans cb648d8ae1 compiler: pass -cflags and -ldflags to tinygo CLI command
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-13 20:10:27 +01:00
Ron Evans 8734732d0c build: Makefile needs to look at changes in all needed sub-directories to decide if rebuild is required
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-11 12:55:03 +01:00
Ayke van Laethem 6cacafb8dc cgo: add package directory to header include paths 2018-12-10 15:38:03 +01:00
Ayke van Laethem c6069476a7 cgo: do not rely on stdint.h to be available 2018-12-10 15:38:03 +01:00
Ayke van Laethem 0af7da9bff cgo: add support for C.int, c.uint, etc 2018-12-10 15:38:02 +01:00
Ayke van Laethem e8c1b5ab6e cgo: add support for C typedefs 2018-12-10 15:38:02 +01:00
Ayke van Laethem ecf6ffa62e all: add bare-bones Cgo support 2018-12-10 15:38:02 +01:00
Ayke van Laethem b99bbc880a main: add support for testing complete packages, not just .go files 2018-12-10 15:38:02 +01:00
Ayke van Laethem 8ee3267260 wasm: compile .c files in packages 2018-12-10 15:38:02 +01:00
Ayke van Laethem dea660b21c main: compile C source files in packages
TODO: C++ etc. files
2018-12-10 15:38:01 +01:00
Ayke van Laethem e10d05c74f loader: switch to custom program loader 2018-12-10 15:36:23 +01:00
Ayke van Laethem 564b1b3312 compiler: always use fat function pointers with context
This reduces complexity in the compiler without affecting binary sizes
too much.

Cortex-M0:   no changes
Linux x64:   no changes
WebAssembly: some testcases (calls, coroutines, map) are slightly bigger
2018-12-09 18:47:39 +01:00
Ayke van Laethem 3fec22e819 compiler: avoid function pointers in defer calls
Implement defer in a different way, which results in smaller binaries.
The binary produced from testdata/calls.go (the only test case with
defer) is reduced a bit in size, but the savings in bytes greatly vary
by architecture:

Cortex-M0:    -96 .text / flash
WebAssembly: -215 entire file
Linux x64:    -32 .text

Deferred functions in TinyGo were implemented by creating a linked list
of struct objects that contain a function pointer to a thunk, a pointer
to the next object, and a list of parameters. When it was time to run
deferred functions, a helper runtime function called each function
pointer (the thunk) with the struct pointer as a parameter. This thunk
would then in turn extract the saved function parameter from the struct
and call the real function.

What this commit changes, is that the loop to call deferred functions is
moved into the end of the function (practically inlining it) and
replacing the thunks with direct calls inside this loop. This makes it
much easier for LLVM to perform all kinds of optimizations like inlining
and dead argument elimination.
2018-12-09 16:44:37 +01:00
Ayke van Laethem e42289ce61 arm: add SVCAll with 0 arguments
Some very basic system calls may have no arguments at all.
2018-12-03 20:13:29 +01:00
Ayke van Laethem 9eaa6a7d7f nrf: set interrupt priorities
The default priority is 0 (highest) which is reserved by the SoftDevice.
For normal operation the exact priority level doesn't matter, only the
relative priority matters. So this change makes the code compatible with
the SoftDevice without actually changing the behavior.
2018-12-03 13:50:41 +01:00
Ayke van Laethem fa5b75464d runtime/nrf: use RTC1 instead of RTC0
The SoftDevice reserves RTC0, so to be compatible use RTC1 instead.
2018-12-03 13:50:39 +01:00
Ayke van Laethem 99daa7b38f arm: implement setting interrupt priorities 2018-12-03 13:50:38 +01:00
Ron Evans 7857c7235b machine/nrf52840: add support for ADC and PWM interfaces
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-02 19:00:33 +01:00
Ron Evans 06ab3a836f machine/nrf: SPI master implementation
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-02 13:26:08 +01:00
Ayke van Laethem 23b283366d compiler: add header comment to defer.go 2018-12-01 22:43:01 +01:00
Ayke van Laethem 69fbfbddbb compiler: move defer code out of compiler.go
This puts all defer-related code into a single file, making it easier to
understand it.
2018-12-01 19:23:56 +01:00
Ayke van Laethem b78562f95c compiler: add names to some of the IR instructions
This makes debugging LLVM IR easier.
2018-12-01 18:36:05 +01:00
Justin Clift cf9fc00ae4 all: add stub pieces for GoLand support
The bin/.keep file is just to ensure the bin directory is present,
whereas the zversion.go file is read by GoLand.
2018-12-01 18:32:34 +01:00
Ron Evans 8325f2a53d reelboard: support Reel Board (nrf52840 dev board)
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-01 18:25:36 +01:00
Ron Evans 8f35a4711a pca10056: support this nrf52840-based board
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-01 18:19:42 +01:00
Ron Evans 70830cd9da tools: correct error generating board files that calculated the address incorrectly after a cluster type
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-01 18:17:28 +01:00
Ayke van Laethem e54a1c4dc0 compiler: disallow exporting functions that have their address taken
This simplifies the ABI a lot and makes future changes easier.
In the future, determining which functions need a context parameter
should be moved from IR generation into an optimization pass, avoiding
the need for recursively scanning the Go SSA.
2018-12-01 17:41:20 +01:00