src/Pure/ML/ml_heap.ML
author wenzelm
Mon, 20 Mar 2023 10:59:27 +0100
changeset 77692 3e746e684f4b
parent 69826 1bea05713dde
child 77765 8db468bd1ec6
permissions -rw-r--r--
clarified operations for ML object sizes;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62508
d0b68218ea55 discontinued RAW session: bootstrap directly from isabelle_process RAW_ML_SYSTEM;
wenzelm
parents: 62468
diff changeset
     1
(*  Title:      Pure/ML/ml_heap.ML
62467
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
     3
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
     4
ML heap operations.
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
     5
*)
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
     6
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
     7
signature ML_HEAP =
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
     8
sig
62825
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
     9
  val obj_size: 'a -> int
77692
3e746e684f4b clarified operations for ML object sizes;
wenzelm
parents: 69826
diff changeset
    10
  val sizeof1: 'a -> int
3e746e684f4b clarified operations for ML object sizes;
wenzelm
parents: 69826
diff changeset
    11
  val sizeof: 'a list -> int
67622
5289d3bdb261 more operations;
wenzelm
parents: 62825
diff changeset
    12
  val full_gc: unit -> unit
69826
1bea05713dde physical vs. logical events, the latter takes GC time into account;
wenzelm
parents: 67622
diff changeset
    13
  val gc_now: unit -> Time.time
62467
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
    14
  val share_common_data: unit -> unit
62825
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
    15
  val save_child: string -> unit
62467
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
    16
end;
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
    17
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
    18
structure ML_Heap: ML_HEAP =
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
    19
struct
62825
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
    20
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
    21
val obj_size = PolyML.objSize;
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
    22
77692
3e746e684f4b clarified operations for ML object sizes;
wenzelm
parents: 69826
diff changeset
    23
fun sizeof1 x = obj_size x * ML_System.platform_obj_size;
3e746e684f4b clarified operations for ML object sizes;
wenzelm
parents: 69826
diff changeset
    24
fun sizeof xs = (obj_size xs - 3 * length xs) * ML_System.platform_obj_size;
3e746e684f4b clarified operations for ML object sizes;
wenzelm
parents: 69826
diff changeset
    25
67622
5289d3bdb261 more operations;
wenzelm
parents: 62825
diff changeset
    26
val full_gc = PolyML.fullGC;
5289d3bdb261 more operations;
wenzelm
parents: 62825
diff changeset
    27
69826
1bea05713dde physical vs. logical events, the latter takes GC time into account;
wenzelm
parents: 67622
diff changeset
    28
fun gc_now () = #timeGCReal (PolyML.Statistics.getLocalStats ());
1bea05713dde physical vs. logical events, the latter takes GC time into account;
wenzelm
parents: 67622
diff changeset
    29
62825
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
    30
fun share_common_data () = PolyML.shareCommonData PolyML.rootFunction;
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
    31
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
    32
fun save_child name =
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
    33
  PolyML.SaveState.saveChild (name, List.length (PolyML.SaveState.showHierarchy ()));
e6e80a8bf624 structure PolyML is sealed after bootstrap: all ML system access is managed by Isabelle;
wenzelm
parents: 62630
diff changeset
    34
62467
c1b88e647e2f clarified ML heap operations;
wenzelm
parents:
diff changeset
    35
end;