[cost] Add some cost models of IntHashMap

Summary: Costs of `IntHashMap.getElement`, `put`, and `remove` are O(1).

Reviewed By: ezgicicek

Differential Revision: D17829788

fbshipit-source-id: f1f6edfbb
master
Sungkeun Cho 5 years ago committed by Facebook Github Bot
parent ad5d5dd89e
commit 96a8b1cf5a

@ -64,10 +64,12 @@ let implements_collections = implements "java.util.Collections"
let implements_list = implements "java.util.List"
let implements_xmob_utils class_name = implements ("com.moblica.common.xmob.utils." ^ class_name)
let implements_pseudo_collection t s =
implements "android.util.SparseArray" t s
|| implements "android.util.SparseIntArray" t s
|| implements "com.moblica.common.xmob.utils.IntArrayList" t s
|| implements_xmob_utils "IntArrayList" t s
let implements_enumeration = implements "java.util.Enumeration"

@ -91,6 +91,9 @@ val implements_google : string -> Tenv.t -> string -> bool
val implements_android : string -> Tenv.t -> string -> bool
(** Check whether class implements a class of Android *)
val implements_xmob_utils : string -> Tenv.t -> string -> bool
(** Check whether class implements a class of xmod.utils *)
val supertype_exists : Tenv.t -> (Typ.Name.t -> Typ.Struct.t -> bool) -> Typ.Name.t -> bool
(** Holds iff the predicate holds on a supertype of the named type, including the type itself *)

@ -9,6 +9,8 @@ open! IStd
module BasicCost = CostDomain.BasicCost
open BufferOverrunUtils.ModelEnv
let unit_cost_model _model_env ~ret:_ _inferbo_mem = BasicCost.one
let linear exp ~of_function {integer_type_widths; location} ~ret:_ inferbo_mem =
let itv =
BufferOverrunSemantics.eval integer_type_widths exp inferbo_mem
@ -164,7 +166,11 @@ module Call = struct
$+ capt_exp $+ capt_exp $--> JavaString.substring_no_end
; +PatternMatch.implements_inject "Provider"
&:: "get"
<>--> modeled ~of_function:"Provider.get" ]
<>--> modeled ~of_function:"Provider.get"
; +PatternMatch.implements_xmob_utils "IntHashMap" &:: "<init>" <>--> unit_cost_model
; +PatternMatch.implements_xmob_utils "IntHashMap" &:: "getElement" <>--> unit_cost_model
; +PatternMatch.implements_xmob_utils "IntHashMap" &:: "put" <>--> unit_cost_model
; +PatternMatch.implements_xmob_utils "IntHashMap" &:: "remove" <>--> unit_cost_model ]
in
merge_dispatchers dispatcher FbCostModels.Call.dispatch
end

Loading…
Cancel
Save