@@ -44,7 +44,7 @@ let check_join_inputs ~env_at_fork _envs_with_levels ~params
4444 extra_lifted_consts_in_use_envs
4545
4646let cut_and_n_way_join definition_typing_env ts_and_use_ids ~params ~cut_after
47- ~extra_lifted_consts_in_use_envs ~ extra_allowed_names : _ =
47+ ~extra_lifted_consts_in_use_envs =
4848 let params = Bound_parameters. to_list params in
4949 check_join_inputs ~env_at_fork: definition_typing_env ts_and_use_ids ~params
5050 ~extra_lifted_consts_in_use_envs ;
@@ -53,61 +53,63 @@ let cut_and_n_way_join definition_typing_env ts_and_use_ids ~params ~cut_after
5353 ~n_way_join_type: Meet_and_n_way_join. n_way_join definition_typing_env
5454 ~cut_after ts
5555
56- let ignore_names =
57- String. split_on_char ','
58- (Option. value ~default: " "
59- (Sys. getenv_opt " FLAMBDA2_JOIN_DEBUG_IGNORE_NAMES" ))
60-
61- let cut_and_n_way_join_checked definition_typing_env ts_and_use_ids ~params
62- ~cut_after ~extra_lifted_consts_in_use_envs ~extra_allowed_names =
63- let scope = TE. current_scope definition_typing_env in
64- let typing_env = TE. increment_scope definition_typing_env in
65- let old_joined_env =
66- Join_levels_old. cut_and_n_way_join typing_env ts_and_use_ids ~params
67- ~cut_after ~extra_lifted_consts_in_use_envs ~extra_allowed_names
68- in
69- let old_joined_level = TE. cut old_joined_env ~cut_after: scope in
70- let new_joined_env =
71- cut_and_n_way_join typing_env ts_and_use_ids ~params ~cut_after
72- ~extra_lifted_consts_in_use_envs ~extra_allowed_names
73- in
74- let new_joined_level = TE. cut new_joined_env ~cut_after: scope in
75- (let distinct_names =
76- Equal_types_for_debug. names_with_non_equal_types_level_ignoring_name_mode
77- ~meet_type: Meet_and_join. meet_type typing_env old_joined_level
78- new_joined_level
79- in
80- let distinct_names =
81- Name.Set. filter
82- (fun name ->
83- match Name. must_be_var_opt name with
84- | Some var ->
85- let raw_name = Variable. raw_name var in
86- not (List. exists (String. equal raw_name) ignore_names)
87- | None -> true )
88- distinct_names
89- in
90- if not (Name.Set. is_empty distinct_names)
91- then (
92- Format. eprintf " @[<v 1>%s Distinct joins %s@ " (String. make 22 '=' )
93- (String. make 22 '=' );
94- if Flambda_features. debug_flambda2 ()
95- then
96- List. iteri
97- (fun i (t , _ , _ ) ->
98- let level = TE. cut t ~cut_after in
99- Format. eprintf " @[<v 1>-- Level %d --@ %a@]@ " i TEL. print level)
100- ts_and_use_ids;
101- Format. eprintf " @[<v 1>-- Old join --@ %a@]@ " TEL. print old_joined_level;
102- Format. eprintf " @[<v 1>-- New join --@ %a@]@ " TEL. print new_joined_level;
103- Format. eprintf " @[Names with distinct types:@ %a@]" Name.Set. print
104- distinct_names;
105- Format. eprintf " @]@\n %s@." (String. make 60 '=' )));
106- TE. add_env_extension_from_level definition_typing_env new_joined_level
107- ~meet_type: Meet_and_join. meet_type
108-
109- let cut_and_n_way_join =
110- match Sys. getenv " FLAMBDA2_JOIN_ALGORITHM" with
111- | "old" -> Join_levels_old. cut_and_n_way_join
112- | "checked" -> cut_and_n_way_join_checked
113- | _ | (exception Not_found) -> cut_and_n_way_join
56+ let cut_and_n_way_join definition_typing_env ts_and_use_ids ~params ~cut_after
57+ ~extra_lifted_consts_in_use_envs ~extra_allowed_names =
58+ match Flambda_features. join_algorithm () with
59+ | Binary ->
60+ Join_levels_old. cut_and_n_way_join definition_typing_env ts_and_use_ids
61+ ~params ~cut_after ~extra_lifted_consts_in_use_envs ~extra_allowed_names
62+ | N_way ->
63+ cut_and_n_way_join definition_typing_env ts_and_use_ids ~params ~cut_after
64+ ~extra_lifted_consts_in_use_envs
65+ | Checked ->
66+ let ignore_names =
67+ String. split_on_char ','
68+ (Option. value ~default: " "
69+ (Sys. getenv_opt " FLAMBDA2_JOIN_DEBUG_IGNORE_NAMES" ))
70+ in
71+ let scope = TE. current_scope definition_typing_env in
72+ let typing_env = TE. increment_scope definition_typing_env in
73+ let old_joined_env =
74+ Join_levels_old. cut_and_n_way_join typing_env ts_and_use_ids ~params
75+ ~cut_after ~extra_lifted_consts_in_use_envs ~extra_allowed_names
76+ in
77+ let old_joined_level = TE. cut old_joined_env ~cut_after: scope in
78+ let new_joined_env =
79+ cut_and_n_way_join typing_env ts_and_use_ids ~params ~cut_after
80+ ~extra_lifted_consts_in_use_envs
81+ in
82+ let new_joined_level = TE. cut new_joined_env ~cut_after: scope in
83+ (let distinct_names =
84+ Equal_types_for_debug. names_with_non_equal_types_level_ignoring_name_mode
85+ ~meet_type: (Meet. meet_type () ) typing_env old_joined_level
86+ new_joined_level
87+ in
88+ let distinct_names =
89+ Name.Set. filter
90+ (fun name ->
91+ match Name. must_be_var_opt name with
92+ | Some var ->
93+ let raw_name = Variable. raw_name var in
94+ not (List. exists (String. equal raw_name) ignore_names)
95+ | None -> true )
96+ distinct_names
97+ in
98+ if not (Name.Set. is_empty distinct_names)
99+ then (
100+ Format. eprintf " @[<v 1>%s Distinct joins %s@ " (String. make 22 '=' )
101+ (String. make 22 '=' );
102+ if Flambda_features. debug_flambda2 ()
103+ then
104+ List. iteri
105+ (fun i (t , _ , _ ) ->
106+ let level = TE. cut t ~cut_after in
107+ Format. eprintf " @[<v 1>-- Level %d --@ %a@]@ " i TEL. print level)
108+ ts_and_use_ids;
109+ Format. eprintf " @[<v 1>-- Old join --@ %a@]@ " TEL. print old_joined_level;
110+ Format. eprintf " @[<v 1>-- New join --@ %a@]@ " TEL. print new_joined_level;
111+ Format. eprintf " @[Names with distinct types:@ %a@]" Name.Set. print
112+ distinct_names;
113+ Format. eprintf " @]@\n %s@." (String. make 60 '=' )));
114+ TE. add_env_extension_from_level definition_typing_env new_joined_level
115+ ~meet_type: (Meet. meet_type () )
0 commit comments