Skip to content

Commit 7199bfb

Browse files
committed
Build on OCaml 5.0 and test unread copies with runtime interfaces
Mutex.protect only exists from OCaml 5.1, so the count table locks with Mutex.lock and Fun.protect like Process_child.with_lock. The unread copy test asked for Belt modules, which the coverage job doesn't build; it now uses runtime interfaces only. Signed-off-by: Jono Prest <jjprest@gmail.com>
1 parent c0eb89c commit 7199bfb

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎changes/defer-dependency-signature-copy.internal.md‎

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Build: copy a dependency's interface only when it is read, after the first copy of the same interface in a build, instead of every time a module checks whether the dependency is an alias.

‎compiler/ml/env.ml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,16 @@ type pers_sig = {
585585
let copy_counts : (Digest.t, int * int) Hashtbl.t = Hashtbl.create 64
586586
let copy_counts_lock = Mutex.create ()
587587

588+
(* [Mutex.protect] needs OCaml 5.1. *)
589+
let with_copy_counts_lock action =
590+
Mutex.lock copy_counts_lock;
591+
Fun.protect ~finally:(fun () -> Mutex.unlock copy_counts_lock) action
592+
588593
let find_copy_counts key =
589-
Mutex.protect copy_counts_lock (fun () -> Hashtbl.find_opt copy_counts key)
594+
with_copy_counts_lock (fun () -> Hashtbl.find_opt copy_counts key)
590595

591596
let record_copy_counts key counts =
592-
Mutex.protect copy_counts_lock (fun () ->
597+
with_copy_counts_lock (fun () ->
593598
if Hashtbl.length copy_counts >= 65536 then Hashtbl.reset copy_counts;
594599
Hashtbl.replace copy_counts key counts)
595600

‎tests/ounit_tests/ounit_deferred_signature_tests.ml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ let deferred_copy_tests _ =
8484
(* A copy that is never read still takes its stamps and ids. *)
8585
let unread_copy_tests _ =
8686
let dirs = interface_dirs () in
87-
let names = ["Belt_Array"; "Stdlib_Array"; "Belt_Id"; "Stdlib"] in
87+
let names = ["Stdlib_Array"; "Stdlib_List"; "Stdlib_Option"; "Stdlib"] in
8888
let ask_only ~eager =
8989
Compiler_request_state.with_fresh (fun () ->
9090
Request_local.with_fresh (fun () ->

0 commit comments

Comments
 (0)