Skip to content

Allow Maybe_null jkinds in more places #2747

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 19 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions ocaml/jane/doc/extensions/unboxed-types/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ by a *type*. There is a small fixed set of layouts:
* `any` is a layout that is the superlayout of all other layouts. It doesn't correspond
to a specific runtime representation. More information [below](#the-any-layout).

* `value_or_null` is a superlayout of `value` including normal OCaml values
and null pointers. Unless `-extension-universe alpha` is set, it is displayed
as `value` and can't be used in jkind annotations.
* `any_non_null` is a sublayout of `any` forbidding null pointers. Unless
`-extension-universe alpha` is set, it is displayed as `any`.
Additionally, `any` jkind annotations are interpreted as `any_non_null` for
backwards compatibility for definitions using arrays.

Over time, we'll be adding more layouts here.

# Layout annotation
Expand Down Expand Up @@ -353,19 +361,19 @@ orders:

* Records
* Constructors

Unboxed numbers can't be put in these structures:

* Constructors with inline record fields
* Exceptions
* Extensible variant constructors
* Top-level fields of modules
* Tuples

There aren't fundamental issues with the structures that lack support. They will
just take some work to implement.

Here's an example of a record with an unboxed field. We call such a record
Here's an example of a record with an unboxed field. We call such a record
a "mixed record".

```ocaml
Expand Down Expand Up @@ -429,7 +437,7 @@ These operations aren't supported:
* polymorphic comparison and equality
* polymorphic hash
* marshaling

These operations raise an exception at runtime, similar to how polymorphic
comparison raises when called on a function.

Expand All @@ -453,7 +461,7 @@ scanned by the garbage collector.
[^can-or-must]: "Can-or-must" is a bit of a mouthful, but it captures the right nuance. Pointer values *must* be scanned, unboxed number fields *must* be skipped, and immediate values *can* be scanned or skipped.

The ordering constraint on structure fields is a reflection of the same
ordering restriction in the runtime representation.
ordering restriction in the runtime representation.

## C bindings for mixed blocks

Expand Down
3 changes: 0 additions & 3 deletions ocaml/testsuite/tests/typing-layouts-arrays/basics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
include stdlib_upstream_compatible;
flambda2;
{
flags = "-extension layouts_alpha -extension small_numbers";
expect;
}{
flags = "-extension layouts_beta -extension small_numbers";
expect;
}{
Expand Down
Loading
Loading