text
stringlengths
12
786k
let filter t ~ f = let funs = Function_slot . Map . filter f t . funs in let in_order = Function_slot . Lmap . filter f t . in_order in { funs ; in_order }
let binds_function_slot t function_slot = Function_slot . Map . mem function_slot t . funs
let make_decision ~ inlining_arguments : args ~ inline ~ stub ~ cost_metrics : metrics ~ is_a_functor ( ~ recursive : Recursive . t ) : Function_decl_inlining_decision_type . t = match ( inline : Inline_attribute . t ) with | Never_inline -> Never_inline_attribute | Always_inline -> Attrib...
type t = | Not_yet_decided | Never_inline_attribute | Function_body_too_large of Code_size . t | Stub | Attribute_inline | Small_function of { size : Code_size . t ; small_function_size : Code_size . t } | Speculatively_inlinable of { size : Code_size . t ; small_function_size : Code_size ...
let [ @ ocamlformat " disable " ] print ppf t = match t with | Not_yet_decided -> Format . fprintf ppf " Not_yet_decided " | Never_inline_attribute -> Format . fprintf ppf " Never_inline_attribute " | Function_body_too_large large_function_size -> Format . fprintf ppf " [ @< hov 1 ( ...
let report_decision ppf t = match t with | Not_yet_decided -> Format . fprintf ppf " no decision has yet been made " | Never_inline_attribute -> Format . fprintf ppf " % a " Format . pp_print_text " the function has an attribute preventing its inlining " | Function_body_too_large large_function...
type inlining_behaviour = | Cannot_be_inlined | Must_be_inlined | Could_possibly_be_inlined
let behaviour t = match t with | Not_yet_decided | Never_inline_attribute | Function_body_too_large _ | Recursive -> Cannot_be_inlined | Stub | Attribute_inline | Small_function _ -> Must_be_inlined | Functor _ | Speculatively_inlinable _ -> Could_possibly_be_inlined
let report fmt t = Format . fprintf fmt " [ @< v > The function % s be inlined at its use - sites @ because [ @< hov >% a ] ] " @@ ( match behaviour t with | Cannot_be_inlined -> " cannot " | Could_possibly_be_inlined -> " could " | Must_be_inlined -> " must " ) report_decis...
let must_be_inlined t = match behaviour t with | Must_be_inlined -> true | Cannot_be_inlined | Could_possibly_be_inlined -> false
let cannot_be_inlined t = match behaviour t with | Cannot_be_inlined -> true | Must_be_inlined | Could_possibly_be_inlined -> false
let equal t1 t2 = match t1 , t2 with | Not_yet_decided , Not_yet_decided | Never_inline_attribute , Never_inline_attribute | Stub , Stub | Attribute_inline , Attribute_inline -> true | Function_body_too_large size1 , Function_body_too_large size2 -> Code_size . equal size1 size2 | ( Small_funct...
module type S = sig val f0 : int -> int -> int val f1 : int -> int -> int val f2 : int -> int -> int val f3 : int -> int -> int val f4 : int -> int -> int val f5 : int -> int -> int val f6 : int -> int -> int val f7 : int -> int -> int val f8 : int -> int -> int val f9 : int -> int -> int...
module Make ( M : S ) = struct include M end
module M = struct let f0 = ( + ) let f1 = ( + ) let f2 = ( + ) let f3 = ( + ) let f4 = ( + ) let f5 = ( + ) let f6 = ( + ) let f7 = ( + ) let f8 = ( + ) let f9 = ( + ) let f10 = ( + ) let f11 = ( + ) let f12 = ( + ) let f13 = ( + ) let...
module type S = sig type t0 type t1 type t2 type t3 type t4 type t5 type t6 type t7 type t8 type t9 type t10 type t11 type t12 type t13 type t14 type t15 type t16 type t17 type t18 type t19 type t20 type t21 type t22 type t23 type t24 type t25 type t26 type t27 type t28 type t29 type t30 type t31 type t32 type t33 typ...
module Make ( M : S ) and type t1 = M . t1 and type t2 = M . t2 and type t3 = M . t3 and type t4 = M . t4 and type t5 = M . t5 and type t6 = M . t6 and type t7 = M . t7 and type t8 = M . t8 and type t9 = M . t9 and type t10 = M . t10 and type t11 = M . t11 and type t12 = M . t12...
module M = struct type t0 = int -> int -> int type t1 = int -> int -> int type t2 = int -> int -> int type t3 = int -> int -> int type t4 = int -> int -> int type t5 = int -> int -> int type t6 = int -> int -> int type t7 = int -> int -> int type t8 = int -> int -> int type t9 = int -> int...
module X = Make ( Make ( Make ( Make ( Make ( Make ( Make ( Make ( Make ( Make ( Make ( M ) ) ) ) ) ) ) ) ) ) )
module type S = sig type t <%= i %> end
module Make ( M : S ) <%- for i in 1 . . with_constrs do -%> and type t <%= i %> = M . t <%= i %> <%- end -%> include M end
module type S2 = sig module M : S end
module Make2 ( M2 : S2 ) include M2 end
module M = struct type t <%= i %> = int -> int -> int end
module M1 = Make ( Make ( M ) <%= ' ) ' * make %>
module M2 = struct module M = M1 end
module X = Make2 ( Make2 ( M2 ) <%= ' ) ' * make2 %>
module rec M0 : sig type t val foo : t -> t type t = M . t let foo t = M . foo 42 t end type t val foo : int -> t -> t include TD . Make ( M0 ) end module Make ( X : sig type t val foo : t -> t end ) : sig type t val s : t val na : X . t -> t val foo : int -> t -> t end module Make ( ...
let f4 list = List . map ( fun s -> String . length s ) list
let test1 ( ) = f4 [ " a " ; " asfda " ; " afda " ]
let g1 s = s " " ^*
let g2 s = " " *^ s
let g3 s = " " *^ s " " ^*
let f5 = function | 1 -> g1 " a " | 2 -> g2 " b " | 3 -> g3 " c " | 4 -> g1 " d " | 5 -> g2 " e " | 6 -> g3 " f " | _ -> " x "
let test2 ( ) = let list = [ f5 5 ; f5 7 ; f5 15 ; f5 26 ] in ignore list
let f0 x = x - 7 ;
let f1 x = x + iter
let f2 x = f1 ( x )
let f3 x = f2 ( x ) * f0 ( x )
let test3 ( ) = f3 iter
let ( ) = ignore ( test1 ( ) ) ; ignore ( test2 ( ) ) ; ignore ( test3 ( ) ) ; ( )
type ' a t = Jv . t
let fut p = Jv . obj [ | " fut " , p ] |
let promise f = Jv . get f " fut "
let promise ' f = Jv . get f " fut "
let create ( ) = let not_set = fun _ -> assert false in let is_set = fun _ -> Jv . throw ( Jstr . v " The future is already set " ) in let setter = ref not_set in let set_setter resolve _reject = setter := resolve in let p = Jv . Promise . create set_setter in let set v = ! setter v ; ...
let await f k = Jv . Promise . await ( promise f ) k
let return v = fut @@ Jv . Promise . resolve v
let bind f fn = fut @@ Jv . Promise . bind ( promise f ) ( fun v -> promise ( fn v ) )
let map fn f = bind f ( fun v -> return ( fn v ) )
let pair f0 f1 = fut @@ Jv . Promise . bind ( promise f0 ) @@ fun v0 -> Jv . Promise . bind ( promise f1 ) @@ fun v1 -> Jv . Promise . resolve ( v0 , v1 )
let of_list fs = let arr = Jv . of_list promise ' fs in let all = Jv . Promise . all arr in let to_list l = Jv . Promise . resolve ( Jv . to_list Obj . magic l ) in fut @@ Jv . Promise . bind all to_list
let tick ~ ms = fut @@ Jv . Promise . create @@ fun res _rej -> ignore ( Jv . apply ( Jv . get Jv . global " setTimeout " ) Jv . [ | repr res ; of_int ms ] ) |
type nonrec ( ' a , ' b ) result = ( ' a , ' b ) result t
type ' a or_error = ( ' a , Jv . Error . t ) result
let ok v = return ( Ok v )
let error e = return ( Error e )
let of_promise ' ~ ok ~ error p = let ok v = Jv . Promise . resolve ( Ok ( ok v ) ) in let error e = Jv . Promise . resolve ( Error ( error e ) ) in fut @@ Jv . Promise . then ' p ok error
let to_promise ' ~ ok ~ error f = Jv . Promise . create @@ fun res rej -> await f @@ function | Ok v -> res ( ok v ) | Error e -> rej ( error e )
let of_promise ~ ok v = of_promise ' ~ ok ~ error : Jv . to_error v
let to_promise ~ ok v = to_promise ' ~ ok ~ error : Jv . of_error v
module Syntax = struct let ( let * ) = bind let ( and * ) = pair let ( let + ) f fn = map fn f let ( and + ) = ( and * ) end
module Result_syntax = struct let result_pair r0 r1 = match r0 , r1 with | ( Error _ as r ) , _ | _ , ( Error _ as r ) -> r | Ok v0 , Ok v1 -> Ok ( v0 , v1 ) let ( let * ) f fn = bind f @@ function | Ok v -> fn v | Error _ as e -> return e let ( and * ) f0 f1 = map res...
type fuzzing_state = { rseed : int64 ; working_dir : string ; knobs : knobs ; stats : fuzzstat array ; initial_time : float ; wnd : window ; }
let dbconnect knobs = let open Mysql in try let dbd = connect ~ options [ ] : { dbhost = knobs . db_host ; dbname = Some knobs . db_name ; dbport = Some knobs . db_port ; dbpwd = Some knobs . db_password ; dbuser = Some knobs . db_user ; dbsocket = None ; } in Some dbd with Error...
let init_fuzzing_state knobs confs stats cwd wnd = let ( ) = init_logger ( get_logfile cwd ) knobs . verbosity in let ( ) = init_testgen confs in let rseed = fst knobs . seed_range in let dbhandle = dbconnect knobs in let ( ) = match dbhandle with | None -> ( ) | Some dbhandle -> Mysql...
let destroy_fuzzing_state st = destroy_interface ( ) ; fin_logger ( )
let interrupt_handler _ = vlogf verbose " Interrupted by the user !\ n " ; flush ( ) ; raise Interrupt
type fuzzing_fn = timeout -> fuzzconf -> fuzzing_state -> fuzzing_state
module type FuzzingAlg = sig val update_time_stat : int -> fuzzstat array -> float -> unit val fuzz : fuzzing_fn val reproduce : fuzzconf -> rseed -> fuzzing_state -> fuzzing_state end
module Fuzzing = functor ( TG : TestGen ) -> functor ( TE : TestEval ) -> struct let file_gen ( ( myfile , _ ) : input ) gendir = let digest = Digest . file myfile in let newfile = Digest . to_hex digest in logf " Generating a file % s into testcase dir \ n " newfile ; Fastlib . ...
module RandomFuzzing = Fuzzing ( RandomTestGen ) ( CrashEvalBySafeStack )
module SurfaceMutFuzzing = Fuzzing ( SurfaceMutGen ) ( CrashEvalBySafeStack )
module BallMutFuzzing = Fuzzing ( BallMutGen ) ( CrashEvalBySafeStack )
module ZzufFuzzing = Fuzzing ( ZzufTestGen ) ( CrashEvalBySafeStack )
let errcheck msg = function | true -> ( ) | false -> endwin ( ) ; failwith msg
let check_screen_size ( height , width ) = if width < 60 then failwith " terminal width must be greater than 80 " else if height < 25 then failwith " terminal height must be greater than 25 " else ( )
let check_colors = errcheck " terminal must support colors "
let check_addstr = errcheck " addstr failure "
let check_refresh = errcheck " refresh failure "
let check_cursor = errcheck " cursor error "
let print_num_right wnd height n = let n = Printf . sprintf " % d " n in mvwaddstr wnd height ( 30 - ( String . length n ) ) n |> check_addstr
let init_interface knobs = let wnd = initscr ( ) in let height , width = get_size ( ) in check_screen_size ( height , width ) ; has_colors ( ) |> check_colors ; start_color ( ) |> check_colors ; curs_set 0 |> check_cursor ; init_pair greenblack 2 0 |> check_colors ; init_pair...
let destroy_interface ( ) = endwin ( )
let update_status stat conf wnd = let uniq = Hashtbl . length stat . unique_set in let t = Unix . localtime stat . start_time in let time = Printf . sprintf " % 02d :% 02d :% 02d -% 02d /% 02d " t . Unix . tm_hour t . Unix . tm_min t . Unix . tm_sec ( t . Unix . tm_mon + 1...
let execute cmds timeout allow_output = Fastlib . exec cmds timeout allow_output
let is_crashing = function | 11 -> Some " SIGSEGV " | 8 -> Some " SIGFPE " | 7 -> Some " SIGBUS " | 4 -> Some " SIGILL " | 6 | _ -> None
let cleanup_dir dirpath = if not ( Sys . file_exists dirpath ) then Unix . mkdir dirpath 0o777 else Libfuzz . remove_dir_contents dirpath
let disable_x_redirection ( ) = ignore ( Sys . command " killall - 9 Xvfb x11vnc 2 > / dev / null " )
let check_xredirection prog = if check_program_availability prog then ( ) else let msg = Printf . sprintf " Could not find % s for X redirection . \ See the manual for more details . " prog in error_exit msg
let enable_x_redirection ( ) = let ( ) = disable_x_redirection ( ) in let ( ) = check_xredirection " Xvfb " in let ( ) = check_xredirection " x11vnc " in let xvfbcmd = " Xvfb : 42 - screen 0 1024x768x16 1 > / dev / null 2 > / dev / null " & in let _ = Sys . command...
let init_fuzzing_env path gui = let ( ) = cleanup_dir path in let ( ) = Unix . chdir path in let cwd = Unix . getcwd ( ) in let ( ) = set_coredump ( ) in let ( ) = if gui then enable_x_redirection ( ) else ( ) in cwd
type testgen_alg = | RandomWithReplacement | RandomWithoutReplacement | SurfaceMutational | BallMutational | ZzufMutational
let alg_to_string = function | RandomWithReplacement -> " Random w / Replacement " | RandomWithoutReplacement -> " Random w / o Replacement " | SurfaceMutational -> " Surface - based Mutational " | BallMutational -> " Ball - based Mutational " | ZzufMutational -> " Zzuf Mutational "
type seed_range = rseed * rseed
let default_seed_range = ( 0L , Int64 . max_int )
type input = string * rseed
type crash_id = { hashval : crashhash ; backtrace : string ; }
type fuzzresult = | Normal | TimedOut | Crashed of crash_id
type fuzzconf = { confid : int ; cmds : string list ; cmds_array : string array ; filearg_idx : int ; mratio : float * float ; seed_file : string ; part_file : string ; input_size : int ; }