You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by tq...@apache.org on 2024/02/05 16:24:32 UTC
(tvm) 01/01: Revert "[Unity][WEB] Temp disable wasm exception (#16444)"
This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch web-exception
in repository https://gitbox.apache.org/repos/asf/tvm.git
commit 2479d4e6bf65e065b7c403ef6e650270cd1e04e2
Author: tqchen <ti...@gmail.com>
AuthorDate: Mon Feb 5 11:23:14 2024 -0500
Revert "[Unity][WEB] Temp disable wasm exception (#16444)"
This reverts commit 61d952c701a8c03e2e897e357e1eed4e79d3269f.
Previously this was disabled because ci-wasm wasn't updated this PR
re-enable it.
---
python/tvm/contrib/emcc.py | 4 +---
web/Makefile | 4 +---
web/package.json | 2 +-
web/tests/node/test_packed_func.js | 15 +++++++++++++++
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/python/tvm/contrib/emcc.py b/python/tvm/contrib/emcc.py
index d4624a3469..d6cdf22a22 100644
--- a/python/tvm/contrib/emcc.py
+++ b/python/tvm/contrib/emcc.py
@@ -42,9 +42,7 @@ def create_tvmjs_wasm(output, objects, options=None, cc="emcc"):
cmd += ["-O3"]
cmd += ["-std=c++17"]
cmd += ["--no-entry"]
- # temp disable for backward compact
- # can enable after emsdk updates
- # cmd += ["-fwasm-exception"]
+ cmd += ["-fwasm-exception"]
cmd += ["-s", "WASM_BIGINT=1"]
cmd += ["-s", "ERROR_ON_UNDEFINED_SYMBOLS=0"]
cmd += ["-s", "STANDALONE_WASM=1"]
diff --git a/web/Makefile b/web/Makefile
index 9ed041e829..bd5e6cbf2b 100644
--- a/web/Makefile
+++ b/web/Makefile
@@ -27,9 +27,7 @@ all: dist/wasm/tvmjs_runtime.wasm dist/wasm/tvmjs_runtime.wasi.js src/tvmjs_runt
EMCC = emcc
-EMCC_CFLAGS = $(INCLUDE_FLAGS) -O3 -std=c++17 -Wno-ignored-attributes
-
-# -fwasm-exceptions
+EMCC_CFLAGS = $(INCLUDE_FLAGS) -O3 -std=c++17 -Wno-ignored-attributes -fwasm-exceptions
EMCC_LDFLAGS = --no-entry -s WASM_BIGINT=1 -s ALLOW_MEMORY_GROWTH=1 -s STANDALONE_WASM=1\
-s ERROR_ON_UNDEFINED_SYMBOLS=0 --pre-js emcc/preload.js
diff --git a/web/package.json b/web/package.json
index 8a08be6d91..2e8de05971 100644
--- a/web/package.json
+++ b/web/package.json
@@ -13,7 +13,7 @@
"build": "rollup -c",
"lint": "eslint -c .eslintrc.json .",
"typedoc": "typedoc src/index.ts --plugin typedoc-plugin-missing-exports",
- "test": "node node_modules/.bin/jest",
+ "test": "node --experimental-wasm-eh node_modules/.bin/jest",
"bundle": "npm run build && cp lib/index.js dist/index.js && cp lib/index.js dist/tvmjs.bundle.js",
"example": "npm run bundle && node apps/node/example.js",
"example:wasi": "npm run bundle && node --experimental-wasi-unstable-preview1 --experimental-wasm-bigint apps/node/wasi_example.js",
diff --git a/web/tests/node/test_packed_func.js b/web/tests/node/test_packed_func.js
index 04b91c861d..f5c0ac6c2f 100644
--- a/web/tests/node/test_packed_func.js
+++ b/web/tests/node/test_packed_func.js
@@ -126,6 +126,21 @@ test("RegisterGlobal", () => {
tvm.endScope();
});
+test("ExceptionPassing", () => {
+ tvm.beginScope();
+ tvm.registerFunc("throw_error", function (msg) {
+ throw Error(msg);
+ });
+ let f = tvm.getGlobalFunc("throw_error");
+ try {
+ f("error-xyz");
+ throw Error("error not caught");
+ } catch (error) {
+ assert(error.message.indexOf("error-xyz") != -1);
+ }
+ tvm.endScope();
+});
+
test("NDArrayCbArg", () => {
tvm.beginScope();
let use_count = tvm.getGlobalFunc("testing.object_use_count");