-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename [Checks] to [Zero_alloc_info] * Remove [enabled] field of [Zero_alloc_info.t] The check is enabled by default. Compilation units compiled with and without CMXs are compatible and it is common to have a mix of both even in an unoptimized build, (since removal of closure and flambda2), which makes [enabled] field useless.
- Loading branch information
Showing
12 changed files
with
117 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module String = Misc.Stdlib.String | ||
|
||
type t = { mutable zero_alloc : int String.Map.t } | ||
|
||
let create () = { zero_alloc = String.Map.empty } | ||
|
||
let reset t = t.zero_alloc <- String.Map.empty | ||
|
||
let merge src ~into:dst = | ||
let join key b1 b2 = | ||
Misc.fatal_errorf "Unexpected merge %s %d %d" key b1 b2 | ||
in | ||
dst.zero_alloc <- String.Map.union join dst.zero_alloc src.zero_alloc | ||
|
||
type value = int | ||
|
||
let get_value (t : t) s = String.Map.find_opt s t.zero_alloc | ||
|
||
let set_value (t : t) s (v : value) = | ||
let f new_ old = | ||
if not (Option.is_none old) | ||
then Misc.fatal_errorf "Value of %s is already set" s; | ||
Some new_ | ||
in | ||
t.zero_alloc <- String.Map.update s (f v) t.zero_alloc | ||
|
||
module Raw = struct | ||
type entries = (string * int) list | ||
|
||
type t = entries option | ||
|
||
let entries_to_map (e : entries) = | ||
List.fold_left (fun acc (k, v) -> String.Map.add k v acc) String.Map.empty e | ||
|
||
let print t = | ||
let print (name, v) = Printf.printf "\t\t%s = %#x\n" name v in | ||
(* CR gyorsh: move encode/decode here somehow for noalloc *) | ||
Printf.printf "Function summaries for static checks:\n"; | ||
List.iter print t | ||
|
||
let print = function None -> () | Some t -> print t | ||
end | ||
|
||
let to_raw (t : t) : Raw.t = | ||
if String.Map.is_empty t.zero_alloc | ||
then None | ||
else Some (String.Map.bindings t.zero_alloc) | ||
|
||
let of_raw (t : Raw.t) : t = | ||
match t with | ||
| None -> create () | ||
| Some t -> { zero_alloc = Raw.entries_to_map t } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
(** Function summaries computed by zero_alloc analysis | ||
and encoded as integers for storing in .cmx files. *) | ||
|
||
type value = int | ||
|
||
type t | ||
|
||
val create : unit -> t | ||
|
||
val reset : t -> unit | ||
|
||
(** [merge_checks t ~into] modifies [into] by adding information from [t]. *) | ||
val merge : t -> into:t -> unit | ||
|
||
(** [get_value t fun_name] returns None if [fun_name] is not associated | ||
with any value. *) | ||
val get_value : t -> string -> value option | ||
|
||
val set_value : t -> string -> value -> unit | ||
|
||
module Raw : sig | ||
type t | ||
|
||
val print : t -> unit | ||
end | ||
|
||
val to_raw : t -> Raw.t | ||
|
||
val of_raw : Raw.t -> t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.