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

1199 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
0c71ed81a4
Rename runtime.itfmethod -> runtime.interfaceMethod 2018-08-27 00:49:33 +02:00
Ayke van Laethem
64e478ef36
Switch to 16-bit typecodes and method IDs
It took Android some time to even hit the 64K limit for regular method
calls, so switching to 16-bit IDs should be fine for method IDs of
interfaces. At least for the time being. When this limit is ever hit,
I'll think of another way, probably involving some platform-dependent
interface code (e.g. microcontrollers won't need 64K of methods) or
detecting the limit at build time.

https://android-developers.googleblog.com/2014/12/google-play-services-and-dex-method.html

Code size isn't changed, probably because the compiler optimizes away
all method calls.
2018-08-27 00:32:30 +02:00
Ayke van Laethem
539de9db9e
Move interface method calls in Go from LLVM IR + documentation
This commit moves the itfmethod call implemented directly in LLVM IR to
a Go implementation in the runtime. Additionally, it fixes variable
names to be more obvious and adds a lot of documentation to explain how
interfaces actually work in TinyGo.

Code size changes for src/examples/hello:
nrf:  -144
unix: -93

I'm guessing this code size reduction is a result of removing the
'noinline' function attribute.
2018-08-26 23:40:11 +02:00
Ayke van Laethem
f9f92de1c3
Add a test for the unicode package
This massively increases .data size, possibly because loads of unused
globals are included. I'll need to investigate what's going on here. For
now, increase the RAM size for nrf chips (the nrf52 has 64kB of RAM).
2018-08-24 03:35:03 +02:00
Ayke van Laethem
179cf74b01
Implement package-global maps (of max 8 entries) 2018-08-24 00:56:20 +02:00
Ayke van Laethem
2b78b6d7e8
Fix bug in runtime.memzero
Not the memory itself, but the byte after the memory was zeroed.
2018-08-23 23:45:39 +02:00
Ayke van Laethem
e884221fad
Implement len() for map types 2018-08-23 23:14:54 +02:00
Ayke van Laethem
005665aee6
Move hashmap creation to runtime 2018-08-23 23:13:38 +02:00
Ayke van Laethem
3a6ef38041
Preliminary implementation of a hashmap, unfinished
Missing features:
  * keys other than strings
  * more than 8 values in the hashmap
  * growing a map when needed
  * initial size hint
  * delete(m, key)
  * iterators (for range)
  * initializing global maps
  * ...more?
2018-08-22 04:50:24 +02:00
Ayke van Laethem
c3cb22030f
Implement == and != for strings 2018-08-22 00:56:11 +02:00
Ayke van Laethem
2777f8464e
Implement printing of booleans 2018-08-22 00:54:39 +02:00
Ayke van Laethem
29d601883b
Implement dummy GOMAXPROCS
This compiler targets single-core machines, GOMAXPROCS is thus fixed to
1.
2018-08-18 20:06:59 +02:00
Ayke van Laethem
8b6cb204cd
Basic support for slices 2018-08-18 20:06:35 +02:00
Ayke van Laethem
70871c98f8
Improve print functions 2018-08-17 23:23:38 +02:00
Ayke van Laethem
62c4c5e90b
go fmt 2018-08-17 23:23:20 +02:00
Ayke van Laethem
a97ca91c1f
compiler: Implement interface calls
This is a big combined change. Other changes in this commit:

  * Analyze makeinterface and make sure type switches don't include
    unnecessary cases.
  * Do not include CGo wrapper functions in the analyzer callgraph.
    This also avoids some unnecessary type IDs.
  * Give all Go named structs a name in LLVM.
  * Use such a named struct for compiler-generated task data.
  * Use the type and function names defined by the ssa and types
    package instead of generating our own.
  * Some improvements to function pointers.
  * A few other minor improvements.

The one thing lacking here is interface-to-interface assertions.
2018-06-17 15:50:19 +02:00
Ayke van Laethem
90fb0ee4eb
Add AVR support
This requires support in LLVM, as AVR support is still experimental. For
example, in bindings/go/build.sh, add
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR to cmake_flags.
2018-06-07 18:35:54 +02:00
Ayke van Laethem
802302a1aa
Add support for inline assembly
This depends on support in LLVM, which hasn't been merged yet.
See: https://reviews.llvm.org/D46437
2018-06-07 18:29:49 +02:00
Ayke van Laethem
0168bf7797
Add goroutines and function pointers 2018-06-07 14:48:24 +02:00
Ayke van Laethem
b4e60deacd
runtime/nrf: Fix allocator by adding align() function 2018-06-03 17:56:56 +02:00
Ayke van Laethem
588910792d
Translate bootstrapping main from C to LLVM IR
This avoids needing a C compiler for every platform.
2018-06-03 17:38:16 +02:00
Ayke van Laethem
89f77fa861
machine/dummy: Add LED1, LED2, etc to dummy machine 2018-06-03 16:42:09 +02:00
Ayke van Laethem
320c583221
Implement printing of int8/uint8/pointers 2018-06-03 16:39:24 +02:00
Ayke van Laethem
e171f32493
Implement minimal bump pointer allocator
Useful for MCUs, until a real garbage collector has been implemented.
2018-06-03 16:30:48 +02:00
Ayke van Laethem
a39951c3d7 runtime: Convert device initialization to Go 2018-05-05 20:10:39 +02:00
Ayke van Laethem
c4f0dc90dd machine: Rewrite most of the GPIO functionality
Split across device types (nrf, dummy) and use registers directly
instead of the HAL.
2018-05-05 20:05:53 +02:00
Ayke van Laethem
8c426b406d Automatically convert .svd files to Go source files 2018-05-05 19:02:43 +02:00
Ayke van Laethem
3a4663150e runtime: Implement GPIO output
Now we can actually blink a LED!
2018-04-27 01:29:13 +02:00
Ayke van Laethem
d4170faa0a runtime/nrf: Add Sleep() 2018-04-26 23:47:59 +02:00
Ayke van Laethem
4491a63fe8 Add print() for 64-bit integers 2018-04-26 23:46:34 +02:00
Ayke van Laethem
c940617849 compiler: Implement init() 2018-04-26 18:54:46 +02:00
Ayke van Laethem
2d19bb11ba compiler: Merge the runtime into the Go code, for better code size 2018-04-26 18:06:54 +02:00
Ayke van Laethem
10427c2b6f Add blinky example (which doesn't blink a LED, yet) 2018-04-25 20:07:04 +02:00
Ayke van Laethem
04fef19753 Add runtime support for the nRF52 2018-04-25 20:06:08 +02:00
Ayke van Laethem
ea129f3072 Implement runtime.Sleep 2018-04-22 19:23:16 +02:00
Ayke van Laethem
5067891236 Implement unsigned integers 2018-04-22 15:59:17 +02:00
Ayke van Laethem
75fce0f949 runtime: Move print functions to separate file 2018-04-22 15:26:07 +02:00
Ayke van Laethem
cf9cea7a0d Implement array bounds check 2018-04-21 01:03:05 +02:00
Ayke van Laethem
1f0651c84c Implement string out of bounds checks 2018-04-21 00:40:21 +02:00
Ayke van Laethem
db66039dfe Implement panic() 2018-04-21 00:26:14 +02:00
Ayke van Laethem
217c48f933 Implement interfaces on the string type 2018-04-20 22:42:43 +02:00
Ayke van Laethem
45e7376f39 Implement print() and println() in Go 2018-04-20 16:32:40 +02:00
Ayke van Laethem
ff9e7a8b77 Implement CGo support
This mostly works around the default CGo support: this compiler doesn't
need special wrappers for C functions as it uses the C calling
convention by default.
2018-04-20 16:31:43 +02:00
Ayke van Laethem
3e3c3d259f Add rudimentary interface support 2018-04-19 20:33:10 +02:00
Ayke van Laethem
850fef9852 Add builtin len(string) 2018-04-19 20:24:01 +02:00
Ayke van Laethem
013b375904 Add type methods 2018-04-16 17:04:49 +02:00
Ayke van Laethem
139ac45cb1 Use only putchar() for printing 2018-04-16 01:56:10 +02:00
Ayke van Laethem
d555ad93d7 Add support for structs 2018-04-16 01:01:11 +02:00
Ayke van Laethem
5dfcb5f085 Reorganize packages 2018-04-15 03:38:01 +02:00