Skip to content

Commit e402150

Browse files
committed
Unbox some types
1 parent 3f4a6bc commit e402150

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/cdomains/floatDomain.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1036,11 +1036,11 @@ module FloatDomTupleImpl = struct
10361036
type 'a m = (module FloatDomain with type t = 'a)
10371037
(* only first-order polymorphism on functions
10381038
-> use records to get around monomorphism restriction on arguments (Same trick as used in intDomain) *)
1039-
type 'b poly_in = { fi : 'a. 'a m -> 'b -> 'a }
1040-
type 'b poly_pr = { fp : 'a. 'a m -> 'a -> 'b }
1041-
type 'b poly2_pr = { f2p : 'a. 'a m -> 'a -> 'a -> 'b }
1042-
type poly1 = { f1 : 'a. 'a m -> 'a -> 'a }
1043-
type poly2 = { f2 : 'a. 'a m -> 'a -> 'a -> 'a }
1039+
type 'b poly_in = { fi : 'a. 'a m -> 'b -> 'a } [@@unboxed]
1040+
type 'b poly_pr = { fp : 'a. 'a m -> 'a -> 'b } [@@unboxed]
1041+
type 'b poly2_pr = { f2p : 'a. 'a m -> 'a -> 'a -> 'b } [@@unboxed]
1042+
type poly1 = { f1 : 'a. 'a m -> 'a -> 'a } [@@unboxed]
1043+
type poly2 = { f2 : 'a. 'a m -> 'a -> 'a -> 'a } [@@unboxed]
10441044

10451045
let create r x (f1 : float_precision) =
10461046
let f b g = if b then Some (g x) else None in

src/cdomains/intDomain.ml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ struct
18951895
module I = BI
18961896
(* We use these types for the functions in this module to make the intended meaning more explicit *)
18971897
type t = Exc of BISet.t * Interval32.t
1898-
type inc = Inc of BISet.t
1898+
type inc = Inc of BISet.t [@@unboxed]
18991899
let max_of_range r = Size.max_from_bit_range (Option.get (R.maximal r))
19001900
let min_of_range r = Size.min_from_bit_range (Option.get (R.minimal r))
19011901
let cardinality_of_range r = BI.add BI.one (BI.add (BI.neg (min_of_range r)) (max_of_range r))
@@ -3403,18 +3403,18 @@ module IntDomTupleImpl = struct
34033403
type 'a m2 = (module SOverflow with type t = 'a and type int_t = int_t )
34043404

34053405
(* only first-order polymorphism on functions -> use records to get around monomorphism restriction on arguments *)
3406-
type 'b poly_in = { fi : 'a. 'a m -> 'b -> 'a } (* inject *)
3407-
type 'b poly2_in = { fi2 : 'a. 'a m2 -> 'b -> 'a } (* inject for functions that depend on int_t *)
3408-
type 'b poly2_in_ovc = { fi2_ovc : 'a. 'a m2 -> 'b -> 'a * overflow_info} (* inject for functions that depend on int_t *)
3409-
3410-
type 'b poly_pr = { fp : 'a. 'a m -> 'a -> 'b } (* project *)
3411-
type 'b poly_pr2 = { fp2 : 'a. 'a m2 -> 'a -> 'b } (* project for functions that depend on int_t *)
3412-
type 'b poly2_pr = {f2p: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a -> 'b}
3413-
type poly1 = {f1: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a} (* needed b/c above 'b must be different from 'a *)
3414-
type poly1_ovc = {f1_ovc: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a * overflow_info } (* needed b/c above 'b must be different from 'a *)
3415-
type poly2 = {f2: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a -> 'a}
3416-
type poly2_ovc = {f2_ovc: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a -> 'a * overflow_info }
3417-
type 'b poly3 = { f3: 'a. 'a m -> 'a option } (* used for projection to given precision *)
3406+
type 'b poly_in = { fi : 'a. 'a m -> 'b -> 'a } [@@unboxed] (* inject *)
3407+
type 'b poly2_in = { fi2 : 'a. 'a m2 -> 'b -> 'a } [@@unboxed] (* inject for functions that depend on int_t *)
3408+
type 'b poly2_in_ovc = { fi2_ovc : 'a. 'a m2 -> 'b -> 'a * overflow_info} [@@unboxed] (* inject for functions that depend on int_t *)
3409+
3410+
type 'b poly_pr = { fp : 'a. 'a m -> 'a -> 'b } [@@unboxed] (* project *)
3411+
type 'b poly_pr2 = { fp2 : 'a. 'a m2 -> 'a -> 'b } [@@unboxed] (* project for functions that depend on int_t *)
3412+
type 'b poly2_pr = {f2p: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a -> 'b} [@@unboxed]
3413+
type poly1 = {f1: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a} [@@unboxed] (* needed b/c above 'b must be different from 'a *)
3414+
type poly1_ovc = {f1_ovc: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a * overflow_info } [@@unboxed] (* needed b/c above 'b must be different from 'a *)
3415+
type poly2 = {f2: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a -> 'a} [@@unboxed]
3416+
type poly2_ovc = {f2_ovc: 'a. 'a m -> ?no_ov:bool -> 'a -> 'a -> 'a * overflow_info } [@@unboxed]
3417+
type 'b poly3 = { f3: 'a. 'a m -> 'a option } [@@unboxed] (* used for projection to given precision *)
34183418
let create r x ((p1, p2, p3, p4, p5): int_precision) =
34193419
let f b g = if b then Some (g x) else None in
34203420
f p1 @@ r.fi (module I1), f p2 @@ r.fi (module I2), f p3 @@ r.fi (module I3), f p4 @@ r.fi (module I4), f p5 @@ r.fi (module I5)

src/domains/queries.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ type 'a result = 'a
134134
Use [Analyses.ask_of_ctx] to convert [ctx] to [ask]. *)
135135
(* Must be in a singleton record due to second-order polymorphism.
136136
See https://ocaml.org/manual/polymorphism.html#s%3Ahigher-rank-poly. *)
137-
type ask = { f: 'a. 'a t -> 'a result }
137+
type ask = { f: 'a. 'a t -> 'a result } [@@unboxed]
138138

139139
(* Result cannot implement Lattice.S because the function types are different due to GADT. *)
140140
module Result =
@@ -267,7 +267,7 @@ end
267267

268268
(* The type any_query can't be directly defined in Any as t,
269269
because it also refers to the t from the outer scope. *)
270-
type any_query = Any: 'a t -> any_query
270+
type any_query = Any: 'a t -> any_query [@@unboxed]
271271

272272
module Any =
273273
struct

0 commit comments

Comments
 (0)