From bf165c99cccf30bee16899133ac51c8bbb62c756 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Sat, 7 Dec 2024 03:01:18 -0800 Subject: [PATCH] [multicore] DLS helper in Utils Summary: As per title, plus a comment fix in AnalysisGlobalState.mli. Reviewed By: skcho Differential Revision: D66805765 Privacy Context Container: L1208441 fbshipit-source-id: de1b9a3506676e9bf10e6c76fc2583ef2f2f99d7 --- infer/src/IR/AnalysisGlobalState.mli | 8 ++++---- infer/src/base/Utils.ml | 3 +++ infer/src/base/Utils.mli | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/infer/src/IR/AnalysisGlobalState.mli b/infer/src/IR/AnalysisGlobalState.mli index 5ee54fd5bd9..f47cbc8fc23 100644 --- a/infer/src/IR/AnalysisGlobalState.mli +++ b/infer/src/IR/AnalysisGlobalState.mli @@ -10,10 +10,10 @@ open! IStd (** {2 Global state for the backend analyses} While global state should be kept under control at possible (so try to introduce as little of it - as possible!), it is sometimes too convenient to ignore. This module lets us do it safely, at - least until infer becomes multicore. In particular, global state is appropriately and safely - stashed away and restored when the analysis of a procedure is suspended to go analyze another - procedure with ondemand (see the {!Backend.Ondemand} module). *) + as possible!), it is sometimes too convenient to ignore. This module lets us do it safely. In + particular, global state (really, domain-local state) is appropriately and safely stashed away + and restored when the analysis of a procedure is suspended to go analyze another procedure with + ondemand (see the {!Backend.Ondemand} module). *) type t diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index 37d289c9554..44627655bd2 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -513,3 +513,6 @@ let is_term_dumb () = true | _ -> false + + +let with_dls key ~f = Domain.DLS.get key |> f |> Domain.DLS.set key diff --git a/infer/src/base/Utils.mli b/infer/src/base/Utils.mli index 265dc96d16c..4a8d79bd2fe 100644 --- a/infer/src/base/Utils.mli +++ b/infer/src/base/Utils.mli @@ -152,3 +152,7 @@ val zip_fold : init:'a -> f:('a -> Zip.in_file -> Zip.entry -> 'a) -> zip_filena val is_term_dumb : unit -> bool (** Check if the terminal is "dumb" or otherwise has very limited functionality. For example, Emacs' eshell reports itself as a dumb terminal. *) + +val with_dls : 'a Domain.DLS.key -> f:('a -> 'a) -> unit +[@@warning "-unused-value-declaration"] +(** get value in domain local storage, pass to [f] and set to result *)