|
@@ -103,12 +103,8 @@ module ServerCompilationContext = struct
|
|
cs : CompilationCache.t;
|
|
cs : CompilationCache.t;
|
|
(* A list of class paths per-signature *)
|
|
(* A list of class paths per-signature *)
|
|
class_paths : (Digest.t,string list) Hashtbl.t;
|
|
class_paths : (Digest.t,string list) Hashtbl.t;
|
|
- (* Increased for each typed module *)
|
|
|
|
- mutable mark_loop : int;
|
|
|
|
(* Increased for each compilation *)
|
|
(* Increased for each compilation *)
|
|
mutable compilation_step : int;
|
|
mutable compilation_step : int;
|
|
- (* The [mark_loop] value at which we started the current compilation *)
|
|
|
|
- mutable compilation_mark : int;
|
|
|
|
(* A list of delays which are run after compilation *)
|
|
(* A list of delays which are run after compilation *)
|
|
mutable delays : (unit -> unit) list;
|
|
mutable delays : (unit -> unit) list;
|
|
(* True if it's an actual compilation, false if it's a display operation *)
|
|
(* True if it's an actual compilation, false if it's a display operation *)
|
|
@@ -123,8 +119,6 @@ module ServerCompilationContext = struct
|
|
class_paths = Hashtbl.create 0;
|
|
class_paths = Hashtbl.create 0;
|
|
changed_directories = Hashtbl.create 0;
|
|
changed_directories = Hashtbl.create 0;
|
|
compilation_step = 0;
|
|
compilation_step = 0;
|
|
- compilation_mark = 0;
|
|
|
|
- mark_loop = 0;
|
|
|
|
delays = [];
|
|
delays = [];
|
|
was_compilation = false;
|
|
was_compilation = false;
|
|
macro_context_setup = false;
|
|
macro_context_setup = false;
|
|
@@ -152,8 +146,6 @@ module ServerCompilationContext = struct
|
|
stats.s_methods_typed := 0;
|
|
stats.s_methods_typed := 0;
|
|
stats.s_macros_called := 0;
|
|
stats.s_macros_called := 0;
|
|
Hashtbl.clear Timer.htimers;
|
|
Hashtbl.clear Timer.htimers;
|
|
- sctx.compilation_step <- sctx.compilation_step + 1;
|
|
|
|
- sctx.compilation_mark <- sctx.mark_loop;
|
|
|
|
Helper.start_time := get_time()
|
|
Helper.start_time := get_time()
|
|
|
|
|
|
let maybe_cache_context sctx com =
|
|
let maybe_cache_context sctx com =
|
|
@@ -207,8 +199,6 @@ module Communication = struct
|
|
write s
|
|
write s
|
|
);
|
|
);
|
|
flush = (fun ctx ->
|
|
flush = (fun ctx ->
|
|
- sctx.compilation_step <- sctx.compilation_step + 1;
|
|
|
|
- sctx.compilation_mark <- sctx.mark_loop;
|
|
|
|
check_display_flush ctx (fun () ->
|
|
check_display_flush ctx (fun () ->
|
|
List.iter
|
|
List.iter
|
|
(fun msg ->
|
|
(fun msg ->
|
|
@@ -325,8 +315,7 @@ let check_module sctx ctx m p =
|
|
end
|
|
end
|
|
) paths
|
|
) paths
|
|
in
|
|
in
|
|
- let mark = sctx.mark_loop in
|
|
|
|
- let start_mark = sctx.compilation_mark in
|
|
|
|
|
|
+ let start_mark = sctx.compilation_step in
|
|
let rec check m =
|
|
let rec check m =
|
|
let check_module_path () =
|
|
let check_module_path () =
|
|
let directories = get_changed_directories sctx ctx in
|
|
let directories = get_changed_directories sctx ctx in
|
|
@@ -390,26 +379,34 @@ let check_module sctx ctx m p =
|
|
| Some _ -> raise (Dirty (DependencyDirty m2.m_path))
|
|
| Some _ -> raise (Dirty (DependencyDirty m2.m_path))
|
|
) m.m_extra.m_deps;
|
|
) m.m_extra.m_deps;
|
|
in
|
|
in
|
|
- begin match m.m_extra.m_dirty with
|
|
|
|
- | Some path ->
|
|
|
|
- Some path
|
|
|
|
- | None ->
|
|
|
|
- if m.m_extra.m_mark = mark then
|
|
|
|
- None
|
|
|
|
- else try
|
|
|
|
- let old_mark = m.m_extra.m_mark in
|
|
|
|
- m.m_extra.m_mark <- mark;
|
|
|
|
- if old_mark <= start_mark then begin
|
|
|
|
- if not (has_policy NoCheckShadowing) then check_module_path();
|
|
|
|
- if not (has_policy NoCheckFileTimeModification) || file_extension (Path.UniqueKey.lazy_path m.m_extra.m_file) <> "hx" then check_file();
|
|
|
|
- end;
|
|
|
|
|
|
+ let check () =
|
|
|
|
+ try
|
|
|
|
+ if not (has_policy NoCheckShadowing) then check_module_path();
|
|
|
|
+ if not (has_policy NoCheckFileTimeModification) || file_extension (Path.UniqueKey.lazy_path m.m_extra.m_file) <> "hx" then check_file();
|
|
if not (has_policy NoCheckDependencies) then check_dependencies();
|
|
if not (has_policy NoCheckDependencies) then check_dependencies();
|
|
None
|
|
None
|
|
with
|
|
with
|
|
| Dirty reason ->
|
|
| Dirty reason ->
|
|
- m.m_extra.m_dirty <- Some reason;
|
|
|
|
Some reason
|
|
Some reason
|
|
- end
|
|
|
|
|
|
+ in
|
|
|
|
+ (* If the module mark matches our compilation mark, we are done *)
|
|
|
|
+ if m.m_extra.m_checked = start_mark then
|
|
|
|
+ m.m_extra.m_dirty
|
|
|
|
+ else begin
|
|
|
|
+ (* Otherwise, set to current compilation mark for recursion *)
|
|
|
|
+ m.m_extra.m_checked <- start_mark;
|
|
|
|
+ let dirty = match m.m_extra.m_dirty with
|
|
|
|
+ | Some _ as dirty ->
|
|
|
|
+ (* If we are already dirty, stick to it. *)
|
|
|
|
+ dirty
|
|
|
|
+ | None ->
|
|
|
|
+ (* Otherwise, run the checks *)
|
|
|
|
+ check ()
|
|
|
|
+ in
|
|
|
|
+ (* Update the module now. It will use this dirty status for the remainder of this compilation. *)
|
|
|
|
+ m.m_extra.m_dirty <- dirty;
|
|
|
|
+ dirty
|
|
|
|
+ end
|
|
in
|
|
in
|
|
check m
|
|
check m
|
|
|
|
|
|
@@ -424,8 +421,8 @@ let add_modules sctx ctx m p =
|
|
(* this was just a dependency to check : do not add to the context *)
|
|
(* this was just a dependency to check : do not add to the context *)
|
|
PMap.iter (Hashtbl.replace com.resources) m.m_extra.m_binded_res;
|
|
PMap.iter (Hashtbl.replace com.resources) m.m_extra.m_binded_res;
|
|
| _ ->
|
|
| _ ->
|
|
- ServerMessage.reusing com tabs m;
|
|
|
|
m.m_extra.m_added <- sctx.compilation_step;
|
|
m.m_extra.m_added <- sctx.compilation_step;
|
|
|
|
+ ServerMessage.reusing com tabs m;
|
|
List.iter (fun t ->
|
|
List.iter (fun t ->
|
|
match t with
|
|
match t with
|
|
| TClassDecl c -> c.cl_restore()
|
|
| TClassDecl c -> c.cl_restore()
|
|
@@ -456,7 +453,6 @@ let type_module sctx (ctx:Typecore.typer) mpath p =
|
|
let t = Timer.timer ["server";"module cache"] in
|
|
let t = Timer.timer ["server";"module cache"] in
|
|
let com = ctx.Typecore.com in
|
|
let com = ctx.Typecore.com in
|
|
let cc = CommonCache.get_cache com in
|
|
let cc = CommonCache.get_cache com in
|
|
- sctx.mark_loop <- sctx.mark_loop + 1;
|
|
|
|
try
|
|
try
|
|
let m = cc#find_module mpath in
|
|
let m = cc#find_module mpath in
|
|
let tcheck = Timer.timer ["server";"module cache";"check"] in
|
|
let tcheck = Timer.timer ["server";"module cache";"check"] in
|
|
@@ -624,11 +620,21 @@ let do_connect host port args =
|
|
process();
|
|
process();
|
|
if !has_error then exit 1
|
|
if !has_error then exit 1
|
|
|
|
|
|
|
|
+let enable_cache_mode sctx =
|
|
|
|
+ TypeloadModule.type_module_hook := type_module sctx;
|
|
|
|
+ MacroContext.macro_enable_cache := true;
|
|
|
|
+ ServerCompilationContext.ensure_macro_setup sctx;
|
|
|
|
+ TypeloadParse.parse_hook := parse_file sctx.cs
|
|
|
|
+
|
|
let rec process sctx comm args =
|
|
let rec process sctx comm args =
|
|
let t0 = get_time() in
|
|
let t0 = get_time() in
|
|
ServerMessage.arguments args;
|
|
ServerMessage.arguments args;
|
|
reset sctx;
|
|
reset sctx;
|
|
let api = {
|
|
let api = {
|
|
|
|
+ on_context_create = (fun () ->
|
|
|
|
+ sctx.compilation_step <- sctx.compilation_step + 1;
|
|
|
|
+ sctx.compilation_step;
|
|
|
|
+ );
|
|
cache = sctx.cs;
|
|
cache = sctx.cs;
|
|
before_anything = before_anything sctx;
|
|
before_anything = before_anything sctx;
|
|
after_arg_parsing = after_arg_parsing sctx;
|
|
after_arg_parsing = after_arg_parsing sctx;
|
|
@@ -651,10 +657,7 @@ and wait_loop verbose accept =
|
|
(* Create server context and set up hooks for parsing and typing *)
|
|
(* Create server context and set up hooks for parsing and typing *)
|
|
let sctx = ServerCompilationContext.create verbose in
|
|
let sctx = ServerCompilationContext.create verbose in
|
|
let cs = sctx.cs in
|
|
let cs = sctx.cs in
|
|
- TypeloadModule.type_module_hook := type_module sctx;
|
|
|
|
- MacroContext.macro_enable_cache := true;
|
|
|
|
- ServerCompilationContext.ensure_macro_setup sctx;
|
|
|
|
- TypeloadParse.parse_hook := parse_file cs;
|
|
|
|
|
|
+ enable_cache_mode sctx;
|
|
let ring = Ring.create 10 0. in
|
|
let ring = Ring.create 10 0. in
|
|
let gc_heap_stats () =
|
|
let gc_heap_stats () =
|
|
let stats = Gc.quick_stat() in
|
|
let stats = Gc.quick_stat() in
|