Commit Graph

797 Commits

Author SHA1 Message Date
Thomas Pelletier
9aca08c5e6 Provide new StackIterator to Before Listener hook (#1363)
Signed-off-by: Thomas Pelletier <thomas@pelletier.codes>
2023-04-18 08:22:58 +09:00
Crypt Keeper
cd34767954 Fixes race where HostFunc names are needlessly lazy set (#1375)
A prior change broke race tests as it lazy set HostFunc.Name even when
saved as a field. This sets name in all places we instantiate HostFunc
for use in fields.

Fixes #1373

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-18 08:14:05 +09:00
Crypt Keeper
9263bef174 logging: fixes bug where unsampled logger is called from a sampled one (#1369)
We had a logging bug where an unsampled function (such as fd_write to
stdout/stderr) would end up with its logging "after" hook called, if it
was called from a sampled function.

For example, if a wasm function called fd_write with stdout, the before
hook on fd_write would skip, but the after would not, and accidentally
use its caller's parameters. This results in a panic due to incorrect
length.

This fixes the bug by ensuring we mute the logging context if there's
one in progress. It ensures the bug won't pop up again by adding test
data that matches the call pattern (from xpdf-wasm).

Thanks to @jerbob92 for helping isolate this!

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-17 17:36:15 +01: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
Takeshi Yoneda
27b405f17b asm/arm64: removes unneeded 16 bytes alignment (#1367)
signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-17 15:16:40 +09:00
Takeshi Yoneda
d9e5d6b0d3 Avoids unnecessary allocations during mmap executables (#1366)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-17 14:03:35 +09: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
5464903d8f interpreter: use slice of values on functions, not ptrs (#1357)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-12 11:35:13 +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
3aeeb0b01d asm/arm64: avoids using unnecessary map access (#1355)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-11 15:40:33 +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
b6d19696da compiler: reuses allocated runtimeValueLocation stacks (#1348)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-10 14:58:47 +09:00
Takeshi Yoneda
f167939c88 wazeroir: avoids allocation with InclusiveRange (#1345)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-07 12:14:39 +09:00
Takeshi Yoneda
24dbf49c79 compiler: avoid alloc with stack pointer ceil and reuse bytes reader (#1344)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-06 16:47:08 +09:00
Takeshi Yoneda
df8586e58b interpreter: reduces allocations in lowerIR (#1343)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-06 15:04:39 +09:00
Takeshi Yoneda
cc28399052 wazeroir: reuses allocated slices for a module (#1342)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-05 20:26:44 +09:00
Edoardo Vacchi
0dc152d672 wazeroir: migrate vector, table, branch and all other remaining ops to compact repr (#1334)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-05 09:38:49 +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
Edoardo Vacchi
f3ef84c9b3 wazeroir: Load Ops, Store Ops, Set, Pick, Select, CallIndirect (#1329)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2023-04-01 08:00:27 +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
Takeshi Yoneda
b9babda2d4 compiler: stop using map for label infos (#1327)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-31 15:14:16 +09:00
Takeshi Yoneda
cee1e50ad2 compiler: avoids allocation in label resolution (#1326)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-30 22:26:18 -07:00
Takeshi Yoneda
bbae781978 compiler: avoid allocation in SetJumpTargetOnNext (#1325)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-31 13:03:26 +09:00
Takeshi Yoneda
276d7015df compiler: removes takeFreeRegisters fn (#1324)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-31 12:34:41 +09:00
Takeshi Yoneda
ef8e12a575 compiler: bitmask for tracking used registers (#1323)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-31 12:28:20 +09:00
Takeshi Yoneda
a0a6331011 asm/amd64: avoids allocation in getting memory location (#1322)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-31 08:52:01 +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
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
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
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
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
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