-
Notifications
You must be signed in to change notification settings - Fork 36
Is the exception section needed? #26
Comments
Talking with @KarlSchimpf, it sounds like imported exceptions are supposed to get the lowest number IDs, which means all exception imports must come before any defined exceptions. Since the type section comes first, and must come before the import section, then this would be an argument in favor of a separate exception section. |
Why are they supposed to get the lowest number IDs? |
Apparently that's the way everything else has done it. |
That's not a reason, please clarify. |
Right. I'm working from this understanding as well, although I may not have been as precise in my terminology. So my understanding is that the exception section (i.e. tag section) has a list of tag definitions (essentially just the tag type) and their location in this list determines each tag index. So if the tag/exception section is effectively a list of types, is there any benefit to having a separate section as opposed to including them in the types section? We reuse the import and export sections to import and export tags, so could do do this for tag types as well? To make an attempt at answering my own question, I think the difference is that types are never imported or exported directly. Instead, imports and exports are done at a specific type defined in the module. This means all type definitions need to happen before any imports and exports. It's still not clear to me why imported items always get the beginning of the relevant index space. Was there a technical reason, or was it just that we needed to put them somewhere and the beginning is as good as any? |
@eholk, the function section also consists of only a "list of types", as do the memory and table sections. But they don't define types. The sections are grouped by what they define (here: exception tags), not what the respective classifiers are. As for indices of imports: yes, pretty much. I remember that we discussed several options for organising the index spaces (for example, V8's first Wasm prototype didn't have an import section but interleaved import entries in the other sections). In the end, every option just buys into a different trade-off with no clear winner. |
It's pretty clear at this point that the exception section is needed, so I'm going to close this issue. |
The type section currently prefixes each function type by the byte
0x60
. It sounds like this was looking to a time when there would be more kinds of types than just functions. Would it make sense to move the exception definitions into the type section rather than defining a whole new section?The text was updated successfully, but these errors were encountered: