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

413 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
b13cfc5255
Be able to deal with anonymous functions 2018-08-30 22:52:00 +02:00
Ayke van Laethem
674b506bb2
Replace compiler hack for sync package with //go:linkname 2018-08-30 22:38:45 +02:00
Ayke van Laethem
74bd378c29
Replace _llvm_* workaround in the scheduler with //go:linkname
This also removes the need for the _llvm_ special case in the compiler.
And it makes the scheduler code a whole lot nicer!
2018-08-30 22:30:16 +02:00
Ayke van Laethem
771f23e320
Implement //go:linkname pragma 2018-08-30 22:27:19 +02:00
Ayke van Laethem
906e061e37
Replace own dummy syscall with standard library syscall
This makes it easier to support other standard library packages.
2018-08-30 05:58:54 +02:00
Ayke van Laethem
e01259ba77
interpreter: string concatenation
Sometimes strings are concatenated in a way that isn't const-propagated
by the SSA transformation (e.g. the result of a function call).
Concatenate them during init() interpretation.
2018-08-30 05:54:40 +02:00
Ayke van Laethem
16cdffc367
Try to interpret simple function calls in init() functions
This is useful for example for globals like these:

    import "errors"

    var MyError = errors.New("mymodule: something went wrong!")
2018-08-30 05:53:22 +02:00
Ayke van Laethem
15f62b29cf
Add runtime.GOOS 2018-08-30 05:48:16 +02:00
Ayke van Laethem
82d0d70ba2
Add (hardcoded) runtime.GOROOT()
Necessary for the time package.
2018-08-30 05:41:48 +02:00
Ayke van Laethem
cfd20c7a12
Add a number for the "error" type by default 2018-08-30 05:40:11 +02:00
Ayke van Laethem
a5252d07f0
Support zero-initialized pointers in globals 2018-08-30 05:38:27 +02:00
Ayke van Laethem
5edf94ea10
Fix named structs inside global named structs 2018-08-30 05:36:44 +02:00
Ayke van Laethem
7956ca2f29
Function pointers in global variables 2018-08-30 05:36:09 +02:00
Ayke van Laethem
a4fd096393
Add dummy channel support 2018-08-30 05:32:18 +02:00
Ayke van Laethem
6e0c60a7a1
Some extra header docs 2018-08-30 02:36:13 +02:00
Ayke van Laethem
0b372ba5bd
Support initialized map values in another global 2018-08-30 02:32:35 +02:00
Ayke van Laethem
42711c11e9
Be able to print maps to some degree
Print the number of elements, or nil if it is a nil map.
2018-08-30 02:26:48 +02:00
Ayke van Laethem
d930a9ba16
Implement print() for interface values 2018-08-30 02:20:36 +02:00
Ayke van Laethem
25344bc08f
Reorder Program.interpret cases 2018-08-30 02:09:02 +02:00
Ayke van Laethem
75477eb14e
Implement global .data-initalized interfaces 2018-08-30 02:08:00 +02:00
Ayke van Laethem
d13c124df9
Implement casting from (Unicode) integer to string 2018-08-30 00:36:54 +02:00
Ayke van Laethem
fdc56d5940
Implement convert string <- []byte 2018-08-29 23:54:46 +02:00
Ayke van Laethem
eed25c78df
Clean up ssa.Convert and ssa.ChangeType 2018-08-29 23:36:58 +02:00
Ayke van Laethem
8b95b869ab
Implement string concatenation 2018-08-29 22:10:46 +02:00
Ayke van Laethem
c912091f8b
Add integer key support to hashmap 2018-08-29 21:50:43 +02:00
Ayke van Laethem
8f7db8661b
Move string type to runtime in separate file 2018-08-29 20:55:09 +02:00
Ayke van Laethem
bf160d096b
Move lenType definition to runtime (partially) 2018-08-29 20:48:56 +02:00
Ayke van Laethem
abaae5b90d
Remove unnecessary compiler workaround
This workaround isn't needed anymore: the feature has been implemented
now.
2018-08-29 20:45:50 +02:00
Ayke van Laethem
7991243554
Remove CGo from machine module
It isn't necessary anymore but apparently the Go importer didn't
complain about an unused import.
2018-08-29 20:44:56 +02:00
Ayke van Laethem
d4f5700625
Remove use of CGo in the runtime
CGo depends on syscall, which (in the standard library) depends on sync,
which depends on the runtime. There are also other import cycles. To be
able to use the syscall package from upstream, stop using CGo.
2018-08-29 20:01:33 +02:00
Ayke van Laethem
d620f0d188
Implement multiple return values from functions
Use structs in LLVM as it appears LLVM has no support for multiple
return values (I should look into how Rust does it...).
2018-08-29 19:42:22 +02:00
Ayke van Laethem
ee10162564
Extra check on interface asserts
Interface asserts haven't been implemented yet. Don't produce incorrect
code in that case.
2018-08-27 00:50:03 +02:00
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
309de00fd6
Simplify function names by removing $async suffix 2018-08-26 21:45:28 +02:00
Ayke van Laethem
58e31fd470
Simplify a bit of code 2018-08-26 21:38:55 +02:00
Ayke van Laethem
de6c20f1bd
Implement untyped bool 2018-08-25 03:24:06 +02:00
Ayke van Laethem
c9e6a52d05
Implement constant slice
It's used somewhere in the sync package, but I'm not sure where.
2018-08-25 02:58:59 +02:00
Ayke van Laethem
9f2bcfe5e3
Implement global interface variable constant 2018-08-25 02:58:00 +02:00
Ayke van Laethem
c25b448758
Rewrite init() interpretation to a real interpreter
Instead of mostly heuristics, actually execute the init() instruction in
an interpreter to calculate initializers for globals. This is far more
flexible and extensible, and gives the option of extending the
interpreter to other code and make it a partial evaluator.
2018-08-25 02:07:01 +02:00
Ayke van Laethem
9b4ac0459b
Make strings constant
For some reason this was disabled.
2018-08-24 05:18:41 +02:00
Ayke van Laethem
f49ceddd73
Enable elimination of dead globals by marking them private
This eliminates most of the newly created dead globals.
2018-08-24 04:25:16 +02:00
Ayke van Laethem
5f28b07f75
Enable aggressive code size optimizations: -Oz 2018-08-24 03:35:39 +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
36a5af9e6d
README: dead code elimination 2018-08-24 03:02:06 +02:00
Ayke van Laethem
ab3358e5a3
Add make fmt 2018-08-24 02:59:18 +02:00
Ayke van Laethem
fa12da95e2
Some documentation fixes 2018-08-24 02:56:09 +02:00
Ayke van Laethem
0defed9677
Resolve named types 2018-08-24 02:55:06 +02:00
Ayke van Laethem
1229667f7c
Support pointers in global variables 2018-08-24 02:54:37 +02:00