Skip to content

Commit ae1a0dd

Browse files
committed
Revert "Add typing hack (for testing only)"
This reverts commit 7dd2282.
1 parent 7dd2282 commit ae1a0dd

File tree

5 files changed

+3
-436
lines changed

5 files changed

+3
-436
lines changed

ocaml/lambda/translprim.ml

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ type prim =
9494
| Identity
9595
| Apply of Lambda.region_close * Lambda.layout
9696
| Revapply of Lambda.region_close * Lambda.layout
97-
| Void
9897

9998
let units_with_used_primitives = Hashtbl.create 7
10099
let add_used_primitive loc env path =
@@ -141,14 +140,6 @@ let to_modify_mode ~poly = function
141140
| None -> assert false
142141
| Some mode -> transl_modify_mode mode
143142

144-
let layout_unboxed_pair_of_values =
145-
Punboxed_product [Pvalue Pgenval; Pvalue Pgenval]
146-
147-
let two_unboxed_pairs_of_values =
148-
[ layout_unboxed_pair_of_values;
149-
layout_unboxed_pair_of_values;
150-
]
151-
152143
let lookup_primitive loc poly pos p =
153144
let mode = to_locality ~poly p.prim_native_repr_res in
154145
let arg_modes = List.map (to_modify_mode ~poly) p.prim_native_repr_args in
@@ -428,40 +419,6 @@ let lookup_primitive loc poly pos p =
428419
| "%unbox_float" -> Primitive(Punbox_float, 1)
429420
| "%box_float" -> Primitive(Pbox_float mode, 1)
430421
| "%get_header" -> Primitive (Pget_header mode, 1)
431-
(* unboxed pairs of void *)
432-
| "%make_unboxed_pair_o_o" ->
433-
Primitive(Pmake_unboxed_product [Punboxed_product []; Punboxed_product []], 2)
434-
| "%unboxed_pair_field_0_o_o" ->
435-
Primitive(Punboxed_product_field (0, [Punboxed_product []; Punboxed_product []]), 1)
436-
| "%unboxed_pair_field_1_o_o" ->
437-
Primitive(Punboxed_product_field (1, [Punboxed_product []; Punboxed_product []]), 1)
438-
(* unboxed pairs of values *)
439-
| "%make_unboxed_pair_v_v" ->
440-
Primitive(Pmake_unboxed_product [Pvalue Pgenval; Pvalue Pgenval], 2)
441-
| "%unboxed_pair_field_0_v_v" ->
442-
Primitive(Punboxed_product_field (0, [Pvalue Pgenval; Pvalue Pgenval]), 1)
443-
| "%unboxed_pair_field_1_v_v" ->
444-
Primitive(Punboxed_product_field (1, [Pvalue Pgenval; Pvalue Pgenval]), 1)
445-
(* unboxed pairs of immediates *)
446-
| "%make_unboxed_pair_i_i" ->
447-
Primitive(Pmake_unboxed_product [Pvalue Pintval; Pvalue Pintval], 2)
448-
| "%unboxed_pair_field_0_i_i" ->
449-
Primitive(Punboxed_product_field (0, [Pvalue Pintval; Pvalue Pintval]), 1)
450-
| "%unboxed_pair_field_1_i_i" ->
451-
Primitive(Punboxed_product_field (1, [Pvalue Pintval; Pvalue Pintval]), 1)
452-
(* unboxed pairs of (unboxed pairs of values) *)
453-
| "%make_unboxed_pair_vup_vup" ->
454-
Primitive(Pmake_unboxed_product [layout_unboxed_pair_of_values; layout_unboxed_pair_of_values], 2)
455-
| "%unboxed_pair_field_0_vup_vup" ->
456-
Primitive(Punboxed_product_field (0, two_unboxed_pairs_of_values), 1)
457-
| "%unboxed_pair_field_1_vup_vup" ->
458-
Primitive(Punboxed_product_field (1, two_unboxed_pairs_of_values), 1)
459-
(* unboxed triples (void, int, void) *)
460-
| "%make_unboxed_triple_o_i_o" ->
461-
Primitive(Pmake_unboxed_product [Punboxed_product []; Pvalue Pintval; Punboxed_product []], 3)
462-
(* void is special as the external is declared to have one parameter
463-
but the primitive takes zero arguments *)
464-
| "%void" -> Void
465422
| s when String.length s > 0 && s.[0] = '%' ->
466423
raise(Error(loc, Unknown_builtin_primitive s))
467424
| _ -> External p
@@ -889,7 +846,6 @@ let lambda_of_prim prim_name prim loc args arg_exps =
889846
ap_region_close = pos;
890847
ap_mode = alloc_heap;
891848
}
892-
| Void, _ -> Lprim (Pmake_unboxed_product [], [], loc)
893849
| (Raise _ | Raise_with_backtrace
894850
| Lazy_force _ | Loc _ | Primitive _ | Sys_argv | Comparison _
895851
| Send _ | Send_self _ | Send_cache _ | Frame_pointers | Identity
@@ -918,7 +874,6 @@ let check_primitive_arity loc p =
918874
| Frame_pointers -> p.prim_arity = 0
919875
| Identity -> p.prim_arity = 1
920876
| Apply _ | Revapply _ -> p.prim_arity = 2
921-
| Void -> true
922877
in
923878
if not ok then raise(Error(loc, Wrong_arity_builtin_primitive p.prim_name))
924879

@@ -1040,7 +995,7 @@ let primitive_needs_event_after = function
1040995
lambda_primitive_needs_event_after (comparison_primitive comp knd)
1041996
| Lazy_force _ | Send _ | Send_self _ | Send_cache _
1042997
| Apply _ | Revapply _ -> true
1043-
| Raise _ | Raise_with_backtrace | Loc _ | Frame_pointers | Identity | Void -> false
998+
| Raise _ | Raise_with_backtrace | Loc _ | Frame_pointers | Identity -> false
1044999

10451000
let transl_primitive_application loc p env ty mode path exp args arg_exps pos =
10461001
let prim =

ocaml/typing/predef.ml

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ and ident_int64x2 = ident_create "int64x2"
5656
and ident_float32x4 = ident_create "float32x4"
5757
and ident_float64x2 = ident_create "float64x2"
5858

59-
and ident_unboxed_pair = ident_create "unboxed_pair"
60-
and ident_unboxed_triple = ident_create "unboxed_triple"
61-
and ident_real_void = ident_create "void"
62-
6359
let path_int = Pident ident_int
6460
and path_char = Pident ident_char
6561
and path_bytes = Pident ident_bytes
@@ -87,10 +83,6 @@ and path_int64x2 = Pident ident_int64x2
8783
and path_float32x4 = Pident ident_float32x4
8884
and path_float64x2 = Pident ident_float64x2
8985

90-
and path_unboxed_pair = Pident ident_unboxed_pair
91-
and path_unboxed_triple = Pident ident_unboxed_triple
92-
and path_void = Pident ident_real_void
93-
9486
let type_int = newgenty (Tconstr(path_int, [], ref Mnil))
9587
and type_char = newgenty (Tconstr(path_char, [], ref Mnil))
9688
and type_bytes = newgenty (Tconstr(path_bytes, [], ref Mnil))
@@ -222,55 +214,6 @@ let common_initial_env add_type add_extension empty_env =
222214
}
223215
in
224216
add_type type_ident decl env
225-
and add_type2 type_ident
226-
?(kind=fun _ -> Type_abstract)
227-
?(layout=Layout.value ~why:(Primitive type_ident))
228-
~variance ~separability env =
229-
let param0 = newgenvar (Layout.value ~why:Type_argument) in
230-
let param1 = newgenvar (Layout.value ~why:Type_argument) in
231-
let decl =
232-
{type_params = [param0; param1];
233-
type_arity = 2;
234-
type_kind = kind param0;
235-
type_layout = layout;
236-
type_loc = Location.none;
237-
type_private = Asttypes.Public;
238-
type_manifest = None;
239-
type_variance = [variance; variance];
240-
type_separability = [separability; separability];
241-
type_is_newtype = false;
242-
type_expansion_scope = lowest_level;
243-
type_attributes = [];
244-
type_unboxed_default = false;
245-
type_uid = Uid.of_predef_id type_ident;
246-
}
247-
in
248-
add_type type_ident decl env
249-
and add_type3 type_ident
250-
?(kind=fun _ -> Type_abstract)
251-
?(layout=Layout.value ~why:(Primitive type_ident))
252-
~variance ~separability env =
253-
let param0 = newgenvar (Layout.value ~why:Type_argument) in
254-
let param1 = newgenvar (Layout.value ~why:Type_argument) in
255-
let param2 = newgenvar (Layout.value ~why:Type_argument) in
256-
let decl =
257-
{type_params = [param0; param1; param2];
258-
type_arity = 3;
259-
type_kind = kind param0;
260-
type_layout = layout;
261-
type_loc = Location.none;
262-
type_private = Asttypes.Public;
263-
type_manifest = None;
264-
type_variance = [variance; variance; variance];
265-
type_separability = [separability; separability; separability];
266-
type_is_newtype = false;
267-
type_expansion_scope = lowest_level;
268-
type_attributes = [];
269-
type_unboxed_default = false;
270-
type_uid = Uid.of_predef_id type_ident;
271-
}
272-
in
273-
add_type type_ident decl env
274217
in
275218
let add_extension id args layouts =
276219
add_extension id
@@ -338,13 +281,6 @@ let common_initial_env add_type add_extension empty_env =
338281
|> add_type ident_unit
339282
~kind:(variant [cstr ident_void []] [| [| |] |])
340283
~layout:(Layout.immediate ~why:Enumeration)
341-
|> add_type2 ident_unboxed_pair
342-
~variance:Variance.covariant
343-
~separability:Separability.Ind
344-
|> add_type3 ident_unboxed_triple
345-
~variance:Variance.covariant
346-
~separability:Separability.Ind
347-
|> add_type ident_real_void
348284
(* Predefined exceptions - alphabetical order *)
349285
|> add_extension ident_assert_failure
350286
[newgenty (Ttuple[type_string; type_int; type_int])]

ocaml/typing/predef.mli

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ val path_int64x2: Path.t
7171
val path_float32x4: Path.t
7272
val path_float64x2: Path.t
7373

74-
val path_unboxed_pair: Path.t
75-
val path_unboxed_triple: Path.t
76-
val path_void: Path.t
77-
7874
val path_match_failure: Path.t
7975
val path_invalid_argument: Path.t
8076
val path_assert_failure : Path.t

ocaml/typing/typeopt.ml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -553,25 +553,13 @@ let value_kind env loc ty =
553553
with
554554
| Missing_cmi_fallback -> raise (Error (loc, Non_value_layout (ty, None)))
555555

556-
let rec layout env loc sort ty =
556+
let layout env loc sort ty =
557557
match Layouts.Sort.get_default_value sort with
558+
| Value -> Lambda.Pvalue (value_kind env loc ty)
558559
| Float64 when Language_extension.(is_at_least Layouts Alpha) ->
559560
Lambda.Punboxed_float
560561
| Float64 -> raise (Error (loc, Non_value_sort (Sort.float64,ty)))
561562
| Void -> raise (Error (loc, Non_value_sort (Sort.void,ty)))
562-
| Value ->
563-
match get_desc (scrape_ty env ty) with
564-
| Tconstr(p, args, _) when Path.same p Predef.path_unboxed_pair ->
565-
let layouts = List.map (layout env loc Layouts.Sort.value) args in
566-
Punboxed_product layouts
567-
| Tconstr(p, args, _) when Path.same p Predef.path_unboxed_triple ->
568-
let layouts = List.map (layout env loc Layouts.Sort.value) args in
569-
Punboxed_product layouts
570-
| Tconstr(p, _, _) when Path.same p Predef.path_void ->
571-
Punboxed_product []
572-
| _ ->
573-
Lambda.Pvalue (value_kind env loc ty)
574-
575563

576564
let layout_of_sort loc sort =
577565
match Layouts.Sort.get_default_value sort with

0 commit comments

Comments
 (0)