Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Clarify the ID and location of the exception section #27

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions proposals/Exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,31 @@ or defined:

### Exception section

The `exception` section is the named section 'exception'. The exception section
declares exception types using exception type signatures.
The `exception` section is the named section 'exception' with id 13. The
exception section may occur anywhere after the import section and before the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of all known sections is fixed. We shouldn't lose that property. For maximum future-proofness I suggest inserting it between import section (2) and function section (3).

export section. There may be at most one exception section. The exception
section declares exception types using exception type signatures.

| Field | Type | Description |
|-------|------|-------------|
| count | `varuint32` | count of the number of exceptions to follow |
| sig | `except_type*` | The type signature of the data fields for each exception |

#### Rationale

The exception is assigned the number 13 because this is the next available
identifier.
The [spec](https://webassembly.github.io/spec/binary/modules.html#sections)
currently shows numbers 0 through 11 are assigned. Section 12 appears to be
reserved for the name section.
Copy link
Member

@binji binji Aug 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is that mentioned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is what? The name section? I was going based on this line of code: https://cs.chromium.org/chromium/src/v8/src/wasm/module-decoder.h?type=cs&q=NameSection+f:v8&l=36

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I meant where is the name sections specified as section 12. I'd say that v8 is wrong here -- the spec says nothing about the name section being numbered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name section is a custom section, numbered zero, and using an explicit string as name.


The position of the exception section is driven by the requirement that items be
defined before they are used. Having the exception section after the import
section allows imported exceptions to be assigned the lower number
tags. Similarly, defining the exceptions before the export section allows
exceptions to be exported. Beyond these constraints, no additional requirements
are imposed.

### Import section

The import section is extended to include exception types by extending an
Expand Down