Commit Graph

1172 Commits

Author SHA1 Message Date
Nuno Cruces
2bf8abe1fe Cleanup scattered documentation TODOs. (#1442)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2023-05-08 18:04:02 +01:00
Crypt Keeper
3bf7e342c2 Adds Utimens to platform.File (#1440)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-08 11:14:28 +08:00
Crypt Keeper
76ef347b8c Adds Read and Pread to platform.File (#1439)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-08 07:54:06 +08:00
Achille
5add4dc0bf experimental: add wazerotest package (#1437) 2023-05-06 08:19:27 -07:00
Nuno Cruces
38a7a0f730 examples(allocation): ensure message outlives host call (#1436)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-05 11:21:13 +02:00
Crypt Keeper
b5198a46ff Adds AccessMode Write and Pwrite to platform.File (#1438)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-05 13:23:30 +08:00
Edoardo Vacchi
e46e803565 site: fix small mistake in TinyGo doc (#1435)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-04 16:31:39 +02:00
Crypt Keeper
5380321eea Adds Truncate to platform.File (#1428)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-04 15:07:18 +08:00
Crypt Keeper
6dd0cef551 Splits EACCES from EPERM on Windows (#1430)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-04 14:50:35 +08:00
Edoardo Vacchi
a912ea844e compiler: update RATIONALE.md for native check (#1432)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-04 07:37:13 +08:00
Crypt Keeper
e5dc733df7 Adds Path to platform.File and refactors tests (#1431)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-04 07:05:40 +08:00
Adrian Cole
cf5ebf6f6b Use require.ErrnoEquals for more precise failures
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-03 13:54:12 +08:00
Crypt Keeper
c7623db7cb Revises instructions to latest guidance from TinyGo (#1429)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Achille <achille.roussel@gmail.com>
2023-05-03 08:15:09 +08:00
Luca Burgazzoli
b2c11d8dfd examples(allocation): free memory after unmarshalling a result from the guest (#1390)
Signed-off-by: Luca Burgazzoli <lburgazzoli@gmail.com>
2023-05-03 07:01:05 +08:00
Crypt Keeper
c5871c772c Adds Datasync to platform.File (#1427)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-02 14:12:47 +08:00
Crypt Keeper
b79c45b91c Adds Sync to platform.File (#1426)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-02 13:16:50 +08:00
Achille
d5a2d3c7b4 wasip1: fix file open modes used by wasi-libc (#1421)
This extends wazero's interpretation of rights in wasi_snapshot_preview1.path_open to allow programs to open files in either read-only, write-only, or read-write mode.

Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2023-05-02 09:48:26 +08:00
Crypt Keeper
20017ca5e6 shows implementation impact of UnimplementedFile (#1424)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-02 07:31:17 +08:00
Crypt Keeper
18c793f8e6 Adds platform.File.Chmod (#1423)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-01 19:18:56 +08:00
Crypt Keeper
1047ddee78 Adds platform.File.Chown (#1422)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-01 18:32:13 +08:00
Crypt Keeper
493fe2d410 sysfs: stubs in approach to defining a new file type (#1290)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-01 12:33:40 +08:00
Takeshi Yoneda
cdaf6d41c8 interpreter: refactors around FunctionDefinition (#1420)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-05-01 12:07:47 +09:00
Takeshi Yoneda
f47b0d3362 Reduces FunctionDefinition usages (#1419)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-05-01 10:37:43 +08:00
Crypt Keeper
f3f7352584 lifts emscripten.InstantiateForModule out of experimental (#1418)
Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-12) (push) Has been cancelled
Release CLI / Pre-release test (ubuntu-22.04) (push) Has been cancelled
Release CLI / Pre-release test (windows-2022) (push) Has been cancelled
Release CLI / Release (push) Has been cancelled
Signed-off-by: Adrian Cole <adrian@tetrate.io>
v1.1.0
2023-05-01 09:12:04 +08:00
Achille
974973d6f5 CONTRIBUTING.md: add bullet point about the merge process (#1416)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2023-04-30 18:05:20 -07:00
Nuno Cruces
77e8d72d67 api: adds CallWithStack to avoid allocations (#1407)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2023-05-01 08:52:40 +09:00
Thomas Pelletier
0bfb4b52eb Give Listener a read-only view of globals (#1404)
* experimental: give listener r/o view of globals

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* experimental: add global support to interpreter

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* exp: replace globals proxy with module interface

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* exp: trim down experimental.InternalModule

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Replace globals view slice with constantGlobal

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Fix tests after merge

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Address PR feedback

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Rename methods of experimental.Module

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Run make check

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

* Add WazeroOnlyType to constantGlobal

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>

---------

Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>
2023-04-29 00:07:28 -07:00
Crypt Keeper
6098f60bd1 Adds SplitCallStack for use in CallWithStack (#1414)
This adds an internal function `wasm.SplitCallStack` for use in #1407.
This is separate because the diff is a lot larger than the destination
change ;)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-29 13:28:52 +08:00
Ashley Jeffs
0dd73938eb Add Benthos to users.md (#1412) 2023-04-28 06:00:04 -07:00
Nuno Cruces
197facf7a9 Close certain api interfaces for external implementation (#1396)
This adds a new type `internalapi.WazeroOnly` which should be embedded on types users are likely to accidentally implement despite docs saying otherwise.

Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2023-04-28 15:32:32 +08:00
Takeshi Yoneda
f9f17031f9 Update the year in license (#1411)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-04-28 09:19:24 +09:00
Edoardo Vacchi
34a639b770 wasi: improve select(2) impl on Windows (#1398)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-04-28 08:36:48 +09:00
Takeshi Yoneda
c82ad896f6 ci: try enabling Windows on wasip1 test (#1406)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-04-27 16:21:02 +09:00
Takeshi Yoneda
86444c67a3 ci: run -race on PRs as well (#1408)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-27 09:54:59 +09:00
Takeshi Yoneda
867459d7d5 compiler: mmap per module instead of per function (#1377)
This changes the mmap strategy used in the compiler backend.
Previously, we used mmap syscall once per function and allocated the 
executable pages each time. Basically, mmap can only allocate the 
boundary of the page size of the underlying os. Even if the requested 
executable is smaller than the page size, the entire page is marked as 
executable and won't be reused by Go runtime. Therefore, we wasted 
roughly `(len(body)%osPageSize)*function`.

Even though we still need to align each function on 16 bytes boundary
when mmaping per module, the wasted space is much smaller than before.

The following benchmark results shows that this improves the overall 
compilation performance while showing the heap usage increased. 
However, the increased heap usage is totally offset by the hidden wasted
memory page which is not measured by Go's -benchmem.
Actually, when I did the experiments, I observed that roughly 20~30mb are
wasted on arm64 previously which is larger than the increased heap usage
in this result. More importantly, this increased heap usage is a target of GC
and should be ignorable in the long-running program vs the wasted page 
is persistent until the CompiledModule is closed.

Not only the actual compilation time, the result indicates that this could 
improve the overall Go runtime's performance maybe thanks to not abusing
runtime.Finalizer since you can see this improves the subsequent interpreter 
benchmark results.

```
goos: darwin
goarch: arm64
pkg: github.com/tetratelabs/wazero/internal/integration_test/bench
                                   │   old.txt   │              new.txt              │
                                   │   sec/op    │   sec/op     vs base              │
Compilation_sqlite3/compiler-10      183.4m ± 0%   175.9m ± 2%  -4.10% (p=0.001 n=7)
Compilation_sqlite3/interpreter-10   61.59m ± 0%   59.57m ± 0%  -3.29% (p=0.001 n=7)
geomean                              106.3m        102.4m       -3.69%

                                   │   old.txt    │               new.txt               │
                                   │     B/op     │     B/op      vs base               │
Compilation_sqlite3/compiler-10      42.93Mi ± 0%   54.33Mi ± 0%  +26.56% (p=0.001 n=7)
Compilation_sqlite3/interpreter-10   51.75Mi ± 0%   51.75Mi ± 0%   -0.01% (p=0.001 n=7)
geomean                              47.13Mi        53.02Mi       +12.49%

                                   │   old.txt   │              new.txt              │
                                   │  allocs/op  │  allocs/op   vs base              │
Compilation_sqlite3/compiler-10      26.07k ± 0%   26.06k ± 0%       ~ (p=0.149 n=7)
Compilation_sqlite3/interpreter-10   13.90k ± 0%   13.90k ± 0%       ~ (p=0.421 n=7)
geomean                              19.03k        19.03k       -0.02%


goos: linux
goarch: amd64
pkg: github.com/tetratelabs/wazero/internal/integration_test/bench
cpu: AMD Ryzen 9 3950X 16-Core Processor
                                   │   old.txt   │              new.txt               │
                                   │   sec/op    │   sec/op     vs base               │
Compilation_sqlite3/compiler-32      384.4m ± 2%   373.0m ± 4%   -2.97% (p=0.001 n=7)
Compilation_sqlite3/interpreter-32   86.09m ± 4%   65.05m ± 2%  -24.44% (p=0.001 n=7)
geomean                              181.9m        155.8m       -14.38%

                                   │   old.txt    │               new.txt               │
                                   │     B/op     │     B/op      vs base               │
Compilation_sqlite3/compiler-32      49.40Mi ± 0%   59.91Mi ± 0%  +21.29% (p=0.001 n=7)
Compilation_sqlite3/interpreter-32   51.77Mi ± 0%   51.76Mi ± 0%   -0.02% (p=0.001 n=7)
geomean                              50.57Mi        55.69Mi       +10.12%

                                   │   old.txt   │              new.txt              │
                                   │  allocs/op  │  allocs/op   vs base              │
Compilation_sqlite3/compiler-32      28.70k ± 0%   28.70k ± 0%       ~ (p=0.925 n=7)
Compilation_sqlite3/interpreter-32   14.00k ± 0%   14.00k ± 0%  -0.04% (p=0.010 n=7)
geomean                              20.05k        20.04k       -0.02%
```

resolves #1060 

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-26 14:11:37 +09:00
Takeshi Yoneda
557c340b2f ci: cleanup GOOS=wasip1 (#1405)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-26 11:53:35 +09:00
Julien Fabre
7b2ba183f8 Add Go test suite against gotip (#1379)
Signed-off-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2023-04-26 08:16:22 +09:00
Crypt Keeper
4c2638e41e wasi: fixes bug where zero length iovec breaks fd_read (#1402)
We should tolerate noop input vs break. This fixes where a zero length
iovec would short circuit latter ones.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-25 14:43:43 +08:00
Takeshi Yoneda
3c1c76e2a1 debug: includes Go stack trace in the face of Go runtime errors (#1401)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-25 10:45:20 +09:00
Takeshi Yoneda
8838d9370b logging: correctly omits result.newoffset in Before (#1400)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-25 09:16:27 +09:00
Crypt Keeper
999176e279 godoc: moves sealed type notes to the top and backfills where missing (#1397)
wazero uses interfaces even when they aren't intended to be implemented
by users. We relied on documentation, to suggest what is implementable,
and in some cases documented correctly types that weren't for
implementation.

However, we didn't add that boilerplate to all types, and we also forgot
to recently when it was discussed a week or two ago. This finishes the
job by boilerplating all types that aren't for implementation. This also
orders to the top when it already existed.

Later, we can choose to enforce by type as well, we didn't know how to
do that before. Basically before we just casted to our internal types,
which would stop accidental implementation for things except people
using the types for wrapping purposes.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-24 18:44:11 +08:00
Takeshi Yoneda
a7e1e693b9 asm/amd64: removes enablePadding flag (#1395)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-24 10:07:27 +09:00
Takeshi Yoneda
62074dc601 asm/amd64: removes nodeImpl.forwardJumpTarget (#1394)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-24 09:55:24 +09:00
Takeshi Yoneda
c6c46114ef asm/amd64: optimizes initializeNodesForEncoding (#1393)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-24 08:22:37 +09:00
Crypt Keeper
601db82f8e ci: ensure release notes script can see prior commits (#1392)
Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-12) (push) Has been cancelled
Release CLI / Pre-release test (ubuntu-22.04) (push) Has been cancelled
Release CLI / Pre-release test (windows-2022) (push) Has been cancelled
Release CLI / Release (push) Has been cancelled
Signed-off-by: Adrian Cole <adrian@tetrate.io>
v1.0.3
2023-04-22 09:06:56 +02:00
Edoardo Vacchi
6f0b85a451 packaging: switch to native WiX toolchain and Windows runner (#1385)
Cross-platform msitools do not support the `Environment` directive,
which should be the proper way to update %PATH%, so we adapt
the Makefile to assume a Windows environment when building, addressing #1374.

`make dist` now runs on all platforms, but on Windows, assuming
`candle.exe`, `light.exe` and GNU `tar` are installed, it builds
all tarballs, zip and msi packages.

On other platforms it will only build the tarballs.

We also address some other issues with msitools
and change the GUID for UpgradeCode which caused
the wazero package to be mistaken for func-e
when installing/uninstalling both on the same
machine.

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-04-22 08:12:12 +02:00
Crypt Keeper
40341af448 fs: returns EBADF on negative file descriptor (#1391)
This changes file descriptors from uint32 to int32 and the
corresponding file table to reject negative values. This ensures
invalid values aren't mistaken for very large descriptor entries, which
can use a lot of memory as the table implementation isn't designed to
be sparse.

See https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirfd.html#tag_16_90

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-21 16:08:35 +02:00
Takeshi Yoneda
010f0a93a2 asm/amd64: optimizes maybeNOPPadding if conds (#1389)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-21 15:11:37 +09:00
Takeshi Yoneda
f3deb47d69 asm/amd64: uses enum for operand types (#1388)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-21 11:30:14 +09:00
Takeshi Yoneda
ae6a43b367 asm/amd64: removes map access in encoding (#1387)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-21 10:50:35 +09:00