[ConfigImpact] Add known cheap functions of System and Number

Reviewed By: ezgicicek

Differential Revision: D27394901

fbshipit-source-id: 3f4af1a24
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent 7a1ec45ebe
commit aff237306f

@ -109,9 +109,11 @@ module Java = struct
supertype_exists tenv is_interface (Typ.Name.Java.from_string typename)
let implements_lang class_name = implements ("java.lang." ^ class_name)
let implements_arrays = implements "java.util.Arrays"
let implements_iterable = implements "java.lang.Iterable"
let implements_iterable = implements_lang "Iterable"
let implements_iterator = implements "java.util.Iterator"
@ -121,7 +123,11 @@ module Java = struct
let implements_list = implements "java.util.List"
let implements_math = implements "java.lang.Math"
let implements_math = implements_lang "Math"
let implements_number = implements_lang "Number"
let implements_system = implements_lang "System"
let implements_xmob_utils class_name = implements ("com.moblica.common.xmob.utils." ^ class_name)
@ -162,8 +168,6 @@ module Java = struct
let implements_queue = implements "java.util.Queue"
let implements_lang class_name = implements ("java.lang." ^ class_name)
let implements_google class_name = implements ("com.google." ^ class_name)
let implements_android class_name = implements ("android." ^ class_name)

@ -95,6 +95,9 @@ module Java : sig
val implements_nio : string -> Tenv.t -> string -> bool
(** Check whether class implements a Java nio *)
val implements_number : Tenv.t -> string -> bool
(** Check whether class implements a Java's Number *)
val implements_org_json : string -> Tenv.t -> string -> bool
(** Check whether class implements a class from Json *)
@ -113,6 +116,9 @@ module Java : sig
val implements_sparse_float_array : Tenv.t -> string -> bool
(** Check whether class implements a class of [com.facebook.litho.internal.SparseFloatArray] *)
val implements_system : Tenv.t -> string -> bool
(** Check whether class implements a Java's System *)
val implements_view_group : Tenv.t -> string -> bool
(** Check whether class implements a class of [android.view.ViewGroup] *)

@ -375,10 +375,40 @@ module TransferFunctions = struct
&& Procname.get_method pname |> String.equal "booleanValue"
let is_cheap_system_method =
let cheap_system_methods =
String.Set.of_list
[ "clearProperty"
; "console"
; "currentTimeMillis"
; "exit"
; "getEnv"
; "getLogger"
; "getProperties"
; "getProperty"
; "getSecurityManager"
; "identityHashCode"
; "inheritedChannel"
; "lineSeparator"
; "mapLibraryName"
; "nanoTime"
; "setErr"
; "setIn"
; "setOut"
; "setProperties"
; "setProperty"
; "setSecurityManager" ]
in
fun _ method_name -> String.Set.mem cheap_system_methods method_name
let is_known_cheap_method =
let dispatch : (Tenv.t, unit, unit) ProcnameDispatcher.ProcName.dispatcher =
let open ProcnameDispatcher.ProcName in
make_dispatcher [+PatternMatch.Java.implements_math &::.*--> ()]
make_dispatcher
[ +PatternMatch.Java.implements_math &::.*--> ()
; +PatternMatch.Java.implements_number &::.*--> ()
; +PatternMatch.Java.implements_system &::+ is_cheap_system_method &--> () ]
in
fun tenv pname -> dispatch tenv pname |> Option.is_some

Loading…
Cancel
Save