Commit c4b4e11
committed
reboot
This re-introduces Go support, with a new implementation written from scratch.
While the previous incarnation targeted TinyGo and reused the C generator for
lifting and lowering, this one targets "big" Go and handles lifting and lowering
itself. In addition, it supports idiomatic, goroutine-based concurrency on top
of the component model async ABI, including streams and futures.
This implementation is also distinct from the
[go-modules](https://github.com/bytecodealliance/go-modules) project, which has
a number of limitations (e.g. no async support, not safe for use with "big" Go)
and is no longer being actively maintained.
Note that the async support currently requires [a small
patch](dicej/go@a1c8322)
to the Go `runtime` library. I plan to work with the upstream project to make
that patch unecessary in the future. Components that don't use async features
should work with stock, unpatched Go.
One of the tricky parts about lowering values and passing pointers to
e.g. `{stream,future}.{read,write}` is that we must tell the Go garbage
collector to pin the pointers (i.e. mark the pointee as both immovable and
uncollectable) for as long as the host has access to them, but then unpin them
promptly afterward to avoid leaks. We do this using `runtime.Pinner` instances,
most of which are locally scoped and easy to reason about. However, we must use
a couple of globally-scoped pinners as well: one for `cabi_realloc` allocations
by the host when it lowers parameters (which we unpin after lifting those
parameters) and another for returning values from sync-lifted exports (which we
unpin in post-return functions).
There are a couple of known missing features which I'll open GitHub issues for:
1. Resource handles are not being restored for unwritten items in the case of an incomplete stream or future write.
2. Importing and/or exporting multiple versions of the same package will cause name clashes.
In addition, I plan to expand the test coverage beyond the basics covered in
this commit.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>wit-bindgen-go
1 parent ba933bd commit c4b4e11
File tree
57 files changed
+5488
-26
lines changed- crates
- core/src
- go
- src
- test/src
- src/bin
- tests
- runtime-async/async
- simple-call-import
- simple-future
- simple-import-params-results
- simple-pending-import
- simple-stream-payload
- simple-stream
- runtime
- demo
- flavorful
- lists
- many-arguments
- numbers
- records
- resource-import-and-export
- resources
- results
- strings-simple
- strings
- variants
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
57 files changed
+5488
-26
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
806 | 806 | | |
807 | 807 | | |
808 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
809 | 815 | | |
810 | 816 | | |
811 | 817 | | |
| |||
1134 | 1140 | | |
1135 | 1141 | | |
1136 | 1142 | | |
1137 | | - | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1138 | 1147 | | |
1139 | 1148 | | |
1140 | 1149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments