Skip to content

Commit bb081b4

Browse files
flambda-backend: Allow Maybe_null jkinds in more places (#2747)
* Tests * `Or_null` sort variables * `Value_or_null` creation reasons * `Any_non_null` creation reasons * Accept or-null tests * Change comment * Hide nullability in jkinds if layouts is not at level alpha * Fix printing error * Improve printing; comments; formatting * Split basics tests with and without alpha * lessen diff * fixes * Fix rebase * Promote test * format * fix * promote tests * Document hiding/substitutions * `concrete_default` -> `concrete_legacy` --------- Co-authored-by: Diana Kalinichenko <dkalinichenko@janestreet.com>
1 parent b98d6a1 commit bb081b4

File tree

34 files changed

+3008
-257
lines changed

34 files changed

+3008
-257
lines changed

jane/doc/extensions/unboxed-types/index.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ by a *type*. There is a small fixed set of layouts:
3636
* `any` is a layout that is the superlayout of all other layouts. It doesn't correspond
3737
to a specific runtime representation. More information [below](#the-any-layout).
3838

39+
* `value_or_null` is a superlayout of `value` including normal OCaml values
40+
and null pointers. Unless `-extension-universe alpha` is set, it is displayed
41+
as `value` and can't be used in jkind annotations.
42+
* `any_non_null` is a sublayout of `any` forbidding null pointers. Unless
43+
`-extension-universe alpha` is set, it is displayed as `any`.
44+
Additionally, `any` jkind annotations are interpreted as `any_non_null` for
45+
backwards compatibility for definitions using arrays.
46+
3947
Over time, we'll be adding more layouts here.
4048

4149
# Layout annotation
@@ -353,19 +361,19 @@ orders:
353361

354362
* Records
355363
* Constructors
356-
364+
357365
Unboxed numbers can't be put in these structures:
358366

359367
* Constructors with inline record fields
360368
* Exceptions
361369
* Extensible variant constructors
362370
* Top-level fields of modules
363371
* Tuples
364-
372+
365373
There aren't fundamental issues with the structures that lack support. They will
366374
just take some work to implement.
367375

368-
Here's an example of a record with an unboxed field. We call such a record
376+
Here's an example of a record with an unboxed field. We call such a record
369377
a "mixed record".
370378

371379
```ocaml
@@ -429,7 +437,7 @@ These operations aren't supported:
429437
* polymorphic comparison and equality
430438
* polymorphic hash
431439
* marshaling
432-
440+
433441
These operations raise an exception at runtime, similar to how polymorphic
434442
comparison raises when called on a function.
435443

@@ -453,7 +461,7 @@ scanned by the garbage collector.
453461
[^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.
454462

455463
The ordering constraint on structure fields is a reflection of the same
456-
ordering restriction in the runtime representation.
464+
ordering restriction in the runtime representation.
457465

458466
## C bindings for mixed blocks
459467

testsuite/tests/typing-layouts-arrays/basics.ml

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
include stdlib_upstream_compatible;
33
flambda2;
44
{
5-
flags = "-extension layouts_alpha -extension small_numbers";
6-
expect;
7-
}{
85
flags = "-extension layouts_beta -extension small_numbers";
96
expect;
107
}{

0 commit comments

Comments
 (0)