diff options
106 files changed, 894 insertions, 909 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"; } diff --git a/test/binaryen.js/event.js.txt b/test/binaryen.js/event.js.txt deleted file mode 100644 index 94e1b1a7a..000000000 --- a/test/binaryen.js/event.js.txt +++ /dev/null @@ -1,15 +0,0 @@ -GetEvent is equal: true -getEventInfo={"name":"a-event","module":"","base":"","attribute":0,"params":2,"results":0} -(module - (type $i32_=>_none (func (param i32))) - (type $i32_f32_=>_none (func (param i32 f32))) - (import "module" "base" (event $a-event-imp (attr 0) (param i32 f32))) - (event $a-event (attr 0) (param i32)) - (export "a-event-exp" (event $a-event)) -) - -(module - (type $i32_f32_=>_none (func (param i32 f32))) - (import "module" "base" (event $a-event-imp (attr 0) (param i32 f32))) -) - diff --git a/test/binaryen.js/exception-handling.js b/test/binaryen.js/exception-handling.js index a8d3dd3a4..1f512bbe8 100644 --- a/test/binaryen.js/exception-handling.js +++ b/test/binaryen.js/exception-handling.js @@ -2,7 +2,7 @@ function cleanInfo(info) { var ret = {}; for (var x in info) { // Filter out address pointers and only print meaningful info - if (x == 'id' || x == 'type' || x == 'name' || x == 'event' || + if (x == 'id' || x == 'type' || x == 'name' || x == 'tag' || x == 'target' || x == 'hasCatchAll' || x == 'delegateTarget' || x == 'isDelegate') { ret[x] = info[x]; @@ -19,7 +19,7 @@ var module = new binaryen.Module(); module.setFeatures(binaryen.Features.ReferenceTypes | binaryen.Features.ExceptionHandling); -var event_ = module.addEvent("e", 0, binaryen.i32, binaryen.none); +module.addTag("e", 0, binaryen.i32, binaryen.none); // (try $l0 // (do @@ -52,7 +52,7 @@ var try_catch = module.try( // (do // (try // (do -// (throw $a-event (i32.const 0)) +// (throw $a-tag (i32.const 0)) // ) // (delegate $try_outer) // ) diff --git a/test/binaryen.js/exception-handling.js.txt b/test/binaryen.js/exception-handling.js.txt index 0fbdc3668..e711f7bfd 100644 --- a/test/binaryen.js/exception-handling.js.txt +++ b/test/binaryen.js/exception-handling.js.txt @@ -1,7 +1,7 @@ (module (type $i32_=>_none (func (param i32))) (type $none_=>_none (func)) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) (func $test (try $l0 (do @@ -34,7 +34,7 @@ ) ) -getExpressionInfo(throw) = {"id":46,"type":1,"event":"e"} +getExpressionInfo(throw) = {"id":46,"type":1,"tag":"e"} getExpressionInfo(rethrow) = {"id":47,"type":1,"target":"l0"} getExpressionInfo(try_catch) = {"id":45,"type":1,"name":"l0","hasCatchAll":0,"delegateTarget":"","isDelegate":0} getExpressionInfo(try_delegate) = {"id":45,"type":0,"name":"try_outer","hasCatchAll":1,"delegateTarget":"","isDelegate":0} diff --git a/test/binaryen.js/expressions.js b/test/binaryen.js/expressions.js index ca45933a7..40d4194fd 100644 --- a/test/binaryen.js/expressions.js +++ b/test/binaryen.js/expressions.js @@ -1565,22 +1565,22 @@ console.log("# RefEq"); console.log("# Try"); (function testTry() { const module = new binaryen.Module(); - module.addEvent("event1", 0, binaryen.none, binaryen.none); - module.addEvent("event2", 0, binaryen.none, binaryen.none); - module.addEvent("event3", 0, binaryen.none, binaryen.none); + module.addTag("tag1", 0, binaryen.none, binaryen.none); + module.addTag("tag2", 0, binaryen.none, binaryen.none); + module.addTag("tag3", 0, binaryen.none, binaryen.none); var body = module.i32.const(1); var catchBodies = [ module.i32.const(2), module.i32.const(3) ]; - const theTry = binaryen.Try(module.try('', body, ["event1"], catchBodies, '')); + const theTry = binaryen.Try(module.try('', body, ["tag1"], catchBodies, '')); assert(theTry instanceof binaryen.Try); assert(theTry instanceof binaryen.Expression); assert(theTry.body === body); assertDeepEqual(theTry.catchBodies, catchBodies); assert(theTry.type === binaryen.i32); - assert(theTry.getNumCatchEvents() == 1); + assert(theTry.getNumCatchTags() == 1); assert(theTry.getNumCatchBodies() == 2); assert(theTry.hasCatchAll() == 1); console.log(theTry.toText()); @@ -1596,31 +1596,31 @@ console.log("# Try"); assertDeepEqual(theTry.getCatchBodies(), catchBodies); console.log(theTry.toText()); - theTry.insertCatchEventAt(1, "event2"); + theTry.insertCatchTagAt(1, "tag2"); theTry.insertCatchBodyAt(0, module.i32.const(6)); - assert(theTry.getNumCatchEvents() == 2); + assert(theTry.getNumCatchTags() == 2); assert(theTry.getNumCatchBodies() == 2); assert(theTry.hasCatchAll() == 0); console.log(theTry.toText()); - assert(theTry.removeCatchEventAt(1) == "event2"); + assert(theTry.removeCatchTagAt(1) == "tag2"); theTry.removeCatchBodyAt(1); - assert(theTry.getNumCatchEvents() == 1); + assert(theTry.getNumCatchTags() == 1); assert(theTry.getNumCatchBodies() == 1); console.log(theTry.toText()); - theTry.appendCatchEvent("event3"); + theTry.appendCatchTag("tag3"); theTry.appendCatchBody(module.drop(module.i32.const(7))); - assert(theTry.getCatchEventAt(0) == "event1"); - assert(theTry.getCatchEventAt(1) == "event3"); - theTry.setCatchEvents(["event2", "event3"]); - assertDeepEqual(theTry.getCatchEvents(), ["event2", "event3"]); + assert(theTry.getCatchTagAt(0) == "tag1"); + assert(theTry.getCatchTagAt(1) == "tag3"); + theTry.setCatchTags(["tag2", "tag3"]); + assertDeepEqual(theTry.getCatchTags(), ["tag2", "tag3"]); theTry.setCatchBodies([module.i32.const(8), module.i32.const(9)]); - assert(theTry.getCatchEventAt(0) == "event2"); - assert(theTry.getCatchEventAt(1) == "event3"); - theTry.setCatchEventAt(1, "event1"); + assert(theTry.getCatchTagAt(0) == "tag2"); + assert(theTry.getCatchTagAt(1) == "tag3"); + theTry.setCatchTagAt(1, "tag1"); theTry.setCatchBodyAt(1, module.i32.const(10)); - assert(theTry.getCatchEventAt(1) == "event1"); + assert(theTry.getCatchTagAt(1) == "tag1"); console.log(theTry.toText()); theTry.type = binaryen.f64; @@ -1643,20 +1643,20 @@ console.log("# Throw"); (function testThrow() { const module = new binaryen.Module(); - var event = "foo"; + var tag = "foo"; var operands = [ module.i32.const(1), module.i32.const(2) ]; - const theThrow = binaryen.Throw(module.throw(event, operands)); + const theThrow = binaryen.Throw(module.throw(tag, operands)); assert(theThrow instanceof binaryen.Throw); assert(theThrow instanceof binaryen.Expression); - assert(theThrow.event === event); + assert(theThrow.tag === tag); assertDeepEqual(theThrow.operands, operands); assert(theThrow.type === binaryen.unreachable); - theThrow.event = "bar"; - assert(theThrow.event === "bar"); + theThrow.tag = "bar"; + assert(theThrow.tag === "bar"); theThrow.operands = operands = [ module.i32.const(3), // set module.i32.const(4), // set diff --git a/test/binaryen.js/expressions.js.txt b/test/binaryen.js/expressions.js.txt index 1d38104af..b9107f5c1 100644 --- a/test/binaryen.js/expressions.js.txt +++ b/test/binaryen.js/expressions.js.txt @@ -238,7 +238,7 @@ (do (i32.const 1) ) - (catch $event1 + (catch $tag1 (i32.const 2) ) (catch_all @@ -250,7 +250,7 @@ (do (i32.const 4) ) - (catch $event1 + (catch $tag1 (i32.const 5) ) ) @@ -259,10 +259,10 @@ (do (i32.const 4) ) - (catch $event1 + (catch $tag1 (i32.const 6) ) - (catch $event2 + (catch $tag2 (i32.const 5) ) ) @@ -271,7 +271,7 @@ (do (i32.const 4) ) - (catch $event1 + (catch $tag1 (i32.const 6) ) ) @@ -280,10 +280,10 @@ (do (i32.const 4) ) - (catch $event2 + (catch $tag2 (i32.const 8) ) - (catch $event1 + (catch $tag1 (i32.const 10) ) ) @@ -292,10 +292,10 @@ (do (i32.const 4) ) - (catch $event2 + (catch $tag2 (i32.const 8) ) - (catch $event1 + (catch $tag1 (i32.const 10) ) ) diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index a8e69e381..dd942b7d7 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -191,8 +191,8 @@ function test_core() { module = new binaryen.Module(); - // Create an event - var event_ = module.addEvent("a-event", 0, binaryen.i32, binaryen.none); + // Create a tag + var tag = module.addTag("a-tag", 0, binaryen.i32, binaryen.none); // Literals and consts @@ -593,8 +593,8 @@ function test_core() { // Exception handling module.try( '', - module.throw("a-event", [module.i32.const(0)]), - ["a-event"], + module.throw("a-tag", [module.i32.const(0)]), + ["a-tag"], [module.drop(module.i32.pop())], '' ), @@ -702,13 +702,13 @@ function test_core() { module.addFunctionImport("an-imported", "module", "base", iF, binaryen.f32); module.addGlobalImport("a-global-imp", "module", "base", binaryen.i32, false); module.addGlobalImport("a-mut-global-imp", "module", "base", binaryen.i32, true); - module.addEventImport("a-event-imp", "module", "base", 0, binaryen.i32, binaryen.none); + module.addTagImport("a-tag-imp", "module", "base", 0, binaryen.i32, binaryen.none); // Exports module.addFunctionExport("kitchen()sinker", "kitchen_sinker"); module.addGlobalExport("a-global", "a-global-exp"); - module.addEventExport("a-event", "a-event-exp"); + module.addTagExport("a-tag", "a-tag-exp"); // Tables module.addTable("t1", 0, 2); @@ -973,7 +973,7 @@ function test_binaries() { var adder = module.addFunction("adder", ii, binaryen.i32, [], add); var initExpr = module.i32.const(3); var global = module.addGlobal("a-global", binaryen.i32, false, initExpr) - var event_ = module.addEvent("a-event", 0, binaryen.createType([binaryen.i32, binaryen.i32]), binaryen.none); + var tag = module.addTag("a-tag", 0, binaryen.createType([binaryen.i32, binaryen.i32]), binaryen.none); binaryen.setDebugInfo(true); // include names section buffer = module.emitBinary(); binaryen.setDebugInfo(false); @@ -1038,7 +1038,7 @@ function test_parsing() { var adder = module.addFunction("adder", ii, binaryen.i32, [], add); var initExpr = module.i32.const(3); var global = module.addGlobal("a-global", binaryen.i32, false, initExpr) - var event_ = module.addEvent("a-event", 0, binaryen.i32, binaryen.none); + var tag = module.addTag("a-tag", 0, binaryen.i32, binaryen.none); text = module.emitText(); module.dispose(); module = null; diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index b8b671de5..745df85f0 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -128,17 +128,17 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (import "module" "base" (global $a-global-imp i32)) (import "module" "base" (global $a-mut-global-imp (mut i32))) (import "module" "base" (func $an-imported (param i32 f64) (result f32))) - (import "module" "base" (event $a-event-imp (attr 0) (param i32))) + (import "module" "base" (tag $a-tag-imp (attr 0) (param i32))) (global $a-global i32 (i32.const 1)) (memory $0 (shared 1 256)) (data (i32.const 10) "hello, world") (data "I am passive") (table $t0 1 funcref) (elem $e0 (i32.const 0) "$kitchen()sinker") - (event $a-event (attr 0) (param i32)) + (tag $a-tag (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "a-global-exp" (global $a-global)) - (export "a-event-exp" (event $a-event)) + (export "a-tag-exp" (tag $a-tag)) (export "mem" (memory $0)) (start $starter) (func "$kitchen()sinker" (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) @@ -2091,11 +2091,11 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (try (do - (throw $a-event + (throw $a-tag (i32.const 0) ) ) - (catch $a-event + (catch $a-tag (drop (pop i32) ) @@ -2220,17 +2220,17 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (import "module" "base" (global $a-global-imp i32)) (import "module" "base" (global $a-mut-global-imp (mut i32))) (import "module" "base" (func $an-imported (param i32 f64) (result f32))) - (import "module" "base" (event $a-event-imp (attr 0) (param i32))) + (import "module" "base" (tag $a-tag-imp (attr 0) (param i32))) (global $a-global i32 (i32.const 1)) (memory $0 (shared 1 256)) (data (i32.const 10) "hello, world") (data "I am passive") (table $t0 1 funcref) (elem $e0 (i32.const 0) "$kitchen()sinker") - (event $a-event (attr 0) (param i32)) + (tag $a-tag (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "a-global-exp" (global $a-global)) - (export "a-event-exp" (event $a-event)) + (export "a-tag-exp" (tag $a-tag)) (export "mem" (memory $0)) (start $starter) (func "$kitchen()sinker" (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) @@ -4183,11 +4183,11 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (try (do - (throw $a-event + (throw $a-tag (i32.const 0) ) ) - (catch $a-event + (catch $a-tag (drop (pop i32) ) @@ -4779,7 +4779,7 @@ module loaded from binary form: (type $i32_i32_=>_none (func (param i32 i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (global $a-global i32 (i32.const 3)) - (event $event$0 (attr 0) (param i32 i32)) + (tag $tag$0 (attr 0) (param i32 i32)) (func $adder (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) @@ -4821,7 +4821,7 @@ test_parsing text: (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (global $a-global i32 (i32.const 3)) - (event $a-event (attr 0) (param i32)) + (tag $a-tag (attr 0) (param i32)) (func $adder (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) @@ -4835,7 +4835,7 @@ module loaded from text form: (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (global $a-global i32 (i32.const 3)) - (event $a-event (attr 0) (param i32)) + (tag $a-tag (attr 0) (param i32)) (func $ADD_ER (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) diff --git a/test/binaryen.js/event.js b/test/binaryen.js/tag.js index f705edc38..17822236d 100644 --- a/test/binaryen.js/event.js +++ b/test/binaryen.js/tag.js @@ -13,21 +13,21 @@ module.setFeatures(binaryen.Features.ReferenceTypes | var pairType = binaryen.createType([binaryen.i32, binaryen.f32]); -var event_ = module.addEvent("a-event", 0, binaryen.i32, binaryen.none); +var tag = module.addTag("a-tag", 0, binaryen.i32, binaryen.none); -console.log("GetEvent is equal: " + (event_ === module.getEvent("a-event"))); +console.log("GetTag is equal: " + (tag === module.getTag("a-tag"))); -var eventInfo = binaryen.getEventInfo(event_); -console.log("getEventInfo=" + JSON.stringify(cleanInfo(eventInfo))); +var tagInfo = binaryen.getTagInfo(tag); +console.log("getTagInfo=" + JSON.stringify(cleanInfo(tagInfo))); -module.addEventExport("a-event", "a-event-exp"); -module.addEventImport("a-event-imp", "module", "base", 0, pairType, binaryen.none); +module.addTagExport("a-tag", "a-tag-exp"); +module.addTagImport("a-tag-imp", "module", "base", 0, pairType, binaryen.none); assert(module.validate()); console.log(module.emitText()); -module.removeExport("a-event-exp"); -module.removeEvent("a-event"); +module.removeExport("a-tag-exp"); +module.removeTag("a-tag"); assert(module.validate()); console.log(module.emitText()); diff --git a/test/binaryen.js/tag.js.txt b/test/binaryen.js/tag.js.txt new file mode 100644 index 000000000..51a0d33ee --- /dev/null +++ b/test/binaryen.js/tag.js.txt @@ -0,0 +1,15 @@ +GetTag is equal: true +getTagInfo={"name":"a-tag","module":"","base":"","attribute":0,"params":2,"results":0} +(module + (type $i32_=>_none (func (param i32))) + (type $i32_f32_=>_none (func (param i32 f32))) + (import "module" "base" (tag $a-tag-imp (attr 0) (param i32 f32))) + (tag $a-tag (attr 0) (param i32)) + (export "a-tag-exp" (tag $a-tag)) +) + +(module + (type $i32_f32_=>_none (func (param i32 f32))) + (import "module" "base" (tag $a-tag-imp (attr 0) (param i32 f32))) +) + diff --git a/test/br_to_try.wasm.fromBinary b/test/br_to_try.wasm.fromBinary index 1deebd37d..e52b8dcf8 100644 --- a/test/br_to_try.wasm.fromBinary +++ b/test/br_to_try.wasm.fromBinary @@ -1,7 +1,7 @@ (module (type $i32_=>_none (func (param i32))) (type $none_=>_none (func)) - (event $event$0 (attr 0) (param i32)) + (tag $tag$0 (attr 0) (param i32)) (func $0 (try $label$3 (do @@ -9,7 +9,7 @@ (br $label$1) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) diff --git a/test/break-within-catch.wasm.fromBinary b/test/break-within-catch.wasm.fromBinary index 74418c177..ecde70f3e 100644 --- a/test/break-within-catch.wasm.fromBinary +++ b/test/break-within-catch.wasm.fromBinary @@ -1,14 +1,14 @@ (module (type $i32_=>_none (func (param i32))) (type $none_=>_none (func)) - (event $event$0 (attr 0) (param i32)) + (tag $tag$0 (attr 0) (param i32)) (func $0 (block $label$2 (try $label$3 (do (nop) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) diff --git a/test/events.wast b/test/events.wast deleted file mode 100644 index f96cf6c95..000000000 --- a/test/events.wast +++ /dev/null @@ -1,16 +0,0 @@ -;; Test events - -(module - (event (attr 0) (param i32)) - (event $e (attr 0) (param i32 f32)) - (event $empty (attr 0)) - - (event $e-params0 (attr 0) (param i32 f32)) - (event $e-params1 (attr 0) (param i32) (param f32)) - - (event $e-export (export "ex0") (attr 0) (param i32)) - (event $e-import (import "env" "im0") (attr 0) (param i32)) - - (import "env" "im1" (event (attr 0) (param i32 f32))) - (export "ex1" (event $e)) -) diff --git a/test/events.wast.from-wast b/test/events.wast.from-wast deleted file mode 100644 index fca3041ab..000000000 --- a/test/events.wast.from-wast +++ /dev/null @@ -1,14 +0,0 @@ -(module - (type $i32_f32_=>_none (func (param i32 f32))) - (type $i32_=>_none (func (param i32))) - (type $none_=>_none (func)) - (import "env" "im0" (event $e-import (attr 0) (param i32))) - (import "env" "im1" (event $eimport$1 (attr 0) (param i32 f32))) - (event $2 (attr 0) (param i32)) - (event $e (attr 0) (param i32 f32)) - (event $empty (attr 0) (param)) - (event $e-params0 (attr 0) (param i32 f32)) - (event $e-params1 (attr 0) (param i32 f32)) - (event $e-export (attr 0) (param i32)) - (export "ex1" (event $e)) -) diff --git a/test/events.wast.fromBinary b/test/events.wast.fromBinary deleted file mode 100644 index 2576ff887..000000000 --- a/test/events.wast.fromBinary +++ /dev/null @@ -1,15 +0,0 @@ -(module - (type $i32_f32_=>_none (func (param i32 f32))) - (type $i32_=>_none (func (param i32))) - (type $none_=>_none (func)) - (import "env" "im0" (event $eimport$0 (attr 0) (param i32))) - (import "env" "im1" (event $eimport$1 (attr 0) (param i32 f32))) - (event $event$0 (attr 0) (param i32)) - (event $event$1 (attr 0) (param i32 f32)) - (event $event$2 (attr 0) (param)) - (event $event$3 (attr 0) (param i32 f32)) - (event $event$4 (attr 0) (param i32 f32)) - (event $event$5 (attr 0) (param i32)) - (export "ex1" (event $event$1)) -) - diff --git a/test/events.wast.fromBinary.noDebugInfo b/test/events.wast.fromBinary.noDebugInfo deleted file mode 100644 index 2576ff887..000000000 --- a/test/events.wast.fromBinary.noDebugInfo +++ /dev/null @@ -1,15 +0,0 @@ -(module - (type $i32_f32_=>_none (func (param i32 f32))) - (type $i32_=>_none (func (param i32))) - (type $none_=>_none (func)) - (import "env" "im0" (event $eimport$0 (attr 0) (param i32))) - (import "env" "im1" (event $eimport$1 (attr 0) (param i32 f32))) - (event $event$0 (attr 0) (param i32)) - (event $event$1 (attr 0) (param i32 f32)) - (event $event$2 (attr 0) (param)) - (event $event$3 (attr 0) (param i32 f32)) - (event $event$4 (attr 0) (param i32 f32)) - (event $event$5 (attr 0) (param i32)) - (export "ex1" (event $event$1)) -) - diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 9b9c7aa6e..cb2f29c77 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -316,9 +316,8 @@ void test_core() { BinaryenRefFunc(module, "kitchen()sinker", BinaryenTypeFuncref()); BinaryenExpressionRef i31refExpr = BinaryenI31New(module, makeInt32(module, 1)); - // Events - BinaryenAddEvent( - module, "a-event", 0, BinaryenTypeInt32(), BinaryenTypeNone()); + // Tags + BinaryenAddTag(module, "a-tag", 0, BinaryenTypeInt32(), BinaryenTypeNone()); BinaryenAddTable(module, "tab", 0, 100); @@ -326,21 +325,21 @@ void test_core() { // (try // (do - // (throw $a-event (i32.const 0)) + // (throw $a-tag (i32.const 0)) // ) - // (catch $a-event + // (catch $a-tag // (drop (i32 pop)) // ) // (catch_all) // ) BinaryenExpressionRef tryBody = BinaryenThrow( - module, "a-event", (BinaryenExpressionRef[]){makeInt32(module, 0)}, 1); + module, "a-tag", (BinaryenExpressionRef[]){makeInt32(module, 0)}, 1); BinaryenExpressionRef catchBody = BinaryenDrop(module, BinaryenPop(module, BinaryenTypeInt32())); BinaryenExpressionRef catchAllBody = BinaryenNop(module); - const char* catchEvents[] = {"a-event"}; + const char* catchTags[] = {"a-tag"}; BinaryenExpressionRef catchBodies[] = {catchBody, catchAllBody}; - const char* emptyCatchEvents[] = {}; + const char* emptyCatchTags[] = {}; BinaryenExpressionRef emptyCatchBodies[] = {}; BinaryenExpressionRef nopCatchBody[] = {BinaryenNop(module)}; @@ -829,12 +828,12 @@ void test_core() { BinaryenRefAsI31(), BinaryenRefNull(module, BinaryenTypeAnyref())), // Exception handling - BinaryenTry(module, NULL, tryBody, catchEvents, 1, catchBodies, 2, NULL), + BinaryenTry(module, NULL, tryBody, catchTags, 1, catchBodies, 2, NULL), // (try $try_outer // (do // (try // (do - // (throw $a-event (i32.const 0)) + // (throw $a-tag (i32.const 0)) // ) // (delegate $try_outer) // ) @@ -846,12 +845,12 @@ void test_core() { BinaryenTry(module, NULL, tryBody, - emptyCatchEvents, + emptyCatchTags, 0, emptyCatchBodies, 0, "try_outer"), - emptyCatchEvents, + emptyCatchTags, 0, nopCatchBody, 1, diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index eb83ffb33..77c433472 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -45,7 +45,7 @@ BinaryenFeatureAll: 16383 (table $0 1 1 funcref) (elem $0 (table $0) (i32.const 0) func "$kitchen()sinker") (elem $passive func "$kitchen()sinker") - (event $a-event (attr 0) (param i32)) + (tag $a-tag (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "mem" (memory $0)) (start $starter) @@ -1990,11 +1990,11 @@ BinaryenFeatureAll: 16383 ) (try (do - (throw $a-event + (throw $a-tag (i32.const 0) ) ) - (catch $a-event + (catch $a-tag (drop (pop i32) ) @@ -2007,7 +2007,7 @@ BinaryenFeatureAll: 16383 (do (try (do - (throw $a-event + (throw $a-tag (i32.const 0) ) ) diff --git a/test/example/module-splitting.cpp b/test/example/module-splitting.cpp index 9ff2818be..a379717f1 100644 --- a/test/example/module-splitting.cpp +++ b/test/example/module-splitting.cpp @@ -76,7 +76,7 @@ int main() { (memory $mem (shared 3 42)) (table $tab 3 42 funcref) (global $glob (mut i32) (i32.const 7)) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) ))"); // Imported global stuff @@ -85,7 +85,7 @@ int main() { (import "env" "mem" (memory $mem (shared 3 42))) (import "env" "tab" (table $tab 3 42 funcref)) (import "env" "glob" (global $glob (mut i32))) - (import "env" "e" (event $e (attr 0) (param i32))) + (import "env" "e" (tag $e (attr 0) (param i32))) ))"); // Exported global stuff @@ -94,11 +94,11 @@ int main() { (memory $mem (shared 3 42)) (table $tab 3 42 funcref) (global $glob (mut i32) (i32.const 7)) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) (export "mem" (memory $mem)) (export "tab" (table $tab)) (export "glob" (global $glob)) - (export "e" (event $e)) + (export "e" (tag $e)) ))"); // Non-deferred function diff --git a/test/example/module-splitting.txt b/test/example/module-splitting.txt index 2b92e9dd6..61529e9ad 100644 --- a/test/example/module-splitting.txt +++ b/test/example/module-splitting.txt @@ -16,7 +16,7 @@ Before: (global $glob (mut i32) (i32.const 7)) (memory $mem (shared 3 42)) (table $tab 3 42 funcref) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) ) Keeping: <none> After: @@ -25,11 +25,11 @@ After: (global $glob (mut i32) (i32.const 7)) (memory $mem (shared 3 42)) (table $tab 3 42 funcref) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) (export "%memory" (memory $mem)) (export "%table" (table $tab)) (export "%global" (global $glob)) - (export "%event" (event $e)) + (export "%tag" (tag $e)) ) Secondary: (module @@ -37,7 +37,7 @@ Secondary: (import "primary" "%memory" (memory $mem (shared 3 42))) (import "primary" "%table" (table $tab 3 42 funcref)) (import "primary" "%global" (global $glob (mut i32))) - (import "primary" "%event" (event $e (attr 0) (param i32))) + (import "primary" "%tag" (tag $e (attr 0) (param i32))) ) @@ -47,7 +47,7 @@ Before: (import "env" "mem" (memory $mem (shared 3 42))) (import "env" "tab" (table $tab 3 42 funcref)) (import "env" "glob" (global $glob (mut i32))) - (import "env" "e" (event $e (attr 0) (param i32))) + (import "env" "e" (tag $e (attr 0) (param i32))) ) Keeping: <none> After: @@ -56,11 +56,11 @@ After: (import "env" "mem" (memory $mem (shared 3 42))) (import "env" "tab" (table $tab 3 42 funcref)) (import "env" "glob" (global $glob (mut i32))) - (import "env" "e" (event $e (attr 0) (param i32))) + (import "env" "e" (tag $e (attr 0) (param i32))) (export "%memory" (memory $mem)) (export "%table" (table $tab)) (export "%global" (global $glob)) - (export "%event" (event $e)) + (export "%tag" (tag $e)) ) Secondary: (module @@ -68,7 +68,7 @@ Secondary: (import "primary" "%memory" (memory $mem (shared 3 42))) (import "primary" "%table" (table $tab 3 42 funcref)) (import "primary" "%global" (global $glob (mut i32))) - (import "primary" "%event" (event $e (attr 0) (param i32))) + (import "primary" "%tag" (tag $e (attr 0) (param i32))) ) @@ -78,11 +78,11 @@ Before: (global $glob (mut i32) (i32.const 7)) (memory $mem (shared 3 42)) (table $tab 3 42 funcref) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) (export "mem" (memory $mem)) (export "tab" (table $tab)) (export "glob" (global $glob)) - (export "e" (event $e)) + (export "e" (tag $e)) ) Keeping: <none> After: @@ -91,11 +91,11 @@ After: (global $glob (mut i32) (i32.const 7)) (memory $mem (shared 3 42)) (table $tab 3 42 funcref) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) (export "mem" (memory $mem)) (export "tab" (table $tab)) (export "glob" (global $glob)) - (export "e" (event $e)) + (export "e" (tag $e)) ) Secondary: (module @@ -103,7 +103,7 @@ Secondary: (import "primary" "mem" (memory $mem (shared 3 42))) (import "primary" "tab" (table $tab 3 42 funcref)) (import "primary" "glob" (global $glob (mut i32))) - (import "primary" "e" (event $e (attr 0) (param i32))) + (import "primary" "e" (tag $e (attr 0) (param i32))) ) diff --git a/test/exception-handling.wast b/test/exception-handling.wast index ee5ffbf54..95f177b2d 100644 --- a/test/exception-handling.wast +++ b/test/exception-handling.wast @@ -1,8 +1,8 @@ (module - (event $e-i32 (attr 0) (param i32)) - (event $e-i64 (attr 0) (param i64)) - (event $e-i32-i64 (attr 0) (param i32 i64)) - (event $e-empty (attr 0)) + (tag $e-i32 (attr 0) (param i32)) + (tag $e-i64 (attr 0) (param i64)) + (tag $e-i32-i64 (attr 0) (param i32 i64)) + (tag $e-empty (attr 0)) (func $foo) (func $bar) @@ -18,7 +18,7 @@ ) ) - ;; try-catch with multivalue event + ;; try-catch with multivalue tag (try (do (throw $e-i32-i64 (i32.const 0) (i64.const 0)) @@ -197,7 +197,7 @@ (delegate 0) ) - ;; 'catch' body can be empty when the event's type is none. + ;; 'catch' body can be empty when the tag's type is none. (try (do) (catch $e-empty) diff --git a/test/exception-handling.wast.from-wast b/test/exception-handling.wast.from-wast index 68034653f..429127a6a 100644 --- a/test/exception-handling.wast.from-wast +++ b/test/exception-handling.wast.from-wast @@ -3,10 +3,10 @@ (type $i32_=>_none (func (param i32))) (type $i64_=>_none (func (param i64))) (type $i32_i64_=>_none (func (param i32 i64))) - (event $e-i32 (attr 0) (param i32)) - (event $e-i64 (attr 0) (param i64)) - (event $e-i32-i64 (attr 0) (param i32 i64)) - (event $e-empty (attr 0) (param)) + (tag $e-i32 (attr 0) (param i32)) + (tag $e-i64 (attr 0) (param i64)) + (tag $e-i32-i64 (attr 0) (param i32 i64)) + (tag $e-empty (attr 0) (param)) (func $foo (nop) ) diff --git a/test/exception-handling.wast.fromBinary b/test/exception-handling.wast.fromBinary index ff9a71f28..e50d18f3a 100644 --- a/test/exception-handling.wast.fromBinary +++ b/test/exception-handling.wast.fromBinary @@ -3,10 +3,10 @@ (type $i32_=>_none (func (param i32))) (type $i64_=>_none (func (param i64))) (type $i32_i64_=>_none (func (param i32 i64))) - (event $event$0 (attr 0) (param i32)) - (event $event$1 (attr 0) (param i64)) - (event $event$2 (attr 0) (param i32 i64)) - (event $event$3 (attr 0) (param)) + (tag $tag$0 (attr 0) (param i32)) + (tag $tag$1 (attr 0) (param i64)) + (tag $tag$2 (attr 0) (param i32 i64)) + (tag $tag$3 (attr 0) (param)) (func $foo (nop) ) @@ -21,11 +21,11 @@ (local $4 i32) (try $label$3 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -33,12 +33,12 @@ ) (try $label$6 (do - (throw $event$2 + (throw $tag$2 (i32.const 0) (i64.const 0) ) ) - (catch $event$2 + (catch $tag$2 (local.set $2 (pop i32 i64) ) @@ -75,7 +75,7 @@ (do (br $label$7) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -87,7 +87,7 @@ (do (nop) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -98,7 +98,7 @@ (call $foo) (call $bar) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -108,16 +108,16 @@ ) (try $label$19 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) ) - (catch $event$1 + (catch $tag$1 (drop (pop i64) ) @@ -125,7 +125,7 @@ ) (try $label$22 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) @@ -135,16 +135,16 @@ ) (try $label$25 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) ) - (catch $event$1 + (catch $tag$1 (drop (pop i64) ) @@ -158,11 +158,11 @@ (do (try $label$29 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -172,7 +172,7 @@ ) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -180,11 +180,11 @@ (catch_all (try $label$33 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -197,7 +197,7 @@ ) (try (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) @@ -269,7 +269,7 @@ (do (nop) ) - (catch $event$3 + (catch $tag$3 (nop) ) ) @@ -279,7 +279,7 @@ (do (call $foo) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -294,7 +294,7 @@ (do (call $foo) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -314,7 +314,7 @@ (do (call $foo) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -335,7 +335,7 @@ (do (call $foo) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) diff --git a/test/exception-handling.wast.fromBinary.noDebugInfo b/test/exception-handling.wast.fromBinary.noDebugInfo index 5a0e3331b..c748ca024 100644 --- a/test/exception-handling.wast.fromBinary.noDebugInfo +++ b/test/exception-handling.wast.fromBinary.noDebugInfo @@ -3,10 +3,10 @@ (type $i32_=>_none (func (param i32))) (type $i64_=>_none (func (param i64))) (type $i32_i64_=>_none (func (param i32 i64))) - (event $event$0 (attr 0) (param i32)) - (event $event$1 (attr 0) (param i64)) - (event $event$2 (attr 0) (param i32 i64)) - (event $event$3 (attr 0) (param)) + (tag $tag$0 (attr 0) (param i32)) + (tag $tag$1 (attr 0) (param i64)) + (tag $tag$2 (attr 0) (param i32 i64)) + (tag $tag$3 (attr 0) (param)) (func $0 (nop) ) @@ -21,11 +21,11 @@ (local $4 i32) (try $label$3 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -33,12 +33,12 @@ ) (try $label$6 (do - (throw $event$2 + (throw $tag$2 (i32.const 0) (i64.const 0) ) ) - (catch $event$2 + (catch $tag$2 (local.set $2 (pop i32 i64) ) @@ -75,7 +75,7 @@ (do (br $label$7) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -87,7 +87,7 @@ (do (nop) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -98,7 +98,7 @@ (call $0) (call $1) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -108,16 +108,16 @@ ) (try $label$19 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) ) - (catch $event$1 + (catch $tag$1 (drop (pop i64) ) @@ -125,7 +125,7 @@ ) (try $label$22 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) @@ -135,16 +135,16 @@ ) (try $label$25 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) ) - (catch $event$1 + (catch $tag$1 (drop (pop i64) ) @@ -158,11 +158,11 @@ (do (try $label$29 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -172,7 +172,7 @@ ) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -180,11 +180,11 @@ (catch_all (try $label$33 (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -197,7 +197,7 @@ ) (try (do - (throw $event$0 + (throw $tag$0 (i32.const 0) ) ) @@ -269,7 +269,7 @@ (do (nop) ) - (catch $event$3 + (catch $tag$3 (nop) ) ) @@ -279,7 +279,7 @@ (do (call $0) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -294,7 +294,7 @@ (do (call $0) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -314,7 +314,7 @@ (do (call $0) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -335,7 +335,7 @@ (do (call $0) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) diff --git a/test/lit/passes/coalesce-locals-eh.wast b/test/lit/passes/coalesce-locals-eh.wast index f564c2991..f13ba5550 100644 --- a/test/lit/passes/coalesce-locals-eh.wast +++ b/test/lit/passes/coalesce-locals-eh.wast @@ -9,7 +9,7 @@ (i32.const 1984) ) - (event $e (attr 0)) + (tag $e (attr 0)) ;; CHECK: (func $bug-cfg-traversal (param $0 i32) (result i32) ;; CHECK-NEXT: (try $try ;; CHECK-NEXT: (do diff --git a/test/lit/passes/code-folding-eh.wast b/test/lit/passes/code-folding-eh.wast index 6a1a1eb36..e810e5c01 100644 --- a/test/lit/passes/code-folding-eh.wast +++ b/test/lit/passes/code-folding-eh.wast @@ -3,7 +3,7 @@ ;; RUN: | filecheck %s (module - (event $e-i32 (attr 0) (param i32)) + (tag $e-i32 (attr 0) (param i32)) ;; CHECK: (func $pop-test ;; CHECK-NEXT: (block $folding-inner0 diff --git a/test/lit/passes/code-pushing-eh.wast b/test/lit/passes/code-pushing-eh.wast index fe406ec2b..37ca0cc5a 100644 --- a/test/lit/passes/code-pushing-eh.wast +++ b/test/lit/passes/code-pushing-eh.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --code-pushing -all -S -o - | filecheck %s (module - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) ;; CHECK: (func $cant-push-past-call ;; CHECK-NEXT: (local $x i32) diff --git a/test/lit/passes/dce-eh.wast b/test/lit/passes/dce-eh.wast index 1bb6358dd..d29056c41 100644 --- a/test/lit/passes/dce-eh.wast +++ b/test/lit/passes/dce-eh.wast @@ -5,7 +5,7 @@ ;; reachable (module (func $foo) - (event $e (attr 0)) + (tag $e (attr 0)) ;; CHECK: (func $try_unreachable ;; CHECK-NEXT: (try $try diff --git a/test/lit/passes/inlining-eh.wast b/test/lit/passes/inlining-eh.wast index 9879978e1..6b648d380 100644 --- a/test/lit/passes/inlining-eh.wast +++ b/test/lit/passes/inlining-eh.wast @@ -4,11 +4,11 @@ (module ;; --------------------------------------------------------------------------- (import "a" "b" (func $foo (result i32))) - (event $event$0 (attr 0) (param i32)) + (tag $tag$0 (attr 0) (param i32)) (func $callee-with-label (try $label (do) - (catch $event$0 + (catch $tag$0 (nop) ) ) @@ -24,7 +24,7 @@ ;; CHECK-NEXT: (do ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (catch $event$0 + ;; CHECK-NEXT: (catch $tag$0 ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/instrument-locals-eh.wast b/test/lit/passes/instrument-locals-eh.wast index 99ba94583..88b4d5526 100644 --- a/test/lit/passes/instrument-locals-eh.wast +++ b/test/lit/passes/instrument-locals-eh.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --instrument-locals -all -S -o - | filecheck %s (module - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) ;; CHECK: (func $test ;; CHECK-NEXT: (local $x i32) diff --git a/test/lit/passes/optimize-instructions-eh.wast b/test/lit/passes/optimize-instructions-eh.wast index 50ae665e2..23c8f9fa5 100644 --- a/test/lit/passes/optimize-instructions-eh.wast +++ b/test/lit/passes/optimize-instructions-eh.wast @@ -4,7 +4,7 @@ (module (func $dummy) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) ;; The following are the unit tests for Properties::getFallthrough for EH ;; instructions, which are used in one of binary optimizations in diff --git a/test/lit/passes/poppify.wast b/test/lit/passes/poppify.wast index bc88dd878..69e6fc17e 100644 --- a/test/lit/passes/poppify.wast +++ b/test/lit/passes/poppify.wast @@ -3,7 +3,7 @@ ;; RUN: wasm-opt %s --poppify --no-validation -all -S -o - | filecheck %s (module - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) ;; CHECK: (func $id (param $x i32) (result i32) ;; CHECK-NEXT: (local.get $x) diff --git a/test/lit/passes/remove-unused-module-elements-eh.wast b/test/lit/passes/remove-unused-module-elements-eh.wast index 7e0c66af4..2a6a3b6b9 100644 --- a/test/lit/passes/remove-unused-module-elements-eh.wast +++ b/test/lit/passes/remove-unused-module-elements-eh.wast @@ -1,20 +1,20 @@ ;; RUN: wasm-opt %s --remove-unused-module-elements -all -S -o - | filecheck %s -;; Non-exported and unused events can be removed +;; Non-exported and unused tags can be removed (module (type $0 (func (param i32))) - ;; CHECK-NOT: (event $e-remove - ;; CHECK: (event $e-export - ;; CHECK: (event $e-throw - ;; CHECK: (event $e-catch - (event $e-remove (attr 0) (type $0)) ;; can be removed - (event $e-export (attr 0) (param i64)) ;; cannot be removed (exported) - (event $e-throw (attr 0) (type $0)) ;; cannot be removed (used in throw) - (event $e-catch (attr 0) (type $0)) ;; cannot be removed (used in catch) + ;; CHECK-NOT: (tag $e-remove + ;; CHECK: (tag $e-export + ;; CHECK: (tag $e-throw + ;; CHECK: (tag $e-catch + (tag $e-remove (attr 0) (type $0)) ;; can be removed + (tag $e-export (attr 0) (param i64)) ;; cannot be removed (exported) + (tag $e-throw (attr 0) (type $0)) ;; cannot be removed (used in throw) + (tag $e-catch (attr 0) (type $0)) ;; cannot be removed (used in catch) - (export "e-export" (event $e-export)) - (import "env" "e" (event $e-import (attr 0) (param i32))) + (export "e-export" (tag $e-export)) + (import "env" "e" (tag $e-import (attr 0) (param i32))) (start $start) (func $start diff --git a/test/lit/passes/remove-unused-names-eh.wast b/test/lit/passes/remove-unused-names-eh.wast index fd20c07e4..3244bd375 100644 --- a/test/lit/passes/remove-unused-names-eh.wast +++ b/test/lit/passes/remove-unused-names-eh.wast @@ -2,14 +2,14 @@ ;; RUN: wasm-opt %s --remove-unused-names -all -S -o - | filecheck %s (module - (event $event$0 (attr 0) (param i32)) + (tag $tag$0 (attr 0) (param i32)) ;; CHECK: (func $func0 ;; CHECK-NEXT: (try $label$9 ;; CHECK-NEXT: (do ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (catch $event$0 + ;; CHECK-NEXT: (catch $tag$0 ;; CHECK-NEXT: (try $label$8 ;; CHECK-NEXT: (do ;; CHECK-NEXT: (try @@ -19,7 +19,7 @@ ;; CHECK-NEXT: (delegate $label$8) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (catch $event$0 + ;; CHECK-NEXT: (catch $tag$0 ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (pop i32) ;; CHECK-NEXT: ) @@ -31,7 +31,7 @@ (func $func0 (try $label$9 ;; needed due to a rethrow (do) - (catch $event$0 + (catch $tag$0 (try $label$8 ;; needed due to a delegate (do (try $label$6 ;; this one is not needed @@ -41,7 +41,7 @@ (delegate $label$8) ) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) diff --git a/test/lit/passes/rse-eh.wast b/test/lit/passes/rse-eh.wast index d6f7074e7..f71c4886d 100644 --- a/test/lit/passes/rse-eh.wast +++ b/test/lit/passes/rse-eh.wast @@ -2,8 +2,8 @@ ;; RUN: wasm-opt %s --rse -all -S -o - | filecheck %s (module - (event $e (attr 0) (param i32)) - (event $e2 (attr 0)) + (tag $e (attr 0) (param i32)) + (tag $e2 (attr 0)) ;; CHECK: (func $try1 ;; CHECK-NEXT: (local $x i32) diff --git a/test/lit/passes/simplify-locals-eh.wast b/test/lit/passes/simplify-locals-eh.wast index fb5f671f3..9a7a94cf7 100644 --- a/test/lit/passes/simplify-locals-eh.wast +++ b/test/lit/passes/simplify-locals-eh.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --simplify-locals -all -S -o - | filecheck %s (module - (event $e-i32 (attr 0) (param i32)) + (tag $e-i32 (attr 0) (param i32)) ;; CHECK: (func $foo (param $0 i32) (param $1 i32) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/stack-ir-eh.wast b/test/lit/passes/stack-ir-eh.wast index a398be325..86ada5059 100644 --- a/test/lit/passes/stack-ir-eh.wast +++ b/test/lit/passes/stack-ir-eh.wast @@ -2,7 +2,7 @@ ;; RUN: -all -S -o - | filecheck %s (module - (event $e0 (attr 0) (param i32)) + (tag $e0 (attr 0) (param i32)) ;; CHECK: (func $eh ;; CHECK-NEXT: try $l0 diff --git a/test/lit/passes/stack-ir-roundtrip-eh.wast b/test/lit/passes/stack-ir-roundtrip-eh.wast index b9bb22d3e..cbc81f294 100644 --- a/test/lit/passes/stack-ir-roundtrip-eh.wast +++ b/test/lit/passes/stack-ir-roundtrip-eh.wast @@ -2,7 +2,7 @@ ;; RUN: wasm-opt %s --generate-stack-ir --roundtrip -all -S -o - | filecheck %s (module - (event $event (attr 0) (param i32)) + (tag $tag (attr 0) (param i32)) ;; CHECK: (func $delegate-child ;; CHECK-NEXT: (try $label$9 ;; CHECK-NEXT: (do @@ -10,7 +10,7 @@ ;; CHECK-NEXT: (do ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (catch $event$0 + ;; CHECK-NEXT: (catch $tag$0 ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (pop i32) ;; CHECK-NEXT: ) @@ -23,7 +23,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (catch $event$0 + ;; CHECK-NEXT: (catch $tag$0 ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (pop i32) ;; CHECK-NEXT: ) @@ -35,7 +35,7 @@ (do (try (do) - (catch $event + (catch $tag (drop (pop i32) ) @@ -51,7 +51,7 @@ ) ) ) - (catch $event + (catch $tag (drop (pop i32) ) diff --git a/test/lit/passes/vacuum-eh.wast b/test/lit/passes/vacuum-eh.wast index d69278319..705f423f0 100644 --- a/test/lit/passes/vacuum-eh.wast +++ b/test/lit/passes/vacuum-eh.wast @@ -2,8 +2,8 @@ ;; RUN: wasm-opt %s --vacuum -all -S -o - | filecheck %s (module - (event $e (attr 0) (param i32)) - (event $e2 (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) + (tag $e2 (attr 0) (param i32)) ;; CHECK: (func $try-test ;; CHECK-NEXT: (nop) diff --git a/test/metadce/rooted-export.wast b/test/metadce/rooted-export.wast index 4b93969b4..790ce802f 100644 --- a/test/metadce/rooted-export.wast +++ b/test/metadce/rooted-export.wast @@ -9,10 +9,10 @@ (unreachable) ) - (export "wasm_event_a" (event $a_wasm_event)) - (export "wasm_event_b" (event $b_wasm_event)) + (export "wasm_tag_a" (tag $a_wasm_tag)) + (export "wasm_tag_b" (tag $b_wasm_tag)) - (event $a_wasm_event (attr 0) (param i32)) - (event $b_wasm_event (attr 0) (param i32)) + (tag $a_wasm_tag (attr 0) (param i32)) + (tag $b_wasm_tag (attr 0) (param i32)) ) diff --git a/test/metadce/rooted-export.wast.dced b/test/metadce/rooted-export.wast.dced index ba0390928..dd9913ab2 100644 --- a/test/metadce/rooted-export.wast.dced +++ b/test/metadce/rooted-export.wast.dced @@ -1,9 +1,9 @@ (module (type $i32_=>_none (func (param i32))) (type $none_=>_none (func)) - (event $b_wasm_event (attr 0) (param i32)) + (tag $b_wasm_tag (attr 0) (param i32)) (export "wasm_func_b" (func $b_wasm_func)) - (export "wasm_event_b" (event $b_wasm_event)) + (export "wasm_tag_b" (tag $b_wasm_tag)) (func $b_wasm_func (unreachable) ) diff --git a/test/metadce/rooted-export.wast.dced.stdout b/test/metadce/rooted-export.wast.dced.stdout index 5b6a25c02..583f248d6 100644 --- a/test/metadce/rooted-export.wast.dced.stdout +++ b/test/metadce/rooted-export.wast.dced.stdout @@ -1,4 +1,4 @@ -unused: event$a_wasm_event$2 -unused: export$wasm_event_a$5 unused: export$wasm_func_a$4 +unused: export$wasm_tag_a$5 unused: func$a_wasm_func$0 +unused: tag$a_wasm_tag$2 diff --git a/test/metadce/rooted-export.wast.graph.txt b/test/metadce/rooted-export.wast.graph.txt index 8ecd66dc0..0137d34f1 100644 --- a/test/metadce/rooted-export.wast.graph.txt +++ b/test/metadce/rooted-export.wast.graph.txt @@ -5,9 +5,9 @@ "export": "wasm_func_b" }, { - "name": "rooted-export-event", + "name": "rooted-export-tag", "root": true, - "export": "wasm_event_b" + "export": "wasm_tag_b" } ] diff --git a/test/passes/O3_low-memory-unused_metrics.txt b/test/passes/O3_low-memory-unused_metrics.txt index 6e937ea11..3de2d66fe 100644 --- a/test/passes/O3_low-memory-unused_metrics.txt +++ b/test/passes/O3_low-memory-unused_metrics.txt @@ -1,5 +1,4 @@ total - [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 @@ -7,6 +6,7 @@ total [memory-data] : 0 [table-data] : 0 [tables] : 0 + [tags] : 0 [total] : 1964 [vars] : 9 Binary : 240 diff --git a/test/passes/converge_O3_metrics.bin.txt b/test/passes/converge_O3_metrics.bin.txt index 1441d577a..5c41b3146 100644 --- a/test/passes/converge_O3_metrics.bin.txt +++ b/test/passes/converge_O3_metrics.bin.txt @@ -1,5 +1,4 @@ total - [events] : 0 [exports] : 2 [funcs] : 6 [globals] : 1 @@ -7,6 +6,7 @@ total [memory-data] : 28 [table-data] : 429 [tables] : 0 + [tags] : 0 [total] : 553 [vars] : 2 Binary : 12 @@ -229,7 +229,6 @@ total ) ) total - [events] : 0 [exports] : 2 [funcs] : 6 [globals] : 0 -1 @@ -237,6 +236,7 @@ total [memory-data] : 28 [table-data] : 429 [tables] : 0 + [tags] : 0 [total] : 549 -4 [vars] : 2 Binary : 12 @@ -452,7 +452,6 @@ total ) ) total - [events] : 0 [exports] : 2 [funcs] : 6 [globals] : 0 @@ -460,6 +459,7 @@ total [memory-data] : 28 [table-data] : 429 [tables] : 0 + [tags] : 0 [total] : 549 [vars] : 2 Binary : 12 diff --git a/test/passes/dwarf_with_exceptions.bin.txt b/test/passes/dwarf_with_exceptions.bin.txt index a08ecf9e5..ebd6be03d 100644 --- a/test/passes/dwarf_with_exceptions.bin.txt +++ b/test/passes/dwarf_with_exceptions.bin.txt @@ -8,7 +8,7 @@ (import "env" "_ZSt9terminatev" (func $std::terminate\28\29)) (global $__stack_pointer (mut i32) (i32.const 66560)) (memory $0 2) - (event $event$0 (attr 0) (param i32)) + (tag $tag$0 (attr 0) (param i32)) (export "memory" (memory $0)) (func $__wasm_call_ctors ) @@ -27,7 +27,7 @@ (call $foo\28\29) ) ;; code offset: 0x18 - (catch $event$0 + (catch $tag$0 ;; code offset: 0x1e (local.set $1 (pop i32) @@ -65,7 +65,7 @@ (call $__cxa_end_catch) ) ;; code offset: 0x4a - (catch $event$0 + (catch $tag$0 ;; code offset: 0x50 (local.set $1 (pop i32) @@ -429,7 +429,7 @@ file_names[ 1]: (import "env" "_ZSt9terminatev" (func $std::terminate\28\29)) (global $__stack_pointer (mut i32) (i32.const 66560)) (memory $0 2) - (event $event$0 (attr 0) (param i32)) + (tag $tag$0 (attr 0) (param i32)) (export "memory" (memory $0)) (func $__wasm_call_ctors ) @@ -448,7 +448,7 @@ file_names[ 1]: (call $foo\28\29) ) ;; code offset: 0x12 - (catch $event$0 + (catch $tag$0 ;; code offset: 0x14 (local.set $1 (pop i32) @@ -486,7 +486,7 @@ file_names[ 1]: (call $__cxa_end_catch) ) ;; code offset: 0x2c - (catch $event$0 + (catch $tag$0 ;; code offset: 0x2e (local.set $1 (pop i32) diff --git a/test/passes/func-metrics.txt b/test/passes/func-metrics.txt index 7782599e7..a8b6885c4 100644 --- a/test/passes/func-metrics.txt +++ b/test/passes/func-metrics.txt @@ -1,5 +1,4 @@ global - [events] : 0 [exports] : 0 [funcs] : 3 [globals] : 1 @@ -7,6 +6,7 @@ global [memory-data] : 9 [table-data] : 3 [tables] : 1 + [tags] : 0 [total] : 6 Const : 3 RefFunc : 3 @@ -92,22 +92,22 @@ func: ifs ) ) global - [events] : 0 [exports] : 0 [funcs] : 0 [globals] : 0 [imports] : 0 [tables] : 0 + [tags] : 0 [total] : 0 (module ) global - [events] : 0 [exports] : 2 [funcs] : 3 [globals] : 0 [imports] : 1 [tables] : 0 + [tags] : 0 [total] : 0 func: func_a [binary-bytes] : 16 @@ -178,12 +178,12 @@ export: b (func_b) ) ) global - [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 [imports] : 1 [tables] : 0 + [tags] : 0 [total] : 0 func: func_a [binary-bytes] : 12 @@ -211,12 +211,12 @@ start: func_a ) ) global - [events] : 0 [exports] : 0 [funcs] : 1 [globals] : 0 [imports] : 1 [tables] : 0 + [tags] : 0 [total] : 0 func: func_a [binary-bytes] : 12 @@ -240,12 +240,12 @@ start: func_a ) ) global - [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 1 [imports] : 1 [tables] : 0 + [tags] : 0 [total] : 1 GlobalGet : 1 func: 0 diff --git a/test/passes/fuzz_metrics_noprint.bin.txt b/test/passes/fuzz_metrics_noprint.bin.txt index 5e0a25330..2b5dad46a 100644 --- a/test/passes/fuzz_metrics_noprint.bin.txt +++ b/test/passes/fuzz_metrics_noprint.bin.txt @@ -1,5 +1,4 @@ total - [events] : 0 [exports] : 57 [funcs] : 82 [globals] : 7 @@ -7,6 +6,7 @@ total [memory-data] : 4 [table-data] : 17 [tables] : 1 + [tags] : 0 [total] : 3244 [vars] : 178 Binary : 261 diff --git a/test/passes/metrics_all-features.txt b/test/passes/metrics_all-features.txt index 7462e768c..d58bd54f9 100644 --- a/test/passes/metrics_all-features.txt +++ b/test/passes/metrics_all-features.txt @@ -1,5 +1,4 @@ total - [events] : 2 [exports] : 0 [funcs] : 1 [globals] : 1 @@ -7,6 +6,7 @@ total [memory-data] : 9 [table-data] : 3 [tables] : 1 + [tags] : 2 [total] : 30 [vars] : 1 Binary : 1 @@ -23,8 +23,8 @@ total (data (i32.const 0) "\ff\ef\0f\1f 0@P\99") (table $0 256 256 funcref) (elem (i32.const 0) $ifs $ifs $ifs) - (event $e0 (attr 0) (param i32)) - (event $e1 (attr 0) (param i32 i32)) + (tag $e0 (attr 0) (param i32)) + (tag $e1 (attr 0) (param i32 i32)) (func $ifs (param $x i32) (local $y f32) (block $block0 @@ -66,12 +66,12 @@ total ) ) total - [events] : 0 [exports] : 0 [funcs] : 0 [globals] : 0 [imports] : 0 [tables] : 0 + [tags] : 0 [total] : 0 [vars] : 0 (module diff --git a/test/passes/metrics_all-features.wast b/test/passes/metrics_all-features.wast index 018262f22..c5894fd67 100644 --- a/test/passes/metrics_all-features.wast +++ b/test/passes/metrics_all-features.wast @@ -5,8 +5,8 @@ (data (i32.const 0) "\ff\ef\0f\1f\20\30\40\50\99") (type $0 (func (param i32))) (global $glob i32 (i32.const 1337)) - (event $e0 (attr 0) (param i32)) - (event $e1 (attr 0) (param i32 i32)) + (tag $e0 (attr 0) (param i32)) + (tag $e1 (attr 0) (param i32 i32)) (func $ifs (type $0) (param $x i32) (local $y f32) (block $block0 diff --git a/test/passes/metrics_strip-debug_metrics.bin.txt b/test/passes/metrics_strip-debug_metrics.bin.txt index 5df5c0772..9760353e0 100644 --- a/test/passes/metrics_strip-debug_metrics.bin.txt +++ b/test/passes/metrics_strip-debug_metrics.bin.txt @@ -1,20 +1,20 @@ total - [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 [imports] : 0 [tables] : 0 + [tags] : 0 [total] : 1 [vars] : 0 Nop : 1 total - [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 [imports] : 0 [tables] : 0 + [tags] : 0 [total] : 1 [vars] : 0 Nop : 1 diff --git a/test/passes/metrics_strip-producers_metrics.bin.txt b/test/passes/metrics_strip-producers_metrics.bin.txt index a7ae38f9a..072f7c827 100644 --- a/test/passes/metrics_strip-producers_metrics.bin.txt +++ b/test/passes/metrics_strip-producers_metrics.bin.txt @@ -1,20 +1,20 @@ total - [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 [imports] : 0 [tables] : 0 + [tags] : 0 [total] : 1 [vars] : 0 Nop : 1 total - [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 [imports] : 0 [tables] : 0 + [tags] : 0 [total] : 1 [vars] : 0 Nop : 1 diff --git a/test/passes/minify-imports-and-exports_all-features.txt b/test/passes/minify-imports-and-exports_all-features.txt index e5b99a84a..8336e47c6 100644 --- a/test/passes/minify-imports-and-exports_all-features.txt +++ b/test/passes/minify-imports-and-exports_all-features.txt @@ -1221,7 +1221,7 @@ longname3489 => M9 longname1491 => MA longname4947 => MAa longname1545 => MB -eventname1 => MBa +tagname1 => MBa longname1599 => MC longname1653 => MD longname1707 => ME @@ -1500,7 +1500,7 @@ longname3492 => P9 longname1494 => PA longname4950 => PAa longname1548 => PB -event1 => PBa +tag1 => PBa longname1602 => PC longname1656 => PD longname1710 => PE @@ -10014,11 +10014,11 @@ longname4880 => zza (import "other" "anything" (func $internalInfinity)) (import "wasi_unstable" "f" (func $internal3_wasi)) (import "wasi_unstable" "LBa" (func $internal3_wasi_only)) - (import "env" "MBa" (event $eventname1 (attr 0) (param i32))) - (event $event1 (attr 0) (param i32 i32)) + (import "env" "MBa" (tag $tagname1 (attr 0) (param i32))) + (tag $tag1 (attr 0) (param i32 i32)) (export "NBa" (func $foo1)) (export "OBa" (func $foo2)) - (export "PBa" (event $event1)) + (export "PBa" (tag $tag1)) (func $foo1 (nop) ) diff --git a/test/passes/minify-imports-and-exports_all-features.wast b/test/passes/minify-imports-and-exports_all-features.wast index 19fdc4d02..169bb881d 100644 --- a/test/passes/minify-imports-and-exports_all-features.wast +++ b/test/passes/minify-imports-and-exports_all-features.wast @@ -5002,13 +5002,13 @@ (import "env" "__memory_base" (global i32)) (import "env" "__table_base" (global i32)) (import "other" "anything" (func $internalInfinity)) - (import "env" "eventname1" (event $eventname1 (attr 0) (param i32))) + (import "env" "tagname1" (tag $tagname1 (attr 0) (param i32))) (import "wasi_unstable" "longname3" (func $internal3_wasi)) ;; overlapping base (import "wasi_unstable" "longname3-only" (func $internal3_wasi_only)) (export "exp1" (func $foo1)) (export "exp2" (func $foo2)) (func $foo1) (func $foo2) - (export "event1" (event $event1)) - (event $event1 (attr 0) (param i32 i32)) + (export "tag1" (tag $tag1)) + (tag $tag1 (attr 0) (param i32 i32)) ) diff --git a/test/passes/minify-imports_all-features.txt b/test/passes/minify-imports_all-features.txt index 1be765254..529fac5be 100644 --- a/test/passes/minify-imports_all-features.txt +++ b/test/passes/minify-imports_all-features.txt @@ -1128,7 +1128,7 @@ longname3488 => L9 longname1490 => LA longname4946 => LAa longname1544 => LB -eventname1 => LBa +tagname1 => LBa longname1598 => LC longname1652 => LD longname1706 => LE @@ -10008,11 +10008,11 @@ longname4880 => zza (import "env" "JBa" (func $internal4998)) (import "env" "KBa" (func $internal4999)) (import "other" "anything" (func $internalInfinity)) - (import "env" "LBa" (event $eventname1 (attr 0) (param i32))) - (event $event1 (attr 0) (param i32 i32)) + (import "env" "LBa" (tag $tagname1 (attr 0) (param i32))) + (tag $tag1 (attr 0) (param i32 i32)) (export "foo1" (func $foo1)) (export "foo2" (func $foo2)) - (export "event1" (event $event1)) + (export "tag1" (tag $tag1)) (func $foo1 (nop) ) diff --git a/test/passes/minify-imports_all-features.wast b/test/passes/minify-imports_all-features.wast index 26c8062ba..ba16241cf 100644 --- a/test/passes/minify-imports_all-features.wast +++ b/test/passes/minify-imports_all-features.wast @@ -5002,11 +5002,11 @@ (import "env" "__memory_base" (global i32)) (import "env" "__table_base" (global i32)) (import "other" "anything" (func $internalInfinity)) - (import "env" "eventname1" (event $eventname1 (attr 0) (param i32))) + (import "env" "tagname1" (tag $tagname1 (attr 0) (param i32))) (export "foo1" (func $foo1)) (export "foo2" (func $foo2)) - (export "event1" (event $event1)) + (export "tag1" (tag $tag1)) (func $foo1) (func $foo2) - (event $event1 (attr 0) (param i32 i32)) + (tag $tag1 (attr 0) (param i32 i32)) ) diff --git a/test/passes/print_g_metrics.bin.txt b/test/passes/print_g_metrics.bin.txt index 0d8cd8a16..ac035635d 100644 --- a/test/passes/print_g_metrics.bin.txt +++ b/test/passes/print_g_metrics.bin.txt @@ -65,12 +65,12 @@ ) ) total - [events] : 0 [exports] : 3 [funcs] : 3 [globals] : 1 [imports] : 0 [tables] : 0 + [tags] : 0 [total] : 37 [vars] : 0 Binary : 11 diff --git a/test/passes/remove-unused-names_merge-blocks_all-features.txt b/test/passes/remove-unused-names_merge-blocks_all-features.txt index 2c06634d2..206373db6 100644 --- a/test/passes/remove-unused-names_merge-blocks_all-features.txt +++ b/test/passes/remove-unused-names_merge-blocks_all-features.txt @@ -1700,7 +1700,7 @@ (module (type $none_=>_none (func)) (type $i32_=>_none (func (param i32))) - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) (func $foo (nop) ) diff --git a/test/passes/remove-unused-names_merge-blocks_all-features.wast b/test/passes/remove-unused-names_merge-blocks_all-features.wast index 8e0145900..2e9af253c 100644 --- a/test/passes/remove-unused-names_merge-blocks_all-features.wast +++ b/test/passes/remove-unused-names_merge-blocks_all-features.wast @@ -1558,7 +1558,7 @@ ) (module - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) (func $foo) ;; 'nop' within 'block' of `throw' can be hoisted diff --git a/test/passes/remove-unused-nonfunction-module-elements_all-features.txt b/test/passes/remove-unused-nonfunction-module-elements_all-features.txt index d70ce61ce..f124d5c04 100644 --- a/test/passes/remove-unused-nonfunction-module-elements_all-features.txt +++ b/test/passes/remove-unused-nonfunction-module-elements_all-features.txt @@ -332,8 +332,8 @@ (module (type $i64_=>_none (func (param i64))) (type $0 (func (param i32))) - (event $e1 (attr 0) (param i64)) - (export "e1" (event $e1)) + (tag $e1 (attr 0) (param i64)) + (export "e1" (tag $e1)) (func $f (param $0 i32) (nop) ) diff --git a/test/passes/remove-unused-nonfunction-module-elements_all-features.wast b/test/passes/remove-unused-nonfunction-module-elements_all-features.wast index c1003ebb0..346acf432 100644 --- a/test/passes/remove-unused-nonfunction-module-elements_all-features.wast +++ b/test/passes/remove-unused-nonfunction-module-elements_all-features.wast @@ -261,11 +261,11 @@ ) ) ) -(module ;; non-exported events can be removed +(module ;; non-exported tags can be removed (type $0 (func (param i32))) - (event $e0 (attr 0) (type $0)) - (event $e1 (attr 0) (param i64)) - (export "e1" (event $e1)) - (import "env" "e" (event $e2 (attr 0) (param i32))) + (tag $e0 (attr 0) (type $0)) + (tag $e1 (attr 0) (param i64)) + (export "e1" (tag $e1)) + (import "env" "e" (tag $e2 (attr 0) (param i32))) (func $f (; 0 ;) (type $0)) ) diff --git a/test/passes/too_much_for_liveness.bin.txt b/test/passes/too_much_for_liveness.bin.txt index 6a9afb9bd..793f9578c 100644 --- a/test/passes/too_much_for_liveness.bin.txt +++ b/test/passes/too_much_for_liveness.bin.txt @@ -1,10 +1,10 @@ total - [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 [imports] : 0 [tables] : 0 + [tags] : 0 [total] : 4 [vars] : 65536 Block : 1 @@ -12,12 +12,12 @@ total LocalGet : 1 LocalSet : 1 total - [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 [imports] : 0 [tables] : 0 + [tags] : 0 [total] : 4 [vars] : 65536 Block : 1 diff --git a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt index 2fe8a8a9e..678cd710d 100644 --- a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt +++ b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt @@ -1,5 +1,4 @@ total - [events] : 2 [exports] : 7 [funcs] : 6 [globals] : 6 @@ -7,6 +6,7 @@ total [memory-data] : 22 [table-data] : 0 [tables] : 1 + [tags] : 2 [total] : 764 [vars] : 29 AtomicFence : 2 diff --git a/test/reference-types.wast b/test/reference-types.wast index 28e24b4d7..c8081182f 100644 --- a/test/reference-types.wast +++ b/test/reference-types.wast @@ -35,7 +35,7 @@ (global $global_anyref3 (mut anyref) (ref.null func)) (global $global_anyref4 (mut anyref) (ref.func $foo)) - (event $e-i32 (attr 0) (param i32)) + (tag $e-i32 (attr 0) (param i32)) (func $test (local $local_externref externref) diff --git a/test/reference-types.wast.from-wast b/test/reference-types.wast.from-wast index 6ac855a21..cb9c31088 100644 --- a/test/reference-types.wast.from-wast +++ b/test/reference-types.wast.from-wast @@ -20,7 +20,7 @@ (table $0 3 3 funcref) (elem (i32.const 0) $take_externref $take_funcref $take_anyref) (elem declare func $foo $ref-taken-but-not-in-table) - (event $e-i32 (attr 0) (param i32)) + (tag $e-i32 (attr 0) (param i32)) (export "export_func" (func $import_func)) (export "export_global" (global $import_global)) (func $take_externref (param $0 externref) diff --git a/test/reference-types.wast.fromBinary b/test/reference-types.wast.fromBinary index 00b621f44..57ef2f08b 100644 --- a/test/reference-types.wast.fromBinary +++ b/test/reference-types.wast.fromBinary @@ -20,7 +20,7 @@ (table $0 3 3 funcref) (elem (i32.const 0) $take_externref $take_funcref $take_anyref) (elem declare func $foo $ref-taken-but-not-in-table) - (event $event$0 (attr 0) (param i32)) + (tag $tag$0 (attr 0) (param i32)) (export "export_func" (func $import_func)) (export "export_global" (global $import_global)) (func $take_externref (param $0 externref) @@ -512,7 +512,7 @@ (do (local.get $local_externref) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -525,7 +525,7 @@ (do (ref.func $foo) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -538,7 +538,7 @@ (do (local.get $local_externref) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -551,7 +551,7 @@ (do (ref.func $foo) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) diff --git a/test/reference-types.wast.fromBinary.noDebugInfo b/test/reference-types.wast.fromBinary.noDebugInfo index 71f7e56ef..8162efa65 100644 --- a/test/reference-types.wast.fromBinary.noDebugInfo +++ b/test/reference-types.wast.fromBinary.noDebugInfo @@ -20,7 +20,7 @@ (table $0 3 3 funcref) (elem (i32.const 0) $0 $1 $2) (elem declare func $27 $3) - (event $event$0 (attr 0) (param i32)) + (tag $tag$0 (attr 0) (param i32)) (export "export_func" (func $fimport$0)) (export "export_global" (global $gimport$0)) (func $0 (param $0 externref) @@ -512,7 +512,7 @@ (do (local.get $0) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -525,7 +525,7 @@ (do (ref.func $3) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -538,7 +538,7 @@ (do (local.get $0) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) @@ -551,7 +551,7 @@ (do (ref.func $3) ) - (catch $event$0 + (catch $tag$0 (drop (pop i32) ) diff --git a/test/spec/events.wast b/test/spec/events.wast deleted file mode 100644 index c864a0c87..000000000 --- a/test/spec/events.wast +++ /dev/null @@ -1,33 +0,0 @@ -;; Test events - -(module - (event (attr 0) (param i32)) - (event $e (attr 0) (param i32 f32)) - - (event $e-params0 (attr 0) (param i32 f32)) - (event $e-params1 (attr 0) (param i32) (param f32)) - - (event $e-export (export "ex0") (attr 0) (param i32)) - (event $e-import (import "env" "im0") (attr 0) (param i32)) - - (import "env" "im1" (event (attr 0) (param i32 f32))) - (export "ex1" (event $e)) -) - -(assert_invalid - (module (event $e (attr 0) (param i32) (result i32))) - "Event type's result type should be none" -) - -(assert_invalid - (module (event $e (attr 1) (param i32))) - "Currently only attribute 0 is supported" -) - -(assert_invalid - (module - (type $t (param i32)) - (event $e (attr 0) (type $t) (param i32 f32)) - ) - "type and param don't match" -) diff --git a/test/spec/exception-handling.wast b/test/spec/exception-handling.wast index 21dc98bd4..d09c21806 100644 --- a/test/spec/exception-handling.wast +++ b/test/spec/exception-handling.wast @@ -1,8 +1,8 @@ (module - (event $e-v (attr 0)) - (event $e-i32 (attr 0) (param i32)) - (event $e-f32 (attr 0) (param f32)) - (event $e-i32-f32 (attr 0) (param i32 f32)) + (tag $e-v (attr 0)) + (tag $e-i32 (attr 0) (param i32)) + (tag $e-f32 (attr 0) (param f32)) + (tag $e-i32-f32 (attr 0) (param i32 f32)) (func $throw_single_value (export "throw_single_value") (throw $e-i32 (i32.const 5)) @@ -246,22 +246,22 @@ (assert_invalid (module - (event $e-i32 (attr 0) (param i32)) + (tag $e-i32 (attr 0) (param i32)) (func $f0 (throw $e-i32 (f32.const 0)) ) ) - "event param types must match" + "tag param types must match" ) (assert_invalid (module - (event $e-i32 (attr 0) (param i32 f32)) + (tag $e-i32 (attr 0) (param i32 f32)) (func $f0 (throw $e-i32 (f32.const 0)) ) ) - "event's param numbers must match" + "tag's param numbers must match" ) (assert_invalid diff --git a/test/spec/tags.wast b/test/spec/tags.wast new file mode 100644 index 000000000..33e24e093 --- /dev/null +++ b/test/spec/tags.wast @@ -0,0 +1,33 @@ +;; Test tags + +(module + (tag (attr 0) (param i32)) + (tag $e (attr 0) (param i32 f32)) + + (tag $e-params0 (attr 0) (param i32 f32)) + (tag $e-params1 (attr 0) (param i32) (param f32)) + + (tag $e-export (export "ex0") (attr 0) (param i32)) + (tag $e-import (import "env" "im0") (attr 0) (param i32)) + + (import "env" "im1" (tag (attr 0) (param i32 f32))) + (export "ex1" (tag $e)) +) + +(assert_invalid + (module (tag $e (attr 0) (param i32) (result i32))) + "Tag type's result type should be none" +) + +(assert_invalid + (module (tag $e (attr 1) (param i32))) + "Currently only attribute 0 is supported" +) + +(assert_invalid + (module + (type $t (param i32)) + (tag $e (attr 0) (type $t) (param i32 f32)) + ) + "type and param don't match" +) diff --git a/test/tags.wast b/test/tags.wast new file mode 100644 index 000000000..08867f876 --- /dev/null +++ b/test/tags.wast @@ -0,0 +1,16 @@ +;; Test tags + +(module + (tag (attr 0) (param i32)) + (tag $e (attr 0) (param i32 f32)) + (tag $empty (attr 0)) + + (tag $e-params0 (attr 0) (param i32 f32)) + (tag $e-params1 (attr 0) (param i32) (param f32)) + + (tag $e-export (export "ex0") (attr 0) (param i32)) + (tag $e-import (import "env" "im0") (attr 0) (param i32)) + + (import "env" "im1" (tag (attr 0) (param i32 f32))) + (export "ex1" (tag $e)) +) diff --git a/test/tags.wast.from-wast b/test/tags.wast.from-wast new file mode 100644 index 000000000..c81c1bc2c --- /dev/null +++ b/test/tags.wast.from-wast @@ -0,0 +1,14 @@ +(module + (type $i32_f32_=>_none (func (param i32 f32))) + (type $i32_=>_none (func (param i32))) + (type $none_=>_none (func)) + (import "env" "im0" (tag $e-import (attr 0) (param i32))) + (import "env" "im1" (tag $eimport$1 (attr 0) (param i32 f32))) + (tag $2 (attr 0) (param i32)) + (tag $e (attr 0) (param i32 f32)) + (tag $empty (attr 0) (param)) + (tag $e-params0 (attr 0) (param i32 f32)) + (tag $e-params1 (attr 0) (param i32 f32)) + (tag $e-export (attr 0) (param i32)) + (export "ex1" (tag $e)) +) diff --git a/test/tags.wast.fromBinary b/test/tags.wast.fromBinary new file mode 100644 index 000000000..e313e6291 --- /dev/null +++ b/test/tags.wast.fromBinary @@ -0,0 +1,15 @@ +(module + (type $i32_f32_=>_none (func (param i32 f32))) + (type $i32_=>_none (func (param i32))) + (type $none_=>_none (func)) + (import "env" "im0" (tag $eimport$0 (attr 0) (param i32))) + (import "env" "im1" (tag $eimport$1 (attr 0) (param i32 f32))) + (tag $tag$0 (attr 0) (param i32)) + (tag $tag$1 (attr 0) (param i32 f32)) + (tag $tag$2 (attr 0) (param)) + (tag $tag$3 (attr 0) (param i32 f32)) + (tag $tag$4 (attr 0) (param i32 f32)) + (tag $tag$5 (attr 0) (param i32)) + (export "ex1" (tag $tag$1)) +) + diff --git a/test/tags.wast.fromBinary.noDebugInfo b/test/tags.wast.fromBinary.noDebugInfo new file mode 100644 index 000000000..e313e6291 --- /dev/null +++ b/test/tags.wast.fromBinary.noDebugInfo @@ -0,0 +1,15 @@ +(module + (type $i32_f32_=>_none (func (param i32 f32))) + (type $i32_=>_none (func (param i32))) + (type $none_=>_none (func)) + (import "env" "im0" (tag $eimport$0 (attr 0) (param i32))) + (import "env" "im1" (tag $eimport$1 (attr 0) (param i32 f32))) + (tag $tag$0 (attr 0) (param i32)) + (tag $tag$1 (attr 0) (param i32 f32)) + (tag $tag$2 (attr 0) (param)) + (tag $tag$3 (attr 0) (param i32 f32)) + (tag $tag$4 (attr 0) (param i32 f32)) + (tag $tag$5 (attr 0) (param i32)) + (export "ex1" (tag $tag$1)) +) + diff --git a/test/try-delegate.wasm.fromBinary b/test/try-delegate.wasm.fromBinary index ee4dbaabe..1ff60fee9 100644 --- a/test/try-delegate.wasm.fromBinary +++ b/test/try-delegate.wasm.fromBinary @@ -1,6 +1,6 @@ (module (type $none_=>_none (func)) - (event $event$0 (attr 0) (param)) + (tag $tag$0 (attr 0) (param)) (func $0 (try $label$6 (do @@ -12,7 +12,7 @@ ) ) ) - (catch $event$0 + (catch $tag$0 ) ) ) @@ -23,7 +23,7 @@ (try $label$7 (do ) - (catch $event$0 + (catch $tag$0 (drop (i32.const 0) ) @@ -36,7 +36,7 @@ ) ) ) - (catch $event$0 + (catch $tag$0 ) ) ) diff --git a/test/unit/test_features.py b/test/unit/test_features.py index 0186e2ba7..06e2661d1 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -184,16 +184,16 @@ class FeatureValidationTest(utils.BinaryenTestCase): ''' self.check_reference_types(module, 'all used types should be allowed') - def test_event(self): + def test_tag(self): module = ''' (module - (event $e (attr 0) (param i32)) + (tag $e (attr 0) (param i32)) (func $foo (throw $e (i32.const 0)) ) ) ''' - self.check_exception_handling(module, 'Module has events') + self.check_exception_handling(module, 'Module has tags') def test_multivalue_import(self): module = ''' @@ -218,13 +218,13 @@ class FeatureValidationTest(utils.BinaryenTestCase): self.check_multivalue(module, 'Multivalue function results ' + '(multivalue is not enabled)') - def test_multivalue_event(self): + def test_multivalue_tag(self): module = ''' (module - (event $foo (attr 0) (param i32 i64)) + (tag $foo (attr 0) (param i32 i64)) ) ''' - self.check_multivalue_exception_handling(module, 'Multivalue event type ' + + self.check_multivalue_exception_handling(module, 'Multivalue tag type ' + '(multivalue is not enabled)') def test_multivalue_block(self): |