prefer Process_Theories over raw ML_Process;
authorwenzelm
Sun, 10 Aug 2025 23:30:55 +0200
changeset 82983 85887dcdef7f
parent 82982 cbeab5584c62
child 82984 98943be48607
prefer Process_Theories over raw ML_Process;
src/Pure/Tools/profiling.scala
--- a/src/Pure/Tools/profiling.scala	Sun Aug 10 22:11:50 2025 +0200
+++ b/src/Pure/Tools/profiling.scala	Sun Aug 10 23:30:55 2025 +0200
@@ -71,24 +71,21 @@
 
     def make(
       store: Store,
-      session_background: Sessions.Background,
+      session_base: Sessions.Base,
+      dirs: List[Path] = Nil,
       parent: Option[Statistics] = None
     ): Statistics = {
-      val session_base = session_background.base
       val session_name = session_base.session_name
 
-      val session = {
-        val args = session_base.used_theories.map(p => p._1.theory)
-        val eval_args =
-          List("--eval", "use_thy " + ML_Syntax.print_string_bytes("~~/src/Tools/Profiling"))
+      val session =
         Isabelle_System.with_tmp_dir("profiling") { dir =>
-          File.write(dir + Path.explode("args.yxml"), YXML.string_of_body(encode_args(args)))
+          File.write(dir + Path.explode("args.yxml"),
+            YXML.string_of_body(encode_args(session_base.used_theories.map(p => p._1.theory))))
           val ml_options = store.options + Options.Spec("profiling_dir", Some(dir.implode))
-          val session_heaps = store.session_heaps(session_background, logic = session_name)
-          ML_Process(ml_options, session_background, session_heaps, args = eval_args).result().check
+          Process_Theories.process_theories(ml_options, session_name,
+            dirs = dirs, files = List(Path.explode("~~/src/Tools/Profiling.thy"))).check
           decode_result(YXML.parse_body(Bytes.read(dir + Path.explode("result.yxml"))))
         }
-      }
 
       new Statistics(parent = parent, session = session_name,
         theories = session.theories,
@@ -247,12 +244,9 @@
       build_heap: Boolean = false,
       clean_build: Boolean = false
     ): Build.Results = {
-      val results =
-        Build.build(build_options, progress = progress,
-          selection = selection, build_heap = build_heap, clean_build = clean_build,
-          dirs = sessions_dirs, numa_shuffling = numa_shuffling, max_jobs = max_jobs)
-
-      if (results.ok) results else error("Build failed")
+      Build.build(build_options, progress = progress,
+        selection = selection, build_heap = build_heap, clean_build = clean_build,
+        dirs = sessions_dirs, numa_shuffling = numa_shuffling, max_jobs = max_jobs).check
     }
 
 
@@ -282,8 +276,8 @@
             parent_stats <- seen.get(parent_name)
           } yield parent_stats
         val stats =
-          Statistics.make(store,
-            build_results.deps.background(session_name),
+          Statistics.make(store, build_results.deps(session_name),
+            dirs = sessions_dirs,
             parent = parent)
         seen += (session_name -> stats)
         stats