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

1199 коммитов

Автор SHA1 Сообщение Дата
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
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
Ayke van Laethem
7bdb606d4f
reflect: update type code type to uintptr
This type was missed after the recent interface updates.
2018-12-01 16:17:35 +01:00
Ayke van Laethem
b4c90f3677
compiler: lower interfaces in a separate pass
This commit changes many things:

  * Most interface-related operations are moved into an optimization
    pass for more modularity. IR construction creates pseudo-calls which
    are lowered in this pass.
  * Type codes are assigned in this interface lowering pass, after DCE.
  * Type codes are sorted by usage: types more often used in type
    asserts are assigned lower numbers to ease jump table construction
    during machine code generation.
  * Interface assertions are optimized: they are replaced by constant
    false, comparison against a constant, or a typeswitch with only
    concrete types in the general case.
  * Interface calls are replaced with unreachable, direct calls, or a
    concrete type switch with direct calls depending on the number of
    implementing types. This hopefully makes some interface patterns
    zero-cost.

These changes lead to a ~0.5K reduction in code size on Cortex-M for
testdata/interface.go. It appears that a major cause for this is the
replacement of function pointers with direct calls, which are far more
susceptible to optimization. Also, not having a fixed global array of
function pointers greatly helps dead code elimination.

This change also makes future optimizations easier, like optimizations
on interface value comparisons.
2018-12-01 13:26:06 +01:00
Ayke van Laethem
dbb3211485
wasm: add glue JS code
The file wasm_glue.js was copied from the Go wasm port and was modified,
most importantly to match the TinyGo calling convention.
2018-11-24 19:03:58 +01:00
Ayke van Laethem
242a1843d1
wasm: fix heap end address 2018-11-24 19:00:42 +01:00
Ayke van Laethem
d887d645f7
arm: implement SVCall
The SVCall function call is lowered to an inline "svc" instruction. The
first parameter *must* be a constant number.
2018-11-21 17:06:56 +01:00
Ron Evans
ce0ad1daa2
pca10031: add support for PCA10031 nrf51 wireless dongle
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-11-21 10:36:36 +01:00
Ayke van Laethem
bf4a43ef04
machine/avr: implement raw GPIO access for bitbanged drivers 2018-11-20 21:04:43 +01:00
Ayke van Laethem
9392ef900d
avr: add support for the digispark
Blinking the on-board LED works. Nothing else has been tested yet.
2018-11-20 18:50:24 +01:00
Ayke van Laethem
8402e84b6d
runtime: implement a simple mark/sweep garbage collector 2018-11-18 19:18:39 +01:00
Ayke van Laethem
27fc397e21
arm: implement arm.ReadRegister
This pseudo-function reads the contents of the specified register, for
example "sp".
2018-11-18 18:40:36 +01:00
Ayke van Laethem
9181f2d4ce
runtime: add "end of heap" to detect out of memory
This can be used in the future to trigger garbage collection. For now,
it provides a more useful error message in case the heap is completely
filled up.
2018-11-17 15:33:32 +01:00
Ayke van Laethem
ef93001ab8
runtime: add "none" garbage collector
This collector does not implement runtime.alloc, so it is a
quick-and-dirty way to check where in a program memory is allocated.
2018-11-17 15:14:29 +01:00
Ayke van Laethem
c220c140ef
all: make garbage collector configurable 2018-11-17 15:14:05 +01:00
Ayke van Laethem
15a4afb22a
runtime: unify GC interface
Make sure every to-be-implemented GC can use the same interface. As a
result, a 1MB chunk of RAM is allocated on Unix systems on init instead
of allocating on demand.
2018-11-17 14:11:58 +01:00
Ayke van Laethem
1ba463c7ee
machine: redesign I2C interface 2018-11-16 23:08:41 +01:00
Ayke van Laethem
9bddaae04a
compiler: support any int type in slice indexes
Make sure the compiler will correctly compile indexes of type uint64,
for example.
2018-11-14 14:41:40 +01:00
Ayke van Laethem
ee7c276493
compiler: update integer type sizes
* Use 64-bit integers on 64-bit platforms, just like gc and gccgo:
  https://golang.org/doc/go1.1#int
* Do not use a separate length type. Instead, use uintptr everywhere a
  length is expected.
2018-11-14 14:01:04 +01:00
Ayke van Laethem
c4ef2908ee
microbit: fix pin numbers for ADC and I2C 2018-11-11 19:23:09 +01:00
Ayke van Laethem
d1c0d6120a
compiler: simplify runtime.interfaceMethod signature slightly
Code size is not affected, as dead arguments are eliminated anyway.
It makes future interface optimizations hopefully easier to implement.
2018-11-09 15:20:38 +01:00
Ayke van Laethem
611bca39ab
all: rename 'arm' to 'tinygo.arm' for Cortex-M
Let the standard library think that it is compiling for js/wasm.

The most correct way of supporting bare metal Cortex-M targets would be
using the 'arm' build tag and specifying no OS or an 'undefined' OS
(perhaps GOOS=noos?). However, there is no build tag for specifying no
OS at all, the closest possible is GOOS=js which makes very few
assumptions.

Sadly GOOS=js also makes some assumptions: it assumes to be running with
GOARCH=wasm. This would not be such a problem, just add js, wasm and arm
as build tags. However, having two GOARCH build tags leads to an error
in internal/cpu: it defines variables for both architectures which then
conflict.

To work around these problems, the 'arm' target has been renamed to
'tinygo.arm', which should work around these problems. In the future, a
GOOS=noos (or similar) should be added which can work with any
architecture and doesn't implement OS-specific stuff.
2018-11-09 11:50:38 +01:00
Marc-Antoine Ruel
b1cf69a523 compiler: implement binop string: <, <=, >, >=
Include unit tests.
2018-11-08 20:48:29 -05:00
Ayke van Laethem
76d04990f4
runtime: stub out some more syscall/js calls
These produce link errors when trying to import the "os" package.
2018-11-05 13:52:56 +01:00
Ayke van Laethem
b4be9e033a
runtime: add syscall/js stubs for microcontrollers 2018-11-05 13:11:15 +01:00
Ayke van Laethem
22914165cc
reflect: add more stubs for encoding/binary
Package encoding/binary uses reflect and is needed by image/png, but
image/png doesn't actually need the reflect-using parts of
encoding/binary. So stub them out for now to get it to compile.

Thanks to Stephen Solka who wrote the patch.
2018-11-03 16:06:44 +01:00
Ayke van Laethem
d7844ce124
compiler, runtime: move defer notes to the runtime file
This seems like the more appropriate place to describe the
implementation of defer.
2018-11-01 11:42:04 +01:00
Ayke van Laethem
a459570d94
wasm: execute an 'unreachable' trap inst on panic
This already happened when directly calling panic() but not with some
runtime panics like accessing a slice out of bounds.
2018-10-30 15:59:29 +01:00
Ayke van Laethem
0314a487ff
compiler: check slice cap instead of len during slicing
When doing a slice operation on a slice, use the capacity value instead
of the length. Of course, for strings and arrays, the slice operation
checks the length because there is no capacity. But according to the
spec, this check should be based on cap for slice instead of len:

> For slices, the upper index bound is the slice capacity cap(a) rather
> than the length.

https://golang.org/ref/spec#Slice_expressions

Fixes: https://github.com/aykevl/tinygo/issues/65
2018-10-30 15:58:50 +01:00
Ayke van Laethem
772c6486ab
runtime: correctly copy a zero-length buffer backwards
Fixes:
https://github.com/aykevl/tinygo/issues/64
2018-10-29 14:02:47 +01:00
Ayke van Laethem
d90d7be8a8
runtime: implement syscall.runtime_envs
It is stubbed out currently, but may be useful in the future.

Note that this function is implemented for a future change to the init
system, it is not yet useful.
2018-10-28 19:25:55 +01:00
Ayke van Laethem
436901dc49
compiler: implement operations on nil hashmaps
* comparing a map against nil
  * getting the length of a nil map
2018-10-27 00:57:37 +02:00
Ayke van Laethem
0b8beb77c1
reflect: add stub reflect package
This is necessary to compile fmt. However, it cannot link yet.
2018-10-23 15:39:53 +02:00
Ayke van Laethem
96f74ec153
compiler: support 64-bit numbers in bounds check 2018-10-23 14:07:27 +02:00
Ayke van Laethem
9b9b66a09d
compiler: add complex manipulation
* builtins: real, imag, complex
* printing of complex numbers

No support for complex arithmetic yet.
2018-10-22 13:49:03 +02:00
Ayke van Laethem
e5e09747f0
all: add WebAssembly backend 2018-10-21 19:47:47 +02:00
Ayke van Laethem
ad06ed46cd
runtime: fix linker error: os.sigpipe 2018-10-20 18:37:58 +02:00
Ayke van Laethem
0a06c6014d
compiler: special slice bounds check for 64-bit numbers
It is allowed to index with an int64 even on a 32-bit platform, so we
have to handle that case. But make sure the normal case isn't penalized
by using 32-bit numbers when possible.
2018-10-20 18:28:00 +02:00
Ayke van Laethem
239504d9f4
compiler: implement recover()
Doesn't do anything useful yet as running deferred calls are not
executed during panic. Only implemented to get code to compile.
2018-10-20 18:00:12 +02:00
Ayke van Laethem
7c2a6169b0
compiler: support comma-ok in map lookup 2018-10-20 17:54:16 +02:00
Ayke van Laethem
c0c1ccb381
compiler, runtime: implement delete builtin 2018-10-20 16:18:55 +02:00
Ayke van Laethem
7f60dd79ee
sync: implement dummy sync.Pool for fmt 2018-10-20 15:52:41 +02:00
Ayke van Laethem
963ba16d7b
compiler: add support for the append builtin 2018-10-19 14:40:19 +02:00
Ayke van Laethem
fd45410c24
runtime: add proper arm arch 2018-10-18 15:23:52 +02:00
Ayke van Laethem
daf92226d8
nrf: add nrf52840-mdk board
With the help of Chillance on GitHub.
2018-10-18 15:07:06 +02:00
Ayke van Laethem
a613d0484e
runtime: add support for time.Now()
TODO: On unix systems, this does not return an accurate value.
2018-10-15 20:20:37 +02:00