Skip to content

Commit

Permalink
Reduce diff and cleanup a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Dec 14, 2024
1 parent ff52375 commit b674071
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/compiler/compilationCache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ class context_cache (index : int) (sign : Digest.t) = object(self)
| _ ->
let writer = HxbWriter.create config (Some string_pool) warn anon_identification in
HxbWriter.write_module writer m;

let chunks = HxbWriter.get_chunks writer in
Hashtbl.replace binary_cache path {
mc_path = path;
mc_id = m.m_id;
mc_chunks = HxbWriter.get_chunks writer;
mc_chunks = chunks;
mc_extra = { m.m_extra with m_cache_state = MSGood; m_display_deps = None }
}

Expand Down
26 changes: 9 additions & 17 deletions src/compiler/hxb/hxbReader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,13 @@ class hxb_reader
method set_delayed_field_loading f =
delayed_field_loading <- f :: delayed_field_loading

method add_dependency mdep =
match current_module.m_extra.m_display_deps with
| Some deps ->
if mdep != null_module && (current_module.m_path != mdep.m_path || current_module.m_extra.m_sign != mdep.m_extra.m_sign) then
current_module.m_extra.m_display_deps <- Some (PMap.add mdep.m_id ({md_sign = mdep.m_extra.m_sign; md_path = mdep.m_path; md_kind = mdep.m_extra.m_kind; md_origin = MDepFromTyping}) deps)
| None -> die "" __LOC__

method resolve_type pack mname tname =
try
let mt = api#resolve_type pack mname tname in
if not full_restore then begin
let tinfos = t_infos mt in
self#add_dependency tinfos.mt_module;
let mdep = (t_infos mt).mt_module in
if mdep != null_module && current_module.m_path != mdep.m_path then
current_module.m_extra.m_display_deps <- Some (PMap.add mdep.m_id (create_dependency mdep MDepFromTyping) (Option.get current_module.m_extra.m_display_deps))
end;
mt
with Not_found ->
Expand Down Expand Up @@ -1947,15 +1941,13 @@ class hxb_reader
if not full_restore then begin
let r = ref (lazy_processing t_dynamic) in
r := lazy_wait (fun() ->
begin match delayed_field_loading with
| [] -> ()
| f :: [] ->
let rec loop = function
| [] -> []
| f :: l ->
f();
delayed_field_loading <- []
| l ->
List.iter (fun f -> f()) l;
delayed_field_loading <- []
end;
loop l
in
delayed_field_loading <- loop delayed_field_loading;
cf.cf_type
);
cf.cf_type <- TLazy r;
Expand Down
5 changes: 4 additions & 1 deletion src/core/tFunctions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,16 @@ let null_abstract = {
a_enum = false;
}

let create_dependency mdep origin =
{md_sign = mdep.m_extra.m_sign; md_path = mdep.m_path; md_kind = mdep.m_extra.m_kind; md_origin = origin}

let add_dependency ?(skip_postprocess=false) m mdep = function
(* These module dependency origins should not add as a dependency *)
| MDepFromMacroInclude -> ()

| origin ->
if m != null_module && mdep != null_module && (m.m_path != mdep.m_path || m.m_extra.m_sign != mdep.m_extra.m_sign) then begin
m.m_extra.m_deps <- PMap.add mdep.m_id ({md_sign = mdep.m_extra.m_sign; md_path = mdep.m_path; md_kind = mdep.m_extra.m_kind; md_origin = origin}) m.m_extra.m_deps;
m.m_extra.m_deps <- PMap.add mdep.m_id (create_dependency mdep origin) m.m_extra.m_deps;
(* In case the module is cached, we'll have to run post-processing on it again (issue #10635) *)
if not skip_postprocess then m.m_extra.m_processed <- 0
end
Expand Down

0 comments on commit b674071

Please sign in to comment.