Skip to content

Separability axis basics #3854

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

Merged
merged 21 commits into from
May 16, 2025
Merged

Conversation

dkalinichenko-js
Copy link
Contributor

@dkalinichenko-js dkalinichenko-js commented Apr 15, 2025

Add the separability jkind axis. Separability is a shallow, non-modal axis going non_float < separable < non_separable, with non_float denoting types whose values are not pointers to Double_tag blocks, separable denoting types with either all values being pointers to Double_tag blocks or none, and non_separable denoting all types.

Add jkinds non_float_value, for non-float values, and immutable_separable_value, for floats. I'm not sold on the second jkind and will likely drop it from the final version of this PR.

Change other jkinds to non_float or separable where appropriate. In particular, default immutable_data to non_float. This will exclude floats from immutable_data, but will mark records, variants and other immutable_data types as non_float. Since immutable_data almost always appears in a covariant positions, this seems like the best choice.

Separability is a shallow axis, so it should not affect with-bounds. Semantics of separability for product layouts are to be determined, but it seems like all products should be non-float?

('a : non_float_value) or_null will be made non_float in a future PR.

t : non_separable_value will provide an escape hatch from existing OCaml separability checks (e.g. for existential) in a future PR. Those checks will also themselves take into account separability annotations.

any_non_null will be changed to any_separable, with arrays accepting any_separable elements, in a future PR.

@goldfirere
Copy link
Collaborator

Nice design write-up. For these comments, I have not looked at all at the implementation — just working through consequences of the design.

Should int64# be non-separable? After all, the type contains both pointers to heap-allocated floats, among other values. According to your definition, it probably should be non-separable, but my guess is that this would cause trouble. We could modify the definition to exclude non-values, and that would fix this little problem. But it also suggests we should never query the separability of non-values in the implementation. (I think this last sentence would be true without effort.)

So I continue to wonder about making separability a part of the value layout somehow. What currently happens with unboxed products of floats in arrays? My guess is that the constructing function for arrays does not do the float-check for non-values. This means that we could get an array full of heap-allocated floats by storing an unboxed product floats…. but my guess is that this is just fine. All that said, I’m not against going ahead with the design here: it’s probably easier to implement than making value more interesting. But maybe we should briefly discuss alternatives today.

@dkalinichenko-js dkalinichenko-js force-pushed the dkalinichenko/separability-axis branch from 44ea17c to 7f23c66 Compare April 17, 2025 17:54
@dkalinichenko-js dkalinichenko-js marked this pull request as ready for review April 17, 2025 18:30
@dkalinichenko-js
Copy link
Contributor Author

Note on mod bounds for immutable_data: we may rename immutable_data to plain_data or simple_data in a subsequent PR for more clarity.

@dkalinichenko-js dkalinichenko-js requested review from glittershark and goldfirere and removed request for glittershark April 17, 2025 19:23
@dkalinichenko-js dkalinichenko-js force-pushed the dkalinichenko/separability-axis branch from 7f23c66 to 500be1b Compare May 6, 2025 17:27
Copy link
Collaborator

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Sorry this took so long to review.

@dkalinichenko-js dkalinichenko-js force-pushed the dkalinichenko/separability-axis branch from 42d1ec4 to a59ae1f Compare May 15, 2025 16:01
@dkalinichenko-js dkalinichenko-js force-pushed the dkalinichenko/separability-axis branch from fce7b48 to 8a8d570 Compare May 15, 2025 16:33
Copy link
Collaborator

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed most recent commit

@goldfirere
Copy link
Collaborator

Small plea: unless there's a good reason, could you avoid rebasing while a patch is under active review? GitHub lacks a mechanism for me to know which commits I've reviewed and which I haven't, and rebasing clobbers the timeline (which would otherwise be such an indication). If/when rebasing is necessary, then it's helpful for commit messages to have some variability, just to use as identifiers (of course, rebasing changes the hash, so we need something to identify the commit). It can just be a little keyboard smash for all I care, but it gives a way of tracking commits across rebases. :) Thanks!

@dkalinichenko-js
Copy link
Contributor Author

Ack, sorry! I usually rebase when going back to the feature to avoid another review cycle for fixes due to the rebase, but I didn't consider the effect on your review.

I think GitHub can track which commits you reviewed though? At least I recall it keep tracking the new additions for me when I'm reviewing PRs. Maybe rebase breaks that?

@goldfirere
Copy link
Collaborator

Yes rebase breaks that. GitHub also tracks files that I've seen, but at a per-file granularity, which is only marginally useful.

(Rebasing the way you have does make sense! It's just too bad that GitHub doesn't accommodate that good workflow so well.)

@dkalinichenko-js dkalinichenko-js merged commit 61ae936 into main May 16, 2025
28 checks passed
@dkalinichenko-js dkalinichenko-js deleted the dkalinichenko/separability-axis branch May 16, 2025 16:56
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.

3 participants