Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove type annotations on ref.as_non_null and br_on_null #31

Merged
merged 2 commits into from
Jun 15, 2020

Conversation

rossberg
Copy link
Member

Following WebAssembly/reference-types#99 and addressing issue #27, this removes the type annotations from ref.as_non_null and br_on_null (they already were absent on call_ref and func.bind).

One small caveat is that this requires extending the bottom type to a bottom heap type, to be able to type an unknown reference type in an instruction output.

@rossberg
Copy link
Member Author

rossberg commented Jun 10, 2020

@jakobkummerow, @lars-t-hansen, let me know if you think this looks reasonable.

(See the pseudo code algorithm in the appendix to get an impression of how it affects a validator.)

@jakobkummerow
Copy link
Contributor

Looks reasonable.

@RossTate
Copy link

Wait, what bottom type?

@lars-t-hansen
Copy link
Contributor

Looks plausible.

@taralx
Copy link

taralx commented Jun 12, 2020

Wait, what bottom type?

Polymorphic type used when stack underflows in unreachable code.

@taralx
Copy link

taralx commented Jun 12, 2020

Is Ref(Bot, false) just simpler to implement than Bot, or is there some other consideration?

@taralx
Copy link

taralx commented Jun 12, 2020

(did anyone notice that matches is not symmetric w.r.t. Bot?)

@RossTate
Copy link

I can't find anything about a bottom type in the overview. Where should I look for more details about it?

@taralx
Copy link

taralx commented Jun 12, 2020

If I understand the history correctly:

Added as Unknown in WebAssembly/reference-types#3.
Renamed to Bot in WebAssembly/reference-types#43.
Removed from reference-types along with subtyping in WebAssembly/reference-types#87.

@RossTate
Copy link

Oh, nullref? But the current overview says ref.null ht: [] -> [(ref null ht)]. I'm confused.

@taralx
Copy link

taralx commented Jun 13, 2020

No, not nullref. That's not polymorphic. There is no way to instantiate the bottom type in real code -- it is a placeholder that exists only during validation.

@RossTate
Copy link

Oh, I see. It’s not part of the spec; it’s just a device used in the reference implementation. Is that right?

@taralx
Copy link

taralx commented Jun 14, 2020

I believe so, but I'll let @rossberg confirm.

@rossberg
Copy link
Member Author

It will appear in the spec, but only as an internal type. You cannot use it in a program. Similar as with the bottom value type that was previously in the reftypes proposal.

@rossberg
Copy link
Member Author

@taralx:

Is Ref(Bot, false) just simpler to implement than Bot, or is there some other consideration?

You'll need both. The latter matches any value type whatsoever, the former only reference types. When you have determined that an operand is a ref type you must not lose that information. Rules out

(unreachable)
(ref.as_non_null)
(i32.add)

(cf. unreached-invalid.wast)

(did anyone notice that matches is not symmetric w.r.t. Bot?)

It shouldn't be. It's a bottom type, not a top type.

@RossTate
Copy link

Got it. Thanks for the explanation!

@taralx
Copy link

taralx commented Jun 15, 2020

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants