Handle indirectly JS-exposed types in Unsubtyping#8353
Conversation
We previously updated Unsubtyping to preserve prototype-configuring descriptors on types that are exposed to JS via JS-called functions, but we didn't handle the case where a supertype without a descriptor is exposed to JS, potentially exposing configured prototypes on its subtypes that do have descriptors. Fix this and also newly handle types exposed to JS via extern.convert_any.
| } | ||
| void visitRefAs(RefAs* curr) { | ||
| Super::visitRefAs(curr); | ||
| if (curr->op == ExternConvertAny && curr->value->type.isRef()) { |
| ) | ||
|
|
||
| ;; Since we assume with a closed world that the environment does not do | ||
| ;; anything to observe differences bewteen private subtypes and their public |
There was a problem hiding this comment.
| ;; anything to observe differences bewteen private subtypes and their public | |
| ;; anything to observe differences between private subtypes and their public |
|
|
||
| ;; CHECK: (global $private (ref null $private-sub) (ref.null none)) | ||
| (global $private (ref null $private-sub) (ref.null none)) | ||
| ) |
There was a problem hiding this comment.
I'm not quite sure I see how this last testcase relates to JS interop?
There was a problem hiding this comment.
We might have reasonably chosen to consider public types JS-exposed by default, in which case we would have had to keep the descriptor in this test case. But I decided not to do that for now. This test case documents that policy decision.
There was a problem hiding this comment.
I see, thanks. Perhaps add a note on that to the closed world comment in pass.h? Or maybe there's a better place.
There was a problem hiding this comment.
I expanded the comment on the test. PTAL!
There was a problem hiding this comment.
lgtm, but I still this we should document this in a more broad place like pass.h's closed-world docs? That can be separate from this PR if you want.
There was a problem hiding this comment.
I think this is already clear from the existing pass.h comment that "The outside may hold on to references and pass them back in, but may not inspect their contents, call them, or reflect on their types in any way." If we decided to change the behavior here, then it would make sense to update that comment to add a carve-out for reading configured prototypes.
|
|
||
| ;; CHECK: (global $private (ref null $private-sub) (ref.null none)) | ||
| (global $private (ref null $private-sub) (ref.null none)) | ||
| ) |
There was a problem hiding this comment.
lgtm, but I still this we should document this in a more broad place like pass.h's closed-world docs? That can be separate from this PR if you want.
We previously updated Unsubtyping to preserve prototype-configuring
descriptors on types that are exposed to JS via JS-called functions, but
we didn't handle the case where a supertype without a descriptor is
exposed to JS, potentially exposing configured prototypes on its
subtypes that do have descriptors. Fix this and also newly handle types
exposed to JS via extern.convert_any.