Browse Source

[server] use path instead of full module_def for m_dirty

This could keep modules referenced in the cache in some rare cases.
Simon Krajewski 6 năm trước cách đây
mục cha
commit
8b9acca714
4 tập tin đã thay đổi với 16 bổ sung16 xóa
  1. 11 11
      src/compiler/server.ml
  2. 2 2
      src/compiler/serverMessage.ml
  3. 1 1
      src/context/compilationServer.ml
  4. 2 2
      src/core/type.ml

+ 11 - 11
src/compiler/server.ml

@@ -9,7 +9,7 @@ open Type
 open DisplayOutput
 open Json
 
-exception Dirty of module_def
+exception Dirty of path
 exception ServerError of string
 
 let measure_times = ref false
@@ -380,12 +380,12 @@ let check_module sctx ctx m p =
 		let check_dependencies () =
 			PMap.iter (fun _ m2 -> match check m2 with
 				| None -> ()
-				| Some m -> raise (Dirty m)
+				| Some path -> raise (Dirty path)
 			) m.m_extra.m_deps;
 		in
 		begin match m.m_extra.m_dirty with
-		| Some m ->
-			Some m
+		| Some path ->
+			Some path
 		| None ->
 			if m.m_extra.m_mark = mark then
 				None
@@ -400,11 +400,11 @@ let check_module sctx ctx m p =
 				None
 			with
 			| Not_found ->
-				m.m_extra.m_dirty <- Some m;
-				Some m
-			| Dirty m' ->
-				m.m_extra.m_dirty <- Some m';
-				Some m'
+				m.m_extra.m_dirty <- Some m.m_path;
+				Some m.m_path
+			| Dirty path ->
+				m.m_extra.m_dirty <- Some path;
+				Some path
 			end
 	in
 	check m
@@ -460,8 +460,8 @@ let type_module sctx (ctx:Typecore.typer) mpath p =
 		let tcheck = Timer.timer ["server";"module cache";"check"] in
 		begin match check_module sctx ctx m p with
 		| None -> ()
-		| Some m' ->
-			ServerMessage.skipping_dep com "" (m,m');
+		| Some path ->
+			ServerMessage.skipping_dep com "" (m,path);
 			tcheck();
 			raise Not_found;
 		end;

+ 2 - 2
src/compiler/serverMessage.ml

@@ -85,8 +85,8 @@ let removed_directory com tabs dir =
 let reusing com tabs m =
 	if config.print_reusing then print_endline (Printf.sprintf "%s%sreusing %s" (sign_string com) tabs (s_type_path m.m_path))
 
-let skipping_dep com tabs (m,m') =
-	if config.print_skipping_dep then print_endline (Printf.sprintf "%sskipping %s%s" (sign_string com) (s_type_path m.m_path) (if m == m' then "" else Printf.sprintf "(%s)" (s_type_path m'.m_path)))
+let skipping_dep com tabs (m,path) =
+	if config.print_skipping_dep then print_endline (Printf.sprintf "%sskipping %s%s" (sign_string com) (s_type_path m.m_path) (if m.m_path = path then "" else Printf.sprintf "(%s)" (s_type_path path)))
 
 let unchanged_content com tabs file =
 	if config.print_unchanged_content then print_endline (Printf.sprintf "%s%s changed time not but content, reusing" (sign_string com) file)

+ 1 - 1
src/context/compilationServer.ml

@@ -141,7 +141,7 @@ class cache = object(self)
 	method taint_modules file =
 		Hashtbl.iter (fun _ cc ->
 			Hashtbl.iter (fun _ m ->
-				if m.m_extra.m_file = file then m.m_extra.m_dirty <- Some m
+				if m.m_extra.m_file = file then m.m_extra.m_dirty <- Some m.m_path
 			) cc#get_modules
 		) contexts
 

+ 2 - 2
src/core/type.ml

@@ -341,7 +341,7 @@ and module_def_extra = {
 	m_display : module_def_display;
 	mutable m_check_policy : module_check_policy list;
 	mutable m_time : float;
-	mutable m_dirty : module_def option;
+	mutable m_dirty : path option;
 	mutable m_added : int;
 	mutable m_mark : int;
 	mutable m_deps : (int,module_def) PMap.t;
@@ -1676,7 +1676,7 @@ module Printer = struct
 			"m_file",me.m_file;
 			"m_sign",me.m_sign;
 			"m_time",string_of_float me.m_time;
-			"m_dirty",s_opt (fun m -> s_type_path m.m_path) me.m_dirty;
+			"m_dirty",s_opt s_type_path me.m_dirty;
 			"m_added",string_of_int me.m_added;
 			"m_mark",string_of_int me.m_mark;
 			"m_deps",s_pmap string_of_int (fun m -> snd m.m_path) me.m_deps;