text stringlengths 12 786k |
|---|
let get_int64_be b i = if not Sys . big_endian then swap64 ( get_int64_ne b i ) else get_int64_ne b i |
let set_int16_le b i x = if Sys . big_endian then set_int16_ne b i ( swap16 x ) else set_int16_ne b i x |
let set_int16_be b i x = if not Sys . big_endian then set_int16_ne b i ( swap16 x ) else set_int16_ne b i x |
let set_int32_le b i x = if Sys . big_endian then set_int32_ne b i ( swap32 x ) else set_int32_ne b i x |
let set_int32_be b i x = if not Sys . big_endian then set_int32_ne b i ( swap32 x ) else set_int32_ne b i x |
let set_int64_le b i x = if Sys . big_endian then set_int64_ne b i ( swap64 x ) else set_int64_ne b i x |
let set_int64_be b i x = if not Sys . big_endian then set_int64_ne b i ( swap64 x ) else set_int64_ne b i x |
type ' a ref = { mutable contents : ' a } = " caml_blit_bytes " [ @@ noalloc ] |
let extend len s left right r = let srcoff , dstoff = if left < 0 then - left , 0 else 0 , left in let cpylen = min ( length s - srcoff ) ( len - dstoff ) in if cpylen > 0 then unsafe_blit s srcoff r dstoff cpylen ; r |
let section_table = ref ( [ ] : ( string * int ) list ) |
let section_beginning = ref 0 |
let init_record outchan = section_beginning := pos_out outchan ; section_table := [ ] |
let record outchan name = let pos = pos_out outchan in section_table := ( name , pos - ! section_beginning ) :: ! section_table ; section_beginning := pos |
let write_toc_and_trailer outchan = List . iter ( fun ( name , len ) -> output_string outchan name ; output_binary_int outchan len ) ( List . rev ! section_table ) ; output_binary_int outchan ( List . length ! section_table ) ; output_string outchan Config . exec_magic_number ; sec... |
let read_toc ic = let pos_trailer = in_channel_length ic - 16 in seek_in ic pos_trailer ; let num_sections = input_binary_int ic in let header = really_input_string ic ( String . length Config . exec_magic_number ) in if header <> Config . exec_magic_number then raise Bad_magic_number ; seek_in ic ... |
let toc ( ) = List . rev ! section_table |
let seek_section ic name = let rec seek_sec curr_ofs = function [ ] -> raise Not_found | ( n , len ) :: rem -> if n = name then begin seek_in ic ( curr_ofs - len ) ; len end else seek_sec ( curr_ofs - len ) rem in seek_sec ( in_channel_length ic - 16 - 8 * List . length ! section_... |
let read_section_string ic name = really_input_string ic ( seek_section ic name ) |
let read_section_struct ic name = ignore ( seek_section ic name ) ; input_value ic |
let pos_first_section ic = in_channel_length ic - 16 - 8 * List . length ! section_table - List . fold_left ( fun total ( _name , len ) -> total + len ) 0 ! section_table |
let reset ( ) = section_table := [ ] ; section_beginning := 0 |
type t = { names_to_types : ( Type_grammar . t * Binding_time . With_name_mode . t ) Name . Map . t ; aliases : Aliases . t ; symbol_projections : Symbol_projection . t Variable . Map . t } |
let print_kind_and_mode ~ min_binding_time ppf ( ty , binding_time_and_mode ) = let kind = Type_grammar . kind ty in let mode = Binding_time . With_name_mode . scoped_name_mode binding_time_and_mode ~ min_binding_time in Format . fprintf ppf " :: % a % a " Flambda_kind . print kind Name_mode... |
let print_name_modes ~ restrict_to ~ min_binding_time ppf t = Name . Map . print ( print_kind_and_mode ~ min_binding_time ) ppf ( Name . Map . filter ( fun name _ -> Name . Set . mem name restrict_to ) t . names_to_types ) |
let empty = { names_to_types = Name . Map . empty ; aliases = Aliases . empty ; symbol_projections = Variable . Map . empty } |
let names_to_types t = t . names_to_types |
let aliases t = t . aliases |
let symbol_projections t = t . symbol_projections |
let add_or_replace_binding t ( name : Name . t ) ty binding_time name_mode = let binding_time_and_mode = Binding_time . With_name_mode . create binding_time name_mode in let names_to_types = Name . Map . add name ( ty , binding_time_and_mode ) t . names_to_types in { names_to_types ; alias... |
let replace_variable_binding t var ty = let names_to_types = Name . Map . replace ( Name . var var ) ( function _old_ty , binding_time_and_mode -> ty , binding_time_and_mode ) t . names_to_types in { names_to_types ; aliases = t . aliases ; symbol_projections = t . symbol_projections... |
let with_aliases t ~ aliases = { t with aliases } |
let add_symbol_projection t var proj = let symbol_projections = Variable . Map . add var proj t . symbol_projections in { t with symbol_projections } |
let find_symbol_projection t var = match Variable . Map . find var t . symbol_projections with | exception Not_found -> None | proj -> Some proj |
let clean_for_export t ~ reachable_names = let current_compilation_unit = Compilation_unit . get_current_exn ( ) in let names_to_types = Name . Map . filter ( fun name _info -> Name_occurrences . mem_name reachable_names name && Compilation_unit . equal ( Name . compilation_unit name ) curr... |
let apply_renaming { names_to_types ; aliases ; symbol_projections } renaming = let names_to_types = Name . Map . fold ( fun name ( ty , binding_time_and_mode ) acc -> Name . Map . add ( Renaming . apply_name renaming name ) ( Type_grammar . apply_renaming ty renaming , binding_ti... |
let merge t1 t2 = let names_to_types = Name . Map . disjoint_union t1 . names_to_types t2 . names_to_types in let aliases = Aliases . merge t1 . aliases t2 . aliases in let symbol_projections = Variable . Map . union ( fun var proj1 proj2 -> if Symbol_projection . equal proj1 proj2 then Some ... |
let canonicalise t simple = Simple . pattern_match simple ~ const ( : fun _ -> simple ) ~ name ( : fun name ~ coercion -> Simple . apply_coercion_exn ( Aliases . get_canonical_ignoring_name_mode t . aliases name ) coercion ) |
let remove_unused_value_slots_and_shortcut_aliases ( { names_to_types ; aliases ; symbol_projections } as t ) ~ used_value_slots = let canonicalise = canonicalise t in let names_to_types = Name . Map . map_sharing ( fun ( ( ty , binding_time_and_mode ) as info ) -> let ty ' = Type_gr... |
let free_function_slots_and_value_slots { names_to_types ; aliases = _ ; symbol_projections } = let from_projections = Variable . Map . fold ( fun _var proj free_names -> Name_occurrences . union free_names ( Name_occurrences . restrict_to_value_slots_and_function_slots ( Symbol_projection .... |
let mem_string ~ elt : c s = try for i = 0 to String . length s - 1 do if s . [ i ] = c then raise Exit done ; false with Exit -> true |
let ops = [ ' ' , ( . ) ; ++ ' ' , ( . ) ; -- ' ' , ( * . ) ; * ' ' , ( . ) ] // val variable = Textvariable . create ( ) val mutable x = 0 . 0 val mutable op = None val mutable displaying = true method set = Textvariable . set variable me... |
let m = [ [ " | 7 " ; " 8 " ; " 9 " ; " " ] ; + [ " 4 " ; " 5 " ; " 6 " ; " " ] ; - [ " 1 " ; " 2 " ; " 3 " ; " " ] ; * [ " 0 " ; " . " ; " " ; " " ] ] =/| inherit calc ( ) as calc val... |
let top = openTk ( ) |
let applet = new calculator ~ parent : top |
let _ = mainLoop ( ) |
module Mode = struct type t = | Disabled | Top_of_stack | Full_trace end |
let mode = ref ( if Base . Exported_for_specific_uses . am_testing then Mode . Disabled else Top_of_stack ) ; ; |
let set_mode m = mode := m |
type t = | Top_of_stack of Printexc . location | Full_trace of Printexc . location option list |
let sexp_of_location ( t : Printexc . location ) = let loc = Printf . sprintf " % s :% i :% i " t . filename t . line_number t . start_char in [ % sexp ( loc : string ) ] ; ; |
let sexp_of_t ( t : t ) = match t with | Top_of_stack s -> [ % sexp ( s : location ) ] | Full_trace s -> [ % sexp ( s : location option list ) ] ; ; |
let get ( ? skip = [ ] ) ( ) = let skip = " list . ml " :: " list0 . ml " :: " array . ml " :: " comb . ml " :: " interface . ml " :: " signal . ml " :: " bits . ml " :: " with_valid . ml " :: " scope . ml " :: " parameter . ml " :: "... |
let check_arity arity = if Flambda_arity . With_subkinds . is_nullary arity then Misc . fatal_error " Invalid nullary arity " |
module Function_call = struct type t = | Direct of { code_id : Code_id . t ; return_arity : Flambda_arity . With_subkinds . t } | Indirect_unknown_arity | Indirect_known_arity of { param_arity : Flambda_arity . With_subkinds . t ; return_arity : Flambda_arity . With_subkinds . t } let... |
type method_kind = | Self | Public | Cached |
let print_method_kind ppf kind = match kind with | Self -> fprintf ppf " Self " | Public -> fprintf ppf " Public " | Cached -> fprintf ppf " Cached " |
let method_kind_from_lambda ( kind : Lambda . meth_kind ) = match kind with Self -> Self | Public -> Public | Cached -> Cached |
type t = | Function of { function_call : Function_call . t ; alloc_mode : Alloc_mode . t } | Method of { kind : method_kind ; obj : Simple . t ; alloc_mode : Alloc_mode . t } | C_call of { alloc : bool ; param_arity : Flambda_arity . t ; return_arity : Flambda_arity . t ; i... |
let [ @ ocamlformat " disable " ] print ppf t = match t with | Function { function_call ; alloc_mode } -> fprintf ppf " [ @< hov 1 ( > Function @ \ [ @< hov 1 ( > function_call @ % a ) ] @@ \ [ @< hov 1 ( > alloc_mode @ % a ) ] @\ ) ] " @ Function_call . ... |
let direct_function_call code_id ~ return_arity alloc_mode = check_arity return_arity ; Function { function_call = Direct { code_id ; return_arity } ; alloc_mode } |
let indirect_function_call_unknown_arity alloc_mode = Function { function_call = Indirect_unknown_arity ; alloc_mode } |
let indirect_function_call_known_arity ~ param_arity ~ return_arity alloc_mode = check_arity return_arity ; Function { function_call = Indirect_known_arity { param_arity ; return_arity } ; alloc_mode } |
let method_call kind ~ obj alloc_mode = Method { kind ; obj ; alloc_mode } |
let c_call ~ alloc ~ param_arity ~ return_arity ~ is_c_builtin = begin match Flambda_arity . to_list return_arity with | [ ] | [ _ ] -> ( ) | _ :: _ :: _ -> Misc . fatal_errorf " Illegal return arity for C call : % a " Flambda_arity . print return_arity end ; C_call { alloc ;... |
let return_arity t = match t with | Function { function_call ; _ } -> Function_call . return_arity function_call | Method _ -> Flambda_arity . With_subkinds . create [ Flambda_kind . With_subkind . any_value ] | C_call { return_arity ; _ } -> Flambda_arity . With_subkinds . of_ar... |
let free_names t = match t with | Function { function_call = Direct { code_id ; return_arity = _ } ; alloc_mode = _ } -> Name_occurrences . add_code_id Name_occurrences . empty code_id Name_mode . normal | Function { function_call = Indirect_unknown_arity ; alloc_mode = _ } | Functi... |
let apply_renaming t perm = match t with | Function { function_call = Direct { code_id ; return_arity } ; alloc_mode } -> let code_id ' = Renaming . apply_code_id perm code_id in if code_id == code_id ' then t else Function { function_call = Direct { code_id = code_id ' ; return_arity ... |
let all_ids_for_export t = match t with | Function { function_call = Direct { code_id ; return_arity = _ } ; alloc_mode = _ } -> Ids_for_export . add_code_id Ids_for_export . empty code_id | Function { function_call = Indirect_unknown_arity ; alloc_mode = _ } | Function { function_c... |
let speculative_inlining dacc ~ apply ~ function_type ~ simplify_expr ~ return_arity = let dacc = DA . set_do_not_rebuild_terms_and_disable_inlining dacc in let dacc , expr = Inlining_transforms . inline dacc ~ apply ~ unroll_to : None function_type in let scope = DE . get_continuation_scope ( DA .... |
let argument_types_useful dacc apply = if not ( Flambda_features . Inlining . speculative_inlining_only_if_arguments_useful ( ) ) then true else let typing_env = DE . typing_env ( DA . denv dacc ) in List . exists ( fun simple -> Simple . pattern_match simple ~ name ( : fun name ~ coer... |
let might_inline dacc ~ apply ~ code_or_metadata ~ function_type ~ simplify_expr ~ return_arity : Call_site_inlining_decision_type . t = let denv = DA . denv dacc in let env_prohibits_inlining = not ( DE . can_inline denv ) in let decision = Code_or_metadata . code_metadata code_or_metadata |> Co... |
let get_rec_info dacc ~ function_type = let rec_info = FT . rec_info function_type in match Flambda2_types . prove_rec_info ( DA . typing_env dacc ) rec_info with | Proved rec_info -> rec_info | Unknown -> Rec_info_expr . unknown | Invalid -> Rec_info_expr . do_not_inline |
let make_decision dacc ~ simplify_expr ~ function_type ~ apply ~ return_arity : Call_site_inlining_decision_type . t = let rec_info = get_rec_info dacc ~ function_type in let inlined = Apply . inlined apply in match inlined with | Never_inlined -> Never_inlined_attribute | Default_inlined | Unroll _ ... |
type t = | Missing_code | Definition_says_not_to_inline | Environment_says_never_inline | Argument_types_not_useful | Unrolling_depth_exceeded | Max_inlining_depth_exceeded | Recursion_depth_exceeded | Never_inlined_attribute | Speculatively_not_inline of { cost_metrics : Cost_metrics . t ; evaluated_t... |
let [ @ ocamlformat " disable " ] print ppf t = match t with | Missing_code -> Format . fprintf ppf " Missing_code " | Definition_says_not_to_inline -> Format . fprintf ppf " Definition_says_not_to_inline " | Environment_says_never_inline -> Format . fprintf ppf " Environment_says_never_... |
type can_inline = | Do_not_inline of { warn_if_attribute_ignored : bool ; because_of_definition : bool } | Inline of { unroll_to : int option } |
let can_inline ( t : t ) : can_inline = match t with | Missing_code | Environment_says_never_inline | Max_inlining_depth_exceeded | Recursion_depth_exceeded | Speculatively_not_inline _ | Definition_says_not_to_inline | Argument_types_not_useful -> Do_not_inline { warn_if_attribute_ignored = true ; ... |
let report_reason fmt t = match ( t : t ) with | Missing_code -> Format . fprintf fmt " the @ code @ could @ not @ be @ found @ ( is @ a @ . cmx @ file @ missing ) " ? | Definition_says_not_to_inline -> Format . fprintf fmt " this @ function @ was @ deemed @ at @ the @ point ... |
let report fmt t = Format . fprintf fmt " [ @< v > The function call % s been inlined @ because [ @< hov >% a ] ] " @@ ( match can_inline t with Inline _ -> " has " | Do_not_inline _ -> " has not " ) report_reason t |
type ' a t = { mutable v : ' a } |
let make v = { v } |
let get r = r . v |
let set r v = r . v <- v let cur = r . v in r . v <- v ; cur let cur = r . v in if cur == seen then ( r . v <- v ; true ) else false let cur = r . v in r . v <- ( cur + n ) ; cur |
let incr r = ignore ( fetch_and_add r 1 ) |
let decr r = ignore ( fetch_and_add r ( - 1 ) ) |
let create_char_set ( ) = Bytes . make 32 ' \ 000 ' |
let add_in_char_set char_set c = let ind = int_of_char c in let str_ind = ind lsr 3 and mask = 1 lsl ( ind land 0b111 ) in Bytes . set char_set str_ind ( char_of_int ( int_of_char ( Bytes . get char_set str_ind ) lor mask ) ) |
let freeze_char_set char_set = Bytes . to_string char_set |
let rev_char_set char_set = let char_set ' = create_char_set ( ) in for i = 0 to 31 do Bytes . set char_set ' i ( char_of_int ( int_of_char ( String . get char_set i ) lxor 0xFF ) ) ; done ; Bytes . unsafe_to_string char_set ' |
let is_in_char_set char_set c = let ind = int_of_char c in let str_ind = ind lsr 3 and mask = 1 lsl ( ind land 0b111 ) in ( int_of_char ( String . get char_set str_ind ) land mask ) <> 0 |
type ( ' a , ' b , ' c , ' d , ' e , ' f ) param_format_ebb = Param_format_EBB : ( ' x -> ' a , ' b , ' c , ' d , ' e , ' f ) fmt -> ( ' a , ' b , ' c , ' d , ' e , ' f ) param_format_ebb |
let pad_of_pad_opt pad_opt = match pad_opt with | None -> No_padding | Some width -> Lit_padding ( Right , width ) |
let prec_of_prec_opt prec_opt = match prec_opt with | None -> No_precision | Some ndec -> Lit_precision ndec |
let param_format_of_ignored_format : type a b c d e f x y . ( a , b , c , d , y , x ) ignored -> ( x , b , c , y , e , f ) fmt -> ( a , b , c , d , e , f ) param_format_ebb = | Ignored_char -> Param_format_EBB ( Char fmt ) | Ignored_caml_char -> Param_format_EBB (... |
type ( ' b , ' c ) acc_formatting_gen = | Acc_open_tag of ( ' b , ' c ) acc | Acc_open_box of ( ' b , ' c ) acc | Acc_formatting_lit of ( ' b , ' c ) acc * formatting_lit | Acc_formatting_gen of ( ' b , ' c ) acc * ( ' b , ' c ) acc_formatting_gen | Ac... |
type ( ' a , ' b ) heter_list = | Cons : ' c * ( ' a , ' b ) heter_list -> ( ' c -> ' a , ' b ) heter_list | Nil : ( ' b , ' b ) heter_list |
type ( ' a , ' b , ' c , ' d , ' e , ' f ) padding_fmtty_ebb = Padding_fmtty_EBB : ( ' x , ' y ) padding * ( ' y , ' b , ' c , ' d , ' e , ' f ) fmtty -> ( ' x , ' b , ' c , ' d , ' e , ' f ) padding_fmtty_ebb |
type ( ' a , ' b , ' c , ' d , ' e , ' f ) padprec_fmtty_ebb = Padprec_fmtty_EBB : ( ' x , ' y ) padding * ( ' y , ' z ) precision * ( ' z , ' b , ' c , ' d , ' e , ' f ) fmtty -> ( ' x , ' b , ' c , ' d , ' e , ' f ) ... |
type ( ' a , ' b , ' c , ' e , ' f ) padding_fmt_ebb = Padding_fmt_EBB : ( _ , ' x -> ' a ) padding * ( ' a , ' b , ' c , ' d , ' e , ' f ) fmt -> ( ' x , ' b , ' c , ' e , ' f ) padding_fmt_ebb |
type ( ' a , ' b , ' c , ' e , ' f ) precision_fmt_ebb = Precision_fmt_EBB : ( _ , ' x -> ' a ) precision * ( ' a , ' b , ' c , ' d , ' e , ' f ) fmt -> ( ' x , ' b , ' c , ' e , ' f ) precision_fmt_ebb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.