text
stringlengths
12
786k
let depth_variable ( ) = fg_256 214
let error ( ) = fg_256 160
let elide ( ) = fg_256 243
let each_file ( ) = fg_256 51
let lambda ( ) = expr_keyword ( )
let flambda2_is_enabled ( ) = Clflags . is_flambda2 ( )
let with_default ( r : ' a Flambda_backend_flags . or_default ) ( ~ f : Flambda_backend_flags . Flambda2 . flags -> ' a ) = match r with | Set a -> a | Default -> f ( Flambda_backend_flags . Flambda2 . default_for_opt_level ! Flambda_backend_flags . opt_level )
let classic_mode ( ) = ! Flambda_backend_flags . Flambda2 . classic_mode |> with_default ~ f ( : fun d -> d . classic_mode )
let join_points ( ) = ! Flambda_backend_flags . Flambda2 . join_points |> with_default ~ f ( : fun d -> d . join_points )
let unbox_along_intra_function_control_flow ( ) = ! Flambda_backend_flags . Flambda2 . unbox_along_intra_function_control_flow |> with_default ~ f ( : fun d -> d . unbox_along_intra_function_control_flow )
let backend_cse_at_toplevel ( ) = ! Flambda_backend_flags . Flambda2 . backend_cse_at_toplevel |> with_default ~ f ( : fun d -> d . backend_cse_at_toplevel )
let cse_depth ( ) = ! Flambda_backend_flags . Flambda2 . cse_depth |> with_default ~ f ( : fun d -> d . cse_depth )
let join_depth ( ) = ! Flambda_backend_flags . Flambda2 . join_depth |> with_default ~ f ( : fun d -> d . join_depth )
let safe_string ( ) = Config . safe_string
let flat_float_array ( ) = Config . flat_float_array
let function_result_types ~ is_a_functor = let when_ = ! Flambda_backend_flags . Flambda2 . function_result_types |> with_default ~ f ( : fun d -> d . function_result_types ) in match when_ with | Never -> false | Functors_only -> is_a_functor | All_functions -> true
let debug ( ) = ! Clflags . debug
let opaque ( ) = ! Clflags . opaque
let float_const_prop ( ) = ! Clflags . float_const_prop
let optimize_for_speed ( ) = ! Clflags . optimize_for_speed
let inlining_report ( ) = ! Clflags . inlining_report
let inlining_report_bin ( ) = ! Flambda_backend_flags . Flambda2 . Inlining . report_bin
let colour ( ) = ! Clflags . color
let unicode ( ) = ! Flambda_backend_flags . Flambda2 . unicode |> with_default ~ f ( : fun d -> d . unicode )
let check_invariants ( ) = ! Clflags . flambda_invariant_checks
let dump_rawflambda ( ) = ! Clflags . dump_rawflambda
let dump_flambda ( ) = ! Clflags . dump_flambda
let dump_rawfexpr ( ) = ! Flambda_backend_flags . Flambda2 . Dump . rawfexpr
let dump_fexpr ( ) = ! Flambda_backend_flags . Flambda2 . Dump . fexpr
let dump_flexpect ( ) = ! Flambda_backend_flags . Flambda2 . Dump . flexpect
let dump_slot_offsets ( ) = ! Flambda_backend_flags . Flambda2 . Dump . slot_offsets
let freshen_when_printing ( ) = ! Flambda_backend_flags . Flambda2 . Dump . freshen
module Inlining = struct module D = Flambda_backend_flags . Flambda2 . Inlining . Default module I = Flambda_backend_flags . Flambda2 . Inlining module IH = Clflags . Int_arg_helper module FH = Clflags . Float_arg_helper type round_or_default = | Round of int | Default let max_depth round_or_defau...
module Debug = struct let concrete_types_only_on_canonicals ( ) = ! Flambda_backend_flags . Flambda2 . Debug . concrete_types_only_on_canonicals let keep_invalid_handlers ( ) = ! Flambda_backend_flags . Flambda2 . Debug . keep_invalid_handlers end
module Expert = struct let with_default ( r : ' a Flambda_backend_flags . or_default ) ( ~ f : Flambda_backend_flags . Flambda2 . Expert . flags -> ' a ) = match r with | Set a -> a | Default -> f ( Flambda_backend_flags . Flambda2 . Expert . default_for_opt_level ! Flambda_backen...
type flambda_kind = | Normal | Lifted
let already_added_bound_variable_to_env ( _ : Variable . t ) = ( )
let will_traverse_named_expression_later ( _ : Flambda . named ) = ( )
let ignore_variable ( _ : Variable . t ) = ( )
let ignore_call_kind ( _ : Flambda . call_kind ) = ( )
let ignore_debuginfo ( _ : Debuginfo . t ) = ( )
let ignore_meth_kind ( _ : Lambda . meth_kind ) = ( )
let ignore_int ( _ : int ) = ( )
let ignore_int_set ( _ : Numbers . Int . Set . t ) = ( )
let ignore_bool ( _ : bool ) = ( )
let ignore_string ( _ : string ) = ( )
let ignore_static_exception ( _ : Static_exception . t ) = ( )
let ignore_direction_flag ( _ : Asttypes . direction_flag ) = ( )
let ignore_primitive ( _ : Clambda_primitives . primitive ) = ( )
let ignore_const ( _ : Flambda . const ) = ( )
let ignore_allocated_const ( _ : Allocated_const . t ) = ( )
let ignore_set_of_closures_id ( _ : Set_of_closures_id . t ) = ( )
let ignore_set_of_closures_origin ( _ : Set_of_closures_origin . t ) = ( )
let ignore_closure_id ( _ : Closure_id . t ) = ( )
let ignore_var_within_closure ( _ : Var_within_closure . t ) = ( )
let ignore_tag ( _ : Tag . t ) = ( )
let ignore_inlined_attribute ( _ : Lambda . inlined_attribute ) = ( )
let ignore_specialise_attribute ( _ : Lambda . specialise_attribute ) = ( )
let ignore_probe ( _ : Lambda . probe ) = ( )
let ignore_value_kind ( _ : Lambda . value_kind ) = ( ) Mutable_variable . t Mutable_variable . t Variable . Set . t * Flambda . set_of_closures * Variable . t Variable . t * Variable . Set . t * Variable . Set . t * Flambda . function_declaration Clambda_primitives . primiti...
let variable_and_symbol_invariants ( program : Flambda . program ) = let all_declared_variables = ref Variable . Set . empty in let declare_variable var = if Variable . Set . mem var ! all_declared_variables then raise ( Binding_occurrence_of_variable_already_bound var ) ; all_declared_variable...
let primitive_invariants flam = Flambda_iterators . iter_named ( function | Prim ( prim , _ , _ ) -> begin match prim with | Psequand | Psequor -> raise ( Sequential_logical_operator_primitives_must_be_expanded prim ) | _ -> ( ) end | _ -> ( ) ) flam
let declared_var_within_closure ( flam : Flambda . program ) = let bound = ref Var_within_closure . Set . empty in let bound_multiple_times = ref None in let add_and_check var = if Var_within_closure . Set . mem var ! bound then begin bound_multiple_times := Some var end ; bound := Var_within_cl...
let no_var_within_closure_is_bound_multiple_times ( flam : Flambda . program ) = match declared_var_within_closure flam with | _ , Some var -> raise ( Var_within_closure_bound_multiple_times var ) | _ , None -> ( )
let every_declared_closure_is_from_current_compilation_unit flam = let current_compilation_unit = Compilation_unit . get_current_exn ( ) in Flambda_iterators . iter_on_sets_of_closures ( fun { Flambda . function_decls ; _ } -> let compilation_unit = Set_of_closures_id . get_compilation_unit fun...
let declared_closure_ids program = let bound = ref Closure_id . Set . empty in let bound_multiple_times = ref None in let add_and_check var = if Closure_id . Set . mem var ! bound then bound_multiple_times := Some var ; bound := Closure_id . Set . add var ! bound in Flambda_iterators . iter_on_s...
let no_closure_id_is_bound_multiple_times program = match declared_closure_ids program with | _ , Some closure_id -> raise ( Closure_id_is_bound_multiple_times closure_id ) | _ , None -> ( )
let declared_set_of_closures_ids program = let bound = ref Set_of_closures_id . Set . empty in let bound_multiple_times = ref None in let add_and_check var = if Set_of_closures_id . Set . mem var ! bound then bound_multiple_times := Some var ; bound := Set_of_closures_id . Set . add var ! bound in...
let no_set_of_closures_id_is_bound_multiple_times program = match declared_set_of_closures_ids program with | _ , Some set_of_closures_id -> raise ( Set_of_closures_id_is_bound_multiple_times set_of_closures_id ) | _ , None -> ( )
let used_closure_ids ( program : Flambda . program ) = let used = ref Closure_id . Set . empty in let f ( flam : Flambda . named ) = match flam with | Project_closure { closure_id ; _ } -> used := Closure_id . Set . add closure_id ! used ; | Move_within_set_of_closures { closure...
let used_vars_within_closures ( flam : Flambda . program ) = let used = ref Var_within_closure . Set . empty in let f ( flam : Flambda . named ) = match flam with | Project_var { closure = _ ; closure_id = _ ; var ; } -> used := Var_within_closure . Set . add var ! used | _ ...
let every_used_function_from_current_compilation_unit_is_declared ( program : Flambda . program ) = let current_compilation_unit = Compilation_unit . get_current_exn ( ) in let declared , _ = declared_closure_ids program in let used = used_closure_ids program in let used_from_current_unit = Closure...
let every_used_var_within_closure_from_current_compilation_unit_is_declared ( flam : Flambda . program ) = let current_compilation_unit = Compilation_unit . get_current_exn ( ) in let declared , _ = declared_var_within_closure flam in let used = used_vars_within_closures flam in let used_from_curren...
let every_static_exception_is_caught flam = let check env ( flam : Flambda . t ) = match flam with | Static_raise ( exn , _ ) -> if not ( Static_exception . Set . mem exn env ) then raise ( Static_exception_not_caught exn ) | _ -> ( ) in let rec loop env ( flam : Flambda . t ) ...
let every_static_exception_is_caught_at_a_single_position flam = let caught = ref Static_exception . Set . empty in let f ( flam : Flambda . t ) = match flam with | Static_catch ( i , _ , _body , _handler ) -> if Static_exception . Set . mem i ! caught then raise ( Static_exception_c...
let _every_move_within_set_of_closures_is_to_a_function_in_the_free_vars program = let moves = ref Closure_id . Map . empty in Flambda_iterators . iter_named_of_program program ~ f ( : function | Move_within_set_of_closures { start_from ; move_to ; _ } -> let moved_to = try Closure_id . Map ....
let check_exn ( ? kind = Normal ) ( flam : Flambda . program ) = ignore kind ; try variable_and_symbol_invariants flam ; no_closure_id_is_bound_multiple_times flam ; no_set_of_closures_id_is_bound_multiple_times flam ; every_used_function_from_current_compilation_unit_is_declared flam ; no_var_w...
let apply_on_subexpressions f f_named ( flam : Flambda . t ) = match flam with | Var _ | Apply _ | Assign _ | Send _ | Proved_unreachable | Static_raise _ -> ( ) | Let { defining_expr ; body ; _ } -> f_named defining_expr ; f body | Let_mutable { body ; _ } -> f body | Let...
let rec list_map_sharing f l = match l with | [ ] -> l | h :: t -> let new_t = list_map_sharing f t in let new_h = f h in if h == new_h && t == new_t then l else new_h :: new_t
let may_map_sharing f v = match v with | None -> v | Some s -> let new_s = f s in if s == new_s then v else Some new_s
let map_snd_sharing f ( ( a , b ) as cpl ) = let new_b = f a b in if b == new_b then cpl else ( a , new_b )
let map_subexpressions f f_named ( tree : Flambda . t ) : Flambda . t = match tree with | Var _ | Apply _ | Assign _ | Send _ | Proved_unreachable | Static_raise _ -> tree | Let { var ; defining_expr ; body ; _ } -> let new_named = f_named var defining_expr in let new_body = f body...
let iter f f_named t = iter_general ~ toplevel : false f f_named ( Is_expr t )
let iter_expr f t = iter f ( fun _ -> ( ) ) t
let iter_on_named f f_named t = iter_general ~ toplevel : false f f_named ( Is_named t )
let iter_named f_named t = iter ( fun ( _ : Flambda . t ) -> ( ) ) f_named t
let iter_named_on_named f_named named = iter_general ~ toplevel : false ( fun ( _ : Flambda . t ) -> ( ) ) f_named ( Is_named named )
let iter_toplevel f f_named t = iter_general ~ toplevel : true f f_named ( Is_expr t )
let iter_named_toplevel f f_named named = iter_general ~ toplevel : true f f_named ( Is_named named )
let iter_all_immutable_let_and_let_rec_bindings t ~ f = iter_expr ( function | Let { var ; defining_expr ; _ } -> f var defining_expr | Let_rec ( defs , _ ) -> List . iter ( fun ( var , named ) -> f var named ) defs | _ -> ( ) ) t
let iter_all_toplevel_immutable_let_and_let_rec_bindings t ~ f = iter_general ~ toplevel : true ( function | Let { var ; defining_expr ; _ } -> f var defining_expr | Let_rec ( defs , _ ) -> List . iter ( fun ( var , named ) -> f var named ) defs | _ -> ( ) ) ( fun _ -...
let iter_on_sets_of_closures f t = iter_named ( function | Set_of_closures clos -> f clos | Symbol _ | Const _ | Allocated_const _ | Read_mutable _ | Read_symbol_field _ | Project_closure _ | Move_within_set_of_closures _ | Project_var _ | Prim _ | Expr _ -> ( ) ) t
let iter_exprs_at_toplevel_of_program ( program : Flambda . program ) ~ f = let rec loop ( program : Flambda . program_body ) = match program with | Let_symbol ( _ , Set_of_closures set_of_closures , program ) -> Variable . Map . iter ( fun _ ( function_decl : Flambda . function_...
let iter_named_of_program program ~ f = iter_exprs_at_toplevel_of_program program ~ f ( : iter_named f )
let iter_on_set_of_closures_of_program ( program : Flambda . program ) ~ f = let rec loop ( program : Flambda . program_body ) = match program with | Let_symbol ( _ , Set_of_closures set_of_closures , program ) -> f ~ constant : true set_of_closures ; Variable . Map . iter ( fun _ ...
let iter_constant_defining_values_on_program ( program : Flambda . program ) ~ f = let rec loop ( program : Flambda . program_body ) = match program with | Let_symbol ( _ , const , program ) -> f const ; loop program | Let_rec_symbol ( defs , program ) -> List . iter ( fun ( ...
let map_general ~ toplevel f f_named tree = let rec aux ( tree : Flambda . t ) = match tree with | Let _ -> Flambda . map_lets tree ~ for_defining_expr : aux_named ~ for_last_body : aux ~ after_rebuild : f | _ -> let exp : Flambda . t = match tree with | Var _ | Apply _ | Assign _ | S...
let iter_apply_on_program program ~ f = iter_exprs_at_toplevel_of_program program ~ f ( : fun expr -> iter ( function | Apply apply -> f apply | _ -> ( ) ) ( fun _ -> ( ) ) expr )
let map f f_named tree = map_general ~ toplevel : false f ( fun _ n -> f_named n ) tree
let map_expr f tree = map f ( fun named -> named ) tree