@@ -625,10 +625,11 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
625
625
let lbl_sort = Jkind. sort_of_jkind lbl.lbl_jkind in
626
626
check_record_field_sort id.loc lbl_sort;
627
627
begin match lbl.lbl_repres with
628
- Record_boxed _ | Record_inlined (_ , Variant_boxed _ ) ->
628
+ Record_boxed _
629
+ | Record_inlined (_ , Constructor_uniform_value, Variant_boxed _ ) ->
629
630
Lprim (Pfield (lbl.lbl_pos, maybe_pointer e, sem), [targ],
630
631
of_location ~scopes e.exp_loc)
631
- | Record_unboxed | Record_inlined (_ , Variant_unboxed) -> targ
632
+ | Record_unboxed | Record_inlined (_ , _ , Variant_unboxed) -> targ
632
633
| Record_float ->
633
634
let alloc_mode =
634
635
match float with
@@ -641,10 +642,18 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
641
642
| Record_ufloat ->
642
643
Lprim (Pufloatfield (lbl.lbl_pos, sem), [targ],
643
644
of_location ~scopes e.exp_loc)
644
- | Record_inlined (_ , Variant_extensible) ->
645
+ | Record_inlined (_ , Constructor_uniform_value, Variant_extensible) ->
645
646
Lprim (Pfield (lbl.lbl_pos + 1 , maybe_pointer e, sem), [targ],
646
647
of_location ~scopes e.exp_loc)
647
- | Record_mixed { value_prefix_len; flat_suffix } ->
648
+ | Record_inlined (_ , Constructor_mixed _ , Variant_extensible) ->
649
+ (* CR layouts v5.9: support this *)
650
+ fatal_error
651
+ " Mixed inlined records not supported for extensible variants"
652
+ | Record_inlined (_, Constructor_mixed shape, Variant_boxed _)
653
+ | Record_mixed shape ->
654
+ let ({ value_prefix_len; flat_suffix } : mixed_product_shape ) =
655
+ shape
656
+ in
648
657
let read =
649
658
if lbl.lbl_num < value_prefix_len then
650
659
Mread_value_prefix (maybe_pointer e)
@@ -682,15 +691,23 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
682
691
let access =
683
692
match lbl.lbl_repres with
684
693
Record_boxed _
685
- | Record_inlined (_ , Variant_boxed _ ) ->
694
+ | Record_inlined (_ , Constructor_uniform_value, Variant_boxed _ ) ->
686
695
Psetfield (lbl.lbl_pos, maybe_pointer newval, mode)
687
- | Record_unboxed | Record_inlined (_ , Variant_unboxed) ->
696
+ | Record_unboxed | Record_inlined (_ , _ , Variant_unboxed) ->
688
697
assert false
689
698
| Record_float -> Psetfloatfield (lbl.lbl_pos, mode)
690
699
| Record_ufloat -> Psetufloatfield (lbl.lbl_pos, mode)
691
- | Record_inlined (_ , Variant_extensible) ->
700
+ | Record_inlined (_ , Constructor_uniform_value, Variant_extensible) ->
692
701
Psetfield (lbl.lbl_pos + 1 , maybe_pointer newval, mode)
693
- | Record_mixed { value_prefix_len; flat_suffix } -> begin
702
+ | Record_inlined (_ , Constructor_mixed _ , Variant_extensible) ->
703
+ (* CR layouts v5.9: support this *)
704
+ fatal_error
705
+ " Mixed inlined records not supported for extensible variants"
706
+ | Record_inlined (_, Constructor_mixed shape, Variant_boxed _)
707
+ | Record_mixed shape -> begin
708
+ let ({ value_prefix_len; flat_suffix } : mixed_product_shape ) =
709
+ shape
710
+ in
694
711
let write =
695
712
if lbl.lbl_num < value_prefix_len then
696
713
Mwrite_value_prefix (maybe_pointer newval)
@@ -1782,18 +1799,27 @@ and transl_record ~scopes loc env mode fields repres opt_init_expr =
1782
1799
in
1783
1800
let access =
1784
1801
match repres with
1785
- Record_boxed _ | Record_inlined (_ , Variant_boxed _ ) ->
1802
+ Record_boxed _
1803
+ | Record_inlined (_ , Constructor_uniform_value, Variant_boxed _ ) ->
1786
1804
Pfield (i, maybe_pointer_type env typ, sem)
1787
- | Record_unboxed | Record_inlined (_ , Variant_unboxed) ->
1805
+ | Record_unboxed | Record_inlined (_ , _ , Variant_unboxed) ->
1788
1806
assert false
1789
- | Record_inlined (_ , Variant_extensible) ->
1807
+ | Record_inlined (_ , Constructor_uniform_value, Variant_extensible) ->
1790
1808
Pfield (i + 1 , maybe_pointer_type env typ, sem)
1809
+ | Record_inlined (_ , Constructor_mixed _ , Variant_extensible) ->
1810
+ (* CR layouts v5.9: support this *)
1811
+ fatal_error
1812
+ " Mixed inlined records not supported for extensible variants"
1791
1813
| Record_float ->
1792
1814
(* This allocation is always deleted,
1793
1815
so it's simpler to leave it Alloc_heap *)
1794
1816
Pfloatfield (i, sem, alloc_heap)
1795
1817
| Record_ufloat -> Pufloatfield (i, sem)
1796
- | Record_mixed { value_prefix_len; flat_suffix } ->
1818
+ | Record_inlined (_, Constructor_mixed shape, Variant_boxed _)
1819
+ | Record_mixed shape ->
1820
+ let { value_prefix_len; flat_suffix } : mixed_product_shape =
1821
+ shape
1822
+ in
1797
1823
let read =
1798
1824
if lbl.lbl_num < value_prefix_len then
1799
1825
Mread_value_prefix (maybe_pointer_type env typ)
@@ -1833,47 +1859,61 @@ and transl_record ~scopes loc env mode fields repres opt_init_expr =
1833
1859
let cl = List. map extract_constant ll in
1834
1860
match repres with
1835
1861
| Record_boxed _ -> Lconst (Const_block (0 , cl))
1836
- | Record_inlined (Ordinary {runtime_tag} , Variant_boxed _ ) ->
1862
+ | Record_inlined (Ordinary {runtime_tag},
1863
+ Constructor_uniform_value , Variant_boxed _) ->
1837
1864
Lconst (Const_block (runtime_tag, cl))
1838
- | Record_unboxed | Record_inlined (_ , Variant_unboxed) ->
1865
+ | Record_unboxed | Record_inlined (_ , _ , Variant_unboxed) ->
1839
1866
Lconst (match cl with [v] -> v | _ -> assert false )
1840
1867
| Record_float ->
1841
1868
Lconst (Const_float_block (List. map extract_float cl))
1869
+ | Record_inlined (_, Constructor_mixed _, Variant_boxed _)
1842
1870
| Record_ufloat | Record_mixed _ ->
1843
1871
(* CR layouts v5.1: We should support structured constants for
1844
1872
blocks containing unboxed float literals.
1845
1873
*)
1846
1874
raise Not_constant
1847
- | Record_inlined (_, Variant_extensible )
1848
- | Record_inlined (Extension _ , _ ) ->
1875
+ | Record_inlined (_, _, Variant_extensible )
1876
+ | Record_inlined (Extension _ , _ , _ ) ->
1849
1877
raise Not_constant
1850
1878
with Not_constant ->
1851
1879
let loc = of_location ~scopes loc in
1852
1880
match repres with
1853
1881
Record_boxed _ ->
1854
1882
let shape = List. map must_be_value shape in
1855
1883
Lprim (Pmakeblock (0 , mut, Some shape, Option. get mode), ll, loc)
1856
- | Record_inlined (Ordinary {runtime_tag} , Variant_boxed _ ) ->
1884
+ | Record_inlined (Ordinary {runtime_tag},
1885
+ Constructor_uniform_value , Variant_boxed _) ->
1857
1886
let shape = List. map must_be_value shape in
1858
1887
Lprim (Pmakeblock (runtime_tag, mut, Some shape, Option. get mode),
1859
1888
ll, loc)
1860
- | Record_unboxed | Record_inlined (Ordinary _ , Variant_unboxed) ->
1889
+ | Record_unboxed | Record_inlined (Ordinary _ , _ , Variant_unboxed) ->
1861
1890
(match ll with [v] -> v | _ -> assert false )
1862
1891
| Record_float ->
1863
1892
Lprim (Pmakefloatblock (mut, Option. get mode), ll, loc)
1864
1893
| Record_ufloat ->
1865
1894
Lprim (Pmakeufloatblock (mut, Option. get mode), ll, loc)
1866
- | Record_inlined (Extension (path , _ ), Variant_extensible) ->
1895
+ | Record_inlined (Extension _,
1896
+ Constructor_mixed _, Variant_extensible ) ->
1897
+ (* CR layouts v5.9: support this *)
1898
+ fatal_error
1899
+ " Mixed inlined records not supported for extensible variants"
1900
+ | Record_inlined (Extension (path, _),
1901
+ Constructor_uniform_value , Variant_extensible ) ->
1867
1902
let shape = List. map must_be_value shape in
1868
1903
let slot = transl_extension_path loc env path in
1869
1904
Lprim (Pmakeblock (0 , mut, Some (Pgenval :: shape), Option. get mode),
1870
1905
slot :: ll, loc)
1871
- | Record_inlined (Extension _, (Variant_unboxed | Variant_boxed _))
1872
- | Record_inlined (Ordinary _ , Variant_extensible) ->
1906
+ | Record_inlined (Extension _, _, (Variant_unboxed | Variant_boxed _))
1907
+ | Record_inlined (Ordinary _ , _ , Variant_extensible) ->
1873
1908
assert false
1874
1909
| Record_mixed shape ->
1875
1910
let shape = transl_mixed_product_shape shape in
1876
1911
Lprim (Pmakemixedblock (0 , mut, shape, Option. get mode), ll, loc)
1912
+ | Record_inlined (Ordinary { runtime_tag },
1913
+ Constructor_mixed shape, Variant_boxed _) ->
1914
+ let shape = transl_mixed_product_shape shape in
1915
+ Lprim (Pmakemixedblock (runtime_tag, mut, shape, Option. get mode),
1916
+ ll, loc)
1877
1917
in
1878
1918
begin match opt_init_expr with
1879
1919
None -> lam
@@ -1893,20 +1933,29 @@ and transl_record ~scopes loc env mode fields repres opt_init_expr =
1893
1933
| Overridden (_lid , expr ) ->
1894
1934
let upd =
1895
1935
match repres with
1896
- Record_boxed _ | Record_inlined (_ , Variant_boxed _ ) ->
1936
+ Record_boxed _
1937
+ | Record_inlined (_ , Constructor_uniform_value, Variant_boxed _ ) ->
1897
1938
let ptr = maybe_pointer expr in
1898
1939
Psetfield (lbl.lbl_pos, ptr, Assignment modify_heap)
1899
- | Record_unboxed | Record_inlined (_ , Variant_unboxed) ->
1940
+ | Record_unboxed | Record_inlined (_ , _ , Variant_unboxed) ->
1900
1941
assert false
1901
1942
| Record_float ->
1902
1943
Psetfloatfield (lbl.lbl_pos, Assignment modify_heap)
1903
1944
| Record_ufloat ->
1904
1945
Psetufloatfield (lbl.lbl_pos, Assignment modify_heap)
1905
- | Record_inlined (_ , Variant_extensible) ->
1946
+ | Record_inlined (_ , Constructor_uniform_value, Variant_extensible) ->
1906
1947
let pos = lbl.lbl_pos + 1 in
1907
1948
let ptr = maybe_pointer expr in
1908
1949
Psetfield (pos, ptr, Assignment modify_heap)
1909
- | Record_mixed { value_prefix_len; flat_suffix } -> begin
1950
+ | Record_inlined (_ , Constructor_mixed _ , Variant_extensible) ->
1951
+ (* CR layouts v5.9: support this *)
1952
+ fatal_error
1953
+ " Mixed inlined records not supported for extensible variants"
1954
+ | Record_inlined (_, Constructor_mixed shape, Variant_boxed _)
1955
+ | Record_mixed shape -> begin
1956
+ let { value_prefix_len; flat_suffix } : mixed_product_shape =
1957
+ shape
1958
+ in
1910
1959
let write =
1911
1960
if lbl.lbl_num < value_prefix_len then
1912
1961
let ptr = maybe_pointer expr in
0 commit comments