@@ -45,12 +45,12 @@ instruction. Thrown exceptions are handled as follows:
45
45
1 . If the call stack is exhausted without any enclosing try blocks, the embedder
46
46
defines how to handle the uncaught exception.
47
47
48
- ### Event handling
48
+ ### Exception handling
49
49
50
50
This proposal adds exception handling to WebAssembly. Part of this proposal is
51
51
to define a new section to declare exceptions. However, rather than limiting
52
52
this new section to just defining exceptions, it defines a more general format
53
- that allows the declaration of other forms of events.
53
+ that allows the declaration of other forms of events in future .
54
54
55
55
In general, an event handler allows one to process an event generated by a block
56
56
of code. Events suspend the current execution and look for a corresponding event
@@ -62,22 +62,21 @@ Exceptions are a special case of an event in that they never resume. Similarly,
62
62
a ` throw ` instruction is the suspending event of an exception. The catch block
63
63
associated with a try block defines how to handle the throw.
64
64
65
- WebAssembly events (i.e. exceptions) are defined by a new ` event ` section of a
66
- WebAssembly module. The event section is a list of declared events associated
67
- with the module.
65
+ WebAssembly exceptions tags are defined in a new ` tag ` section of a WebAssembly
66
+ module. The tag section is a list of declared tags associated with the module.
68
67
69
- Each event has an ` attribute ` and a ` type ` . Currently, the attribute can only
70
- specify that the event is an exception. In the future, additional attribute
68
+ Each tag has an ` attribute ` and a ` type ` . Currently, the attribute can only
69
+ specify that the tag is for an exception. In the future, additional attribute
71
70
values may be added when other events are added to WebAssembly.
72
71
73
72
To allow for such a future extension possibility, we reserve a byte in the
74
73
binary format of an exception definition, set to 0 to denote an exception
75
- attribute, but for the moment we won't use the term event in the formal spec .
74
+ attribute.
76
75
77
76
### Exceptions
78
77
79
78
An ` exception ` is an internal construct in WebAssembly. WebAssembly exceptions
80
- are defined in the event and import sections of a module.
79
+ are defined in the tag and import sections of a module.
81
80
82
81
The type of an exception is denoted by an index to a function signature defined
83
82
in the ` type ` section. The parameters of the function signature define the list
@@ -418,28 +417,21 @@ Each exception type has the fields:
418
417
A single-byte unsigned integer indicating the kind of definition being imported
419
418
or defined:
420
419
421
- * ` 0 ` indicating a ` Function ` [ import] ( Modules.md#imports ) or
422
- [ definition] ( Modules.md#function-and-code-sections )
423
- * ` 1 ` indicating a ` Table ` [ import] ( Modules.md#imports ) or
424
- [ definition] ( Modules.md#table-section )
425
- * ` 2 ` indicating a ` Memory ` [ import] ( Modules.md#imports ) or
426
- [ definition] ( Modules.md#linear-memory-section )
427
- * ` 3 ` indicating a ` Global ` [ import] ( Modules.md#imports ) or
428
- [ definition] ( Modules.md#global-section )
429
- * ` 4 ` indicating an ` Event ` [ import] ( #import-section ) or
430
- [ definition] ( #event-section )
420
+ * ` 4 ` indicating a ` Tag `
421
+ [ import] ( https://github.com/WebAssembly/design/blob/main/BinaryEncoding.md#import-section ) or
422
+ [ definition] ( #tag-section )
431
423
432
424
### Module structure
433
425
434
426
#### High-level structure
435
427
436
- A new ` event ` section is introduced and is named ` event ` . If included, it must
437
- appear immediately after the memory section.
428
+ A new ` tag ` section is introduced. If included, it must appear immediately after
429
+ the memory section.
438
430
439
- ##### Exception section
431
+ ##### Tag section
440
432
441
- The ` event ` section is the named section 'exception '. For ease of validation,
442
- this section comes after the [ memory
433
+ The ` tag ` section is the named section 'tag '. For ease of validation, this
434
+ section comes after the [ memory
443
435
section] ( https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#memory-section )
444
436
and before the [ global
445
437
section] ( https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#global-section ) .
@@ -452,42 +444,42 @@ So the list of all sections will be:
452
444
| Function | ` 3 ` | Function declarations |
453
445
| Table | ` 4 ` | Indirect function table and other tables |
454
446
| Memory | ` 5 ` | Memory attributes |
455
- | Event | ` 13 ` | Event declarations |
447
+ | Tag | ` 13 ` | Tag declarations |
456
448
| Global | ` 6 ` | Global declarations |
457
449
| Export | ` 7 ` | Exports |
458
450
| Start | ` 8 ` | Start function declaration |
459
451
| Element | ` 9 ` | Elements section |
460
452
| Code | ` 10 ` | Function bodies (code) |
461
453
| Data | ` 11 ` | Data segments |
462
454
463
- The event section declares a list of event types as follows:
455
+ The tag section declares a list of tag types as follows:
464
456
465
457
| Field | Type | Description |
466
458
| -------| ------| -------------|
467
- | count | ` varuint32 ` | count of the number of event to follow |
468
- | type | ` event_type *` | The definitions of the event types |
459
+ | count | ` varuint32 ` | count of the number of tags to follow |
460
+ | type | ` tag_type *` | The definitions of the tag types |
469
461
470
462
##### Import section
471
463
472
464
The import section is extended to include exception definitions by extending an
473
465
` import_entry ` as follows:
474
466
475
- If the ` kind ` is ` Event ` :
467
+ If the ` kind ` is ` Tag ` :
476
468
477
469
| Field | Type | Description |
478
470
| -------| ------| -------------|
479
- | ` type ` | ` event_type ` | the event being imported |
471
+ | ` type ` | ` tag_type ` | the tag being imported |
480
472
481
473
##### Export section
482
474
483
475
The export section is extended to reference exception types by extending an
484
476
` export_entry ` as follows:
485
477
486
- If the ` kind ` is ` Event ` :
478
+ If the ` kind ` is ` Tag ` :
487
479
488
480
| Field | Type | Description |
489
481
| -------| ------| -------------|
490
- | ` index ` | ` varuint32 ` | the index into the corresponding event index space |
482
+ | ` index ` | ` varuint32 ` | the index into the corresponding exception index space |
491
483
492
484
##### Name section
493
485
@@ -498,12 +490,12 @@ follows:
498
490
| --------- | ---- | ----------- |
499
491
| [ Function] ( #function-names ) | ` 1 ` | Assigns names to functions |
500
492
| [ Local] ( #local-names ) | ` 2 ` | Assigns names to locals in functions |
501
- | [ Event ] ( #event -names ) | ` 3 ` | Assigns names to event types |
493
+ | [ Tag ] ( #tag -names ) | ` 3 ` | Assigns names to tag types |
502
494
503
- ###### Event names
495
+ ###### Tag names
504
496
505
- The event names subsection is a ` name_map ` which assigns names to a subset of
506
- the exception indices (Used for both imports and module-defined).
497
+ The tag names subsection is a ` name_map ` which assigns names to a subset of
498
+ the tag indices (Used for both imports and module-defined).
507
499
508
500
### Control flow operators
509
501
0 commit comments