Skip to content

Commit

Permalink
Only delay make_lazy_type with PForce; use PConnectField for delaying…
Browse files Browse the repository at this point in the history
… chunks reading
  • Loading branch information
kLabz committed Jan 20, 2025
1 parent e134358 commit 2ad591b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/compiler/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ let get_hxb_module com cc path =
class hxb_reader_api_server
(com : Common.context)
(cc : context_cache)
(delay : (unit -> unit) -> unit)
(delay : Typecore.typer_pass -> (unit -> unit) -> unit)
= object(self)

method make_module (path : path) (file : string) =
Expand Down Expand Up @@ -453,7 +453,7 @@ class hxb_reader_api_server
(* We try to avoid reading expressions as much as possible, so we only do this for
our current display file if we're in display mode. *)
if full_restore then ignore(f_next chunks EOM)
else delay (fun () -> ignore(f_next chunks EOF));
else delay PConnectField (fun () -> ignore(f_next chunks EOF));
m
| BadModule reason ->
die (Printf.sprintf "Unexpected BadModule %s (%s)" (s_type_path path) (Printer.s_module_skip_reason reason)) __LOC__
Expand All @@ -476,7 +476,7 @@ class hxb_reader_api_server

method make_lazy_type t f =
let r = make_unforced_lazy t f "server-api" in
delay (fun () -> ignore(lazy_type r));
delay PForce (fun () -> ignore(lazy_type r));
TLazy r
end

Expand Down Expand Up @@ -605,7 +605,7 @@ and type_module sctx com delay mpath p =
(* We try to avoid reading expressions as much as possible, so we only do this for
our current display file if we're in display mode. *)
if full_restore then ignore(f_next chunks EOM)
else delay (fun () -> ignore(f_next chunks EOF));
else delay PConnectField (fun () -> ignore(f_next chunks EOF));
add_modules true m;
| Some reason ->
skip mpath reason
Expand Down
2 changes: 1 addition & 1 deletion src/context/display/displayTexpr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ let check_display_file ctx cs =
let m = try
ctx.com.module_lut#find path
with Not_found ->
begin match !TypeloadCacheHook.type_module_hook ctx.com (delay ctx.g PForce) path null_pos with
begin match !TypeloadCacheHook.type_module_hook ctx.com (delay ctx.g) path null_pos with
| NoModule | BadModule _ -> raise Not_found
| BinaryModule mc ->
let api = (new TypeloadModule.hxb_reader_api_typeload ctx.com ctx.g TypeloadModule.load_module' p :> HxbReaderApi.hxb_reader_api) in
Expand Down
2 changes: 1 addition & 1 deletion src/typing/typeloadCacheHook.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type find_module_result =
| BinaryModule of HxbData.module_cache
| NoModule

let type_module_hook : (Common.context -> ((unit -> unit) -> unit) -> path -> pos -> find_module_result) ref = ref (fun _ _ _ _ -> NoModule)
let type_module_hook : (Common.context -> (Typecore.typer_pass -> (unit -> unit) -> unit) -> path -> pos -> find_module_result) ref = ref (fun _ _ _ _ -> NoModule)

let fake_modules = Hashtbl.create 0

Expand Down
2 changes: 1 addition & 1 deletion src/typing/typeloadModule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ and load_module' com g m p =
com.module_lut#find m
with Not_found ->
(* Check cache *)
match !TypeloadCacheHook.type_module_hook com (delay g PForce) m p with
match !TypeloadCacheHook.type_module_hook com (delay g) m p with
| GoodModule m ->
m
| BinaryModule _ ->
Expand Down

0 comments on commit 2ad591b

Please sign in to comment.