Summary: This diff adds some FB-specific cost models. Reviewed By: ezgicicek Differential Revision: D17787903 fbshipit-source-id: cc49fad83master
parent
d3dc73a96e
commit
c509f1c178
@ -0,0 +1,34 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
open! IStd
|
||||||
|
module BasicCost = CostDomain.BasicCost
|
||||||
|
open BufferOverrunUtils.ModelEnv
|
||||||
|
|
||||||
|
type model = model_env -> ret:Ident.t * Typ.t -> BufferOverrunDomain.Mem.t -> BasicCost.t
|
||||||
|
|
||||||
|
let of_itv ~(itv : Itv.t) ~degree_kind ~of_function loc =
|
||||||
|
let upper_bound =
|
||||||
|
match itv with Bottom -> Bounds.Bound.pinf | NonBottom itv_pure -> Itv.ItvPure.ub itv_pure
|
||||||
|
in
|
||||||
|
Bounds.NonNegativeBound.of_modeled_function of_function loc upper_bound
|
||||||
|
|> BasicCost.of_non_negative_bound ~degree_kind
|
||||||
|
|
||||||
|
|
||||||
|
(** Given a string of length n and an optional starting index i (0 by
|
||||||
|
default), return itv [0, n_u-i_l] *)
|
||||||
|
let string_len_range_itv model_env exp ~from mem =
|
||||||
|
let itv =
|
||||||
|
BufferOverrunModels.JavaString.get_length model_env exp mem |> BufferOverrunDomain.Val.get_itv
|
||||||
|
in
|
||||||
|
Option.value_map from ~default:itv ~f:(fun (start_exp, integer_type_widths) ->
|
||||||
|
let start_itv =
|
||||||
|
BufferOverrunSemantics.eval integer_type_widths start_exp mem
|
||||||
|
|> BufferOverrunDomain.Val.get_itv
|
||||||
|
in
|
||||||
|
Itv.minus itv start_itv )
|
||||||
|
|> Itv.set_lb_zero
|
@ -0,0 +1,12 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
open! IStd
|
||||||
|
|
||||||
|
module Call = struct
|
||||||
|
let dispatch = ProcnameDispatcher.Call.make_dispatcher []
|
||||||
|
end
|
@ -0,0 +1,12 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
open! IStd
|
||||||
|
|
||||||
|
module Call : sig
|
||||||
|
val dispatch : (Tenv.t, CostUtils.model) ProcnameDispatcher.Call.dispatcher
|
||||||
|
end
|
@ -0,0 +1,13 @@
|
|||||||
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the MIT license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
|
TESTS_DIR = ../../..
|
||||||
|
|
||||||
|
INFER_OPTIONS = --cost-only --bufferoverrun --debug-exceptions --use-cost-threshold \
|
||||||
|
--report-force-relative-path
|
||||||
|
INFERPRINT_OPTIONS = --issues-tests
|
||||||
|
SOURCES = $(wildcard *.java)
|
||||||
|
|
||||||
|
include $(TESTS_DIR)/javac.make
|
Loading…
Reference in new issue