Commit Graph

320 Commits

Author SHA1 Message Date
Takeshi Yoneda
4aca6fbd0e Updates Spectest to the latest (May 23, 2023) (#1490)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-05-23 15:09:36 +10:00
Takeshi Yoneda
50723a0fd2 Refactors spectest harness (#1489)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-05-23 09:59:49 +10:00
Anuraag Agrawal
714368bcea Remove threads support (#1487)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2023-05-22 12:18:36 +10:00
Crypt Keeper
34324031cb extracts FS interfaces into fsapi package and consolidates impls (#1477)
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-17 07:19:54 +03:00
Anuraag Agrawal
90eba1b81c Require max size for shared memory (#1473)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2023-05-16 16:14:13 +08:00
Anuraag Agrawal
bc96257575 Implement WebAssembly threads proposal with interpreter (#1460)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2023-05-16 12:22:17 +08:00
Nuno Cruces
4ceef7b245 memory: avoid integer overflow (#1459)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2023-05-12 14:53:00 +08:00
Takeshi Yoneda
80452a94c3 Bulk lazy initialization of FunctionDefinitions (#1425)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-12 08:02:40 +10: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
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
f47b0d3362 Reduces FunctionDefinition usages (#1419)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-05-01 10:37:43 +08: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
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
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
d33ecd0e3a cache: fixes consistency with CloseOnContextDone and listeners (#1381)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-19 15:00:46 +09:00
Crypt Keeper
df0faa5d16 emscripten: adds experimental InstantiateForModule for invoke exports (#1372)
This adds emscripten.InstantiateForModule into the experimental package.
This builds dynamic invoke exports in the same order and only matching
those needed by the importing modules.

Finally, this removes special casing of function type IDs by deferring
resolution of them only in Emscripten.

Fixes #1364

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-18 09:13:50 +02:00
Crypt Keeper
b9e03dc691 Makes host function index insertion order (#1370)
This makes host functions index consistently on insertion order, rather
than lexicographic order. This helps with ABI such as Emscripten, which
need an expected order.

This also constrains the internal code around host functions to only one
export name. More than one was never used. By restricting this, logic is
simpler and smaller.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-17 17:18:11 +01:00
Clifton Kaznocha
00d9d885ff Cleanup aliased modules when the main module is deleted (#1365)
Signed-off-by: Clifton Kaznocha <ckaznocha@users.noreply.github.com>
2023-04-17 09:32:08 +09:00
Clifton Kaznocha
a9ec3b62d3 Shrink the store's nameToModule map (#1285)
Signed-off-by: Clifton Kaznocha <ckaznocha@users.noreply.github.com>
2023-04-17 08:40:58 +09:00
Takeshi Yoneda
8ac9a54923 wasm: reduces allocs during import resolution (#1361)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-13 12:35:04 +09:00
Takeshi Yoneda
a979e0f643 wasm: removes name node to simplify instantiation path (#1359)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-13 09:26:18 +09:00
Takeshi Yoneda
a56b4435c1 Fixes memory capacity with max larger than limit (#1356)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-12 09:23:48 +09:00
Takeshi Yoneda
c719af9a14 binary: avoids copy in decodeUTF8 (#1354)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-11 14:26:28 +09:00
Takeshi Yoneda
84ea9efc14 binary: reduces allocation during code section decoding (#1352)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-10 21:48:09 +09:00
Takeshi Yoneda
3cbd881201 binary: makes NameMap and IndirectNameMap slices over values, not ptrs (#1351)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-10 21:27:50 +09:00
Takeshi Yoneda
87942692bf Reuses stack in requireStackValues of func validation (#1341)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-04 10:49:07 +09:00
Takeshi Yoneda
4f6b9f6637 Reuses bytes.Reader and value stack in func validation (#1340)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-04 10:31:15 +09:00
Takeshi Yoneda
18195355d5 Fixes race in TestModuleInstance_CloseModuleOnCanceledOrTimeout (#1339)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-03 16:48:19 +09:00
Takeshi Yoneda
4dbdbc79a2 Defer resource closure on context cancelation to ModuleInstance.FailIfClosed (#1336)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-03 12:42:27 +09:00
Takeshi Yoneda
fa3090a022 Allows WithMemoryLimitPages to override the default pages (#1335)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-03 09:30:34 +09:00
Takeshi Yoneda
ebe48da023 Reuses allocated slices in func validation (#1328)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-31 15:58:15 +09:00
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
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
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
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
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
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
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
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
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
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