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

76 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
efdc2b8672
compiler: add basic debug info
Only implements debugging with source lines and stacktraces (without
parameters), which already is a huge improvement over no debug
information at all. This should be extended to arguments and local
variables (of the correct DWARF type), but this is more work.
2018-09-03 19:17:44 +02:00
Ayke van Laethem
a7fcef62e0
compiler: implement comparing interfaces to nil
Comparing an interface to nil is easy, as the dynamic type is also nil.
Comparing the dynamic values (when the dynamic types match) is much
harder and depends on reflection capabilities, so is not yet implemented.
2018-09-03 01:13:07 +02:00
Ayke van Laethem
c100e4d67f
compiler: fix nil constant interface
A nil interface has no dynamic type (or: nil dynamic type). Don't try to
use the static type as the dynamic type, because these are different.
2018-09-03 01:01:24 +02:00
Ayke van Laethem
4ed04309a3
compiler: truncate shift amount when needed 2018-09-03 00:22:55 +02:00
Ayke van Laethem
ebd87ce4cd
compiler: implement []byte(str) 2018-09-03 00:21:33 +02:00
Ayke van Laethem
a080ce26ef
compiler: implement string slicing 2018-09-02 23:46:31 +02:00
Ayke van Laethem
1170cdc21f
compiler: implement Field expression
This expression is used when calling a method on an embedded type in a
struct.
2018-09-02 21:14:33 +02:00
Ayke van Laethem
9519f989bc
runtime/scheduler: make debugging easier + rename some functions
This shouldn't affect functionality but makes debugging a whole lot
easier. A scheduler is difficult so make it easy to debug.
2018-09-02 19:30:13 +02:00
Ayke van Laethem
1e90858145
Fix blocking functions
Don't think they're blocking when the scheduler has been disabled.
2018-09-02 18:39:39 +02:00
Ayke van Laethem
bfff0c33e4
Fix external globals
This broke the allocator on ARM, and with that the blinky example.
2018-09-02 18:37:28 +02:00
Ayke van Laethem
88b6b2e7f5
Optimize/eliminate bounds checking
TODO: do better at it by tracking min/max values of integers. The
following straightforward code doesn't have its bounds checks removed:

    for _, n := range slice {
        println(n)
    }
2018-09-02 16:28:46 +02:00
Ayke van Laethem
42cddd3260
Move runtime.TargetBits out of the compiler 2018-09-02 16:00:31 +02:00
Ayke van Laethem
9fca0e99b5
compiler: use InternalLinkage where appropriate
Internal linkage means that symbols show up in tools like objdump, which
is very useful for debugging.
2018-09-02 15:58:49 +02:00
Ayke van Laethem
58c87329d4
Implement closures and bound methods 2018-09-02 03:39:37 +02:00
Ayke van Laethem
58b853bbef
Defer for trivial cases 2018-09-01 17:14:38 +02:00
Ayke van Laethem
887814a69d
Be able to handle complex64 and complex128 types
No support for complex types yet, but at least be able to handle their
types.
2018-08-31 21:30:21 +02:00
Ayke van Laethem
94ce893ab4
Copy printfloat() from original runtime
I've tried writing my own, but I couldn't make it correct in all cases.
So just copy the one from upstream for now, hopefully to be replaced at
some point.

TODO: add a printfloat32() implementation, now it just casts to float64.
This will be useful for embedded systems that sometimes have float32 but
not float64.
2018-08-31 21:29:34 +02:00
Ayke van Laethem
46d2d2e777
Add support for floats
I'm not sure all operations are supported but the vast majority should
be supported now.

This commit also refactors binop translation.
2018-08-31 21:29:13 +02:00
Ayke van Laethem
f057d612fc
Add support for indexing in an array by a non-constant 2018-08-31 21:20:10 +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
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
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
a5252d07f0
Support zero-initialized pointers in globals 2018-08-30 05:38:27 +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
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
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
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
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