Просмотр исходного кода

[hxb] remove writer stats

I broke parts of it already anyway.
Simon Krajewski 1 год назад
Родитель
Сommit
d9fc90a850

+ 2 - 2
src/compiler/compilationCache.ml

@@ -69,12 +69,12 @@ class context_cache (index : int) (sign : Digest.t) = object(self)
 	method find_module_extra path =
 	method find_module_extra path =
 		try (Hashtbl.find modules path).m_extra with Not_found -> (Hashtbl.find binary_cache path).mc_extra
 		try (Hashtbl.find modules path).m_extra with Not_found -> (Hashtbl.find binary_cache path).mc_extra
 
 
-	method cache_module config warn anon_identification hxb_writer_stats path m =
+	method cache_module config warn anon_identification path m =
 		match m.m_extra.m_kind with
 		match m.m_extra.m_kind with
 		| MImport ->
 		| MImport ->
 			Hashtbl.add modules m.m_path m
 			Hashtbl.add modules m.m_path m
 		| _ ->
 		| _ ->
-			let writer = HxbWriter.create config warn anon_identification hxb_writer_stats in
+			let writer = HxbWriter.create config warn anon_identification in
 			HxbWriter.write_module writer m;
 			HxbWriter.write_module writer m;
 			let chunks = HxbWriter.get_chunks writer in
 			let chunks = HxbWriter.get_chunks writer in
 			Hashtbl.replace binary_cache path {
 			Hashtbl.replace binary_cache path {

+ 1 - 1
src/compiler/generate.ml

@@ -42,7 +42,7 @@ let export_hxb com config cc platform zip m =
 			with Not_found ->
 			with Not_found ->
 				let anon_identification = new tanon_identification in
 				let anon_identification = new tanon_identification in
 				let warn w s p = com.Common.warning w com.warning_options s p in
 				let warn w s p = com.Common.warning w com.warning_options s p in
-				let writer = HxbWriter.create config warn anon_identification com.hxb_writer_stats in
+				let writer = HxbWriter.create config warn anon_identification in
 				HxbWriter.write_module writer m;
 				HxbWriter.write_module writer m;
 				let out = IO.output_string () in
 				let out = IO.output_string () in
 				HxbWriter.export writer out;
 				HxbWriter.export writer out;

+ 5 - 78
src/compiler/hxb/hxbWriter.ml

@@ -45,63 +45,6 @@ let unop_index op flag = match op,flag with
 	| NegBits,Postfix -> 10
 	| NegBits,Postfix -> 10
 	| Spread,Postfix -> 11
 	| Spread,Postfix -> 11
 
 
-type hxb_writer_stats = {
-	type_instance_kind_writes : int array;
-	texpr_writes : int array;
-	type_instance_immediate : int ref;
-	type_instance_cache_hits : int ref;
-	type_instance_cache_misses : int ref;
-	pos_writes_full : int ref;
-	pos_writes_min : int ref;
-	pos_writes_max : int ref;
-	pos_writes_minmax : int ref;
-	pos_writes_eq : int ref;
-	chunk_sizes : (string,int ref * int ref) Hashtbl.t;
-}
-
-let create_hxb_writer_stats () = {
-	type_instance_kind_writes = Array.make 255 0;
-	texpr_writes = Array.make 255 0;
-	type_instance_immediate = ref 0;
-	type_instance_cache_hits = ref 0;
-	type_instance_cache_misses = ref 0;
-	pos_writes_full = ref 0;
-	pos_writes_min = ref 0;
-	pos_writes_max = ref 0;
-	pos_writes_minmax = ref 0;
-	pos_writes_eq = ref 0;
-	chunk_sizes = Hashtbl.create 0;
-}
-
-let dump_stats name stats =
-	let sort_and_filter_array a =
-		let _,kind_writes = Array.fold_left (fun (index,acc) writes ->
-			(index + 1,if writes = 0 then acc else (index,writes) :: acc)
-		) (0,[]) a in
-		let kind_writes = List.sort (fun (_,writes1) (_,writes2) -> compare writes2 writes1) kind_writes in
-		List.map (fun (index,writes) -> Printf.sprintf "    %3i: %9i" index writes) kind_writes
-	in
-	let t_kind_writes = sort_and_filter_array stats.type_instance_kind_writes in
-	print_endline (Printf.sprintf "hxb_writer stats for %s" name);
-	print_endline "  type instance kind writes:";
-	List.iter print_endline t_kind_writes;
-	let texpr_writes = sort_and_filter_array stats.texpr_writes in
-	print_endline "  texpr writes:";
-	List.iter print_endline texpr_writes;
-
-	print_endline "  type instance writes:";
-	print_endline (Printf.sprintf "     immediate: %9i" !(stats.type_instance_immediate));
-	print_endline (Printf.sprintf "    cache hits: %9i" !(stats.type_instance_cache_hits));
-	print_endline (Printf.sprintf "    cache miss: %9i" !(stats.type_instance_cache_misses));
-	print_endline "  pos writes:";
-	print_endline (Printf.sprintf "      full: %9i\n       min: %9i\n       max: %9i\n    minmax: %9i\n     equal: %9i" !(stats.pos_writes_full) !(stats.pos_writes_min) !(stats.pos_writes_max) !(stats.pos_writes_minmax) !(stats.pos_writes_eq));
-	(* let chunk_sizes = Hashtbl.fold (fun name (imin,imax) acc -> (name,!imin,!imax) :: acc) stats.chunk_sizes [] in
-	let chunk_sizes = List.sort (fun (_,imin1,imax1) (_,imin2,imax2) -> compare imax1 imax2) chunk_sizes in
-	print_endline "chunk sizes:";
-	List.iter (fun (name,imin,imax) ->
-		print_endline (Printf.sprintf "    %s: %i - %i" name imin imax)
-	) chunk_sizes *)
-
 module StringHashtbl = Hashtbl.Make(struct
 module StringHashtbl = Hashtbl.Make(struct
 	type t = string
 	type t = string
 
 
@@ -400,17 +343,10 @@ module Chunk = struct
 	let write_bool io b =
 	let write_bool io b =
 		write_u8 io (if b then 1 else 0)
 		write_u8 io (if b then 1 else 0)
 
 
-	let export : 'a . hxb_writer_stats -> t -> 'a IO.output -> unit = fun stats io chex ->
+	let export : 'a . t -> 'a IO.output -> unit = fun io chex ->
 		let bytes = get_bytes io in
 		let bytes = get_bytes io in
 		let length = Bytes.length bytes in
 		let length = Bytes.length bytes in
 		write_chunk_prefix io.kind length chex;
 		write_chunk_prefix io.kind length chex;
-		(* begin try
-			let (imin,imax) = Hashtbl.find stats.chunk_sizes io.name in
-			if length < !imin then imin := length;
-			if length > !imax then imax := length
-		with Not_found ->
-			Hashtbl.add stats.chunk_sizes io.name (ref length,ref length);
-		end; *)
 		IO.nwrite chex bytes
 		IO.nwrite chex bytes
 
 
 	let write_string chunk s =
 	let write_string chunk s =
@@ -438,22 +374,19 @@ end
 
 
 module PosWriter = struct
 module PosWriter = struct
 	type t = {
 	type t = {
-		stats : hxb_writer_stats;
 		mutable p_file : string;
 		mutable p_file : string;
 		mutable p_min : int;
 		mutable p_min : int;
 		mutable p_max : int;
 		mutable p_max : int;
 	}
 	}
 
 
 	let do_write_pos (chunk : Chunk.t) (p : pos) =
 	let do_write_pos (chunk : Chunk.t) (p : pos) =
-		(* incr stats.pos_writes_full; *)
 		Chunk.write_string chunk p.pfile;
 		Chunk.write_string chunk p.pfile;
 		Chunk.write_leb128 chunk p.pmin;
 		Chunk.write_leb128 chunk p.pmin;
 		Chunk.write_leb128 chunk p.pmax
 		Chunk.write_leb128 chunk p.pmax
 
 
-	let create stats chunk p =
+	let create chunk p =
 		do_write_pos chunk p;
 		do_write_pos chunk p;
 	{
 	{
-		stats;
 		p_file = p.pfile;
 		p_file = p.pfile;
 		p_min = p.pmin;
 		p_min = p.pmin;
 		p_max = p.pmax;
 		p_max = p.pmax;
@@ -470,7 +403,6 @@ module PosWriter = struct
 		end else if p.pmin <> pw.p_min then begin
 		end else if p.pmin <> pw.p_min then begin
 			if p.pmax <> pw.p_max then begin
 			if p.pmax <> pw.p_max then begin
 				(* pmin and pmax changed *)
 				(* pmin and pmax changed *)
-				(* incr stats.pos_writes_minmax; *)
 				Chunk.write_u8 chunk (3 + offset);
 				Chunk.write_u8 chunk (3 + offset);
 				Chunk.write_leb128 chunk p.pmin;
 				Chunk.write_leb128 chunk p.pmin;
 				Chunk.write_leb128 chunk p.pmax;
 				Chunk.write_leb128 chunk p.pmax;
@@ -478,19 +410,16 @@ module PosWriter = struct
 				pw.p_max <- p.pmax;
 				pw.p_max <- p.pmax;
 			end else begin
 			end else begin
 				(* pmin changed *)
 				(* pmin changed *)
-				(* incr stats.pos_writes_min; *)
 				Chunk.write_u8 chunk (1 + offset);
 				Chunk.write_u8 chunk (1 + offset);
 				Chunk.write_leb128 chunk p.pmin;
 				Chunk.write_leb128 chunk p.pmin;
 				pw.p_min <- p.pmin;
 				pw.p_min <- p.pmin;
 			end
 			end
 		end else if p.pmax <> pw.p_max then begin
 		end else if p.pmax <> pw.p_max then begin
 			(* pmax changed *)
 			(* pmax changed *)
-			(* incr stats.pos_writes_max; *)
 			Chunk.write_u8 chunk (2 + offset);
 			Chunk.write_u8 chunk (2 + offset);
 			Chunk.write_leb128 chunk p.pmax;
 			Chunk.write_leb128 chunk p.pmax;
 			pw.p_max <- p.pmax;
 			pw.p_max <- p.pmax;
 		end else begin
 		end else begin
-			(* incr stats.pos_writes_eq; *)
 			if write_equal then
 			if write_equal then
 				Chunk.write_u8 chunk offset;
 				Chunk.write_u8 chunk offset;
 		end
 		end
@@ -514,7 +443,6 @@ type hxb_writer = {
 	config : HxbWriterConfig.writer_target_config;
 	config : HxbWriterConfig.writer_target_config;
 	warn : Warning.warning -> string -> Globals.pos -> unit;
 	warn : Warning.warning -> string -> Globals.pos -> unit;
 	anon_id : Type.t Tanon_identification.tanon_identification;
 	anon_id : Type.t Tanon_identification.tanon_identification;
-	stats : hxb_writer_stats;
 	mutable current_module : module_def;
 	mutable current_module : module_def;
 	chunks : Chunk.t DynArray.t;
 	chunks : Chunk.t DynArray.t;
 	cp : StringPool.t;
 	cp : StringPool.t;
@@ -1794,7 +1722,7 @@ module HxbWriter = struct
 
 
 	and start_texpr writer (p: pos) =
 	and start_texpr writer (p: pos) =
 		let restore = start_temporary_chunk writer 512 in
 		let restore = start_temporary_chunk writer 512 in
-		let fctx = create_field_writer_context (PosWriter.create writer.stats writer.chunk p) in
+		let fctx = create_field_writer_context (PosWriter.create writer.chunk p) in
 		fctx,(fun () ->
 		fctx,(fun () ->
 			restore(fun new_chunk ->
 			restore(fun new_chunk ->
 				let restore = start_temporary_chunk writer 512 in
 				let restore = start_temporary_chunk writer 512 in
@@ -2287,13 +2215,12 @@ module HxbWriter = struct
 		l
 		l
 end
 end
 
 
-let create config warn anon_id stats =
+let create config warn anon_id =
 	let cp = StringPool.create () in
 	let cp = StringPool.create () in
 	{
 	{
 		config;
 		config;
 		warn;
 		warn;
 		anon_id;
 		anon_id;
-		stats;
 		current_module = null_module;
 		current_module = null_module;
 		chunks = DynArray.create ();
 		chunks = DynArray.create ();
 		cp = cp;
 		cp = cp;
@@ -2333,5 +2260,5 @@ let export : 'a . hxb_writer -> 'a IO.output -> unit = fun writer ch ->
 	write_header ch;
 	write_header ch;
 	let l = HxbWriter.get_sorted_chunks writer in
 	let l = HxbWriter.get_sorted_chunks writer in
 	List.iter (fun io ->
 	List.iter (fun io ->
-		Chunk.export writer.stats io ch
+		Chunk.export io ch
 	) l
 	) l

+ 0 - 3
src/context/common.ml

@@ -420,7 +420,6 @@ type context = {
 	mutable basic : basic_types;
 	mutable basic : basic_types;
 	memory_marker : float array;
 	memory_marker : float array;
 	hxb_reader_stats : HxbReader.hxb_reader_stats;
 	hxb_reader_stats : HxbReader.hxb_reader_stats;
-	hxb_writer_stats : HxbWriter.hxb_writer_stats;
 	mutable hxb_writer_config : HxbWriterConfig.t option;
 	mutable hxb_writer_config : HxbWriterConfig.t option;
 }
 }
 
 
@@ -883,7 +882,6 @@ let create compilation_step cs version args display_mode =
 		report_mode = RMNone;
 		report_mode = RMNone;
 		is_macro_context = false;
 		is_macro_context = false;
 		hxb_reader_stats = HxbReader.create_hxb_reader_stats ();
 		hxb_reader_stats = HxbReader.create_hxb_reader_stats ();
-		hxb_writer_stats = HxbWriter.create_hxb_writer_stats ();
 		hxb_writer_config = None;
 		hxb_writer_config = None;
 	} in
 	} in
 	com
 	com
@@ -935,7 +933,6 @@ let clone com is_macro_context =
 		overload_cache = new hashtbl_lookup;
 		overload_cache = new hashtbl_lookup;
 		module_lut = new module_lut;
 		module_lut = new module_lut;
 		hxb_reader_stats = HxbReader.create_hxb_reader_stats ();
 		hxb_reader_stats = HxbReader.create_hxb_reader_stats ();
-		hxb_writer_stats = HxbWriter.create_hxb_writer_stats ();
 		std = null_class;
 		std = null_class;
 		empty_class_path = new ClassPath.directory_class_path "" User;
 		empty_class_path = new ClassPath.directory_class_path "" User;
 		class_paths = new ClassPaths.class_paths;
 		class_paths = new ClassPaths.class_paths;

+ 1 - 2
src/context/commonCache.ml

@@ -95,7 +95,7 @@ let rec cache_context cs com =
 		(* If we have a signature mismatch, look-up cache for module. Physical equality check is fine as a heueristic. *)
 		(* If we have a signature mismatch, look-up cache for module. Physical equality check is fine as a heueristic. *)
 		let cc = if m.m_extra.m_sign = sign then cc else cs#get_context m.m_extra.m_sign in
 		let cc = if m.m_extra.m_sign = sign then cc else cs#get_context m.m_extra.m_sign in
 		let warn w s p = com.warning w com.warning_options s p in
 		let warn w s p = com.warning w com.warning_options s p in
-		cc#cache_module config warn anon_identification com.hxb_writer_stats m.m_path m;
+		cc#cache_module config warn anon_identification m.m_path m;
 	in
 	in
 	List.iter cache_module com.modules;
 	List.iter cache_module com.modules;
 	begin match com.get_macros() with
 	begin match com.get_macros() with
@@ -104,7 +104,6 @@ let rec cache_context cs com =
 	end;
 	end;
 	if Define.raw_defined com.defines "hxb.stats" then begin
 	if Define.raw_defined com.defines "hxb.stats" then begin
 		HxbReader.dump_stats (platform_name com.platform) com.hxb_reader_stats;
 		HxbReader.dump_stats (platform_name com.platform) com.hxb_reader_stats;
-		HxbWriter.dump_stats (platform_name com.platform) com.hxb_writer_stats
 	end
 	end
 
 
 let maybe_add_context_sign cs com desc =
 let maybe_add_context_sign cs com desc =