Commit Graph

1070 Commits

Author SHA1 Message Date
Tristan Willy
f3516a656f wasm: move ModuleInstance.Closed to the top (#1321)
ModuleInstance.Closed is an atomic variable meant to be loaded and
swapped with sync/atomic. Closed, being a 64 bit integer, requires 64
bit alignment. The simplest way we can get alignment is to place these
atomic fields at the top of their struct.

Closed can be moved to a more logical place once support for Go 1.18 is
dropped and its type changed to atomic.Uint64.

Signed-off-by: Tristan Willy <tristan.willy@gmail.com>
2023-03-31 08:13:44 +09:00
Edoardo Vacchi
8887799da7 wazeroir: move unary byte ops to UnionOperator (#1320)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-31 08:07:12 +09:00
Louis Thibault
8b46c75ccd Add Wetware to users.md (#1319)
Signed-off-by: Louis Thibault <l.thibault@sentimens.com>
2023-03-31 08:00:21 +09:00
Edoardo Vacchi
c5d37877bd wazeroir: migrate unary operations to UnionOperation (#1318)
* refactor: OperationCall, OperationGlobalGet, OperationGlobalSet

* refactor: Constant Operations

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

---------
2023-03-30 12:57:45 +02:00
Takeshi Yoneda
448c990ab6 asm/amd64: avoids allocations on forward jump resolution (#1315)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-30 17:46:09 +09:00
Edoardo Vacchi
37135067b6 wazeroir: rm nullary Operations, move interpreterOp to UnionOperation (#1310)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-30 16:57:41 +09:00
Crypt Keeper
035c0ffaf4 wasi: adds preopen test for use in homebrew (#1309)
This adds a test to verify the wazero binary produced by homebrew.
Notably, this was made to be small enough to copy/paste in hex format.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-30 13:06:51 +08:00
Crypt Keeper
44636d02ee corrects out-of-date docs around 1.0 and fixes some relrefs (#1316)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-30 13:06:34 +08:00
Alan Braithwaite
b1dd5d9000 sys/error: handle errors.Is for common context use-cases (#1313)
Signed-off-by: Alan Braithwaite <alan@runreveal.com>
2023-03-30 11:21:19 +08:00
Takeshi Yoneda
8a9d3f2874 doc: note on using compilation cache in non-main package tests (#1312)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2023-03-30 10:01:26 +09:00
Takeshi Yoneda
76815dbd75 asm/amd64: avoids map allocation per node (#1307)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-29 16:27:54 +09:00
C.C
2c0938f1b1 add YoMo project to users.md (#1306)
Signed-off-by: C.C <fanweixiao@gmail.com>
2023-03-29 12:32:05 +08:00
Takeshi Yoneda
15e393c7e9 asm: reuse StaticConstPool (#1304)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-29 13:30:16 +09:00
Takeshi Yoneda
0f7b691555 bench: do not call _start in concurrent instantiation (#1302)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-29 12:21:05 +09:00
Takeshi Yoneda
376292fe53 asm: reuses the slice on SetBranchTargetOnNextNodes (#1303)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-29 12:20:50 +09:00
Takeshi Yoneda
2fc1fa9d79 Stop using pointer of function pointers in sys.Context (#1301)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-29 11:23:38 +09:00
Crypt Keeper
e188b646f7 godoc: clarifies UTC on clock sources (#1300)
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
This makes clock source configuration more clear about the timestamps
returned. Specifically, that realtime is UTC and the most common
consumers.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
v1.0.1
2023-03-29 09:28:52 +09:00
Edoardo Vacchi
54ba876002 interpreter: add u1, u2 int64 to interpreterOp (#1298)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-29 08:26:29 +09:00
Edoardo Vacchi
d63813a830 fs: stat and cache mode for stdio devices (#1295)
Ensure that stdio device modes are consistent with the given
file descriptors by stat'ing, instead of returning mocks.

* Use `Stat()` on `poll_oneoff()` too, instead of `IsTerminal()`,
thus avoiding a useless syscall.

* Delete leftover type decl `fileModeStat`.

* Remove IsPlatform()

* Propagate error when Stat() fails

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-28 12:48:24 +02:00
Takeshi Yoneda
fa722dd9e3 Implements api.Function directly over engine specific callEngine (#1297)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-28 16:49:35 +09:00
Takeshi Yoneda
0857336746 Removes wasm.FunctionInstance type (#1294)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-28 14:43:44 +09:00
Takeshi Yoneda
9a87d2628b Removes validatedActiveElementSegment (#1292)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-28 08:19:40 +09:00
jerbob92
a9829b627b Add pdfium-cli to users (#1293)
Signed-off-by: Jeroen Bobbeldijk <jeroen@klippa.com>
2023-03-27 16:07:18 +09:00
Takeshi Yoneda
cd606bde04 Refactors NewModuleEngine and NewCallEngine (#1291)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-27 09:40:55 +09:00
Takeshi Yoneda
a4226906cf Deletes wasm.CallCtx (#1280)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-24 17:00:43 -07:00
José Carlos Chávez
721950abc5 docs: adds import to example. (#1288)
Signed-off-by: José Carlos Chávez <jcchavezs@gmail.com>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2023-03-25 00:06:57 +01:00
jerbob92
8e6ae9c314 Add go-pdfium to users (#1289)
Signed-off-by: Jeroen Bobbeldijk <jeroen@klippa.com>
2023-03-25 00:06:41 +01:00
José Carlos Chávez
c4e34a2495 chore: fixes syntax in home site (#1287) 2023-03-24 22:00:55 +01:00
Crypt Keeper
22f8d9da69 fixes nil panic on close (#1286)
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
The last PR over-solved the WASI close problem as it special cased both
"_start", used by WASI, and the start section (wasm level) which isn't
used by WASI. In the latter case, we ended up returning nil for both the
module *and* the error result. We should never do that.. If we coerce
exit error zero to nil, we have to return a non-nil module, even if it
is unusable as otherwise code like `defer mod.Close(ctx)` will panic.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
v1.0.0
2023-03-24 18:46:43 +01:00
Crypt Keeper
451c792ee8 Avoids returning ExitError on exit code zero, and optimizes for no allocations (#1284)
Fixes #1283

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-24 16:42:30 +01:00
Crypt Keeper
86f3b190eb documents WithDirMount wrt windows (#1282)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-24 17:19:30 +09:00
Takeshi Yoneda
d0fc0c6232 Import function type check at validation phrase (#1281)
Import function type check at compilation

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-24 09:10:18 +01:00
Crypt Keeper
244c5c5792 ensures we don't open a file to close it (#1279)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-24 08:20:06 +09:00
Achille
4eba21372c Support registering multiple instances of anonymous modules (#1259)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Signed-off-by: Clifton Kaznocha <ckaznocha@users.noreply.github.com>
Co-authored-by: Clifton Kaznocha <ckaznocha@users.noreply.github.com>
2023-03-23 18:27:19 +01:00
Crypt Keeper
53bb95eeaa Allow ModuleConfig.WithName("") to clear the module name (#1277)
We currently allow clearing other config with nil, such as FSConfig.
However, we missed a spot as internally we couldn't differentiate
between name never set, or explicitly set to empty. Now, when someone
sets the module name to empty, the name in the binary section is
ignored.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-23 16:53:14 +09:00
Takeshi Yoneda
d8f356e644 Removes unused GoFunc types (#1276)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-23 16:48:14 +09:00
Takeshi Yoneda
cd1110c088 Avoids allocation of exports map per instance (#1275)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-23 16:37:56 +09:00
Crypt Keeper
7721f0ab97 build: makes wazero buildable on solaris and illumos (#1274)
This fixes a build problem on solaris and illumos. This also closes
issue #1106 because we can't make everything build with CGO (e.g. our
examples won't build unless CGO is available).

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-23 08:09:21 +09:00
Crypt Keeper
b600ed98a2 renames internal wasi package to wasip1 and removes dot imports (#1273)
This removes the generally frowned upon practice of dot imports by
shortening the name of internal/wasi_snapshot_preview1 to
internal/wasip1. This leaves the external one alone as it would break
users to change it.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-23 08:08:27 +09:00
Crypt Keeper
a2ddb04fdb wasi: enforce EPERM on malformed paths (#1266)
It seems WASI now forbids root and relative paths on the at file descriptor and returns EPERM otherwise. This enforces the following:

* require EPERM when you escape a directory (../)
* require EPERM if you add a leading slash (absolute path)
* require ENOENT if you add a trailing slash to a file
* require success if you add a trailing slash to a directory

See https://github.com/WebAssembly/wasi-testsuite/pull/67

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-22 14:46:32 +01:00
Takeshi Yoneda
48f079ad83 build: correctly replace space with comma regardless GNU/BSD (#1272)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-22 22:15:47 +09:00
Takeshi Yoneda
cd05a22df2 Reduces allocations during instantiation (#1267)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-22 18:55:58 +09:00
Takeshi Yoneda
c20073d228 Removes unnecessary .Index field of FunctionInstance (#1270)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-22 18:55:35 +09:00
Takeshi Yoneda
8c0e30b5f3 Removes unnecessary uint64 allocation on callContext (#1271)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-22 18:55:25 +09:00
Takeshi Yoneda
f8eb6a8535 Removes unused function types on encoder/decoder (#1269)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-22 08:42:55 +01:00
Crypt Keeper
cc58931352 wasi: stop suggesting lookup of files by absolute path (#1268)
WASI are recently suggesting by test that users who provide an
absolute path should fail via EPERM. Not all compilers deal with
pre-opens the same way. Notably, zig is pass-through, so it doesn't
expect to wash leading slashes around this rule.

While the jury is out on if we should break users as wasi-testsuite
wants us to, or not.. Meanwhile, we can stop suggesting use of absolute
paths, as relative ones work ("/" is the implied workdir in WASI).

See #1266

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-22 08:42:41 +01:00
Crypt Keeper
36bf277534 sysfs: requires all methods to return syscall.Errno (#1264)
This forces all syscall functions, notably filesystem, to return numeric
codes as opposed to mapping in two different areas. The result of this
change is better consolidation in call sites of `sysfs.FS`, while
further refactoring is needed to address consolidation of file errors.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-22 07:47:57 +01:00
Crypt Keeper
046af4356e wasi: removes constraint around closing a pre-open, and temporarily skips interesting_paths (#1265)
wasi-testsuite changed its mind on pre-open WebAssembly/wasi-testsuite#66

they also now explicitly forbid paths being passed in with a leading slash. Even when the config bug on WebAssembly/wasi-testsuite#67 is finished, this requires discussion if we want to EPERM on that.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-21 23:43:59 +08:00
Adrian Cole
a43a0f11e4 Revert "sysfs: requires all methods to return syscall.Errno"
This reverts commit 4ea9d1a7b5.
2023-03-21 22:22:36 +08:00
Adrian Cole
4ea9d1a7b5 sysfs: requires all methods to return syscall.Errno
This forces all syscall functions, notably filesystem, to return numeric
codes as opposed to mapping in two different areas. The result of this
change is better consolidation in call sites of `sysfs.FS`, while
further refactoring is needed to address consolidation of file errors.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-21 22:20:28 +08:00