Skip to content

Commit 64d23e1

Browse files
authored
Handle the rename of "events" to "tags" in exception handling proposal (#291)
* Update wabt test submodule to latest * Update wasm-encoder linking tests for latest wabt A recent PR to wabt changed the printing slightly for these test cases: WebAssembly/wabt#1669 * Rename "events" to "tags" for exception handling The exception handling proposal spec was recently changed to rename the event section to the tag section, in order to use a clearer name that conflicts with fewer things in the web context: WebAssembly/exception-handling#161
1 parent ca97cf2 commit 64d23e1

36 files changed

+272
-267
lines changed

crates/dump/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct Indices {
2222
globals: u32,
2323
tables: u32,
2424
memories: u32,
25-
events: u32,
25+
tags: u32,
2626
modules: u32,
2727
instances: u32,
2828
types: u32,
@@ -74,9 +74,9 @@ impl<'a> Dump<'a> {
7474
write!(me.state, "[memory {}]", i.memories)?;
7575
i.memories += 1;
7676
}
77-
ImportSectionEntryType::Event(_) => {
78-
write!(me.state, "[event {}]", i.events)?;
79-
i.events += 1;
77+
ImportSectionEntryType::Tag(_) => {
78+
write!(me.state, "[tag {}]", i.tags)?;
79+
i.tags += 1;
8080
}
8181
ImportSectionEntryType::Table(_) => {
8282
write!(me.state, "[table {}]", i.tables)?;
@@ -116,9 +116,9 @@ impl<'a> Dump<'a> {
116116
i.memories += 1;
117117
me.print(end)
118118
})?,
119-
Payload::EventSection(s) => self.section(s, "event", |me, end, m| {
120-
write!(me.state, "[event {}] {:?}", i.events, m)?;
121-
i.events += 1;
119+
Payload::TagSection(s) => self.section(s, "tag", |me, end, m| {
120+
write!(me.state, "[tag {}] {:?}", i.tags, m)?;
121+
i.tags += 1;
122122
me.print(end)
123123
})?,
124124
Payload::ExportSection(s) => self.section(s, "export", |me, end, e| {
@@ -141,7 +141,7 @@ impl<'a> Dump<'a> {
141141
ExternalKind::Table => i.tables += 1,
142142
ExternalKind::Instance => i.instances += 1,
143143
ExternalKind::Memory => i.memories += 1,
144-
ExternalKind::Event => i.events += 1,
144+
ExternalKind::Tag => i.tags += 1,
145145
ExternalKind::Type => i.types += 1,
146146
},
147147
Alias::OuterType { .. } => i.types += 1,

crates/wasm-encoder/src/linking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const SYMTAB_GLOBAL: u32 = 2;
109109
#[allow(unused)]
110110
const SYMTAB_SECTION: u32 = 3;
111111
#[allow(unused)]
112-
const SYMTAB_EVENT: u32 = 4;
112+
const SYMTAB_TAG: u32 = 4;
113113
const SYMTAB_TABLE: u32 = 5;
114114

115115
impl SymbolTable {
@@ -161,7 +161,7 @@ impl SymbolTable {
161161
self
162162
}
163163

164-
// TODO: events
164+
// TODO: tags
165165

166166
/// Define a table symbol in this symbol table.
167167
///

crates/wasm-encoder/tests/linking.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn sym_tab_function() -> Result<()> {
9292
"
9393
- name: \"linking\"
9494
- symbol table [count=1]
95-
- 0: F <func> func=42 binding=global vis=default
95+
- 0: F <func> func=42 [ binding=global vis=default ]
9696
",
9797
)
9898
}
@@ -114,7 +114,7 @@ fn sym_tab_flags() -> Result<()> {
114114
"
115115
- name: \"linking\"
116116
- symbol table [count=1]
117-
- 0: F <func> func=1337 binding=weak vis=hidden
117+
- 0: F <func> func=1337 [ binding=weak vis=hidden ]
118118
",
119119
)
120120
}
@@ -132,7 +132,7 @@ fn sym_tab_global() -> Result<()> {
132132
"
133133
- name: \"linking\"
134134
- symbol table [count=1]
135-
- 0: G <my_global> global=42 binding=global vis=default",
135+
- 0: G <my_global> global=42 [ binding=global vis=default ]",
136136
)
137137
}
138138

@@ -149,7 +149,7 @@ fn sym_tab_table() -> Result<()> {
149149
"
150150
- name: \"linking\"
151151
- symbol table [count=1]
152-
- 0: T <my_table> table=42 binding=global vis=default",
152+
- 0: T <my_table> table=42 [ binding=global vis=default ]",
153153
)
154154
}
155155

@@ -174,7 +174,7 @@ fn sym_tab_data_defined() -> Result<()> {
174174
"
175175
- name: \"linking\"
176176
- symbol table [count=1]
177-
- 0: D <my_data> segment=42 offset=1337 size=1234 binding=global vis=default
177+
- 0: D <my_data> segment=42 offset=1337 size=1234 [ binding=global vis=default ]
178178
",
179179
)
180180
}
@@ -192,7 +192,7 @@ fn sym_tab_data_undefined() -> Result<()> {
192192
"
193193
- name: \"linking\"
194194
- symbol table [count=1]
195-
- 0: D <my_data> undefined binding=global vis=default
195+
- 0: D <my_data> [ undefined binding=global vis=default ]
196196
",
197197
)
198198
}

crates/wasmparser/benches/benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ fn read_all_wasm(wasm: &[u8]) -> Result<()> {
119119
item?;
120120
}
121121
}
122-
EventSection(s) => {
122+
TagSection(s) => {
123123
for item in s {
124124
item?;
125125
}

crates/wasmparser/src/binary_reader.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::primitives::{
2525
ResizableLimits, ResizableLimits64, Result, SIMDLaneIndex, SectionCode, TableType, Type,
2626
TypeOrFuncType, V128,
2727
};
28-
use crate::{EventType, ExportType, Import, ImportSectionEntryType, InstanceType, ModuleType};
28+
use crate::{ExportType, Import, ImportSectionEntryType, InstanceType, ModuleType, TagType};
2929

3030
const MAX_WASM_BR_TABLE_SIZE: usize = MAX_WASM_FUNCTION_SIZE;
3131

@@ -203,7 +203,7 @@ impl<'a> BinaryReader<'a> {
203203
1 => Ok(ExternalKind::Table),
204204
2 => Ok(ExternalKind::Memory),
205205
3 => Ok(ExternalKind::Global),
206-
4 => Ok(ExternalKind::Event),
206+
4 => Ok(ExternalKind::Tag),
207207
5 => Ok(ExternalKind::Module),
208208
6 => Ok(ExternalKind::Instance),
209209
7 => Ok(ExternalKind::Type),
@@ -302,7 +302,7 @@ impl<'a> BinaryReader<'a> {
302302
ExternalKind::Function => ImportSectionEntryType::Function(self.read_var_u32()?),
303303
ExternalKind::Table => ImportSectionEntryType::Table(self.read_table_type()?),
304304
ExternalKind::Memory => ImportSectionEntryType::Memory(self.read_memory_type()?),
305-
ExternalKind::Event => ImportSectionEntryType::Event(self.read_event_type()?),
305+
ExternalKind::Tag => ImportSectionEntryType::Tag(self.read_tag_type()?),
306306
ExternalKind::Global => ImportSectionEntryType::Global(self.read_global_type()?),
307307
ExternalKind::Module => ImportSectionEntryType::Module(self.read_var_u32()?),
308308
ExternalKind::Instance => ImportSectionEntryType::Instance(self.read_var_u32()?),
@@ -371,16 +371,16 @@ impl<'a> BinaryReader<'a> {
371371
}
372372
}
373373

374-
pub(crate) fn read_event_type(&mut self) -> Result<EventType> {
374+
pub(crate) fn read_tag_type(&mut self) -> Result<TagType> {
375375
let attribute = self.read_var_u32()?;
376376
if attribute != 0 {
377377
return Err(BinaryReaderError::new(
378-
"invalid event attributes",
378+
"invalid tag attributes",
379379
self.original_position() - 1,
380380
));
381381
}
382382
let type_index = self.read_var_u32()?;
383-
Ok(EventType { type_index })
383+
Ok(TagType { type_index })
384384
}
385385

386386
pub(crate) fn read_global_type(&mut self) -> Result<GlobalType> {
@@ -449,7 +449,7 @@ impl<'a> BinaryReader<'a> {
449449
10 => Ok(SectionCode::Code),
450450
11 => Ok(SectionCode::Data),
451451
12 => Ok(SectionCode::DataCount),
452-
13 => Ok(SectionCode::Event),
452+
13 => Ok(SectionCode::Tag),
453453
14 => Ok(SectionCode::Module),
454454
15 => Ok(SectionCode::Instance),
455455
16 => Ok(SectionCode::Alias),

crates/wasmparser/src/limits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ pub const MAX_WASM_TABLES: usize = 100;
3535
pub const MAX_WASM_MEMORIES: usize = 100;
3636
pub const MAX_WASM_MODULES: usize = 1_000;
3737
pub const MAX_WASM_INSTANCES: usize = 1_000;
38-
pub const MAX_WASM_EVENTS: usize = 1_000_000;
38+
pub const MAX_WASM_TAGS: usize = 1_000_000;
3939
pub const MAX_TYPE_SIZE: u32 = 100_000;

crates/wasmparser/src/module_resources.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ pub trait WasmModuleResources {
202202
fn table_at(&self, at: u32) -> Option<TableType>;
203203
/// Returns the linear memory at given index.
204204
fn memory_at(&self, at: u32) -> Option<MemoryType>;
205-
/// Returns the event at given index.
206-
fn event_at(&self, at: u32) -> Option<&Self::FuncType>;
205+
/// Returns the tag at given index.
206+
fn tag_at(&self, at: u32) -> Option<&Self::FuncType>;
207207
/// Returns the global variable at given index.
208208
fn global_at(&self, at: u32) -> Option<GlobalType>;
209209
/// Returns the `FuncType` associated with the given type index.
@@ -234,8 +234,8 @@ where
234234
fn memory_at(&self, at: u32) -> Option<MemoryType> {
235235
T::memory_at(self, at)
236236
}
237-
fn event_at(&self, at: u32) -> Option<&Self::FuncType> {
238-
T::event_at(self, at)
237+
fn tag_at(&self, at: u32) -> Option<&Self::FuncType> {
238+
T::tag_at(self, at)
239239
}
240240
fn global_at(&self, at: u32) -> Option<GlobalType> {
241241
T::global_at(self, at)
@@ -275,8 +275,8 @@ where
275275
T::memory_at(self, at)
276276
}
277277

278-
fn event_at(&self, at: u32) -> Option<&Self::FuncType> {
279-
T::event_at(self, at)
278+
fn tag_at(&self, at: u32) -> Option<&Self::FuncType> {
279+
T::tag_at(self, at)
280280
}
281281

282282
fn global_at(&self, at: u32) -> Option<GlobalType> {

crates/wasmparser/src/operators_validator.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,15 @@ impl OperatorValidator {
604604
unreachable: false,
605605
});
606606
// Push exception argument types.
607-
let ty = event_at(&resources, index)?;
607+
let ty = tag_at(&resources, index)?;
608608
for ty in ty.inputs() {
609609
self.push_operand(ty)?;
610610
}
611611
}
612612
Operator::Throw { index } => {
613613
self.check_exceptions_enabled()?;
614614
// Check values associated with the exception.
615-
let ty = event_at(&resources, index)?;
615+
let ty = tag_at(&resources, index)?;
616616
for ty in ty.inputs().rev() {
617617
self.pop_operand(Some(ty))?;
618618
}
@@ -1972,13 +1972,10 @@ fn func_type_at<T: WasmModuleResources>(
19721972
.ok_or_else(|| OperatorValidatorError::new("unknown type: type index out of bounds"))
19731973
}
19741974

1975-
fn event_at<T: WasmModuleResources>(
1976-
resources: &T,
1977-
at: u32,
1978-
) -> OperatorValidatorResult<&T::FuncType> {
1975+
fn tag_at<T: WasmModuleResources>(resources: &T, at: u32) -> OperatorValidatorResult<&T::FuncType> {
19791976
resources
1980-
.event_at(at)
1981-
.ok_or_else(|| OperatorValidatorError::new("unknown event: event index out of bounds"))
1977+
.tag_at(at)
1978+
.ok_or_else(|| OperatorValidatorError::new("unknown tag: tag index out of bounds"))
19821979
}
19831980

19841981
enum Either<A, B> {

crates/wasmparser/src/parser.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::EventSectionReader;
1+
use crate::TagSectionReader;
22
use crate::{AliasSectionReader, InstanceSectionReader};
33
use crate::{BinaryReader, BinaryReaderError, FunctionBody, Range, Result};
44
use crate::{DataSectionReader, ElementSectionReader, ExportSectionReader};
@@ -109,9 +109,9 @@ pub enum Payload<'a> {
109109
/// A memory section was received, and the provided reader can be used to
110110
/// parse the contents of the memory section.
111111
MemorySection(crate::MemorySectionReader<'a>),
112-
/// An event section was received, and the provided reader can be used to
113-
/// parse the contents of the event section.
114-
EventSection(crate::EventSectionReader<'a>),
112+
/// An tag section was received, and the provided reader can be used to
113+
/// parse the contents of the tag section.
114+
TagSection(crate::TagSectionReader<'a>),
115115
/// A global section was received, and the provided reader can be used to
116116
/// parse the contents of the global section.
117117
GlobalSection(crate::GlobalSectionReader<'a>),
@@ -346,7 +346,7 @@ impl Parser {
346346
/// FunctionSection(_) => { /* ... */ }
347347
/// TableSection(_) => { /* ... */ }
348348
/// MemorySection(_) => { /* ... */ }
349-
/// EventSection(_) => { /* ... */ }
349+
/// TagSection(_) => { /* ... */ }
350350
/// GlobalSection(_) => { /* ... */ }
351351
/// ExportSection(_) => { /* ... */ }
352352
/// StartSection { .. } => { /* ... */ }
@@ -537,7 +537,7 @@ impl Parser {
537537
let (count, range) = single_u32(reader, len, "data count")?;
538538
Ok(DataCountSection { count, range })
539539
}
540-
13 => section(reader, len, EventSectionReader::new, EventSection),
540+
13 => section(reader, len, TagSectionReader::new, TagSection),
541541
14 => {
542542
let start = reader.original_position();
543543
let count = delimited(reader, &mut len, |r| r.read_var_u32())?;
@@ -916,7 +916,7 @@ impl fmt::Debug for Payload<'_> {
916916
FunctionSection(_) => f.debug_tuple("FunctionSection").field(&"...").finish(),
917917
TableSection(_) => f.debug_tuple("TableSection").field(&"...").finish(),
918918
MemorySection(_) => f.debug_tuple("MemorySection").field(&"...").finish(),
919-
EventSection(_) => f.debug_tuple("EventSection").field(&"...").finish(),
919+
TagSection(_) => f.debug_tuple("TagSection").field(&"...").finish(),
920920
GlobalSection(_) => f.debug_tuple("GlobalSection").field(&"...").finish(),
921921
ExportSection(_) => f.debug_tuple("ExportSection").field(&"...").finish(),
922922
ElementSection(_) => f.debug_tuple("ElementSection").field(&"...").finish(),

crates/wasmparser/src/primitives.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub enum SectionCode<'a> {
114114
Code, // Function bodies (code)
115115
Data, // Data segments
116116
DataCount, // Count of passive data segments
117-
Event, // Event declarations
117+
Tag, // Tag declarations
118118
}
119119

120120
/// Types as defined [here].
@@ -155,7 +155,7 @@ pub enum ExternalKind {
155155
Function,
156156
Table,
157157
Memory,
158-
Event,
158+
Tag,
159159
Global,
160160
Type,
161161
Module,
@@ -223,7 +223,7 @@ pub enum MemoryType {
223223
}
224224

225225
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
226-
pub struct EventType {
226+
pub struct TagType {
227227
pub type_index: u32,
228228
}
229229

@@ -247,7 +247,7 @@ pub enum ImportSectionEntryType {
247247
Function(u32),
248248
Table(TableType),
249249
Memory(MemoryType),
250-
Event(EventType),
250+
Tag(TagType),
251251
Global(GlobalType),
252252
Module(u32),
253253
Instance(u32),

0 commit comments

Comments
 (0)