text stringlengths 12 786k |
|---|
let size t = let initial_length = initial_length t in Dwarf_int . add ( Initial_length . size initial_length ) ( Initial_length . to_dwarf_int initial_length ) |
let entry_to_dwarf_value ( entry : entry_and_soc_symbol ) = let adjustment = Targetint . of_int_exn entry . entry . adjustment in Dwarf_value . code_address_from_label_symbol_diff ~ comment " : ending address " ~ upper : entry . entry . addr ~ lower : entry . start_of_code_symbol ~ offse... |
let emit ~ asm_directives t = let module A = ( val asm_directives : Asm_directives . S ) in Initial_length . emit ~ asm_directives ( initial_length t ) ; Dwarf_version . emit ~ asm_directives Dwarf_version . five ; A . uint8 ( Uint8 . of_nonnegative_int_exn Dwarf_arch_sizes . size_addr... |
let afl_area_ptr dbg = Cconst_symbol ( " caml_afl_area_ptr " , dbg ) |
let afl_prev_loc dbg = Cconst_symbol ( " caml_afl_prev_loc " , dbg ) |
let afl_map_size = 1 lsl 16 |
let rec with_afl_logging b dbg = if ! Clflags . afl_inst_ratio < 100 && Random . int 100 >= ! Clflags . afl_inst_ratio then instrument b else let instrumentation = let cur_location = Random . int afl_map_size in let cur_pos = V . create_local " pos " in let afl_area = V . create_local " sh... |
let instrument_function c dbg = with_afl_logging c dbg |
let instrument_initialiser c dbg = with_afl_logging ( Csequence ( Cop ( Cextcall ( " caml_setup_afl " , typ_int , [ ] , false ) , [ Cconst_int ( 0 , dbg ( ) ) ] , dbg ( ) ) , c ) ) ( dbg ( ) ) |
let total = ref 0 |
let err = ref 0 |
let res = Hashtbl . create 256 |
let print_title title = print_string " \ x1b [ 1 ; 37m " ; print_endline title ; print_endline ( String . make ( String . length title ) ' ' ) ; ~ print_endline " \ x1b [ 0m " |
let rec update file form value = try let line = input_line file in if String . length line > 2 && not ( Hashtbl . mem res line ) then if line . [ 0 ] = ' . ' && line . [ 1 ] <> ' ' > && not ( Hashtbl . mem res line ) then Hashtbl . add res line true else if line . [ ... |
let rec process n = if n = 0 then ( ) else begin let file = open_in Sys . argv . ( n ) in print_title ( Filename . chop_extension Sys . argv . ( n ) ) ; update file " Total : \ x1b [ 0 ; % dm % d % s " total ; update file " Failed : \ x1b [ 0 ; % dm % d % s " ... |
let print_res title total err = print_title title ; print_string " Total : \ x1b [ 0 ; 34m " ; print_int total ; print_string " \ x1b [ 0m \ nFailed : \ x1b [ 0 ; 31m " ; print_int err ; let ratio = ( . - ) 100 . @@ ( . * ) 100 . @@ ( float_of_int total ... |
let ( ) = process ( Array . length Sys . argv - 1 ) ; print_endline " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \ n \ n \ x1b [ 1 ; 37m " ; pr... |
let compose_map_values_exn map ~ then_ : coercion = if Coercion . is_id coercion then map else Name . Map . map_sharing ( fun old_coercion -> Coercion . compose_exn old_coercion ~ then_ : coercion ) map |
module Map_to_canonical = struct type t = coercion_to_canonical Name . Map . t let fatal_inconsistent ~ func_name elt coercion1 coercion2 = Misc . fatal_errorf " [ % s ] maps with inconsistent element / coercion couples ; % a has coercions \ % a and % a " func_name Name . print elt Coercion ... |
module Aliases_of_canonical_element : sig type t val print : Format . formatter -> t -> unit val invariant : t -> unit val empty : t val is_empty : t -> bool val add : t -> Name . t -> coercion_to_canonical : coercion_to_canonical -> Name_mode . t -> t val find_earliest_candidates : t -> filter_b... |
module Alias_set = struct type t = { const : Reg_width_const . t option ; names : Coercion . t Name . Map . t } let empty = { const = None ; names = Name . Map . empty } let create_aliases_of_element ~ element : _ ~ canonical_element ~ coercion_from_canonical_to_element ~ alias_name... |
type t = { canonical_elements : ( Simple . t * coercion_to_canonical ) Name . Map . t ; aliases_of_canonical_names : Aliases_of_canonical_element . t Name . Map . t ; aliases_of_consts : Aliases_of_canonical_element . t Reg_width_const . Map . t } |
let [ @ ocamlformat " disable " ] print ppf { canonical_elements ; aliases_of_canonical_names ; aliases_of_consts ; } = let print_element_and_coercion ppf ( elt , coercion ) = Format . fprintf ppf " [ @< hov 1 ( >\ % a @ \ [ @< hov 1 >@< 0 >% s ( coercion @ % a ) @... |
let name_defined_earlier ~ binding_time_resolver ~ binding_times_and_modes alias ~ than = if Name . equal alias than || ( Name . is_symbol alias && Name . is_symbol than ) then false else if Name . is_symbol alias && not ( Name . is_symbol than ) then true else if Name . is_symbol than && no... |
let defined_earlier ~ binding_time_resolver ~ binding_times_and_modes alias ~ than = Simple . pattern_match than ~ const ( : fun _ -> false ) ~ name ( : fun than ~ coercion : _ -> Simple . pattern_match alias ~ const ( : fun _ -> true ) ~ name ( : fun alias ~ coercion : _ -> name... |
let binding_time_and_name_mode ~ binding_times_and_modes elt = Simple . pattern_match ' elt ~ const ( : fun _ -> Binding_time . With_name_mode . consts ) ~ var ( : fun var ~ coercion : _ -> let name = Name . var var in match Name . Map . find name binding_times_and_modes with | _ , ... |
let compute_name_mode_unscoped ~ binding_times_and_modes elt = Binding_time . With_name_mode . name_mode ( binding_time_and_name_mode ~ binding_times_and_modes elt ) |
let compute_name_mode ~ binding_times_and_modes elt ~ min_binding_time = Binding_time . With_name_mode . scoped_name_mode ( binding_time_and_name_mode ~ binding_times_and_modes elt ) ~ min_binding_time |
let invariant ~ binding_time_resolver ~ binding_times_and_modes t = if Flambda_features . check_invariants ( ) then let all_aliases_of_names : Map_to_canonical . t = Name . Map . fold ( fun canonical_element aliases all_aliases -> Aliases_of_canonical_element . invariant aliases ; let aliases =... |
let empty = { canonical_elements = Name . Map . empty ; aliases_of_canonical_names = Name . Map . empty ; aliases_of_consts = Reg_width_const . Map . empty } |
type canonical = | Is_canonical | Alias_of_canonical of { canonical_element : Simple . t ; coercion_to_canonical : coercion_to_canonical } |
let canonical t element : canonical = Simple . pattern_match element ~ const ( : fun _ -> Is_canonical ) ~ name ( : fun name ~ coercion : coercion_from_bare_element_to_element -> match Name . Map . find name t . canonical_elements with | exception Not_found -> Is_canonical | canonical_elemen... |
let get_aliases_of_canonical_element t ~ canonical_element = assert ( not ( Simple . has_coercion canonical_element ) ) ; let name name ~ coercion : _ = Name . Map . find name t . aliases_of_canonical_names in let const const = Reg_width_const . Map . find const t . aliases_of_consts in m... |
let add_alias_between_canonical_elements ~ binding_time_resolver ~ binding_times_and_modes t ~ canonical_element ~ coercion_to_canonical ~ to_be_demoted = if Simple . equal canonical_element to_be_demoted then if Coercion . is_id coercion_to_canonical then t else Misc . fatal_errorf " Cannot add an alias ... |
type to_be_demoted = | Demote_canonical_element1 | Demote_canonical_element2 |
let choose_canonical_element_to_be_demoted ~ binding_time_resolver ~ binding_times_and_modes ~ canonical_element1 ~ canonical_element2 = if defined_earlier ~ binding_time_resolver ~ binding_times_and_modes canonical_element1 ~ than : canonical_element2 then Demote_canonical_element2 else Demote_canonical_eleme... |
type add_result = { t : t ; canonical_element : Simple . t ; alias_of_demoted_element : Simple . t } |
let invariant_add_result ~ binding_time_resolver ~ binding_times_and_modes ~ original_t { canonical_element ; alias_of_demoted_element ; t } = if Flambda_features . check_invariants ( ) then begin invariant ~ binding_time_resolver ~ binding_times_and_modes t ; if not ( defined_earlier ~ binding... |
let add_alias ~ binding_time_resolver ~ binding_times_and_modes t ~ canonical_element1 ~ coercion_from_canonical_element2_to_canonical_element1 ~ canonical_element2 = assert ( not ( Simple . has_coercion canonical_element1 ) ) ; assert ( not ( Simple . has_coercion canonical_element2 ) ) ; ... |
let add ~ binding_time_resolver ~ binding_times_and_modes t ~ canonical_element1 : element1_with_coercion ~ canonical_element2 : element2_with_coercion = let original_t = t in let canonical_element1 = element1_with_coercion |> Simple . without_coercion in let canonical_element2 = element2_with_coercion |>... |
let find_earliest_alias t ~ canonical_element ~ binding_times_and_modes ~ min_binding_time ~ min_name_mode ~ binding_time_resolver ~ coercion_from_canonical_to_element = let aliases = get_aliases_of_canonical_element t ~ canonical_element in let filter_by_scope name_mode names = if Name_mode . equal name_mo... |
let get_canonical_element_exn ~ binding_time_resolver ~ binding_times_and_modes t element elt_name_mode ~ min_name_mode ~ min_binding_time = let canonical = canonical t element in match canonical with | Is_canonical when match Name_mode . compare_partial_order elt_name_mode min_name_mode with | None -> false... |
let get_aliases t element = match canonical t element with | Is_canonical -> let canonical_element = Simple . without_coercion element in assert ( not ( Simple . has_coercion canonical_element ) ) ; let alias_names_with_coercions_to_canonical = Aliases_of_canonical_element . all ( get_aliases_of_... |
let all_ids_for_export { canonical_elements ; aliases_of_canonical_names ; aliases_of_consts } = let ids = Name . Map . fold ( fun elt ( canonical , coercion ) ids -> let ids = Ids_for_export . union ids ( Coercion . all_ids_for_export coercion ) in Ids_for_export . add_name ( Ids_fo... |
let apply_renaming { canonical_elements ; aliases_of_canonical_names ; aliases_of_consts } renaming = let rename_name = Renaming . apply_name renaming in let rename_simple = Renaming . apply_simple renaming in let canonical_elements = Name . Map . fold ( fun elt ( canonical , coercion ) acc ... |
let merge t1 t2 = let canonical_elements = Name . Map . disjoint_union t1 . canonical_elements t2 . canonical_elements in ( if Flambda_features . check_invariants ( ) then let empty_maps = Name . Map . is_empty t1 . aliases_of_canonical_names && Reg_width_const . Map . is_empty t1 . alia... |
let get_canonical_ignoring_name_mode t name = let elt = Simple . name name in match canonical t elt with | Is_canonical -> elt | Alias_of_canonical { canonical_element ; coercion_to_canonical } -> let coercion_from_canonical = Coercion . inverse coercion_to_canonical in Simple . apply_coercion_exn ca... |
let clean_for_export { canonical_elements ; aliases_of_canonical_names = _ ; aliases_of_consts = _ } ~ reachable_names = let canonical_elements = Name . Map . filter ( fun name _canonical_and_coercion_to_canonical -> ( not ( Name . is_imported name ) ) && Name_occurrences . mem_name ... |
type allocation_point = | Symbol of Symbol . t | Variable of Variable . t |
type allocated_const = | Normal of Allocated_const . t | Array of Lambda . array_kind * Lambda . mutable_flag * Variable . t list | Duplicate_array of Lambda . array_kind * Lambda . mutable_flag * Variable . t |
type constant_defining_value = | Allocated_const of allocated_const | Block of Tag . t * Variable . t list | Set_of_closures of Flambda . set_of_closures | Project_closure of Flambda . project_closure | Move_within_set_of_closures of Flambda . move_within_set_of_closures | Project_var of Flambda . p... |
type initialize_symbol_field = Variable . t option |
type definitions = { variable : constant_defining_value Variable . Tbl . t ; initialize_symbol : initialize_symbol_field list Symbol . Tbl . t ; symbol : Flambda . constant_defining_value Symbol . Tbl . t ; } |
let print_constant_defining_value ppf = function | Allocated_const ( Normal const ) -> Allocated_const . print ppf const | Allocated_const ( Array ( _ , _ , vars ) ) -> Format . fprintf ppf " [ | % a ] " | ( Format . pp_print_list Variable . print ) vars | Allocated_const ... |
let rec resolve_definition ( definitions : definitions ) ( var : Variable . t ) ( def : constant_defining_value ) ~ the_dead_constant : allocation_point = match def with | Allocated_const _ | Block _ | Set_of_closures _ | Project_closure _ | Const _ | Move_within_set_of_closures _ -> Va... |
let run variable initialize_symbol symbol ~ the_dead_constant = let definitions = { variable ; initialize_symbol ; symbol ; } in Variable . Tbl . fold ( fun var definition result -> let definition = resolve_definition definitions var definition ~ the_dead_constant in Variable . Map . add var d... |
let ar = Array . create l " " ; ; |
let compact_flag = ref false ; ; |
let main ( ) = while true do for i = 1 to 100000 do ar . ( Random . int l ) <- String . create ( Random . int m ) ; done ; if ! compact_flag then Gc . compact ( ) else Gc . full_major ( ) ; print_newline ( ) ; Gc . print_stat stdout ; flush stdout ; done ; ; |
let argspecs = [ " - c " , Arg . Set compact_flag , " do heap compactions " ; ] ; ; |
type t = | Float of float | Int32 of int32 | Int64 of int64 | Nativeint of nativeint | Float_array of float list | Immutable_float_array of float list | String of string | Immutable_string of string |
let compare_floats x1 x2 = Int64 . compare ( Int64 . bits_of_float x1 ) ( Int64 . bits_of_float x2 ) |
let compare ( x : t ) ( y : t ) = let rec compare_float_lists l1 l2 = match l1 , l2 with | [ ] , [ ] -> 0 | [ ] , _ :: _ -> - 1 | _ :: _ , [ ] -> 1 | h1 :: t1 , h2 :: t2 -> let c = compare_floats h1 h2 in if c <> 0 then c else compare_float_lists t1 t2 in mat... |
let print ppf ( t : t ) = let fprintf = Format . fprintf in let floats ppf fl = List . iter ( fun f -> fprintf ppf " @ % f " f ) fl in match t with | String s -> fprintf ppf " % S " s | Immutable_string s -> fprintf ppf " #% S " s | Int32 n -> fprintf ppf " % lil " n | Int64... |
let twopi = 2 . 0 . * pic |
let test_loops = 5 [ | 0 . 3870983098 ; 0 . 0 ; 0 . 0 ] ; | [ | 0 . 7233298200 ; 0 . 0 ; 0 . 0 ] ; | [ | 1 . 0000010178 ; 0 . 0 ; 0 . 0 ] ; | [ | 1 . 5236793419 ; 3e - 10 ; 0 . 0 ] ; | [ | 5 . 2026032092 ; 19132e ... |
let anpm a = let w = mod_float a twopi in if abs_float w >= pic then begin if a < 0 . 0 then else end else w |
let planetpv epoch np pv = let t = ( ( epoch . ( 0 ) . - j2000 ) . + epoch . ( 1 ) ) . / jmillenia in let da = ref ( a . ( np ) . ( 0 ) . + ( a . ( np ) . ( 1 ) . + a . ( np ) . ( 2 ) . * t ) . * t ) and dl = ref ( ( 3600 ... |
let radecdist state rdd = rdd . ( 2 ) <- sqrt ( state . ( 0 ) . ( 0 ) . * state . ( 0 ) . ( 0 ) rdd . ( 0 ) <- atan2 state . ( 0 ) . ( 1 ) state . ( 0 ) . ( 0 ) . * r2h ; if rdd . ( 0 ) < 0 . 0 then rdd . ( 0 ) <- rdd... |
let _ = let jd = [ | 0 . 0 ; 0 . 0 ] | and pv = [ | [ | 0 . 0 ; 0 . 0 ; 0 . 0 ] ; | [ | 0 . 0 ; 0 . 0 ; 0 . 0 ] | ] | and position = [ | 0 . 0 ; 0 . 0 ; 0 . 0 ] | in jd . ( 0 ) <- j2000 ; jd . ( 1 ) <- 1 . ... |
let ( ==: ) = Signal . ( ==: ) |
module Variable = struct module Internal = struct type t = { assigns_to_wire : Signal . t ; default : Signal . t } end type internal = Internal . t type t = { value : Signal . t ; internal : Internal . t } [ @@ deriving fields ] let sexp_of_t { value ; internal = _ } = [ ... |
type t = | Assign of Variable . t * Signal . t | If of Signal . t * t list * t list | Switch of Signal . t * ( Signal . t * t list ) list |
type always = t [ @@ deriving sexp_of ] |
type ' a case = ' a * t list [ @@ deriving sexp_of ] |
type ' a cases = ' a case list [ @@ deriving sexp_of ] |
let if_ sel on_true on_false = If ( sel , on_true , on_false ) |
let elif c t f = [ if_ c t f ] |
let when_ sel on_true = if_ sel on_true [ ] |
let unless sel on_false = if_ sel [ ] on_false |
let switch sel cases = Switch ( sel , cases ) |
let proc s = if_ Signal . vdd s [ ] |
let ( <-- ) ( a : Variable . t ) b = if Signal . width a . value <> Signal . width b then raise_s [ % message " attempt to assign expression to [ Always . variable ] of different width " ~ variable_name ( : Signal . names a . value : string list ) ~ guared_variable_width ( ... |
let ( . <-- ) ( a : Variable . t ) b = a <-- Signal . of_int ~ width ( : Signal . width a . value ) b |
let list_of_set s = Set . fold s ~ init [ ] : ~ f ( : fun l e -> e :: l ) |
let rec find_targets set statements = List . fold statements ~ init : set ~ f ( : fun set statement -> match statement with | Assign ( variable , _ ) -> Set . add set variable | If ( _ , t , f ) -> let set = find_targets set t in find_targets set f | Switch ( _ , cases ) -> Lis... |
let filter_by_target variable statements = let rec loops statements = List . filter_map statements ~ f : loop and loop statement = match statement with | Assign ( v , _ ) -> if Variable . equal v variable then Some statement else None | If ( s , t , f ) -> let t = loops t in let f = loops ... |
let rec compile_mux statements ~ default = match statements with | [ ] -> default | statement :: statements -> let default = match statement with | If ( s , t , f ) -> let s = Signal . reduce ~ f : Signal . ( |: ) ( Signal . bits_msb s ) in let t = compile_mux t ~ default in le... |
let compile statements = let targets = list_of_set ( find_targets ( Set . empty ( module Variable ) ) statements ) in List . iter targets ~ f ( : fun target -> let statements = filter_by_target target statements in Signal . ( <== ) target . internal . assigns_to_wire ( compile_mux s... |
module State_machine = struct type ' a t = { current : Signal . t ; is : ' a -> Signal . t ; set_next : ' a -> always ; switch : ? default : always list -> ' a cases -> always } [ @@ deriving sexp_of ] module Encoding = struct type t = | Binary | Gray | Onehot [ @@ derivin... |
type dep_type = System | Internal |
type dependency_tag = Target of Name . t | Dependency of Libname . t |
type cpkg_config = { cpkg_conf_libs : string list ; cpkg_conf_includes : filepath list } |
type project_config = { project_dep_data : ( Libname . t , dep_type ) Hashtbl . t ; project_pkgdeps_dag : dependency_tag Dag . t ; project_targets_dag : Name . t Dag . t ; project_all_deps : dependency list ; project_file : Project . t ; project_ocamlcfg : ( string , string ) ... |
let get_ocaml_config_key_hashtbl key h = try Hashtbl . find h key with Not_found -> raise ( OcamlConfigMissing key ) |
let getOcamlConfigKey key = get_ocaml_config_key_hashtbl key ( Prog . getOcamlConfig ( ) ) |
let get_ocaml_config_key key project = get_ocaml_config_key_hashtbl key project . project_ocamlcfg |
let get_pkg_deps target project = let pkgs = Taskdep . linearize project . project_pkgdeps_dag Taskdep . FromParent [ Target target . target_name ] in List . rev ( list_filter_map ( fun pkg -> match pkg with Dependency d -> Some d | Target _ -> None ) pkgs ) |
let get_c_pkg cname project = try Hashtbl . find project . project_cpkgs cname with Not_found -> failwith ( sprintf " C package % s not found in the hashtbl : internal error " cname ) |
let is_pkg_internal project pkg = Hashtbl . find project . project_dep_data pkg = Internal |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.