summaryrefslogtreecommitdiff
path: root/src/wasm-delegations-fields.h
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2021-01-15 18:48:00 +0900
committerGitHub <noreply@github.com>2021-01-15 18:48:00 +0900
commitbeccdf70258cd99ea25f10af13103e14dc243ffa (patch)
tree1081d7d350fbab7f901b917f2f082c8d351c3157 /src/wasm-delegations-fields.h
parentf18c18e01d03d6d293fe3d701408855bbcea58bd (diff)
downloadbinaryen-beccdf70258cd99ea25f10af13103e14dc243ffa.tar.gz
binaryen-beccdf70258cd99ea25f10af13103e14dc243ffa.tar.bz2
binaryen-beccdf70258cd99ea25f10af13103e14dc243ffa.zip
Basic EH instrucion support for the new spec (#3487)
This updates `try`-`catch`-`catch_all` and `rethrow` instructions to match the new spec. `delegate` is not included. Now `Try` contains not a single `catchBody` expression but a vector of catch bodies and events. This updates most existing routines, optimizations, and tests modulo the interpreter and the CFG traversal. Because the interpreter has not been updated yet, the EH spec test is temporarily disabled in check.py. Also, because the CFG traversal for EH is not yet updated, several EH tests in `rse_all-features.wast`, which uses CFG traversal, are temporarily commented out. Also added a few more tests in existing EH test functions in test/passes. In the previous spec, `catch` was catching all exceptions so it was assumed that anything `try` body throws is caught by its `catch`, but now we can assume the same only if there is a `catch_all`. Newly added tests test cases when there is a `catch_all` and cases there are only `catch`es separately.
Diffstat (limited to 'src/wasm-delegations-fields.h')
-rw-r--r--src/wasm-delegations-fields.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/wasm-delegations-fields.h b/src/wasm-delegations-fields.h
index 37fb60ef2..b5d80b86a 100644
--- a/src/wasm-delegations-fields.h
+++ b/src/wasm-delegations-fields.h
@@ -57,6 +57,10 @@
//
// DELEGATE_FIELD_NAME(id, name) - called for a Name.
//
+// DELEGATE_FIELD_NAME_VECTOR(id, name) - called for a variable-sized vector of
+// names (like try's catch event names). If this is not defined, and
+// DELEGATE_GET_FIELD is, then DELEGATE_FIELD_CHILD is called on them.
+//
// DELEGATE_FIELD_SCOPE_NAME_DEF(id, name) - called for a scope name definition
// (like a block's name).
//
@@ -124,6 +128,17 @@
#error please define DELEGATE_FIELD_NAME(id, name)
#endif
+#ifndef DELEGATE_FIELD_NAME_VECTOR
+#ifdef DELEGATE_GET_FIELD
+#define DELEGATE_FIELD_NAME_VECTOR(id, name) \
+ for (Index i = 0; i < (DELEGATE_GET_FIELD(id, name)).size(); i++) { \
+ DELEGATE_FIELD_NAME(id, name[i]); \
+ }
+#else
+#error please define DELEGATE_FIELD_NAME_VECTOR(id, name)
+#endif
+#endif
+
#ifndef DELEGATE_FIELD_SCOPE_NAME_DEF
#error please define DELEGATE_FIELD_SCOPE_NAME_DEF(id, name)
#endif
@@ -490,7 +505,8 @@ switch (DELEGATE_ID) {
}
case Expression::Id::TryId: {
DELEGATE_START(Try);
- DELEGATE_FIELD_CHILD(Try, catchBody);
+ DELEGATE_FIELD_CHILD_VECTOR(Try, catchBodies);
+ DELEGATE_FIELD_NAME_VECTOR(Try, catchEvents);
DELEGATE_FIELD_CHILD(Try, body);
DELEGATE_END(Try);
break;
@@ -504,7 +520,7 @@ switch (DELEGATE_ID) {
}
case Expression::Id::RethrowId: {
DELEGATE_START(Rethrow);
- DELEGATE_FIELD_CHILD(Rethrow, exnref);
+ DELEGATE_FIELD_INT(Rethrow, depth);
DELEGATE_END(Rethrow);
break;
}
@@ -665,6 +681,7 @@ switch (DELEGATE_ID) {
#undef DELEGATE_FIELD_INT_ARRAY
#undef DELEGATE_FIELD_LITERAL
#undef DELEGATE_FIELD_NAME
+#undef DELEGATE_FIELD_NAME_VECTOR
#undef DELEGATE_FIELD_SCOPE_NAME_DEF
#undef DELEGATE_FIELD_SCOPE_NAME_USE
#undef DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR