Skip to content

Commit 9500425

Browse files
authored
[EH] Replace event with tag (#1678)
We recently decided to change 'event' to 'tag', and 'event section' to 'tag section', out of the rationale that the section contains a generalized tag that references a type, which may be used for something other than exceptions, and the name 'event' can be confusing in the web context. See - WebAssembly/exception-handling#159 (comment) - WebAssembly/exception-handling#161
1 parent c6cd633 commit 9500425

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1741
-1749
lines changed

src/apply-names.cc

+13-13
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ class NameApplier : public ExprVisitor::DelegateNop {
8181
Result UseNameForGlobalVar(Var* var);
8282
Result UseNameForTableVar(Var* var);
8383
Result UseNameForMemoryVar(Var* var);
84-
Result UseNameForEventVar(Var* var);
84+
Result UseNameForTagVar(Var* var);
8585
Result UseNameForDataSegmentVar(Var* var);
8686
Result UseNameForElemSegmentVar(Var* var);
8787
Result UseNameForParamAndLocalVar(Func* func, Var* var);
8888
Result VisitFunc(Index func_index, Func* func);
8989
Result VisitGlobal(Global* global);
90-
Result VisitEvent(Event* event);
90+
Result VisitTag(Tag* tag);
9191
Result VisitExport(Index export_index, Export* export_);
9292
Result VisitElemSegment(Index elem_segment_index, ElemSegment* segment);
9393
Result VisitDataSegment(Index data_segment_index, DataSegment* segment);
@@ -183,12 +183,12 @@ Result NameApplier::UseNameForMemoryVar(Var* var) {
183183
return Result::Ok;
184184
}
185185

186-
Result NameApplier::UseNameForEventVar(Var* var) {
187-
Event* event = module_->GetEvent(*var);
188-
if (!event) {
186+
Result NameApplier::UseNameForTagVar(Var* var) {
187+
Tag* tag = module_->GetTag(*var);
188+
if (!tag) {
189189
return Result::Error;
190190
}
191-
UseNameForVar(event->name, var);
191+
UseNameForVar(tag->name, var);
192192
return Result::Ok;
193193
}
194194

@@ -335,7 +335,7 @@ Result NameApplier::EndTryExpr(TryExpr*) {
335335

336336
Result NameApplier::OnCatchExpr(TryExpr*, Catch* expr) {
337337
if (!expr->IsCatchAll()) {
338-
CHECK_RESULT(UseNameForEventVar(&expr->var));
338+
CHECK_RESULT(UseNameForTagVar(&expr->var));
339339
}
340340
return Result::Ok;
341341
}
@@ -347,7 +347,7 @@ Result NameApplier::OnDelegateExpr(TryExpr* expr) {
347347
}
348348

349349
Result NameApplier::OnThrowExpr(ThrowExpr* expr) {
350-
CHECK_RESULT(UseNameForEventVar(&expr->var));
350+
CHECK_RESULT(UseNameForTagVar(&expr->var));
351351
return Result::Ok;
352352
}
353353

@@ -442,9 +442,9 @@ Result NameApplier::VisitGlobal(Global* global) {
442442
return Result::Ok;
443443
}
444444

445-
Result NameApplier::VisitEvent(Event* event) {
446-
if (event->decl.has_func_type) {
447-
CHECK_RESULT(UseNameForFuncTypeVar(&event->decl.type_var));
445+
Result NameApplier::VisitTag(Tag* tag) {
446+
if (tag->decl.has_func_type) {
447+
CHECK_RESULT(UseNameForFuncTypeVar(&tag->decl.type_var));
448448
}
449449
return Result::Ok;
450450
}
@@ -486,8 +486,8 @@ Result NameApplier::VisitModule(Module* module) {
486486
CHECK_RESULT(VisitFunc(i, module->funcs[i]));
487487
for (size_t i = 0; i < module->globals.size(); ++i)
488488
CHECK_RESULT(VisitGlobal(module->globals[i]));
489-
for (size_t i = 0; i < module->events.size(); ++i)
490-
CHECK_RESULT(VisitEvent(module->events[i]));
489+
for (size_t i = 0; i < module->tags.size(); ++i)
490+
CHECK_RESULT(VisitTag(module->tags[i]));
491491
for (size_t i = 0; i < module->exports.size(); ++i)
492492
CHECK_RESULT(VisitExport(i, module->exports[i]));
493493
for (size_t i = 0; i < module->elem_segments.size(); ++i)

src/binary-reader-ir.cc

+38-34
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ class BinaryReaderIR : public BinaryReaderNop {
8383
Index global_index,
8484
Type type,
8585
bool mutable_) override;
86-
Result OnImportEvent(Index import_index,
87-
string_view module_name,
88-
string_view field_name,
89-
Index event_index,
90-
Index sig_index) override;
86+
Result OnImportTag(Index import_index,
87+
string_view module_name,
88+
string_view field_name,
89+
Index tag_index,
90+
Index sig_index) override;
9191

9292
Result OnFunctionCount(Index count) override;
9393
Result OnFunction(Index index, Index sig_index) override;
@@ -144,7 +144,7 @@ class BinaryReaderIR : public BinaryReaderNop {
144144
Index* target_depths,
145145
Index default_target_depth) override;
146146
Result OnCallExpr(Index func_index) override;
147-
Result OnCatchExpr(Index event_index) override;
147+
Result OnCatchExpr(Index tag_index) override;
148148
Result OnCatchAllExpr() override;
149149
Result OnCallIndirectExpr(Index sig_index, Index table_index) override;
150150
Result OnReturnCallExpr(Index func_index) override;
@@ -194,7 +194,7 @@ class BinaryReaderIR : public BinaryReaderNop {
194194
Result OnStoreExpr(Opcode opcode,
195195
Address alignment_log2,
196196
Address offset) override;
197-
Result OnThrowExpr(Index event_index) override;
197+
Result OnThrowExpr(Index tag_index) override;
198198
Result OnTryExpr(Type sig_type) override;
199199
Result OnUnaryExpr(Opcode opcode) override;
200200
Result OnTernaryExpr(Opcode opcode) override;
@@ -252,10 +252,10 @@ class BinaryReaderIR : public BinaryReaderNop {
252252
Index index,
253253
string_view name) override;
254254

255-
Result BeginEventSection(Offset size) override { return Result::Ok; }
256-
Result OnEventCount(Index count) override { return Result::Ok; }
257-
Result OnEventType(Index index, Index sig_index) override;
258-
Result EndEventSection() override { return Result::Ok; }
255+
Result BeginTagSection(Offset size) override { return Result::Ok; }
256+
Result OnTagCount(Index count) override { return Result::Ok; }
257+
Result OnTagType(Index index, Index sig_index) override;
258+
Result EndTagSection() override { return Result::Ok; }
259259

260260
Result OnInitExprF32ConstExpr(Index index, uint32_t value) override;
261261
Result OnInitExprF64ConstExpr(Index index, uint64_t value) override;
@@ -274,8 +274,10 @@ class BinaryReaderIR : public BinaryReaderNop {
274274
Index global_index) override;
275275
Result OnSectionSymbol(Index index, uint32_t flags,
276276
Index section_index) override;
277-
Result OnEventSymbol(Index index, uint32_t flags, string_view name,
278-
Index event_index) override;
277+
Result OnTagSymbol(Index index,
278+
uint32_t flags,
279+
string_view name,
280+
Index tag_index) override;
279281
Result OnTableSymbol(Index index, uint32_t flags, string_view name,
280282
Index table_index) override;
281283

@@ -525,15 +527,15 @@ Result BinaryReaderIR::OnImportGlobal(Index import_index,
525527
return Result::Ok;
526528
}
527529

528-
Result BinaryReaderIR::OnImportEvent(Index import_index,
529-
string_view module_name,
530-
string_view field_name,
531-
Index event_index,
532-
Index sig_index) {
533-
auto import = MakeUnique<EventImport>();
530+
Result BinaryReaderIR::OnImportTag(Index import_index,
531+
string_view module_name,
532+
string_view field_name,
533+
Index tag_index,
534+
Index sig_index) {
535+
auto import = MakeUnique<TagImport>();
534536
import->module_name = module_name.to_string();
535537
import->field_name = field_name.to_string();
536-
SetFuncDeclaration(&import->event.decl, Var(sig_index, GetLocation()));
538+
SetFuncDeclaration(&import->tag.decl, Var(sig_index, GetLocation()));
537539
module_->AppendField(
538540
MakeUnique<ImportModuleField>(std::move(import), GetLocation()));
539541
return Result::Ok;
@@ -975,8 +977,8 @@ Result BinaryReaderIR::OnStoreExpr(Opcode opcode,
975977
return AppendExpr(MakeUnique<StoreExpr>(opcode, 1 << alignment_log2, offset));
976978
}
977979

978-
Result BinaryReaderIR::OnThrowExpr(Index event_index) {
979-
return AppendExpr(MakeUnique<ThrowExpr>(Var(event_index, GetLocation())));
980+
Result BinaryReaderIR::OnThrowExpr(Index tag_index) {
981+
return AppendExpr(MakeUnique<ThrowExpr>(Var(tag_index, GetLocation())));
980982
}
981983

982984
Result BinaryReaderIR::OnLocalTeeExpr(Index local_index) {
@@ -1482,10 +1484,10 @@ Result BinaryReaderIR::OnLocalName(Index func_index,
14821484
return Result::Ok;
14831485
}
14841486

1485-
Result BinaryReaderIR::OnEventType(Index index, Index sig_index) {
1486-
auto field = MakeUnique<EventModuleField>(GetLocation());
1487-
Event& event = field->event;
1488-
SetFuncDeclaration(&event.decl, Var(sig_index, GetLocation()));
1487+
Result BinaryReaderIR::OnTagType(Index index, Index sig_index) {
1488+
auto field = MakeUnique<TagModuleField>(GetLocation());
1489+
Tag& tag = field->tag;
1490+
SetFuncDeclaration(&tag.decl, Var(sig_index, GetLocation()));
14891491
module_->AppendField(std::move(field));
14901492
return Result::Ok;
14911493
}
@@ -1548,20 +1550,22 @@ Result BinaryReaderIR::OnSectionSymbol(Index index, uint32_t flags,
15481550
return Result::Ok;
15491551
}
15501552

1551-
Result BinaryReaderIR::OnEventSymbol(Index index, uint32_t flags,
1552-
string_view name, Index event_index) {
1553+
Result BinaryReaderIR::OnTagSymbol(Index index,
1554+
uint32_t flags,
1555+
string_view name,
1556+
Index tag_index) {
15531557
if (name.empty()) {
15541558
return Result::Ok;
15551559
}
1556-
if (event_index >= module_->events.size()) {
1557-
PrintError("invalid event index: %" PRIindex, event_index);
1560+
if (tag_index >= module_->tags.size()) {
1561+
PrintError("invalid tag index: %" PRIindex, tag_index);
15581562
return Result::Error;
15591563
}
1560-
Event* event = module_->events[event_index];
1564+
Tag* tag = module_->tags[tag_index];
15611565
std::string dollar_name =
1562-
GetUniqueName(&module_->event_bindings, MakeDollarName(name));
1563-
event->name = dollar_name;
1564-
module_->event_bindings.emplace(dollar_name, Binding(event_index));
1566+
GetUniqueName(&module_->tag_bindings, MakeDollarName(name));
1567+
tag->name = dollar_name;
1568+
module_->tag_bindings.emplace(dollar_name, Binding(tag_index));
15651569
return Result::Ok;
15661570
}
15671571

src/binary-reader-logging.cc

+23-23
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,16 @@ Result BinaryReaderLogging::OnImportGlobal(Index import_index,
241241
global_index, type, mutable_);
242242
}
243243

244-
Result BinaryReaderLogging::OnImportEvent(Index import_index,
245-
string_view module_name,
246-
string_view field_name,
247-
Index event_index,
248-
Index sig_index) {
249-
LOGF("OnImportEvent(import_index: %" PRIindex ", event_index: %" PRIindex
244+
Result BinaryReaderLogging::OnImportTag(Index import_index,
245+
string_view module_name,
246+
string_view field_name,
247+
Index tag_index,
248+
Index sig_index) {
249+
LOGF("OnImportTag(import_index: %" PRIindex ", tag_index: %" PRIindex
250250
", sig_index: %" PRIindex ")\n",
251-
import_index, event_index, sig_index);
252-
return reader_->OnImportEvent(import_index, module_name, field_name,
253-
event_index, sig_index);
251+
import_index, tag_index, sig_index);
252+
return reader_->OnImportTag(import_index, module_name, field_name, tag_index,
253+
sig_index);
254254
}
255255

256256
Result BinaryReaderLogging::OnTable(Index index,
@@ -614,14 +614,14 @@ Result BinaryReaderLogging::OnSectionSymbol(Index index,
614614
return reader_->OnSectionSymbol(index, flags, section_index);
615615
}
616616

617-
Result BinaryReaderLogging::OnEventSymbol(Index index,
618-
uint32_t flags,
619-
string_view name,
620-
Index event_index) {
621-
LOGF("OnEventSymbol(name: " PRIstringview " flags: 0x%x index: %" PRIindex
622-
")\n",
623-
WABT_PRINTF_STRING_VIEW_ARG(name), flags, event_index);
624-
return reader_->OnEventSymbol(index, flags, name, event_index);
617+
Result BinaryReaderLogging::OnTagSymbol(Index index,
618+
uint32_t flags,
619+
string_view name,
620+
Index tag_index) {
621+
LOGF("OnTagSymbol(name: " PRIstringview " flags: 0x%x index: %" PRIindex
622+
")\n",
623+
WABT_PRINTF_STRING_VIEW_ARG(name), flags, tag_index);
624+
return reader_->OnTagSymbol(index, flags, name, tag_index);
625625
}
626626

627627
Result BinaryReaderLogging::OnTableSymbol(Index index,
@@ -802,7 +802,7 @@ DEFINE_LOAD_STORE_OPCODE(OnAtomicNotifyExpr);
802802
DEFINE_OPCODE(OnBinaryExpr)
803803
DEFINE_INDEX_DESC(OnCallExpr, "func_index")
804804
DEFINE_INDEX_INDEX(OnCallIndirectExpr, "sig_index", "table_index")
805-
DEFINE_INDEX_DESC(OnCatchExpr, "event_index");
805+
DEFINE_INDEX_DESC(OnCatchExpr, "tag_index");
806806
DEFINE0(OnCatchAllExpr);
807807
DEFINE_OPCODE(OnCompareExpr)
808808
DEFINE_OPCODE(OnConvertExpr)
@@ -842,7 +842,7 @@ DEFINE0(OnReturnExpr)
842842
DEFINE_LOAD_STORE_OPCODE(OnLoadSplatExpr);
843843
DEFINE_LOAD_STORE_OPCODE(OnLoadZeroExpr);
844844
DEFINE_LOAD_STORE_OPCODE(OnStoreExpr);
845-
DEFINE_INDEX_DESC(OnThrowExpr, "event_index")
845+
DEFINE_INDEX_DESC(OnThrowExpr, "tag_index")
846846
DEFINE0(OnUnreachableExpr)
847847
DEFINE0(OnUnwindExpr)
848848
DEFINE_OPCODE(OnUnaryExpr)
@@ -898,10 +898,10 @@ DEFINE_INDEX(OnInitFunctionCount)
898898
DEFINE_INDEX(OnComdatCount)
899899
DEFINE_END(EndLinkingSection)
900900

901-
DEFINE_BEGIN(BeginEventSection);
902-
DEFINE_INDEX(OnEventCount);
903-
DEFINE_INDEX_INDEX(OnEventType, "index", "sig_index")
904-
DEFINE_END(EndEventSection);
901+
DEFINE_BEGIN(BeginTagSection);
902+
DEFINE_INDEX(OnTagCount);
903+
DEFINE_INDEX_INDEX(OnTagType, "index", "sig_index")
904+
DEFINE_END(EndTagSection);
905905

906906
// We don't need to log these (the individual opcodes are logged instead), but
907907
// we still need to forward the calls.

src/binary-reader-logging.h

+16-16
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
8181
Index global_index,
8282
Type type,
8383
bool mutable_) override;
84-
Result OnImportEvent(Index import_index,
85-
string_view module_name,
86-
string_view field_name,
87-
Index event_index,
88-
Index sig_index) override;
84+
Result OnImportTag(Index import_index,
85+
string_view module_name,
86+
string_view field_name,
87+
Index tag_index,
88+
Index sig_index) override;
8989
Result EndImportSection() override;
9090

9191
Result BeginFunctionSection(Offset size) override;
@@ -166,7 +166,7 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
166166
Index* target_depths,
167167
Index default_target_depth) override;
168168
Result OnCallExpr(Index func_index) override;
169-
Result OnCatchExpr(Index event_index) override;
169+
Result OnCatchExpr(Index tag_index) override;
170170
Result OnCatchAllExpr() override;
171171
Result OnCallIndirectExpr(Index sig_index, Index table_index) override;
172172
Result OnCompareExpr(Opcode opcode) override;
@@ -217,7 +217,7 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
217217
Result OnStoreExpr(Opcode opcode,
218218
Address alignment_log2,
219219
Address offset) override;
220-
Result OnThrowExpr(Index event_index) override;
220+
Result OnThrowExpr(Index tag_index) override;
221221
Result OnTryExpr(Type sig_type) override;
222222
Result OnUnaryExpr(Opcode opcode) override;
223223
Result OnTernaryExpr(Opcode opcode) override;
@@ -346,14 +346,14 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
346346
Result OnSectionSymbol(Index index,
347347
uint32_t flags,
348348
Index section_index) override;
349-
Result OnEventSymbol(Index index,
350-
uint32_t flags,
351-
string_view name,
352-
Index event_index) override;
349+
Result OnTagSymbol(Index index,
350+
uint32_t flags,
351+
string_view name,
352+
Index tag_index) override;
353353
Result OnTableSymbol(Index index,
354354
uint32_t flags,
355355
string_view name,
356-
Index event_index) override;
356+
Index tag_index) override;
357357
Result OnSegmentInfoCount(Index count) override;
358358
Result OnSegmentInfo(Index index,
359359
string_view name,
@@ -366,10 +366,10 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
366366
Result OnComdatEntry(ComdatType kind, Index index) override;
367367
Result EndLinkingSection() override;
368368

369-
Result BeginEventSection(Offset size) override;
370-
Result OnEventCount(Index count) override;
371-
Result OnEventType(Index index, Index sig_index) override;
372-
Result EndEventSection() override;
369+
Result BeginTagSection(Offset size) override;
370+
Result OnTagCount(Index count) override;
371+
Result OnTagType(Index index, Index sig_index) override;
372+
Result EndTagSection() override;
373373

374374
Result OnInitExprF32ConstExpr(Index index, uint32_t value) override;
375375
Result OnInitExprF64ConstExpr(Index index, uint64_t value) override;

0 commit comments

Comments
 (0)