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

Is the exception section needed? #26

Closed
eholk opened this issue Aug 15, 2017 · 8 comments
Closed

Is the exception section needed? #26

eholk opened this issue Aug 15, 2017 · 8 comments

Comments

@eholk
Copy link
Contributor

eholk commented Aug 15, 2017

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?

@eholk
Copy link
Contributor Author

eholk commented Aug 15, 2017

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.

@jfbastien
Copy link
Member

Why are they supposed to get the lowest number IDs?

@eholk
Copy link
Contributor Author

eholk commented Aug 15, 2017

Apparently that's the way everything else has done it.

@jfbastien
Copy link
Member

That's not a reason, please clarify.

@rossberg
Copy link
Member

As I argued before, exception tags are values, not types. (According to my email archive, I had a more extensive explanation in an earlier comment on a PR #2 on this repo, but that seems to have vanished from GitHub somehow. I'm puzzled, was the original repo deleted?)

@eholk
Copy link
Contributor Author

eholk commented Aug 28, 2017

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?

@rossberg
Copy link
Member

@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.

@eholk
Copy link
Contributor Author

eholk commented Feb 15, 2018

It's pretty clear at this point that the exception section is needed, so I'm going to close this issue.

@eholk eholk closed this as completed Feb 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants