-
Notifications
You must be signed in to change notification settings - Fork 810
[Custom Descriptors] Handle a null descriptor in Heap2Local #7915
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why this is necessary. If ref.get_desc
would return a null, then the original allocation that installed the null descriptor would already have trapped, so the ref.get_desc
will never be reached.
But the type is not right. We cannot return |
;; CHECK-NEXT: (block (result nullref) | ||
;; CHECK-NEXT: (local.set $1 | ||
;; CHECK-NEXT: (ref.as_non_null | ||
;; CHECK-NEXT: (ref.null none) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This traps, as you say. But the ref.null below is what determines the type of the entire expression, and it is wrong without the unreachable this PR appends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, thanks. So another solution would be to add a ref.as_non_null, but adding unreachable is no more complex and gives better results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could ref.as_non_null
work? It just affects nullability, but the problem is we can't return an exact descriptor since we don't have one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But none <: (exact $desc)
, so the only problem here is the nullability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, I forgot exact types do have one subtype...
The type must change to unreachable in this case: the
ref.get_desc
will not return a descriptor of the proper type, and we trap.
Found by #7913