summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binaryen-c.cpp158
-rw-r--r--src/binaryen-c.h132
-rw-r--r--src/cfg/cfg-traversal.h7
-rw-r--r--src/ir/ReFinalize.cpp2
-rw-r--r--src/ir/import-utils.h18
-rw-r--r--src/ir/module-splitting.cpp14
-rw-r--r--src/ir/module-utils.h28
-rw-r--r--src/ir/names.h4
-rw-r--r--src/ir/utils.h4
-rw-r--r--src/js/binaryen.js-post.js90
-rw-r--r--src/passes/Metrics.cpp2
-rw-r--r--src/passes/Print.cpp36
-rw-r--r--src/passes/RemoveUnusedModuleElements.cpp18
-rw-r--r--src/shared-constants.h2
-rw-r--r--src/tools/fuzzing.h13
-rw-r--r--src/tools/wasm-metadce.cpp35
-rw-r--r--src/wasm-binary.h14
-rw-r--r--src/wasm-builder.h42
-rw-r--r--src/wasm-delegations-fields.def6
-rw-r--r--src/wasm-interpreter.h10
-rw-r--r--src/wasm-s-parser.h8
-rw-r--r--src/wasm-stack.h2
-rw-r--r--src/wasm-traversal.h12
-rw-r--r--src/wasm.h36
-rw-r--r--src/wasm/wasm-binary.cpp108
-rw-r--r--src/wasm/wasm-interpreter.cpp2
-rw-r--r--src/wasm/wasm-s-parser.cpp100
-rw-r--r--src/wasm/wasm-stack.cpp4
-rw-r--r--src/wasm/wasm-validator.cpp41
-rw-r--r--src/wasm/wasm.cpp32
-rw-r--r--src/wasm2js.h2
31 files changed, 484 insertions, 498 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp
index e6ef2a366..182a687a3 100644
--- a/src/binaryen-c.cpp
+++ b/src/binaryen-c.cpp
@@ -201,8 +201,8 @@ BinaryenExternalKind BinaryenExternalMemory(void) {
BinaryenExternalKind BinaryenExternalGlobal(void) {
return static_cast<BinaryenExternalKind>(ExternalKind::Global);
}
-BinaryenExternalKind BinaryenExternalEvent(void) {
- return static_cast<BinaryenExternalKind>(ExternalKind::Event);
+BinaryenExternalKind BinaryenExternalTag(void) {
+ return static_cast<BinaryenExternalKind>(ExternalKind::Tag);
}
// Features
@@ -1287,8 +1287,8 @@ BinaryenExpressionRef BinaryenRefEq(BinaryenModuleRef module,
BinaryenExpressionRef BinaryenTry(BinaryenModuleRef module,
const char* name,
BinaryenExpressionRef body,
- const char** catchEvents,
- BinaryenIndex numCatchEvents,
+ const char** catchTags,
+ BinaryenIndex numCatchTags,
BinaryenExpressionRef* catchBodies,
BinaryenIndex numCatchBodies,
const char* delegateTarget) {
@@ -1297,8 +1297,8 @@ BinaryenExpressionRef BinaryenTry(BinaryenModuleRef module,
ret->name = name;
}
ret->body = (Expression*)body;
- for (BinaryenIndex i = 0; i < numCatchEvents; i++) {
- ret->catchEvents.push_back(catchEvents[i]);
+ for (BinaryenIndex i = 0; i < numCatchTags; i++) {
+ ret->catchTags.push_back(catchTags[i]);
}
for (BinaryenIndex i = 0; i < numCatchBodies; i++) {
ret->catchBodies.push_back((Expression*)catchBodies[i]);
@@ -1311,7 +1311,7 @@ BinaryenExpressionRef BinaryenTry(BinaryenModuleRef module,
}
BinaryenExpressionRef BinaryenThrow(BinaryenModuleRef module,
- const char* event,
+ const char* tag,
BinaryenExpressionRef* operands,
BinaryenIndex numOperands) {
std::vector<Expression*> args;
@@ -1319,7 +1319,7 @@ BinaryenExpressionRef BinaryenThrow(BinaryenModuleRef module,
args.push_back((Expression*)operands[i]);
}
return static_cast<Expression*>(
- Builder(*(Module*)module).makeThrow(event, args));
+ Builder(*(Module*)module).makeThrow(tag, args));
}
BinaryenExpressionRef BinaryenRethrow(BinaryenModuleRef module,
@@ -2979,55 +2979,55 @@ void BinaryenTrySetBody(BinaryenExpressionRef expr,
assert(bodyExpr);
static_cast<Try*>(expression)->body = (Expression*)bodyExpr;
}
-BinaryenIndex BinaryenTryGetNumCatchEvents(BinaryenExpressionRef expr) {
+BinaryenIndex BinaryenTryGetNumCatchTags(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
assert(expression->is<Try>());
- return static_cast<Try*>(expression)->catchEvents.size();
+ return static_cast<Try*>(expression)->catchTags.size();
}
BinaryenIndex BinaryenTryGetNumCatchBodies(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
assert(expression->is<Try>());
return static_cast<Try*>(expression)->catchBodies.size();
}
-const char* BinaryenTryGetCatchEventAt(BinaryenExpressionRef expr,
- BinaryenIndex index) {
+const char* BinaryenTryGetCatchTagAt(BinaryenExpressionRef expr,
+ BinaryenIndex index) {
auto* expression = (Expression*)expr;
assert(expression->is<Try>());
- assert(index < static_cast<Try*>(expression)->catchEvents.size());
- return static_cast<Try*>(expression)->catchEvents[index].c_str();
+ assert(index < static_cast<Try*>(expression)->catchTags.size());
+ return static_cast<Try*>(expression)->catchTags[index].c_str();
}
-void BinaryenTrySetCatchEventAt(BinaryenExpressionRef expr,
- BinaryenIndex index,
- const char* catchEvent) {
+void BinaryenTrySetCatchTagAt(BinaryenExpressionRef expr,
+ BinaryenIndex index,
+ const char* catchTag) {
auto* expression = (Expression*)expr;
assert(expression->is<Try>());
- assert(index < static_cast<Try*>(expression)->catchEvents.size());
- assert(catchEvent);
- static_cast<Try*>(expression)->catchEvents[index] = catchEvent;
+ assert(index < static_cast<Try*>(expression)->catchTags.size());
+ assert(catchTag);
+ static_cast<Try*>(expression)->catchTags[index] = catchTag;
}
-BinaryenIndex BinaryenTryAppendCatchEvent(BinaryenExpressionRef expr,
- const char* catchEvent) {
+BinaryenIndex BinaryenTryAppendCatchTag(BinaryenExpressionRef expr,
+ const char* catchTag) {
auto* expression = (Expression*)expr;
assert(expression->is<Try>());
- assert(catchEvent);
- auto& list = static_cast<Try*>(expression)->catchEvents;
+ assert(catchTag);
+ auto& list = static_cast<Try*>(expression)->catchTags;
auto index = list.size();
- list.push_back(catchEvent);
+ list.push_back(catchTag);
return index;
}
-void BinaryenTryInsertCatchEventAt(BinaryenExpressionRef expr,
- BinaryenIndex index,
- const char* catchEvent) {
+void BinaryenTryInsertCatchTagAt(BinaryenExpressionRef expr,
+ BinaryenIndex index,
+ const char* catchTag) {
auto* expression = (Expression*)expr;
assert(expression->is<Try>());
- assert(catchEvent);
- static_cast<Try*>(expression)->catchEvents.insertAt(index, catchEvent);
+ assert(catchTag);
+ static_cast<Try*>(expression)->catchTags.insertAt(index, catchTag);
}
-const char* BinaryenTryRemoveCatchEventAt(BinaryenExpressionRef expr,
- BinaryenIndex index) {
+const char* BinaryenTryRemoveCatchTagAt(BinaryenExpressionRef expr,
+ BinaryenIndex index) {
auto* expression = (Expression*)expr;
assert(expression->is<Try>());
- return static_cast<Try*>(expression)->catchEvents.removeAt(index).c_str();
+ return static_cast<Try*>(expression)->catchTags.removeAt(index).c_str();
}
BinaryenExpressionRef BinaryenTryGetCatchBodyAt(BinaryenExpressionRef expr,
BinaryenIndex index) {
@@ -3092,15 +3092,15 @@ bool BinaryenTryIsDelegate(BinaryenExpressionRef expr) {
return static_cast<Try*>(expression)->isDelegate();
}
// Throw
-const char* BinaryenThrowGetEvent(BinaryenExpressionRef expr) {
+const char* BinaryenThrowGetTag(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
assert(expression->is<Throw>());
- return static_cast<Throw*>(expression)->event.c_str();
+ return static_cast<Throw*>(expression)->tag.c_str();
}
-void BinaryenThrowSetEvent(BinaryenExpressionRef expr, const char* eventName) {
+void BinaryenThrowSetTag(BinaryenExpressionRef expr, const char* tagName) {
auto* expression = (Expression*)expr;
assert(expression->is<Throw>());
- static_cast<Throw*>(expression)->event = eventName;
+ static_cast<Throw*>(expression)->tag = tagName;
}
BinaryenIndex BinaryenThrowGetNumOperands(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
@@ -3348,26 +3348,26 @@ BinaryenGlobalRef BinaryenGetGlobalByIndex(BinaryenModuleRef module,
return globals[index].get();
}
-// Events
+// Tags
-BinaryenEventRef BinaryenAddEvent(BinaryenModuleRef module,
- const char* name,
- uint32_t attribute,
- BinaryenType params,
- BinaryenType results) {
- auto* ret = new Event();
+BinaryenTagRef BinaryenAddTag(BinaryenModuleRef module,
+ const char* name,
+ uint32_t attribute,
+ BinaryenType params,
+ BinaryenType results) {
+ auto* ret = new Tag();
ret->setExplicitName(name);
ret->attribute = attribute;
ret->sig = Signature(Type(params), Type(results));
- ((Module*)module)->addEvent(ret);
+ ((Module*)module)->addTag(ret);
return ret;
}
-BinaryenEventRef BinaryenGetEvent(BinaryenModuleRef module, const char* name) {
- return ((Module*)module)->getEventOrNull(name);
+BinaryenTagRef BinaryenGetTag(BinaryenModuleRef module, const char* name) {
+ return ((Module*)module)->getTagOrNull(name);
}
-void BinaryenRemoveEvent(BinaryenModuleRef module, const char* name) {
- ((Module*)module)->removeEvent(name);
+void BinaryenRemoveTag(BinaryenModuleRef module, const char* name) {
+ ((Module*)module)->removeTag(name);
}
// Imports
@@ -3419,19 +3419,19 @@ void BinaryenAddGlobalImport(BinaryenModuleRef module,
ret->mutable_ = mutable_;
((Module*)module)->addGlobal(ret);
}
-void BinaryenAddEventImport(BinaryenModuleRef module,
- const char* internalName,
- const char* externalModuleName,
- const char* externalBaseName,
- uint32_t attribute,
- BinaryenType params,
- BinaryenType results) {
- auto* ret = new Event();
+void BinaryenAddTagImport(BinaryenModuleRef module,
+ const char* internalName,
+ const char* externalModuleName,
+ const char* externalBaseName,
+ uint32_t attribute,
+ BinaryenType params,
+ BinaryenType results) {
+ auto* ret = new Tag();
ret->name = internalName;
ret->module = externalModuleName;
ret->base = externalBaseName;
ret->sig = Signature(Type(params), Type(results));
- ((Module*)module)->addEvent(ret);
+ ((Module*)module)->addTag(ret);
}
// Exports
@@ -3481,13 +3481,13 @@ BinaryenExportRef BinaryenAddGlobalExport(BinaryenModuleRef module,
((Module*)module)->addExport(ret);
return ret;
}
-BinaryenExportRef BinaryenAddEventExport(BinaryenModuleRef module,
- const char* internalName,
- const char* externalName) {
+BinaryenExportRef BinaryenAddTagExport(BinaryenModuleRef module,
+ const char* internalName,
+ const char* externalName) {
auto* ret = new Export();
ret->value = internalName;
ret->name = externalName;
- ret->kind = ExternalKind::Event;
+ ret->kind = ExternalKind::Tag;
((Module*)module)->addExport(ret);
return ret;
}
@@ -4146,21 +4146,21 @@ BinaryenExpressionRef BinaryenGlobalGetInitExpr(BinaryenGlobalRef global) {
}
//
-// =========== Event operations ===========
+// =========== Tag operations ===========
//
-const char* BinaryenEventGetName(BinaryenEventRef event) {
- return ((Event*)event)->name.c_str();
+const char* BinaryenTagGetName(BinaryenTagRef tag) {
+ return ((Tag*)tag)->name.c_str();
}
-uint32_t BinaryenEventGetAttribute(BinaryenEventRef event) {
- return ((Event*)event)->attribute;
+uint32_t BinaryenTagGetAttribute(BinaryenTagRef tag) {
+ return ((Tag*)tag)->attribute;
}
-BinaryenType BinaryenEventGetParams(BinaryenEventRef event) {
- return ((Event*)event)->sig.params.getID();
+BinaryenType BinaryenTagGetParams(BinaryenTagRef tag) {
+ return ((Tag*)tag)->sig.params.getID();
}
-BinaryenType BinaryenEventGetResults(BinaryenEventRef event) {
- return ((Event*)event)->sig.results.getID();
+BinaryenType BinaryenTagGetResults(BinaryenTagRef tag) {
+ return ((Tag*)tag)->sig.results.getID();
}
//
@@ -4191,10 +4191,10 @@ const char* BinaryenGlobalImportGetModule(BinaryenGlobalRef import) {
return "";
}
}
-const char* BinaryenEventImportGetModule(BinaryenEventRef import) {
- auto* event = (Event*)import;
- if (event->imported()) {
- return event->module.c_str();
+const char* BinaryenTagImportGetModule(BinaryenTagRef import) {
+ auto* tag = (Tag*)import;
+ if (tag->imported()) {
+ return tag->module.c_str();
} else {
return "";
}
@@ -4223,10 +4223,10 @@ const char* BinaryenGlobalImportGetBase(BinaryenGlobalRef import) {
return "";
}
}
-const char* BinaryenEventImportGetBase(BinaryenEventRef import) {
- auto* event = (Event*)import;
- if (event->imported()) {
- return event->base.c_str();
+const char* BinaryenTagImportGetBase(BinaryenTagRef import) {
+ auto* tag = (Tag*)import;
+ if (tag->imported()) {
+ return tag->base.c_str();
} else {
return "";
}
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index 79613bd65..a92e7b6bd 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -140,7 +140,7 @@ BINARYEN_API BinaryenExternalKind BinaryenExternalFunction(void);
BINARYEN_API BinaryenExternalKind BinaryenExternalTable(void);
BINARYEN_API BinaryenExternalKind BinaryenExternalMemory(void);
BINARYEN_API BinaryenExternalKind BinaryenExternalGlobal(void);
-BINARYEN_API BinaryenExternalKind BinaryenExternalEvent(void);
+BINARYEN_API BinaryenExternalKind BinaryenExternalTag(void);
// Features. Call to get the value of each; you can cache them. Use bitwise
// operators to combine and test particular features.
@@ -855,14 +855,14 @@ BINARYEN_API BinaryenExpressionRef
BinaryenTry(BinaryenModuleRef module,
const char* name,
BinaryenExpressionRef body,
- const char** catchEvents,
- BinaryenIndex numCatchEvents,
+ const char** catchTags,
+ BinaryenIndex numCatchTags,
BinaryenExpressionRef* catchBodies,
BinaryenIndex numCatchBodies,
const char* delegateTarget);
BINARYEN_API BinaryenExpressionRef
BinaryenThrow(BinaryenModuleRef module,
- const char* event,
+ const char* tag,
BinaryenExpressionRef* operands,
BinaryenIndex numOperands);
BINARYEN_API BinaryenExpressionRef BinaryenRethrow(BinaryenModuleRef module,
@@ -1842,33 +1842,32 @@ BinaryenTryGetBody(BinaryenExpressionRef expr);
// Sets the body expression of a `try` expression.
BINARYEN_API void BinaryenTrySetBody(BinaryenExpressionRef expr,
BinaryenExpressionRef bodyExpr);
-// Gets the number of catch blocks (= the number of catch events) of a `try`
+// Gets the number of catch blocks (= the number of catch tags) of a `try`
// expression.
BINARYEN_API BinaryenIndex
-BinaryenTryGetNumCatchEvents(BinaryenExpressionRef expr);
+BinaryenTryGetNumCatchTags(BinaryenExpressionRef expr);
// Gets the number of catch/catch_all blocks of a `try` expression.
BINARYEN_API BinaryenIndex
BinaryenTryGetNumCatchBodies(BinaryenExpressionRef expr);
-// Gets the catch event at the specified index of a `try` expression.
-BINARYEN_API const char* BinaryenTryGetCatchEventAt(BinaryenExpressionRef expr,
- BinaryenIndex index);
-// Sets the catch event at the specified index of a `try` expression.
-BINARYEN_API void BinaryenTrySetCatchEventAt(BinaryenExpressionRef expr,
- BinaryenIndex index,
- const char* catchEvent);
-// Appends a catch event to a `try` expression, returning its insertion index.
-BINARYEN_API BinaryenIndex
-BinaryenTryAppendCatchEvent(BinaryenExpressionRef expr, const char* catchEvent);
-// Inserts a catch event at the specified index of a `try` expression, moving
-// existing catch events including the one previously at that index one index
-// up.
-BINARYEN_API void BinaryenTryInsertCatchEventAt(BinaryenExpressionRef expr,
- BinaryenIndex index,
- const char* catchEvent);
-// Removes the catch event at the specified index of a `try` expression, moving
-// all subsequent catch events one index down. Returns the event.
-BINARYEN_API const char*
-BinaryenTryRemoveCatchEventAt(BinaryenExpressionRef expr, BinaryenIndex index);
+// Gets the catch tag at the specified index of a `try` expression.
+BINARYEN_API const char* BinaryenTryGetCatchTagAt(BinaryenExpressionRef expr,
+ BinaryenIndex index);
+// Sets the catch tag at the specified index of a `try` expression.
+BINARYEN_API void BinaryenTrySetCatchTagAt(BinaryenExpressionRef expr,
+ BinaryenIndex index,
+ const char* catchTag);
+// Appends a catch tag to a `try` expression, returning its insertion index.
+BINARYEN_API BinaryenIndex BinaryenTryAppendCatchTag(BinaryenExpressionRef expr,
+ const char* catchTag);
+// Inserts a catch tag at the specified index of a `try` expression, moving
+// existing catch tags including the one previously at that index one index up.
+BINARYEN_API void BinaryenTryInsertCatchTagAt(BinaryenExpressionRef expr,
+ BinaryenIndex index,
+ const char* catchTag);
+// Removes the catch tag at the specified index of a `try` expression, moving
+// all subsequent catch tags one index down. Returns the tag.
+BINARYEN_API const char* BinaryenTryRemoveCatchTagAt(BinaryenExpressionRef expr,
+ BinaryenIndex index);
// Gets the catch body expression at the specified index of a `try` expression.
BINARYEN_API BinaryenExpressionRef
BinaryenTryGetCatchBodyAt(BinaryenExpressionRef expr, BinaryenIndex index);
@@ -1904,11 +1903,11 @@ BINARYEN_API bool BinaryenTryIsDelegate(BinaryenExpressionRef expr);
// Throw
-// Gets the name of the event being thrown by a `throw` expression.
-BINARYEN_API const char* BinaryenThrowGetEvent(BinaryenExpressionRef expr);
-// Sets the name of the event being thrown by a `throw` expression.
-BINARYEN_API void BinaryenThrowSetEvent(BinaryenExpressionRef expr,
- const char* eventName);
+// Gets the name of the tag being thrown by a `throw` expression.
+BINARYEN_API const char* BinaryenThrowGetTag(BinaryenExpressionRef expr);
+// Sets the name of the tag being thrown by a `throw` expression.
+BINARYEN_API void BinaryenThrowSetTag(BinaryenExpressionRef expr,
+ const char* tagName);
// Gets the number of operands of a `throw` expression.
BINARYEN_API BinaryenIndex
BinaryenThrowGetNumOperands(BinaryenExpressionRef expr);
@@ -2069,13 +2068,13 @@ BINARYEN_API void BinaryenAddGlobalImport(BinaryenModuleRef module,
const char* externalBaseName,
BinaryenType globalType,
bool mutable_);
-BINARYEN_API void BinaryenAddEventImport(BinaryenModuleRef module,
- const char* internalName,
- const char* externalModuleName,
- const char* externalBaseName,
- uint32_t attribute,
- BinaryenType params,
- BinaryenType results);
+BINARYEN_API void BinaryenAddTagImport(BinaryenModuleRef module,
+ const char* internalName,
+ const char* externalModuleName,
+ const char* externalBaseName,
+ uint32_t attribute,
+ BinaryenType params,
+ BinaryenType results);
// Exports
@@ -2097,10 +2096,10 @@ BINARYEN_API BinaryenExportRef BinaryenAddMemoryExport(
// Adds a global export to the module.
BINARYEN_API BinaryenExportRef BinaryenAddGlobalExport(
BinaryenModuleRef module, const char* internalName, const char* externalName);
-// Adds an event export to the module.
-BINARYEN_API BinaryenExportRef BinaryenAddEventExport(BinaryenModuleRef module,
- const char* internalName,
- const char* externalName);
+// Adds a tag export to the module.
+BINARYEN_API BinaryenExportRef BinaryenAddTagExport(BinaryenModuleRef module,
+ const char* internalName,
+ const char* externalName);
// Gets an export reference by external name. Returns NULL if the export does
// not exist.
BINARYEN_API BinaryenExportRef BinaryenGetExport(BinaryenModuleRef module,
@@ -2136,22 +2135,21 @@ BINARYEN_API BinaryenIndex BinaryenGetNumGlobals(BinaryenModuleRef module);
BINARYEN_API BinaryenGlobalRef
BinaryenGetGlobalByIndex(BinaryenModuleRef module, BinaryenIndex index);
-// Events
+// Tags
-BINARYEN_REF(Event);
+BINARYEN_REF(Tag);
-// Adds an event to the module.
-BINARYEN_API BinaryenEventRef BinaryenAddEvent(BinaryenModuleRef module,
- const char* name,
- uint32_t attribute,
- BinaryenType params,
- BinaryenType results);
-// Gets an event reference by name. Returns NULL if the event does not exist.
-BINARYEN_API BinaryenEventRef BinaryenGetEvent(BinaryenModuleRef module,
- const char* name);
-// Removes an event by name.
-BINARYEN_API void BinaryenRemoveEvent(BinaryenModuleRef module,
- const char* name);
+// Adds a tag to the module.
+BINARYEN_API BinaryenTagRef BinaryenAddTag(BinaryenModuleRef module,
+ const char* name,
+ uint32_t attribute,
+ BinaryenType params,
+ BinaryenType results);
+// Gets a tag reference by name. Returns NULL if the tag does not exist.
+BINARYEN_API BinaryenTagRef BinaryenGetTag(BinaryenModuleRef module,
+ const char* name);
+// Removes a tag by name.
+BINARYEN_API void BinaryenRemoveTag(BinaryenModuleRef module, const char* name);
// Tables
@@ -2552,17 +2550,17 @@ BINARYEN_API BinaryenExpressionRef
BinaryenGlobalGetInitExpr(BinaryenGlobalRef global);
//
-// ========== Event Operations ==========
+// ========== Tag Operations ==========
//
-// Gets the name of the specified `Event`.
-BINARYEN_API const char* BinaryenEventGetName(BinaryenEventRef event);
-// Gets the attribute of the specified `Event`.
-BINARYEN_API uint32_t BinaryenEventGetAttribute(BinaryenEventRef event);
-// Gets the parameters type of the specified `Event`.
-BINARYEN_API BinaryenType BinaryenEventGetParams(BinaryenEventRef event);
-// Gets the results type of the specified `Event`.
-BINARYEN_API BinaryenType BinaryenEventGetResults(BinaryenEventRef event);
+// Gets the name of the specified `Tag`.
+BINARYEN_API const char* BinaryenTagGetName(BinaryenTagRef tag);
+// Gets the attribute of the specified `Tag`.
+BINARYEN_API uint32_t BinaryenTagGetAttribute(BinaryenTagRef tag);
+// Gets the parameters type of the specified `Tag`.
+BINARYEN_API BinaryenType BinaryenTagGetParams(BinaryenTagRef tag);
+// Gets the results type of the specified `Tag`.
+BINARYEN_API BinaryenType BinaryenTagGetResults(BinaryenTagRef tag);
//
// ========== Import Operations ==========
@@ -2574,13 +2572,13 @@ BinaryenFunctionImportGetModule(BinaryenFunctionRef import);
BINARYEN_API const char* BinaryenTableImportGetModule(BinaryenTableRef import);
BINARYEN_API const char*
BinaryenGlobalImportGetModule(BinaryenGlobalRef import);
-BINARYEN_API const char* BinaryenEventImportGetModule(BinaryenEventRef import);
+BINARYEN_API const char* BinaryenTagImportGetModule(BinaryenTagRef import);
// Gets the external base name of the specified import.
BINARYEN_API const char*
BinaryenFunctionImportGetBase(BinaryenFunctionRef import);
BINARYEN_API const char* BinaryenTableImportGetBase(BinaryenTableRef import);
BINARYEN_API const char* BinaryenGlobalImportGetBase(BinaryenGlobalRef import);
-BINARYEN_API const char* BinaryenEventImportGetBase(BinaryenEventRef import);
+BINARYEN_API const char* BinaryenTagImportGetBase(BinaryenTagRef import);
//
// ========== Export Operations ==========
diff --git a/src/cfg/cfg-traversal.h b/src/cfg/cfg-traversal.h
index f66dc8d3f..b9d9c8f1b 100644
--- a/src/cfg/cfg-traversal.h
+++ b/src/cfg/cfg-traversal.h
@@ -238,13 +238,12 @@ struct CFGWalker : public ControlFlowWalker<SubType, VisitorType> {
// try-catch also does not have a catch_all, this continues until we
// encounter a try-catch_all. Create a link to all those possible catch
// unwind destinations.
- // TODO This can be more precise for `throw`s if we compare event types
- // and create links to outer catch BBs only when the exception is not
- // caught.
+ // TODO This can be more precise for `throw`s if we compare tag types and
+ // create links to outer catch BBs only when the exception is not caught.
// TODO This can also be more precise if we analyze the structure of nested
// try-catches. For example, in the example below, 'call $foo' doesn't need
// a link to the BB of outer 'catch $e1', because if the exception thrown by
- // the call is of event $e1, it would've already been caught by the inner
+ // the call is of tag $e1, it would've already been caught by the inner
// 'catch $e1'. Optimize these cases later.
// try
// try
diff --git a/src/ir/ReFinalize.cpp b/src/ir/ReFinalize.cpp
index b024c94be..6f1a22095 100644
--- a/src/ir/ReFinalize.cpp
+++ b/src/ir/ReFinalize.cpp
@@ -184,7 +184,7 @@ void ReFinalize::visitElementSegment(ElementSegment* curr) {
WASM_UNREACHABLE("unimp");
}
void ReFinalize::visitMemory(Memory* curr) { WASM_UNREACHABLE("unimp"); }
-void ReFinalize::visitEvent(Event* curr) { WASM_UNREACHABLE("unimp"); }
+void ReFinalize::visitTag(Tag* curr) { WASM_UNREACHABLE("unimp"); }
void ReFinalize::visitModule(Module* curr) { WASM_UNREACHABLE("unimp"); }
void ReFinalize::updateBreakValueType(Name name, Type type) {
diff --git a/src/ir/import-utils.h b/src/ir/import-utils.h
index e4a656379..2e7a4f44c 100644
--- a/src/ir/import-utils.h
+++ b/src/ir/import-utils.h
@@ -30,7 +30,7 @@ struct ImportInfo {
std::vector<Global*> importedGlobals;
std::vector<Function*> importedFunctions;
std::vector<Table*> importedTables;
- std::vector<Event*> importedEvents;
+ std::vector<Tag*> importedTags;
ImportInfo(Module& wasm) : wasm(wasm) {
for (auto& import : wasm.globals) {
@@ -48,9 +48,9 @@ struct ImportInfo {
importedTables.push_back(import.get());
}
}
- for (auto& import : wasm.events) {
+ for (auto& import : wasm.tags) {
if (import->imported()) {
- importedEvents.push_back(import.get());
+ importedTags.push_back(import.get());
}
}
}
@@ -73,8 +73,8 @@ struct ImportInfo {
return nullptr;
}
- Event* getImportedEvent(Name module, Name base) {
- for (auto* import : importedEvents) {
+ Tag* getImportedTag(Name module, Name base) {
+ for (auto* import : importedTags) {
if (import->module == module && import->base == base) {
return import;
}
@@ -88,11 +88,11 @@ struct ImportInfo {
Index getNumImportedTables() { return importedTables.size(); }
- Index getNumImportedEvents() { return importedEvents.size(); }
+ Index getNumImportedTags() { return importedTags.size(); }
Index getNumImports() {
return getNumImportedGlobals() + getNumImportedFunctions() +
- getNumImportedEvents() + (wasm.memory.imported() ? 1 : 0) +
+ getNumImportedTags() + (wasm.memory.imported() ? 1 : 0) +
getNumImportedTables();
}
@@ -108,9 +108,7 @@ struct ImportInfo {
return wasm.tables.size() - getNumImportedTables();
}
- Index getNumDefinedEvents() {
- return wasm.events.size() - getNumImportedEvents();
- }
+ Index getNumDefinedTags() { return wasm.tags.size() - getNumImportedTags(); }
};
} // namespace wasm
diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp
index 9c5c66641..8ad501fe1 100644
--- a/src/ir/module-splitting.cpp
+++ b/src/ir/module-splitting.cpp
@@ -18,7 +18,7 @@
//
// 1. Create the new secondary module.
//
-// 2. Export globals, events, tables, and memories from the primary module and
+// 2. Export globals, tags, tables, and memories from the primary module and
// import them in the secondary module.
//
// 3. Move the deferred functions from the primary to the secondary module.
@@ -648,12 +648,12 @@ void ModuleSplitter::shareImportableItems() {
secondary.addGlobal(std::move(secondaryGlobal));
}
- for (auto& event : primary.events) {
- auto secondaryEvent = std::make_unique<Event>();
- secondaryEvent->attribute = event->attribute;
- secondaryEvent->sig = event->sig;
- makeImportExport(*event, *secondaryEvent, "event", ExternalKind::Event);
- secondary.addEvent(std::move(secondaryEvent));
+ for (auto& tag : primary.tags) {
+ auto secondaryTag = std::make_unique<Tag>();
+ secondaryTag->attribute = tag->attribute;
+ secondaryTag->sig = tag->sig;
+ makeImportExport(*tag, *secondaryTag, "tag", ExternalKind::Tag);
+ secondary.addTag(std::move(secondaryTag));
}
}
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h
index aaf484036..c93b24293 100644
--- a/src/ir/module-utils.h
+++ b/src/ir/module-utils.h
@@ -63,12 +63,12 @@ inline Global* copyGlobal(Global* global, Module& out) {
return ret;
}
-inline Event* copyEvent(Event* event, Module& out) {
- auto* ret = new Event();
- ret->name = event->name;
- ret->attribute = event->attribute;
- ret->sig = event->sig;
- out.addEvent(ret);
+inline Tag* copyTag(Tag* tag, Module& out) {
+ auto* ret = new Tag();
+ ret->name = tag->name;
+ ret->attribute = tag->attribute;
+ ret->sig = tag->sig;
+ out.addTag(ret);
return ret;
}
@@ -120,8 +120,8 @@ inline void copyModule(const Module& in, Module& out) {
for (auto& curr : in.globals) {
copyGlobal(curr.get(), out);
}
- for (auto& curr : in.events) {
- copyEvent(curr.get(), out);
+ for (auto& curr : in.tags) {
+ copyTag(curr.get(), out);
}
for (auto& curr : in.elementSegments) {
copyElementSegment(curr.get(), out);
@@ -278,16 +278,16 @@ template<typename T> inline void iterDefinedFunctions(Module& wasm, T visitor) {
}
}
-template<typename T> inline void iterImportedEvents(Module& wasm, T visitor) {
- for (auto& import : wasm.events) {
+template<typename T> inline void iterImportedTags(Module& wasm, T visitor) {
+ for (auto& import : wasm.tags) {
if (import->imported()) {
visitor(import.get());
}
}
}
-template<typename T> inline void iterDefinedEvents(Module& wasm, T visitor) {
- for (auto& import : wasm.events) {
+template<typename T> inline void iterDefinedTags(Module& wasm, T visitor) {
+ for (auto& import : wasm.tags) {
if (!import->imported()) {
visitor(import.get());
}
@@ -299,7 +299,7 @@ template<typename T> inline void iterImports(Module& wasm, T visitor) {
iterImportedTables(wasm, visitor);
iterImportedGlobals(wasm, visitor);
iterImportedFunctions(wasm, visitor);
- iterImportedEvents(wasm, visitor);
+ iterImportedTags(wasm, visitor);
}
// Helper class for performing an operation on all the functions in the module,
@@ -514,7 +514,7 @@ inline void collectHeapTypes(Module& wasm,
// Collect module-level info.
Counts counts;
CodeScanner(counts).walkModuleCode(&wasm);
- for (auto& curr : wasm.events) {
+ for (auto& curr : wasm.tags) {
counts.note(curr->sig);
}
for (auto& curr : wasm.tables) {
diff --git a/src/ir/names.h b/src/ir/names.h
index 46cb239ef..5fe77dd2b 100644
--- a/src/ir/names.h
+++ b/src/ir/names.h
@@ -78,9 +78,9 @@ inline Name getValidTableName(Module& module, Name root) {
return getValidName(root,
[&](Name test) { return !module.getTableOrNull(test); });
}
-inline Name getValidEventName(Module& module, Name root) {
+inline Name getValidTagName(Module& module, Name root) {
return getValidName(root,
- [&](Name test) { return !module.getEventOrNull(test); });
+ [&](Name test) { return !module.getTagOrNull(test); });
}
inline Name getValidElementSegmentName(Module& module, Name root) {
return getValidName(
diff --git a/src/ir/utils.h b/src/ir/utils.h
index 40f5aeb9a..78b546962 100644
--- a/src/ir/utils.h
+++ b/src/ir/utils.h
@@ -122,7 +122,7 @@ struct ReFinalize
void visitTable(Table* curr);
void visitElementSegment(ElementSegment* curr);
void visitMemory(Memory* curr);
- void visitEvent(Event* curr);
+ void visitTag(Tag* curr);
void visitModule(Module* curr);
private:
@@ -146,7 +146,7 @@ struct ReFinalizeNode : public OverriddenVisitor<ReFinalizeNode> {
void visitTable(Table* curr) { WASM_UNREACHABLE("unimp"); }
void visitElementSegment(ElementSegment* curr) { WASM_UNREACHABLE("unimp"); }
void visitMemory(Memory* curr) { WASM_UNREACHABLE("unimp"); }
- void visitEvent(Event* curr) { WASM_UNREACHABLE("unimp"); }
+ void visitTag(Tag* curr) { WASM_UNREACHABLE("unimp"); }
void visitModule(Module* curr) { WASM_UNREACHABLE("unimp"); }
// given a stack of nested expressions, update them all from child to parent
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 8e0120e36..c33916734 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -122,7 +122,7 @@ function initializeConstants() {
'Table',
'Memory',
'Global',
- 'Event'
+ 'Tag'
].forEach(name => {
Module['ExternalKinds'][name] = Module['External' + name] = Module['_BinaryenExternal' + name]();
});
@@ -2297,12 +2297,12 @@ function wrapModule(module, self = {}) {
}
};
- self['try'] = function(name, body, catchEvents, catchBodies, delegateTarget) {
+ self['try'] = function(name, body, catchTags, catchBodies, delegateTarget) {
return preserveStack(() =>
- Module['_BinaryenTry'](module, name ? strToStack(name) : 0, body, i32sToStack(catchEvents.map(strToStack)), catchEvents.length, i32sToStack(catchBodies), catchBodies.length, delegateTarget ? strToStack(delegateTarget) : 0));
+ Module['_BinaryenTry'](module, name ? strToStack(name) : 0, body, i32sToStack(catchTags.map(strToStack)), catchTags.length, i32sToStack(catchBodies), catchBodies.length, delegateTarget ? strToStack(delegateTarget) : 0));
};
- self['throw'] = function(event_, operands) {
- return preserveStack(() => Module['_BinaryenThrow'](module, strToStack(event_), i32sToStack(operands), operands.length));
+ self['throw'] = function(tag, operands) {
+ return preserveStack(() => Module['_BinaryenThrow'](module, strToStack(tag), i32sToStack(operands), operands.length));
};
self['rethrow'] = function(target) {
return Module['_BinaryenRethrow'](module, strToStack(target));
@@ -2396,14 +2396,14 @@ function wrapModule(module, self = {}) {
self['removeElementSegment'] = function(name) {
return preserveStack(() => Module['_BinaryenRemoveElementSegment'](module, strToStack(name)));
};
- self['addEvent'] = function(name, attribute, params, results) {
- return preserveStack(() => Module['_BinaryenAddEvent'](module, strToStack(name), attribute, params, results));
+ self['addTag'] = function(name, attribute, params, results) {
+ return preserveStack(() => Module['_BinaryenAddTag'](module, strToStack(name), attribute, params, results));
};
- self['getEvent'] = function(name) {
- return preserveStack(() => Module['_BinaryenGetEvent'](module, strToStack(name)));
+ self['getTag'] = function(name) {
+ return preserveStack(() => Module['_BinaryenGetTag'](module, strToStack(name)));
};
- self['removeEvent'] = function(name) {
- return preserveStack(() => Module['_BinaryenRemoveEvent'](module, strToStack(name)));
+ self['removeTag'] = function(name) {
+ return preserveStack(() => Module['_BinaryenRemoveTag'](module, strToStack(name)));
};
self['addFunctionImport'] = function(internalName, externalModuleName, externalBaseName, params, results) {
return preserveStack(() =>
@@ -2425,9 +2425,9 @@ function wrapModule(module, self = {}) {
Module['_BinaryenAddGlobalImport'](module, strToStack(internalName), strToStack(externalModuleName), strToStack(externalBaseName), globalType, mutable)
);
};
- self['addEventImport'] = function(internalName, externalModuleName, externalBaseName, attribute, params, results) {
+ self['addTagImport'] = function(internalName, externalModuleName, externalBaseName, attribute, params, results) {
return preserveStack(() =>
- Module['_BinaryenAddEventImport'](module, strToStack(internalName), strToStack(externalModuleName), strToStack(externalBaseName), attribute, params, results)
+ Module['_BinaryenAddTagImport'](module, strToStack(internalName), strToStack(externalModuleName), strToStack(externalBaseName), attribute, params, results)
);
};
self['addExport'] = // deprecated
@@ -2443,8 +2443,8 @@ function wrapModule(module, self = {}) {
self['addGlobalExport'] = function(internalName, externalName) {
return preserveStack(() => Module['_BinaryenAddGlobalExport'](module, strToStack(internalName), strToStack(externalName)));
};
- self['addEventExport'] = function(internalName, externalName) {
- return preserveStack(() => Module['_BinaryenAddEventExport'](module, strToStack(internalName), strToStack(externalName)));
+ self['addTagExport'] = function(internalName, externalName) {
+ return preserveStack(() => Module['_BinaryenAddTagExport'](module, strToStack(internalName), strToStack(externalName)));
};
self['removeExport'] = function(externalName) {
return preserveStack(() => Module['_BinaryenRemoveExport'](module, strToStack(externalName)));
@@ -3075,7 +3075,7 @@ Module['getExpressionInfo'] = function(expr) {
'type': type,
'name': UTF8ToString(Module['_BinaryenTryGetName'](expr)),
'body': Module['_BinaryenTryGetBody'](expr),
- 'catchEvents': getAllNested(expr, Module['_BinaryenTryGetNumCatchEvents'], Module['_BinaryenTryGetCatchEventAt']),
+ 'catchTags': getAllNested(expr, Module['_BinaryenTryGetNumCatchTags'], Module['_BinaryenTryGetCatchTagAt']),
'catchBodies': getAllNested(expr, Module['_BinaryenTryGetNumCatchBodies'], Module['_BinaryenTryGetCatchBodyAt']),
'hasCatchAll': Module['_BinaryenTryHasCatchAll'](expr),
'delegateTarget': UTF8ToString(Module['_BinaryenTryGetDelegateTarget'](expr)),
@@ -3085,7 +3085,7 @@ Module['getExpressionInfo'] = function(expr) {
return {
'id': id,
'type': type,
- 'event': UTF8ToString(Module['_BinaryenThrowGetEvent'](expr)),
+ 'tag': UTF8ToString(Module['_BinaryenThrowGetTag'](expr)),
'operands': getAllNested(expr, Module['_BinaryenThrowGetNumOperands'], Module['_BinaryenThrowGetOperandAt'])
};
case Module['RethrowId']:
@@ -3206,15 +3206,15 @@ Module['getElementSegmentInfo'] = function(segment) {
}
}
-// Obtains information about a 'Event'
-Module['getEventInfo'] = function(event_) {
+// Obtains information about a 'Tag'
+Module['getTagInfo'] = function(tag) {
return {
- 'name': UTF8ToString(Module['_BinaryenEventGetName'](event_)),
- 'module': UTF8ToString(Module['_BinaryenEventImportGetModule'](event_)),
- 'base': UTF8ToString(Module['_BinaryenEventImportGetBase'](event_)),
- 'attribute': Module['_BinaryenEventGetAttribute'](event_),
- 'params': Module['_BinaryenEventGetParams'](event_),
- 'results': Module['_BinaryenEventGetResults'](event_)
+ 'name': UTF8ToString(Module['_BinaryenTagGetName'](tag)),
+ 'module': UTF8ToString(Module['_BinaryenTagImportGetModule'](tag)),
+ 'base': UTF8ToString(Module['_BinaryenTagImportGetBase'](tag)),
+ 'attribute': Module['_BinaryenTagGetAttribute'](tag),
+ 'params': Module['_BinaryenTagGetParams'](tag),
+ 'results': Module['_BinaryenTagGetResults'](tag)
};
};
@@ -4443,31 +4443,31 @@ Module['Try'] = makeExpressionWrapper({
'setBody'(expr, bodyExpr) {
Module['_BinaryenTrySetBody'](expr, bodyExpr);
},
- 'getNumCatchEvents'(expr) {
- return Module['_BinaryenTryGetNumCatchEvents'](expr);
+ 'getNumCatchTags'(expr) {
+ return Module['_BinaryenTryGetNumCatchTags'](expr);
},
- 'getCatchEvents'(expr) {
- return getAllNested(expr, Module['_BinaryenTryGetNumCatchEvents'], Module['_BinaryenTryGetCatchEventAt']).map(p => UTF8ToString(p));
+ 'getCatchTags'(expr) {
+ return getAllNested(expr, Module['_BinaryenTryGetNumCatchTags'], Module['_BinaryenTryGetCatchTagAt']).map(p => UTF8ToString(p));
},
- 'setCatchEvents'(expr, catchEvents) {
+ 'setCatchTags'(expr, catchTags) {
preserveStack(() => {
- setAllNested(expr, catchEvents.map(strToStack), Module['_BinaryenTryGetNumCatchEvents'], Module['_BinaryenTrySetCatchEventAt'], Module['_BinaryenTryAppendCatchEvent'], Module['_BinaryenTryRemoveCatchEventAt']);
+ setAllNested(expr, catchTags.map(strToStack), Module['_BinaryenTryGetNumCatchTags'], Module['_BinaryenTrySetCatchTagAt'], Module['_BinaryenTryAppendCatchTag'], Module['_BinaryenTryRemoveCatchTagAt']);
});
},
- 'getCatchEventAt'(expr, index) {
- return UTF8ToString(Module['_BinaryenTryGetCatchEventAt'](expr, index));
+ 'getCatchTagAt'(expr, index) {
+ return UTF8ToString(Module['_BinaryenTryGetCatchTagAt'](expr, index));
},
- 'setCatchEventAt'(expr, index, catchEvent) {
- preserveStack(() => { Module['_BinaryenTrySetCatchEventAt'](expr, index, strToStack(catchEvent)) });
+ 'setCatchTagAt'(expr, index, catchTag) {
+ preserveStack(() => { Module['_BinaryenTrySetCatchTagAt'](expr, index, strToStack(catchTag)) });
},
- 'appendCatchEvent'(expr, catchEvent) {
- preserveStack(() => Module['_BinaryenTryAppendCatchEvent'](expr, strToStack(catchEvent)));
+ 'appendCatchTag'(expr, catchTag) {
+ preserveStack(() => Module['_BinaryenTryAppendCatchTag'](expr, strToStack(catchTag)));
},
- 'insertCatchEventAt'(expr, index, catchEvent) {
- preserveStack(() => { Module['_BinaryenTryInsertCatchEventAt'](expr, index, strToStack(catchEvent)) });
+ 'insertCatchTagAt'(expr, index, catchTag) {
+ preserveStack(() => { Module['_BinaryenTryInsertCatchTagAt'](expr, index, strToStack(catchTag)) });
},
- 'removeCatchEventAt'(expr, index) {
- return UTF8ToString(Module['_BinaryenTryRemoveCatchEventAt'](expr, index));
+ 'removeCatchTagAt'(expr, index) {
+ return UTF8ToString(Module['_BinaryenTryRemoveCatchTagAt'](expr, index));
},
'getNumCatchBodies'(expr) {
return Module['_BinaryenTryGetNumCatchBodies'](expr);
@@ -4509,11 +4509,11 @@ Module['Try'] = makeExpressionWrapper({
});
Module['Throw'] = makeExpressionWrapper({
- 'getEvent'(expr) {
- return UTF8ToString(Module['_BinaryenThrowGetEvent'](expr));
+ 'getTag'(expr) {
+ return UTF8ToString(Module['_BinaryenThrowGetTag'](expr));
},
- 'setEvent'(expr, eventName) {
- preserveStack(() => { Module['_BinaryenThrowSetEvent'](expr, strToStack(eventName)) });
+ 'setTag'(expr, tagName) {
+ preserveStack(() => { Module['_BinaryenThrowSetTag'](expr, strToStack(tagName)) });
},
'getNumOperands'(expr) {
return Module['_BinaryenThrowGetNumOperands'](expr);
diff --git a/src/passes/Metrics.cpp b/src/passes/Metrics.cpp
index 231ad928c..2209bcfbb 100644
--- a/src/passes/Metrics.cpp
+++ b/src/passes/Metrics.cpp
@@ -61,7 +61,7 @@ struct Metrics
counts["[imports]"] = imports.getNumImports();
counts["[funcs]"] = imports.getNumDefinedFunctions();
counts["[globals]"] = imports.getNumDefinedGlobals();
- counts["[events]"] = imports.getNumDefinedEvents();
+ counts["[tags]"] = imports.getNumDefinedTags();
counts["[exports]"] = module->exports.size();
counts["[tables]"] = imports.getNumDefinedTables();
// add memory and table
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 18c10ac8e..750bfbb38 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1849,7 +1849,7 @@ struct PrintExpressionContents
}
void visitThrow(Throw* curr) {
printMedium(o, "throw ");
- printName(curr->event, o);
+ printName(curr->tag, o);
}
void visitRethrow(Rethrow* curr) {
printMedium(o, "rethrow ");
@@ -2345,12 +2345,12 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
maybePrintImplicitBlock(curr->body, true);
decIndent();
o << "\n";
- for (size_t i = 0; i < curr->catchEvents.size(); i++) {
+ for (size_t i = 0; i < curr->catchTags.size(); i++) {
doIndent(o, indent);
printDebugDelimiterLocation(curr, i);
o << '(';
printMedium(o, "catch ");
- printName(curr->catchEvents[i], o);
+ printName(curr->catchTags[i], o);
incIndent();
maybePrintImplicitBlock(curr->catchBodies[i], true);
decIndent();
@@ -2358,7 +2358,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
}
if (curr->hasCatchAll()) {
doIndent(o, indent);
- printDebugDelimiterLocation(curr, curr->catchEvents.size());
+ printDebugDelimiterLocation(curr, curr->catchTags.size());
o << '(';
printMedium(o, "catch_all");
incIndent();
@@ -2534,8 +2534,8 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
case ExternalKind::Global:
o << "global";
break;
- case ExternalKind::Event:
- o << "event";
+ case ExternalKind::Tag:
+ o << "tag";
break;
case ExternalKind::Invalid:
WASM_UNREACHABLE("invalid ExternalKind");
@@ -2672,28 +2672,28 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
}
o << maybeNewLine;
}
- void visitEvent(Event* curr) {
+ void visitTag(Tag* curr) {
if (curr->imported()) {
- visitImportedEvent(curr);
+ visitImportedTag(curr);
} else {
- visitDefinedEvent(curr);
+ visitDefinedTag(curr);
}
}
- void visitImportedEvent(Event* curr) {
+ void visitImportedTag(Tag* curr) {
doIndent(o, indent);
o << '(';
emitImportHeader(curr);
- o << "(event ";
+ o << "(tag ";
printName(curr->name, o);
o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace;
printParamType(o, curr->sig.params, currModule);
o << "))";
o << maybeNewLine;
}
- void visitDefinedEvent(Event* curr) {
+ void visitDefinedTag(Tag* curr) {
doIndent(o, indent);
o << '(';
- printMedium(o, "event ");
+ printMedium(o, "tag ");
printName(curr->name, o);
o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace;
printParamType(o, curr->sig.params, currModule);
@@ -2910,8 +2910,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
*curr, [&](Global* global) { visitGlobal(global); });
ModuleUtils::iterImportedFunctions(
*curr, [&](Function* func) { visitFunction(func); });
- ModuleUtils::iterImportedEvents(*curr,
- [&](Event* event) { visitEvent(event); });
+ ModuleUtils::iterImportedTags(*curr, [&](Tag* tag) { visitTag(tag); });
ModuleUtils::iterDefinedGlobals(
*curr, [&](Global* global) { visitGlobal(global); });
ModuleUtils::iterDefinedMemories(
@@ -2931,8 +2930,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
}
o << ')' << maybeNewLine;
}
- ModuleUtils::iterDefinedEvents(*curr,
- [&](Event* event) { visitEvent(event); });
+ ModuleUtils::iterDefinedTags(*curr, [&](Tag* tag) { visitTag(tag); });
for (auto& child : curr->exports) {
doIndent(o, indent);
visitExport(child.get());
@@ -3102,7 +3100,7 @@ printStackInst(StackInst* inst, std::ostream& o, Function* func) {
}
case StackInst::Catch: {
// Because StackInst does not have info on which catch within a try this
- // is, we can't print the event name.
+ // is, we can't print the tag name.
printMedium(o, "catch");
break;
}
@@ -3186,7 +3184,7 @@ printStackIR(StackIR* ir, std::ostream& o, Function* func) {
doIndent();
printMedium(o, "catch ");
Try* curr = inst->origin->cast<Try>();
- printName(curr->catchEvents[catchIndexStack.back()++], o);
+ printName(curr->catchTags[catchIndexStack.back()++], o);
indent++;
break;
}
diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp
index a26fd5d45..2b460a0fd 100644
--- a/src/passes/RemoveUnusedModuleElements.cpp
+++ b/src/passes/RemoveUnusedModuleElements.cpp
@@ -16,7 +16,7 @@
//
// Removes module elements that are are never used: functions, globals, and
-// events, which may be imported or not, and function types (which we merge and
+// tags, which may be imported or not, and function types (which we merge and
// remove if unneeded)
//
@@ -30,7 +30,7 @@
namespace wasm {
-enum class ModuleElementKind { Function, Global, Event, Table, ElementSegment };
+enum class ModuleElementKind { Function, Global, Tag, Table, ElementSegment };
typedef std::pair<ModuleElementKind, Name> ModuleElement;
@@ -129,11 +129,11 @@ struct ReachabilityAnalyzer : public PostWalker<ReachabilityAnalyzer> {
maybeAdd(ModuleElement(ModuleElementKind::Function, curr->func));
}
void visitThrow(Throw* curr) {
- maybeAdd(ModuleElement(ModuleElementKind::Event, curr->event));
+ maybeAdd(ModuleElement(ModuleElementKind::Tag, curr->tag));
}
void visitTry(Try* curr) {
- for (auto event : curr->catchEvents) {
- maybeAdd(ModuleElement(ModuleElementKind::Event, event));
+ for (auto tag : curr->catchTags) {
+ maybeAdd(ModuleElement(ModuleElementKind::Tag, tag));
}
}
};
@@ -176,8 +176,8 @@ struct RemoveUnusedModuleElements : public Pass {
roots.emplace_back(ModuleElementKind::Function, curr->value);
} else if (curr->kind == ExternalKind::Global) {
roots.emplace_back(ModuleElementKind::Global, curr->value);
- } else if (curr->kind == ExternalKind::Event) {
- roots.emplace_back(ModuleElementKind::Event, curr->value);
+ } else if (curr->kind == ExternalKind::Tag) {
+ roots.emplace_back(ModuleElementKind::Tag, curr->value);
} else if (curr->kind == ExternalKind::Table) {
roots.emplace_back(ModuleElementKind::Table, curr->value);
ModuleUtils::iterTableSegments(
@@ -209,9 +209,9 @@ struct RemoveUnusedModuleElements : public Pass {
return analyzer.reachable.count(
ModuleElement(ModuleElementKind::Global, curr->name)) == 0;
});
- module->removeEvents([&](Event* curr) {
+ module->removeTags([&](Tag* curr) {
return analyzer.reachable.count(
- ModuleElement(ModuleElementKind::Event, curr->name)) == 0;
+ ModuleElement(ModuleElementKind::Tag, curr->name)) == 0;
});
module->removeElementSegments([&](ElementSegment* curr) {
return curr->data.empty() ||
diff --git a/src/shared-constants.h b/src/shared-constants.h
index 59c7af3ba..a0de4b9bb 100644
--- a/src/shared-constants.h
+++ b/src/shared-constants.h
@@ -65,7 +65,7 @@ extern Name SPECTEST;
extern Name PRINT;
extern Name EXIT;
extern Name SHARED;
-extern Name EVENT;
+extern Name TAG;
extern Name ATTR;
} // namespace wasm
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index 0635dc61d..f1fc61e06 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -200,7 +200,7 @@ public:
setupTables();
setupGlobals();
if (wasm.features.hasExceptionHandling()) {
- setupEvents();
+ setupTags();
}
modifyInitialFunctions();
addImportLoggingSupport();
@@ -495,14 +495,13 @@ private:
}
}
- void setupEvents() {
+ void setupTags() {
Index num = upTo(3);
for (size_t i = 0; i < num; i++) {
- auto event =
- builder.makeEvent(Names::getValidEventName(wasm, "event$"),
- WASM_EVENT_ATTRIBUTE_EXCEPTION,
- Signature(getControlFlowType(), Type::none));
- wasm.addEvent(std::move(event));
+ auto tag = builder.makeTag(Names::getValidTagName(wasm, "tag$"),
+ WASM_TAG_ATTRIBUTE_EXCEPTION,
+ Signature(getControlFlowType(), Type::none));
+ wasm.addTag(std::move(tag));
}
}
diff --git a/src/tools/wasm-metadce.cpp b/src/tools/wasm-metadce.cpp
index a0890c8c4..29ac01f90 100644
--- a/src/tools/wasm-metadce.cpp
+++ b/src/tools/wasm-metadce.cpp
@@ -58,12 +58,12 @@ struct MetaDCEGraph {
std::unordered_map<Name, Name> exportToDCENode;
std::unordered_map<Name, Name> functionToDCENode; // function name => DCE name
std::unordered_map<Name, Name> globalToDCENode; // global name => DCE name
- std::unordered_map<Name, Name> eventToDCENode; // event name => DCE name
+ std::unordered_map<Name, Name> tagToDCENode; // tag name => DCE name
std::unordered_map<Name, Name> DCENodeToExport; // reverse maps
std::unordered_map<Name, Name> DCENodeToFunction;
std::unordered_map<Name, Name> DCENodeToGlobal;
- std::unordered_map<Name, Name> DCENodeToEvent;
+ std::unordered_map<Name, Name> DCENodeToTag;
// imports are not mapped 1:1 to DCE nodes in the wasm, since env.X might
// be imported twice, for example. So we don't map a DCE node to an Import,
@@ -95,8 +95,8 @@ struct MetaDCEGraph {
return getImportId(imp->module, imp->base);
}
- ImportId getEventImportId(Name name) {
- auto* imp = wasm.getEvent(name);
+ ImportId getTagImportId(Name name) {
+ auto* imp = wasm.getTag(name);
return getImportId(imp->module, imp->base);
}
@@ -126,14 +126,14 @@ struct MetaDCEGraph {
globalToDCENode[global->name] = dceName;
nodes[dceName] = DCENode(dceName);
});
- ModuleUtils::iterDefinedEvents(wasm, [&](Event* event) {
- auto dceName = getName("event", event->name.str);
- DCENodeToEvent[dceName] = event->name;
- eventToDCENode[event->name] = dceName;
+ ModuleUtils::iterDefinedTags(wasm, [&](Tag* tag) {
+ auto dceName = getName("tag", tag->name.str);
+ DCENodeToTag[dceName] = tag->name;
+ tagToDCENode[tag->name] = dceName;
nodes[dceName] = DCENode(dceName);
});
- // only process function, global, and event imports - the table and memory
- // are always there
+ // only process function, global, and tag imports - the table and memory are
+ // always there
ModuleUtils::iterImportedFunctions(wasm, [&](Function* import) {
auto id = getImportId(import->module, import->base);
if (importIdToDCENode.find(id) == importIdToDCENode.end()) {
@@ -148,7 +148,7 @@ struct MetaDCEGraph {
importIdToDCENode[id] = dceName;
}
});
- ModuleUtils::iterImportedEvents(wasm, [&](Event* import) {
+ ModuleUtils::iterImportedTags(wasm, [&](Tag* import) {
auto id = getImportId(import->module, import->base);
if (importIdToDCENode.find(id) == importIdToDCENode.end()) {
auto dceName = getName("importId", import->name.str);
@@ -178,12 +178,11 @@ struct MetaDCEGraph {
node.reaches.push_back(
importIdToDCENode[getGlobalImportId(exp->value)]);
}
- } else if (exp->kind == ExternalKind::Event) {
- if (!wasm.getEvent(exp->value)->imported()) {
- node.reaches.push_back(eventToDCENode[exp->value]);
+ } else if (exp->kind == ExternalKind::Tag) {
+ if (!wasm.getTag(exp->value)->imported()) {
+ node.reaches.push_back(tagToDCENode[exp->value]);
} else {
- node.reaches.push_back(
- importIdToDCENode[getEventImportId(exp->value)]);
+ node.reaches.push_back(importIdToDCENode[getTagImportId(exp->value)]);
}
}
}
@@ -394,8 +393,8 @@ public:
if (DCENodeToGlobal.find(name) != DCENodeToGlobal.end()) {
std::cout << " is global " << DCENodeToGlobal[name] << '\n';
}
- if (DCENodeToEvent.find(name) != DCENodeToEvent.end()) {
- std::cout << " is event " << DCENodeToEvent[name] << '\n';
+ if (DCENodeToTag.find(name) != DCENodeToTag.end()) {
+ std::cout << " is tag " << DCENodeToTag[name] << '\n';
}
for (auto target : node.reaches) {
std::cout << " reaches: " << target.str << '\n';
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 1d1ec2e88..51c2b3e52 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -326,7 +326,7 @@ enum Section {
Code = 10,
Data = 11,
DataCount = 12,
- Event = 13
+ Tag = 13
};
// A passive segment is a segment that will not be automatically copied into a
@@ -1109,7 +1109,7 @@ class WasmBinaryWriter {
// just use them directly).
struct BinaryIndexes {
std::unordered_map<Name, Index> functionIndexes;
- std::unordered_map<Name, Index> eventIndexes;
+ std::unordered_map<Name, Index> tagIndexes;
std::unordered_map<Name, Index> globalIndexes;
std::unordered_map<Name, Index> tableIndexes;
std::unordered_map<Name, Index> elemIndexes;
@@ -1132,7 +1132,7 @@ class WasmBinaryWriter {
}
};
addIndexes(wasm.functions, functionIndexes);
- addIndexes(wasm.events, eventIndexes);
+ addIndexes(wasm.tags, tagIndexes);
addIndexes(wasm.tables, tableIndexes);
for (auto& curr : wasm.elementSegments) {
@@ -1212,12 +1212,12 @@ public:
void writeExports();
void writeDataCount();
void writeDataSegments();
- void writeEvents();
+ void writeTags();
uint32_t getFunctionIndex(Name name) const;
uint32_t getTableIndex(Name name) const;
uint32_t getGlobalIndex(Name name) const;
- uint32_t getEventIndex(Name name) const;
+ uint32_t getTagIndex(Name name) const;
uint32_t getTypeIndex(HeapType type) const;
void writeTableDeclarations();
@@ -1393,7 +1393,7 @@ public:
Name getFunctionName(Index index);
Name getTableName(Index index);
Name getGlobalName(Index index);
- Name getEventName(Index index);
+ Name getTagName(Index index);
void getResizableLimits(Address& initial,
Address& max,
@@ -1555,7 +1555,7 @@ public:
void readTableDeclarations();
void readElementSegments();
- void readEvents();
+ void readTags();
static Name escape(Name name);
void readNames(size_t);
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index 79f3ec8df..ca3fed286 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -125,13 +125,13 @@ public:
return glob;
}
- static std::unique_ptr<Event>
- makeEvent(Name name, uint32_t attribute, Signature sig) {
- auto event = std::make_unique<Event>();
- event->name = name;
- event->attribute = attribute;
- event->sig = sig;
- return event;
+ static std::unique_ptr<Tag>
+ makeTag(Name name, uint32_t attribute, Signature sig) {
+ auto tag = std::make_unique<Tag>();
+ tag->name = name;
+ tag->attribute = attribute;
+ tag->sig = sig;
+ return tag;
}
// IR nodes
@@ -647,7 +647,7 @@ public:
private:
Try* makeTry(Name name,
Expression* body,
- const std::vector<Name>& catchEvents,
+ const std::vector<Name>& catchTags,
const std::vector<Expression*>& catchBodies,
Name delegateTarget,
Type type,
@@ -655,7 +655,7 @@ private:
auto* ret = wasm.allocator.alloc<Try>();
ret->name = name;
ret->body = body;
- ret->catchEvents.set(catchEvents);
+ ret->catchTags.set(catchTags);
ret->catchBodies.set(catchBodies);
if (hasType) {
ret->finalize(type);
@@ -667,30 +667,30 @@ private:
public:
Try* makeTry(Expression* body,
- const std::vector<Name>& catchEvents,
+ const std::vector<Name>& catchTags,
const std::vector<Expression*>& catchBodies) {
return makeTry(
- Name(), body, catchEvents, catchBodies, Name(), Type::none, false);
+ Name(), body, catchTags, catchBodies, Name(), Type::none, false);
}
Try* makeTry(Expression* body,
- const std::vector<Name>& catchEvents,
+ const std::vector<Name>& catchTags,
const std::vector<Expression*>& catchBodies,
Type type) {
- return makeTry(Name(), body, catchEvents, catchBodies, Name(), type, true);
+ return makeTry(Name(), body, catchTags, catchBodies, Name(), type, true);
}
Try* makeTry(Name name,
Expression* body,
- const std::vector<Name>& catchEvents,
+ const std::vector<Name>& catchTags,
const std::vector<Expression*>& catchBodies) {
return makeTry(
- name, body, catchEvents, catchBodies, Name(), Type::none, false);
+ name, body, catchTags, catchBodies, Name(), Type::none, false);
}
Try* makeTry(Name name,
Expression* body,
- const std::vector<Name>& catchEvents,
+ const std::vector<Name>& catchTags,
const std::vector<Expression*>& catchBodies,
Type type) {
- return makeTry(name, body, catchEvents, catchBodies, Name(), type, true);
+ return makeTry(name, body, catchTags, catchBodies, Name(), type, true);
}
Try* makeTry(Expression* body, Name delegateTarget) {
return makeTry(Name(), body, {}, {}, delegateTarget, Type::none, false);
@@ -704,12 +704,12 @@ public:
Try* makeTry(Name name, Expression* body, Name delegateTarget, Type type) {
return makeTry(name, body, {}, {}, delegateTarget, type, true);
}
- Throw* makeThrow(Event* event, const std::vector<Expression*>& args) {
- return makeThrow(event->name, args);
+ Throw* makeThrow(Tag* tag, const std::vector<Expression*>& args) {
+ return makeThrow(tag->name, args);
}
- Throw* makeThrow(Name event, const std::vector<Expression*>& args) {
+ Throw* makeThrow(Name tag, const std::vector<Expression*>& args) {
auto* ret = wasm.allocator.alloc<Throw>();
- ret->event = event;
+ ret->tag = tag;
ret->operands.set(args);
ret->finalize();
return ret;
diff --git a/src/wasm-delegations-fields.def b/src/wasm-delegations-fields.def
index 70676e716..ab68b5206 100644
--- a/src/wasm-delegations-fields.def
+++ b/src/wasm-delegations-fields.def
@@ -58,7 +58,7 @@
// 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
+// names (like try's catch tag 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
@@ -500,7 +500,7 @@ switch (DELEGATE_ID) {
DELEGATE_START(Try);
DELEGATE_FIELD_SCOPE_NAME_USE(Try, delegateTarget);
DELEGATE_FIELD_CHILD_VECTOR(Try, catchBodies);
- DELEGATE_FIELD_NAME_VECTOR(Try, catchEvents);
+ DELEGATE_FIELD_NAME_VECTOR(Try, catchTags);
DELEGATE_FIELD_SCOPE_NAME_DEF(Try, name);
DELEGATE_FIELD_CHILD(Try, body);
DELEGATE_END(Try);
@@ -509,7 +509,7 @@ switch (DELEGATE_ID) {
case Expression::Id::ThrowId: {
DELEGATE_START(Throw);
DELEGATE_FIELD_CHILD_VECTOR(Throw, operands);
- DELEGATE_FIELD_NAME(Throw, event);
+ DELEGATE_FIELD_NAME(Throw, tag);
DELEGATE_END(Throw);
break;
}
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index c3148d9c6..2ffb542c7 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -41,7 +41,7 @@
namespace wasm {
struct WasmException {
- Name event;
+ Name tag;
Literals values;
};
std::ostream& operator<<(std::ostream& o, const WasmException& exn);
@@ -1358,9 +1358,9 @@ public:
if (flow.breaking()) {
return flow;
}
- NOTE_EVAL1(curr->event);
+ NOTE_EVAL1(curr->tag);
WasmException exn;
- exn.event = curr->event;
+ exn.tag = curr->tag;
for (auto item : arguments) {
exn.values.push_back(item);
}
@@ -3227,8 +3227,8 @@ private:
return ret;
};
- for (size_t i = 0; i < curr->catchEvents.size(); i++) {
- if (curr->catchEvents[i] == e.event) {
+ for (size_t i = 0; i < curr->catchTags.size(); i++) {
+ if (curr->catchTags[i] == e.tag) {
instance.multiValues.push_back(e.values);
return processCatchBody(curr->catchBodies[i]);
}
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index cc603e2e4..4145d781a 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -127,10 +127,10 @@ class SExpressionWasmBuilder {
std::vector<Name> functionNames;
std::vector<Name> tableNames;
std::vector<Name> globalNames;
- std::vector<Name> eventNames;
+ std::vector<Name> tagNames;
int functionCounter = 0;
int globalCounter = 0;
- int eventCounter = 0;
+ int tagCounter = 0;
int tableCounter = 0;
int elemCounter = 0;
int memoryCounter = 0;
@@ -168,7 +168,7 @@ private:
Name getFunctionName(Element& s);
Name getTableName(Element& s);
Name getGlobalName(Element& s);
- Name getEventName(Element& s);
+ Name getTagName(Element& s);
void parseStart(Element& s) { wasm.addStart(getFunctionName(*s[1])); }
// returns the next index in s
@@ -323,7 +323,7 @@ private:
// Parses something like (func ..), (array ..), (struct)
HeapType parseHeapType(Element& s);
- void parseEvent(Element& s, bool preParseImport = false);
+ void parseTag(Element& s, bool preParseImport = false);
Function::DebugLocation getDebugLocation(const SourceLocation& loc);
diff --git a/src/wasm-stack.h b/src/wasm-stack.h
index 13edc0138..bd527b51a 100644
--- a/src/wasm-stack.h
+++ b/src/wasm-stack.h
@@ -345,7 +345,7 @@ void BinaryenIRWriter<SubType>::visitLoop(Loop* curr) {
template<typename SubType> void BinaryenIRWriter<SubType>::visitTry(Try* curr) {
emit(curr);
visitPossibleBlockContents(curr->body);
- for (Index i = 0; i < curr->catchEvents.size(); i++) {
+ for (Index i = 0; i < curr->catchTags.size(); i++) {
emitCatch(curr, i);
visitPossibleBlockContents(curr->catchBodies[i]);
}
diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h
index 67177e848..5678d2f77 100644
--- a/src/wasm-traversal.h
+++ b/src/wasm-traversal.h
@@ -50,7 +50,7 @@ template<typename SubType, typename ReturnType = void> struct Visitor {
ReturnType visitTable(Table* curr) { return ReturnType(); }
ReturnType visitElementSegment(ElementSegment* curr) { return ReturnType(); }
ReturnType visitMemory(Memory* curr) { return ReturnType(); }
- ReturnType visitEvent(Event* curr) { return ReturnType(); }
+ ReturnType visitTag(Tag* curr) { return ReturnType(); }
ReturnType visitModule(Module* curr) { return ReturnType(); }
ReturnType visit(Expression* curr) {
@@ -176,9 +176,7 @@ struct Walker : public VisitorType {
setFunction(nullptr);
}
- void walkEvent(Event* event) {
- static_cast<SubType*>(this)->visitEvent(event);
- }
+ void walkTag(Tag* tag) { static_cast<SubType*>(this)->visitTag(tag); }
void walkFunctionInModule(Function* func, Module* module) {
setModule(module);
@@ -243,11 +241,11 @@ struct Walker : public VisitorType {
self->walkFunction(curr.get());
}
}
- for (auto& curr : module->events) {
+ for (auto& curr : module->tags) {
if (curr->imported()) {
- self->visitEvent(curr.get());
+ self->visitTag(curr.get());
} else {
- self->walkEvent(curr.get());
+ self->walkTag(curr.get());
}
}
for (auto& curr : module->tables) {
diff --git a/src/wasm.h b/src/wasm.h
index 261fa91ce..4b2f6fb4b 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -1266,16 +1266,16 @@ public:
class Try : public SpecificExpression<Expression::TryId> {
public:
- Try(MixedArena& allocator) : catchEvents(allocator), catchBodies(allocator) {}
+ Try(MixedArena& allocator) : catchTags(allocator), catchBodies(allocator) {}
Name name; // label that can only be targeted by 'delegate's
Expression* body;
- ArenaVector<Name> catchEvents;
+ ArenaVector<Name> catchTags;
ExpressionList catchBodies;
Name delegateTarget; // target try's label
bool hasCatchAll() const {
- return catchBodies.size() - catchEvents.size() == 1;
+ return catchBodies.size() - catchTags.size() == 1;
}
bool isCatch() const { return !catchBodies.empty(); }
bool isDelegate() const { return delegateTarget.is(); }
@@ -1287,7 +1287,7 @@ class Throw : public SpecificExpression<Expression::ThrowId> {
public:
Throw(MixedArena& allocator) : operands(allocator) {}
- Name event;
+ Name tag;
ExpressionList operands;
void finalize();
@@ -1686,7 +1686,7 @@ enum class ExternalKind {
Table = 1,
Memory = 2,
Global = 3,
- Event = 4,
+ Tag = 4,
Invalid = -1
};
@@ -1801,13 +1801,13 @@ public:
bool mutable_ = false;
};
-// Kinds of event attributes.
-enum WasmEventAttribute : unsigned { WASM_EVENT_ATTRIBUTE_EXCEPTION = 0x0 };
+// Kinds of tag attributes.
+enum WasmTagAttribute : unsigned { WASM_TAG_ATTRIBUTE_EXCEPTION = 0x0 };
-class Event : public Importable {
+class Tag : public Importable {
public:
- // Kind of event. Currently only WASM_EVENT_ATTRIBUTE_EXCEPTION is possible.
- uint32_t attribute = WASM_EVENT_ATTRIBUTE_EXCEPTION;
+ // Kind of tag. Currently only WASM_TAG_ATTRIBUTE_EXCEPTION is possible.
+ uint32_t attribute = WASM_TAG_ATTRIBUTE_EXCEPTION;
Signature sig;
};
@@ -1833,7 +1833,7 @@ public:
std::vector<std::unique_ptr<Export>> exports;
std::vector<std::unique_ptr<Function>> functions;
std::vector<std::unique_ptr<Global>> globals;
- std::vector<std::unique_ptr<Event>> events;
+ std::vector<std::unique_ptr<Tag>> tags;
std::vector<std::unique_ptr<ElementSegment>> elementSegments;
std::vector<std::unique_ptr<Table>> tables;
@@ -1879,7 +1879,7 @@ private:
std::unordered_map<Name, Table*> tablesMap;
std::unordered_map<Name, ElementSegment*> elementSegmentsMap;
std::unordered_map<Name, Global*> globalsMap;
- std::unordered_map<Name, Event*> eventsMap;
+ std::unordered_map<Name, Tag*> tagsMap;
public:
Module() = default;
@@ -1889,26 +1889,26 @@ public:
Table* getTable(Name name);
ElementSegment* getElementSegment(Name name);
Global* getGlobal(Name name);
- Event* getEvent(Name name);
+ Tag* getTag(Name name);
Export* getExportOrNull(Name name);
Table* getTableOrNull(Name name);
ElementSegment* getElementSegmentOrNull(Name name);
Function* getFunctionOrNull(Name name);
Global* getGlobalOrNull(Name name);
- Event* getEventOrNull(Name name);
+ Tag* getTagOrNull(Name name);
Export* addExport(Export* curr);
Function* addFunction(Function* curr);
Global* addGlobal(Global* curr);
- Event* addEvent(Event* curr);
+ Tag* addTag(Tag* curr);
Export* addExport(std::unique_ptr<Export>&& curr);
Function* addFunction(std::unique_ptr<Function>&& curr);
Table* addTable(std::unique_ptr<Table>&& curr);
ElementSegment* addElementSegment(std::unique_ptr<ElementSegment>&& curr);
Global* addGlobal(std::unique_ptr<Global>&& curr);
- Event* addEvent(std::unique_ptr<Event>&& curr);
+ Tag* addTag(std::unique_ptr<Tag>&& curr);
void addStart(const Name& s);
@@ -1917,14 +1917,14 @@ public:
void removeTable(Name name);
void removeElementSegment(Name name);
void removeGlobal(Name name);
- void removeEvent(Name name);
+ void removeTag(Name name);
void removeExports(std::function<bool(Export*)> pred);
void removeFunctions(std::function<bool(Function*)> pred);
void removeTables(std::function<bool(Table*)> pred);
void removeElementSegments(std::function<bool(ElementSegment*)> pred);
void removeGlobals(std::function<bool(Global*)> pred);
- void removeEvents(std::function<bool(Event*)> pred);
+ void removeTags(std::function<bool(Tag*)> pred);
void updateMaps();
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 7625d1f2a..b7c074377 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -52,7 +52,7 @@ void WasmBinaryWriter::write() {
writeFunctionSignatures();
writeTableDeclarations();
writeMemory();
- writeEvents();
+ writeTags();
writeGlobals();
writeExports();
writeStart();
@@ -278,12 +278,12 @@ void WasmBinaryWriter::writeImports() {
writeType(global->type);
o << U32LEB(global->mutable_);
});
- ModuleUtils::iterImportedEvents(*wasm, [&](Event* event) {
- BYN_TRACE("write one event\n");
- writeImportHeader(event);
- o << U32LEB(int32_t(ExternalKind::Event));
- o << U32LEB(event->attribute);
- o << U32LEB(getTypeIndex(event->sig));
+ ModuleUtils::iterImportedTags(*wasm, [&](Tag* tag) {
+ BYN_TRACE("write one tag\n");
+ writeImportHeader(tag);
+ o << U32LEB(int32_t(ExternalKind::Tag));
+ o << U32LEB(tag->attribute);
+ o << U32LEB(getTypeIndex(tag->sig));
});
if (wasm->memory.imported()) {
BYN_TRACE("write one memory\n");
@@ -460,8 +460,8 @@ void WasmBinaryWriter::writeExports() {
case ExternalKind::Global:
o << U32LEB(getGlobalIndex(curr->value));
break;
- case ExternalKind::Event:
- o << U32LEB(getEventIndex(curr->value));
+ case ExternalKind::Tag:
+ o << U32LEB(getTagIndex(curr->value));
break;
default:
WASM_UNREACHABLE("unexpected extern kind");
@@ -523,9 +523,9 @@ uint32_t WasmBinaryWriter::getGlobalIndex(Name name) const {
return it->second;
}
-uint32_t WasmBinaryWriter::getEventIndex(Name name) const {
- auto it = indexes.eventIndexes.find(name);
- assert(it != indexes.eventIndexes.end());
+uint32_t WasmBinaryWriter::getTagIndex(Name name) const {
+ auto it = indexes.tagIndexes.find(name);
+ assert(it != indexes.tagIndexes.end());
return it->second;
}
@@ -646,18 +646,18 @@ void WasmBinaryWriter::writeElementSegments() {
finishSection(start);
}
-void WasmBinaryWriter::writeEvents() {
- if (importInfo->getNumDefinedEvents() == 0) {
+void WasmBinaryWriter::writeTags() {
+ if (importInfo->getNumDefinedTags() == 0) {
return;
}
- BYN_TRACE("== writeEvents\n");
- auto start = startSection(BinaryConsts::Section::Event);
- auto num = importInfo->getNumDefinedEvents();
+ BYN_TRACE("== writeTags\n");
+ auto start = startSection(BinaryConsts::Section::Tag);
+ auto num = importInfo->getNumDefinedTags();
o << U32LEB(num);
- ModuleUtils::iterDefinedEvents(*wasm, [&](Event* event) {
+ ModuleUtils::iterDefinedTags(*wasm, [&](Tag* tag) {
BYN_TRACE("write one\n");
- o << U32LEB(event->attribute);
- o << U32LEB(getTypeIndex(event->sig));
+ o << U32LEB(tag->attribute);
+ o << U32LEB(getTypeIndex(tag->sig));
});
finishSection(start);
@@ -1419,8 +1419,8 @@ void WasmBinaryBuilder::read() {
case BinaryConsts::Section::Table:
readTableDeclarations();
break;
- case BinaryConsts::Section::Event:
- readEvents();
+ case BinaryConsts::Section::Tag:
+ readTags();
break;
default: {
readUserSection(payloadLen);
@@ -1956,11 +1956,11 @@ Name WasmBinaryBuilder::getGlobalName(Index index) {
return wasm.globals[index]->name;
}
-Name WasmBinaryBuilder::getEventName(Index index) {
- if (index >= wasm.events.size()) {
- throwError("invalid event index");
+Name WasmBinaryBuilder::getTagName(Index index) {
+ if (index >= wasm.tags.size()) {
+ throwError("invalid tag index");
}
- return wasm.events[index]->name;
+ return wasm.tags[index]->name;
}
void WasmBinaryBuilder::getResizableLimits(Address& initial,
@@ -1994,7 +1994,7 @@ void WasmBinaryBuilder::readImports() {
size_t memoryCounter = 0;
size_t functionCounter = 0;
size_t globalCounter = 0;
- size_t eventCounter = 0;
+ size_t tagCounter = 0;
for (size_t i = 0; i < num; i++) {
BYN_TRACE("read one\n");
auto module = getInlineString();
@@ -2069,15 +2069,15 @@ void WasmBinaryBuilder::readImports() {
wasm.addGlobal(std::move(curr));
break;
}
- case ExternalKind::Event: {
- Name name(std::string("eimport$") + std::to_string(eventCounter++));
+ case ExternalKind::Tag: {
+ Name name(std::string("eimport$") + std::to_string(tagCounter++));
auto attribute = getU32LEB();
auto index = getU32LEB();
auto curr =
- builder.makeEvent(name, attribute, getSignatureByTypeIndex(index));
+ builder.makeTag(name, attribute, getSignatureByTypeIndex(index));
curr->module = module;
curr->base = base;
- wasm.addEvent(std::move(curr));
+ wasm.addTag(std::move(curr));
break;
}
default: {
@@ -2705,8 +2705,8 @@ void WasmBinaryBuilder::processNames() {
case ExternalKind::Global:
curr->value = getGlobalName(index);
break;
- case ExternalKind::Event:
- curr->value = getEventName(index);
+ case ExternalKind::Tag:
+ curr->value = getTagName(index);
break;
default:
throwError("bad export kind");
@@ -2902,17 +2902,17 @@ void WasmBinaryBuilder::readElementSegments() {
}
}
-void WasmBinaryBuilder::readEvents() {
- BYN_TRACE("== readEvents\n");
- size_t numEvents = getU32LEB();
- BYN_TRACE("num: " << numEvents << std::endl);
- for (size_t i = 0; i < numEvents; i++) {
+void WasmBinaryBuilder::readTags() {
+ BYN_TRACE("== readTags\n");
+ size_t numTags = getU32LEB();
+ BYN_TRACE("num: " << numTags << std::endl);
+ for (size_t i = 0; i < numTags; i++) {
BYN_TRACE("read one\n");
auto attribute = getU32LEB();
auto typeIndex = getU32LEB();
- wasm.addEvent(Builder::makeEvent("event$" + std::to_string(i),
- attribute,
- getSignatureByTypeIndex(typeIndex)));
+ wasm.addTag(Builder::makeTag("tag$" + std::to_string(i),
+ attribute,
+ getSignatureByTypeIndex(typeIndex)));
}
}
@@ -6113,10 +6113,10 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) {
Name catchLabel = getNextLabel();
breakStack.push_back({catchLabel, curr->type});
- auto readCatchBody = [&](Type eventType) {
+ auto readCatchBody = [&](Type tagType) {
auto start = expressionStack.size();
- if (eventType != Type::none) {
- pushExpression(builder.makePop(eventType));
+ if (tagType != Type::none) {
+ pushExpression(builder.makePop(tagType));
}
processExpressions();
size_t end = expressionStack.size();
@@ -6137,12 +6137,12 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) {
lastSeparator == BinaryConsts::CatchAll) {
if (lastSeparator == BinaryConsts::Catch) {
auto index = getU32LEB();
- if (index >= wasm.events.size()) {
- throwError("bad event index");
+ if (index >= wasm.tags.size()) {
+ throwError("bad tag index");
}
- auto* event = wasm.events[index].get();
- curr->catchEvents.push_back(event->name);
- readCatchBody(event->sig.params);
+ auto* tag = wasm.tags[index].get();
+ curr->catchTags.push_back(tag->name);
+ readCatchBody(tag->sig.params);
} else { // catch_all
if (curr->hasCatchAll()) {
@@ -6240,12 +6240,12 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) {
void WasmBinaryBuilder::visitThrow(Throw* curr) {
BYN_TRACE("zz node: Throw\n");
auto index = getU32LEB();
- if (index >= wasm.events.size()) {
- throwError("bad event index");
+ if (index >= wasm.tags.size()) {
+ throwError("bad tag index");
}
- auto* event = wasm.events[index].get();
- curr->event = event->name;
- size_t num = event->sig.params.size();
+ auto* tag = wasm.tags[index].get();
+ curr->tag = tag->name;
+ size_t num = tag->sig.params.size();
curr->operands.resize(num);
for (size_t i = 0; i < num; i++) {
curr->operands[num - i - 1] = popNonVoidExpression();
diff --git a/src/wasm/wasm-interpreter.cpp b/src/wasm/wasm-interpreter.cpp
index f37758808..b49eeef4b 100644
--- a/src/wasm/wasm-interpreter.cpp
+++ b/src/wasm/wasm-interpreter.cpp
@@ -20,7 +20,7 @@ void Indenter::print() {
#endif // WASM_INTERPRETER_DEBUG
std::ostream& operator<<(std::ostream& o, const WasmException& exn) {
- return o << exn.event << " " << exn.values;
+ return o << exn.tag << " " << exn.values;
}
} // namespace wasm
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 4f1cd412e..c688630c3 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -411,8 +411,8 @@ void SExpressionWasmBuilder::preParseImports(Element& curr) {
parseTable(curr, true /* preParseImport */);
} else if (id == MEMORY) {
parseMemory(curr, true /* preParseImport */);
- } else if (id == EVENT) {
- parseEvent(curr, true /* preParseImport */);
+ } else if (id == TAG) {
+ parseTag(curr, true /* preParseImport */);
} else {
throw ParseException(
"fancy import we don't support yet", curr.line, curr.col);
@@ -455,8 +455,8 @@ void SExpressionWasmBuilder::parseModuleElement(Element& curr) {
if (id == TYPE) {
return; // already done
}
- if (id == EVENT) {
- return parseEvent(curr);
+ if (id == TAG) {
+ return parseTag(curr);
}
std::cerr << "bad module element " << id.str << '\n';
throw ParseException("unknown module element", curr.line, curr.col);
@@ -502,16 +502,16 @@ Name SExpressionWasmBuilder::getGlobalName(Element& s) {
}
}
-Name SExpressionWasmBuilder::getEventName(Element& s) {
+Name SExpressionWasmBuilder::getTagName(Element& s) {
if (s.dollared()) {
return s.str();
} else {
// index
size_t offset = atoi(s.str().c_str());
- if (offset >= eventNames.size()) {
- throw ParseException("unknown event in getEventName", s.line, s.col);
+ if (offset >= tagNames.size()) {
+ throw ParseException("unknown tag in getTagName", s.line, s.col);
}
- return eventNames[offset];
+ return tagNames[offset];
}
}
@@ -2454,11 +2454,11 @@ Expression* SExpressionWasmBuilder::makeTry(Element& s) {
if (inner.size() < 2) {
throw ParseException("invalid catch block", inner.line, inner.col);
}
- Name event = getEventName(*inner[1]);
- if (!wasm.getEventOrNull(event)) {
- throw ParseException("bad event name", inner[1]->line, inner[1]->col);
+ Name tag = getTagName(*inner[1]);
+ if (!wasm.getTagOrNull(tag)) {
+ throw ParseException("bad tag name", inner[1]->line, inner[1]->col);
}
- ret->catchEvents.push_back(getEventName(*inner[1]));
+ ret->catchTags.push_back(getTagName(*inner[1]));
ret->catchBodies.push_back(makeMaybeBlock(inner, 2, type));
}
@@ -2505,9 +2505,9 @@ Expression* SExpressionWasmBuilder::makeThrow(Element& s) {
auto ret = allocator.alloc<Throw>();
Index i = 1;
- ret->event = getEventName(*s[i++]);
- if (!wasm.getEventOrNull(ret->event)) {
- throw ParseException("bad event name", s[1]->line, s[1]->col);
+ ret->tag = getTagName(*s[i++]);
+ if (!wasm.getTagOrNull(ret->tag)) {
+ throw ParseException("bad tag name", s[1]->line, s[1]->col);
}
for (; i < s.size(); i++) {
ret->operands.push_back(parseExpression(s[i]));
@@ -2955,9 +2955,9 @@ void SExpressionWasmBuilder::parseExport(Element& s) {
} else if (elementStartsWith(inner, GLOBAL)) {
ex->kind = ExternalKind::Global;
ex->value = getGlobalName(*inner[1]);
- } else if (inner[0]->str() == EVENT) {
- ex->kind = ExternalKind::Event;
- ex->value = getEventName(*inner[1]);
+ } else if (inner[0]->str() == TAG) {
+ ex->kind = ExternalKind::Tag;
+ ex->value = getTagName(*inner[1]);
} else {
throw ParseException("invalid export", inner.line, inner.col);
}
@@ -2990,8 +2990,8 @@ void SExpressionWasmBuilder::parseImport(Element& s) {
kind = ExternalKind::Table;
} else if (elementStartsWith(*s[3], GLOBAL)) {
kind = ExternalKind::Global;
- } else if ((*s[3])[0]->str() == EVENT) {
- kind = ExternalKind::Event;
+ } else if ((*s[3])[0]->str() == TAG) {
+ kind = ExternalKind::Tag;
} else {
newStyle = false; // either (param..) or (result..)
}
@@ -3016,9 +3016,9 @@ void SExpressionWasmBuilder::parseImport(Element& s) {
name = Name("mimport$" + std::to_string(memoryCounter++));
} else if (kind == ExternalKind::Table) {
name = Name("timport$" + std::to_string(tableCounter++));
- } else if (kind == ExternalKind::Event) {
- name = Name("eimport$" + std::to_string(eventCounter++));
- eventNames.push_back(name);
+ } else if (kind == ExternalKind::Tag) {
+ name = Name("eimport$" + std::to_string(tagCounter++));
+ tagNames.push_back(name);
} else {
throw ParseException("invalid import", s[3]->line, s[3]->col);
}
@@ -3107,21 +3107,21 @@ void SExpressionWasmBuilder::parseImport(Element& s) {
} else {
j = parseMemoryLimits(inner, j);
}
- } else if (kind == ExternalKind::Event) {
- auto event = make_unique<Event>();
+ } else if (kind == ExternalKind::Tag) {
+ auto tag = make_unique<Tag>();
if (j >= inner.size()) {
- throw ParseException("event does not have an attribute", s.line, s.col);
+ throw ParseException("tag does not have an attribute", s.line, s.col);
}
auto& attrElem = *inner[j++];
if (!elementStartsWith(attrElem, ATTR) || attrElem.size() != 2) {
throw ParseException("invalid attribute", attrElem.line, attrElem.col);
}
- event->attribute = atoi(attrElem[1]->c_str());
- j = parseTypeUse(inner, j, event->sig);
- event->setName(name, hasExplicitName);
- event->module = module;
- event->base = base;
- wasm.addEvent(event.release());
+ tag->attribute = atoi(attrElem[1]->c_str());
+ j = parseTypeUse(inner, j, tag->sig);
+ tag->setName(name, hasExplicitName);
+ tag->module = module;
+ tag->base = base;
+ wasm.addTag(tag.release());
}
// If there are more elements, they are invalid
if (j < inner.size()) {
@@ -3436,23 +3436,23 @@ HeapType SExpressionWasmBuilder::parseHeapType(Element& s) {
throw ParseException("invalid heap type", s.line, s.col);
}
-void SExpressionWasmBuilder::parseEvent(Element& s, bool preParseImport) {
- auto event = make_unique<Event>();
+void SExpressionWasmBuilder::parseTag(Element& s, bool preParseImport) {
+ auto tag = make_unique<Tag>();
size_t i = 1;
// Parse name
if (s[i]->isStr() && s[i]->dollared()) {
auto& inner = *s[i++];
- event->setExplicitName(inner.str());
- if (wasm.getEventOrNull(event->name)) {
- throw ParseException("duplicate event", inner.line, inner.col);
+ tag->setExplicitName(inner.str());
+ if (wasm.getTagOrNull(tag->name)) {
+ throw ParseException("duplicate tag", inner.line, inner.col);
}
} else {
- event->name = Name::fromInt(eventCounter);
- assert(!wasm.getEventOrNull(event->name));
+ tag->name = Name::fromInt(tagCounter);
+ assert(!wasm.getTagOrNull(tag->name));
}
- eventCounter++;
- eventNames.push_back(event->name);
+ tagCounter++;
+ tagNames.push_back(tag->name);
// Parse import, if any
if (i < s.size() && elementStartsWith(*s[i], IMPORT)) {
@@ -3469,14 +3469,14 @@ void SExpressionWasmBuilder::parseEvent(Element& s, bool preParseImport) {
throw ParseException(
"invalid import base name", importElem[2]->line, importElem[2]->col);
}
- event->module = importElem[1]->str();
- event->base = importElem[2]->str();
+ tag->module = importElem[1]->str();
+ tag->base = importElem[2]->str();
}
// Parse export, if any
if (i < s.size() && elementStartsWith(*s[i], EXPORT)) {
auto& exportElem = *s[i++];
- if (event->module.is()) {
+ if (tag->module.is()) {
throw ParseException("import and export cannot be specified together",
exportElem.line,
exportElem.col);
@@ -3494,13 +3494,13 @@ void SExpressionWasmBuilder::parseEvent(Element& s, bool preParseImport) {
throw ParseException(
"duplicate export", exportElem[1]->line, exportElem[1]->col);
}
- ex->value = event->name;
- ex->kind = ExternalKind::Event;
+ ex->value = tag->name;
+ ex->kind = ExternalKind::Tag;
}
// Parse attribute
if (i >= s.size()) {
- throw ParseException("event does not have an attribute", s.line, s.col);
+ throw ParseException("tag does not have an attribute", s.line, s.col);
}
auto& attrElem = *s[i++];
if (!elementStartsWith(attrElem, ATTR) || attrElem.size() != 2) {
@@ -3510,17 +3510,17 @@ void SExpressionWasmBuilder::parseEvent(Element& s, bool preParseImport) {
throw ParseException(
"invalid attribute", attrElem[1]->line, attrElem[1]->col);
}
- event->attribute = atoi(attrElem[1]->c_str());
+ tag->attribute = atoi(attrElem[1]->c_str());
// Parse typeuse
- i = parseTypeUse(s, i, event->sig);
+ i = parseTypeUse(s, i, tag->sig);
// If there are more elements, they are invalid
if (i < s.size()) {
throw ParseException("invalid element", s[i]->line, s[i]->col);
}
- wasm.addEvent(event.release());
+ wasm.addTag(tag.release());
}
void SExpressionWasmBuilder::validateHeapTypeUsingChild(Expression* child,
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 3200e77a7..7b682a264 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -1858,7 +1858,7 @@ void BinaryInstWriter::emitCatch(Try* curr, Index i) {
parent.writeExtraDebugLocation(curr, func, i);
}
o << int8_t(BinaryConsts::Catch)
- << U32LEB(parent.getEventIndex(curr->catchEvents[i]));
+ << U32LEB(parent.getTagIndex(curr->catchTags[i]));
}
void BinaryInstWriter::emitCatchAll(Try* curr) {
@@ -1879,7 +1879,7 @@ void BinaryInstWriter::emitDelegate(Try* curr) {
}
void BinaryInstWriter::visitThrow(Throw* curr) {
- o << int8_t(BinaryConsts::Throw) << U32LEB(parent.getEventIndex(curr->event));
+ o << int8_t(BinaryConsts::Throw) << U32LEB(parent.getTagIndex(curr->tag));
}
void BinaryInstWriter::visitRethrow(Rethrow* curr) {
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index d704ee15e..a42ff36ec 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2071,9 +2071,9 @@ void FunctionValidator::visitTry(Try* curr) {
"unreachable try-catch must have unreachable catch body");
}
}
- shouldBeTrue(curr->catchBodies.size() - curr->catchEvents.size() <= 1,
+ shouldBeTrue(curr->catchBodies.size() - curr->catchTags.size() <= 1,
curr,
- "the number of catch blocks and events do not match");
+ "the number of catch blocks and tags do not match");
shouldBeFalse(curr->isCatch() && curr->isDelegate(),
curr,
@@ -2097,21 +2097,21 @@ void FunctionValidator::visitThrow(Throw* curr) {
if (!info.validateGlobally) {
return;
}
- auto* event = getModule()->getEventOrNull(curr->event);
- if (!shouldBeTrue(!!event, curr, "throw's event must exist")) {
+ auto* tag = getModule()->getTagOrNull(curr->tag);
+ if (!shouldBeTrue(!!tag, curr, "throw's tag must exist")) {
return;
}
- if (!shouldBeTrue(curr->operands.size() == event->sig.params.size(),
+ if (!shouldBeTrue(curr->operands.size() == tag->sig.params.size(),
curr,
- "event's param numbers must match")) {
+ "tag's param numbers must match")) {
return;
}
size_t i = 0;
- for (const auto& param : event->sig.params) {
+ for (const auto& param : tag->sig.params) {
if (!shouldBeSubType(curr->operands[i]->type,
param,
curr->operands[i],
- "event param types must match") &&
+ "tag param types must match") &&
!info.quiet) {
getStream() << "(on argument " << i << ")\n";
}
@@ -2737,10 +2737,9 @@ static void validateExports(Module& module, ValidationInfo& info) {
info.shouldBeTrue(name == Name("0") || name == module.memory.name,
name,
"module memory exports must be found");
- } else if (exp->kind == ExternalKind::Event) {
- info.shouldBeTrue(module.getEventOrNull(name),
- name,
- "module event exports must be found");
+ } else if (exp->kind == ExternalKind::Tag) {
+ info.shouldBeTrue(
+ module.getTagOrNull(name), name, "module tag exports must be found");
} else {
WASM_UNREACHABLE("invalid ExternalKind");
}
@@ -2978,13 +2977,13 @@ static void validateTables(Module& module, ValidationInfo& info) {
}
}
-static void validateEvents(Module& module, ValidationInfo& info) {
- if (!module.events.empty()) {
+static void validateTags(Module& module, ValidationInfo& info) {
+ if (!module.tags.empty()) {
info.shouldBeTrue(module.features.hasExceptionHandling(),
- module.events[0]->name,
- "Module has events (event-handling is disabled)");
+ module.tags[0]->name,
+ "Module has tags (exception-handling is disabled)");
}
- for (auto& curr : module.events) {
+ for (auto& curr : module.tags) {
info.shouldBeEqual(curr->attribute,
(unsigned)0,
curr->attribute,
@@ -2992,16 +2991,16 @@ static void validateEvents(Module& module, ValidationInfo& info) {
info.shouldBeEqual(curr->sig.results,
Type(Type::none),
curr->name,
- "Event type's result type should be none");
+ "Tag type's result type should be none");
if (curr->sig.params.isTuple()) {
info.shouldBeTrue(module.features.hasMultivalue(),
curr->name,
- "Multivalue event type (multivalue is not enabled)");
+ "Multivalue tag type (multivalue is not enabled)");
}
for (const auto& param : curr->sig.params) {
info.shouldBeTrue(param.isConcrete(),
curr->name,
- "Values in an event should have concrete types");
+ "Values in a tag should have concrete types");
}
}
}
@@ -3048,7 +3047,7 @@ bool WasmValidator::validate(Module& module, Flags flags) {
validateGlobals(module, info);
validateMemory(module, info);
validateTables(module, info);
- validateEvents(module, info);
+ validateTags(module, info);
validateModule(module, info);
validateFeatures(module, info);
}
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index f769cb1f5..ea82bac39 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -96,7 +96,7 @@ Name SPECTEST("spectest");
Name PRINT("print");
Name EXIT("exit");
Name SHARED("shared");
-Name EVENT("event");
+Name TAG("tag");
Name ATTR("attr");
// Expressions
@@ -1194,8 +1194,8 @@ Global* Module::getGlobal(Name name) {
return getModuleElement(globalsMap, name, "getGlobal");
}
-Event* Module::getEvent(Name name) {
- return getModuleElement(eventsMap, name, "getEvent");
+Tag* Module::getTag(Name name) {
+ return getModuleElement(tagsMap, name, "getTag");
}
template<typename Map>
@@ -1227,8 +1227,8 @@ Global* Module::getGlobalOrNull(Name name) {
return getModuleElementOrNull(globalsMap, name);
}
-Event* Module::getEventOrNull(Name name) {
- return getModuleElementOrNull(eventsMap, name);
+Tag* Module::getTagOrNull(Name name) {
+ return getModuleElementOrNull(tagsMap, name);
}
// TODO(@warchant): refactor all usages to use variant with unique_ptr
@@ -1275,8 +1275,8 @@ Global* Module::addGlobal(Global* curr) {
return addModuleElement(globals, globalsMap, curr, "addGlobal");
}
-Event* Module::addEvent(Event* curr) {
- return addModuleElement(events, eventsMap, curr, "addEvent");
+Tag* Module::addTag(Tag* curr) {
+ return addModuleElement(tags, tagsMap, curr, "addTag");
}
Export* Module::addExport(std::unique_ptr<Export>&& curr) {
@@ -1302,8 +1302,8 @@ Global* Module::addGlobal(std::unique_ptr<Global>&& curr) {
return addModuleElement(globals, globalsMap, std::move(curr), "addGlobal");
}
-Event* Module::addEvent(std::unique_ptr<Event>&& curr) {
- return addModuleElement(events, eventsMap, std::move(curr), "addEvent");
+Tag* Module::addTag(std::unique_ptr<Tag>&& curr) {
+ return addModuleElement(tags, tagsMap, std::move(curr), "addTag");
}
void Module::addStart(const Name& s) { start = s; }
@@ -1334,9 +1334,7 @@ void Module::removeElementSegment(Name name) {
void Module::removeGlobal(Name name) {
removeModuleElement(globals, globalsMap, name);
}
-void Module::removeEvent(Name name) {
- removeModuleElement(events, eventsMap, name);
-}
+void Module::removeTag(Name name) { removeModuleElement(tags, tagsMap, name); }
template<typename Vector, typename Map, typename Elem>
void removeModuleElements(Vector& v,
@@ -1369,8 +1367,8 @@ void Module::removeElementSegments(std::function<bool(ElementSegment*)> pred) {
void Module::removeGlobals(std::function<bool(Global*)> pred) {
removeModuleElements(globals, globalsMap, pred);
}
-void Module::removeEvents(std::function<bool(Event*)> pred) {
- removeModuleElements(events, eventsMap, pred);
+void Module::removeTags(std::function<bool(Tag*)> pred) {
+ removeModuleElements(tags, tagsMap, pred);
}
void Module::updateMaps() {
@@ -1394,9 +1392,9 @@ void Module::updateMaps() {
for (auto& curr : globals) {
globalsMap[curr->name] = curr.get();
}
- eventsMap.clear();
- for (auto& curr : events) {
- eventsMap[curr->name] = curr.get();
+ tagsMap.clear();
+ for (auto& curr : tags) {
+ tagsMap[curr->name] = curr.get();
}
}
diff --git a/src/wasm2js.h b/src/wasm2js.h
index 268f3424f..5d2f95e94 100644
--- a/src/wasm2js.h
+++ b/src/wasm2js.h
@@ -769,7 +769,7 @@ void Wasm2JSBuilder::addExports(Ref ast, Module* wasm) {
ValueBuilder::makeName(fromName(export_->value, NameScope::Top)));
break;
}
- case ExternalKind::Event:
+ case ExternalKind::Tag:
case ExternalKind::Invalid:
Fatal() << "unsupported export type: " << export_->name << "\n";
}