743 Commits
Author SHA1 Message Date
Volodymyr Shymanskyy 7f0dc04993 Boost ver 2024-08-25 20:42:39 +03:00
tommie 35b5e2fb53 fix: memory.grow by a negative number is an error (#498)
This is to comply with e.g. wasmtime. The spec does not make it
explicit what growing by a negative number should mean. It's likely a
mistake, so let's fail.

Closes #442.
2024-08-07 12:28:25 +03:00
Volodymyr ShymanskyyandTommie Gannert 256cd37bbd Implements the custom-page-size proposal. (#496)
Co-authored-by: Tommie Gannert <tommie@gannert.se>
2024-08-03 12:48:28 +03:00
Volodymyr Shymanskyy f37749cb4c Fix #493 2024-08-03 02:19:22 +03:00
Volodymyr Shymanskyy 5814318ac6 Revert "fix: Makes CopyStackSlotsR use numSlots. (#489)"
This reverts commit e887a3b084.
2024-08-03 01:54:23 +03:00
tommie e887a3b084 fix: Makes CopyStackSlotsR use numSlots. (#489)
Closes #471.
2024-08-03 01:48:23 +03:00
tommie 526c1251b6 fix: Releases M3Module.memoryImport. (#490)
Fixes #462
2024-08-03 01:42:22 +03:00
tommie 2c54e3d2ab fix: Adjust number of values when handling f32 in block results. (#491)
Fixes #465.
2024-08-03 01:41:06 +03:00
garrison hinson-hasty 139076a98b bugfix: use gcc/clang compatible overflow builtins for integer arithmetic (#450) 2024-01-30 23:17:28 +02:00
Volodymyr Shymanskyy ee813c31f4 Fix build 2023-12-18 11:39:06 +02:00
Volodymyr Shymanskyy a118277040 Fix build 2023-12-18 11:33:35 +02:00
Finn 7ed176d985 Add m3_GetTableFunction to allow calling functions by index (#448) 2023-12-18 03:35:48 +02:00
Tatsuyuki Kobayashi 6512cc99d0 Check global mutability (#417) 2023-12-18 03:27:50 +02:00
Nathan Rajlich 8f3fe3bd1d Allow for retrieval of "memory" type import / export name (#449)
* Store the memory export name

When the memory export is defined in the WASM module,
store the name of the export so that it can be read by
the application.

This is necessary for implementing the JavaScript
`WebAssembly.Module.exports()` function.

* Store the memory import name

When the memory import is defined in the WASM module,
store the name of the import so that it can be read by
the application.

This is necessary for implementing the JavaScript
`WebAssembly.Module.imports()` function.

* Store the table0 export name

When the table export is defined in the WASM module,
store the name of the export so that it can be read by
the application.

This is necessary for implementing the JavaScript
`WebAssembly.Module.exports()` function.
2023-12-18 03:27:24 +02:00
DianQK c5fe08894f Fix freeing the stack address incorrectly when unwinding local functions. (#436) 2023-12-18 03:23:03 +02:00
Guus Waals 69bc275e4b Disable tail calls on emscripten (#434)
By default, unless M3_HAS_TAIL_CALL is defined as 1
2023-12-18 03:21:25 +02:00
YenFuChen 0e7b874529 Fix function signature (#412) 2023-12-18 02:48:37 +02:00
coderzh a0f4ec9e63 fix consts limit bug (#391) 2022-11-12 12:08:46 +00:00
Cheng Shao 6ad2d3fea1 Bump up some default limits to align with mainstream wasm implementations (#403)
This commit bumps up some default limit values to align with some
mainstream wasm implementations, and allows wasm3 to execute some
larger wasm32 modules that it would previously report errors like "too
many functions" and such. There are specialized m3_core.h for more
restricted platforms, and this commit doesn't touch those, so it
shouldn't increase the overhead on those platforms.

Wasm spec discussion: https://github.com/WebAssembly/spec/issues/607
V8 limits: https://chromium.googlesource.com/v8/v8/+/master/src/wasm/wasm-limits.h
SpiderMonkey limits: https://hg.mozilla.org/mozilla-central/file/tip/js/src/wasm/WasmConstants.h
JavaScriptCore limits: https://github.com/WebKit/WebKit/blob/main/Source/JavaScriptCore/wasm/WasmLimits.h
2022-11-12 12:06:56 +00:00
Bill d3a763c84c Remove alignment attributes defined as vectorcall. The compiler interprets this as an alignment requirement on the pointer itself, not what it points to, which is probably not what was intended. (#393) 2022-11-12 10:01:46 +00:00
I-mikan-I bd152c79aa Fix operations preventing tail-call-elimination: (#402)
If the compiler cannot analyze memcpy, it must expect that pointer arguments may be stored as static data and must live for recursive calls.
In such cases, op_Store and op_Load operations will not get tail-call optimized.
By enclosing the local variables in a block before the recursive call, the storage duration does not extend far enough, allowing for TCO.
2022-11-12 10:00:06 +00:00
Balint Molnar aba42b533e feat: add support for multi return value for raw functions (#385) 2022-09-12 13:26:12 +03:00
Volodymyr Shymanskyy 9a2894387d Detect musttail attribute 2022-08-31 23:24:23 +03:00
skrphv 7dd43c11d8 m3_Call*-functions fix (#364)
* fix for [issues#363](https://github.com/wasm3/wasm3/issues/363)

* minor
2022-08-31 23:16:22 +03:00
Volodymyr Shymanskyy 8e2db951d6 Fix strict aliasing warnings 2022-08-31 22:31:25 +03:00
Volodymyr Shymanskyy e43e93046a Fix CI 2022-08-31 22:01:35 +03:00
Volodymyr Shymanskyy 89964f456b Fix build 2022-08-31 21:54:59 +03:00
Volodymyr Shymanskyy 03a4652520 Use musttail attribute for Clang 13+ 2022-08-31 20:15:33 +03:00
Volodymyr Shymanskyy 22fa923eef Fix strict aliasing warnings 2022-08-31 19:33:51 +03:00
Volodymyr Shymanskyy d97045a804 Increase d_m3MaxFunctionStackHeight on some platforms 2022-08-31 17:35:37 +03:00
Volodymyr Shymanskyy 3a144c0d39 Drop DEBUG requirement for d_m3EnableStrace >= 2 2022-08-30 14:42:51 +03:00
Yuta Saito 99cbf5144d m3_env.c: prefer export name in searching function (#328)
Since https://reviews.llvm.org/D81689, wasm-ld has started wrapping
all exported functions including "_start" with surrounding ctor/dtor
calls. The wrapper function "_start.command_export" is exposed as
"_start".
wasm3 searched the entry function by looking up names indiscriminately.
However, it sometimes found the internal "_start" function, so ctor/dtor
were not called. To pick up the wrapper "_start", this patch changes to
search export names at first.
2022-08-30 14:03:41 +03:00
Volodymyr Shymanskyy fbbacefeaf Set linear memory limit to 65536 pages. Fix #353 2022-08-30 13:22:11 +03:00
Volodymyr Shymanskyy 7a8eec8fae Try fix CI 2022-08-30 12:48:53 +03:00
Volodymyr Shymanskyy 17fc9b4728 Try fix CI 2022-08-30 12:41:42 +03:00
Volodymyr Shymanskyy 1a68d516b5 Fix warnings 2022-08-30 11:12:19 +03:00
Volodymyr Shymanskyy 3443437f46 Fix build 2022-08-29 20:01:17 +03:00
Volodymyr Shymanskyy 2d5ce699f5 Fix CI 2022-08-29 18:56:22 +03:00
Volodymyr Shymanskyy 321ba58316 Merge branch 'main' of https://github.com/wasm3/wasm3 into main 2022-08-29 16:57:22 +03:00
Volodymyr Shymanskyy 43cea2cfd9 Move d_m3EnableWasiTracing to m3_config.h 2022-08-29 16:55:30 +03:00
Volodymyr Shymanskyy 2d2c2c7489 Fix warnings 2022-08-29 16:51:54 +03:00
Alex Rebert 8f3986a66c Fix memory safety issues found by OSS-Fuzz (#301)
* Add integer overflow checks in NewCodePage

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33457

* TouchSlot should track slots outside of functions

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33554.

The OSS-Fuzz inputs led to a crash on a Const64 instruction that
overflows the stack. The overflow was not detected during compilation as
TouchSlot did not track maxStackSlots if o->function is NULL. This
commit changes TouchSlot to track slots outside of functions.

* Fix out-of-bounds write in MarkSlotsAllocatedByType

While pushing the params back onto the stack in CompileBlock,
GetSlotForStackIndex may return c_slotUnused. If that is the case,
passing the slot to MarkSlotsAllocatedByType leads to a crash.

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33555
Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=36551

* Fix memory leak in CompileElseBlock

In the case of an exception in CompileElseBlock, the original page was not
properly restored and was leaked. This commit moves the release/restore
in the _catch: block which always executes.

* Fix stackIndex underflow in param deallocation

When the stack is polymorphic, the stack should never underflow. This
commits fixes an unreported stack underflow while led to an integer
underflow in stackIndex. Now, if the stack is polymorphic, we only
decrement stackIndex up until blockStackIndex.
2022-08-29 15:22:17 +03:00
Felipe Gasper 4fb6d9e426 Fix parsing of i32 constant globals on big-endian systems. (#322)
FIx #321. This replaces `intValue` in the global value union with
separate `i32Value` and `i64Value`. A CI test is added against s390x.
2022-08-29 15:10:23 +03:00
Volodymyr Shymanskyy 0d60e827a8 Remove d_m3EnableCodePageRefCounting from config 2022-08-29 14:20:06 +03:00
Volodymyr Shymanskyy cbf910387f Link more uvwasi functions.
Fix #309
2022-08-29 14:12:51 +03:00
Nick Wanninger 9dcfce271c Check for if slot == c_slotUnused in PushConst (#315) 2022-06-20 18:00:55 +03:00
Felipe Gasper 8523770b80 Fix Cygwin compatibility (#330)
* Make simple WASI work in Cygwin.

Issue #329

* Prevent M3_WEAK from taking effect on Cygwin.

Issue #329

* Add CI to ensure that Cygwin doesn’t regress.

Issue #329
2022-06-01 12:53:58 +03:00
ha1vkand赵海 8441c82c4a fix WASI API read/write pread/pwrite buffer overflow (#324)
Co-authored-by: 赵海 <zhaohai@cyberpeace.cn>
2022-04-13 20:48:13 +03:00
cui fliter 839e57a220 fix some typos (#316)
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-04 14:55:40 +03:00
Vladimir Serbinenko c101549795 w3_defs.h: Ensure that endian.h or stdint.h is included before using uint* (#304)
This is an addendum to my previous patch as it missed to ensure inclusion of
some header that provides uint*. It worked for me only because of local flags
to add this include
2022-01-19 16:43:12 +02:00