tools: add log information about reachable and unreachable methods
authorJean-Sebastien Gelinas <calestar@gmail.com>
Fri, 18 Sep 2009 19:54:15 +0000 (15:54 -0400)
committerJean Privat <jean@pryen.org>
Mon, 11 Jan 2010 21:52:26 +0000 (16:52 -0500)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

src/analysis/analysis.nit
src/analysis/reachable_method_analysis.nit
src/nitc.nit

index c2a1845..9e77ff0 100644 (file)
@@ -68,6 +68,12 @@ redef class Program
                assert tc.global
                if not tc.no_dead_method_removal then optimize_dead_methods
        end
+
+       # This method will create log files storing analysis information
+       fun dump_global_analysis_information(directory_name: String) do
+               dump_reachable_methods(directory_name, tc.global_callgraph)
+               dump_unreachable_methods(directory_name, tc.global_callgraph)
+       end
 end
 
 redef class IRoutine
index 75c91ea..c1c37d9 100644 (file)
@@ -23,6 +23,28 @@ import program
 redef class Program
        # This attribute is the ReachableMethodAnalysis results 
        readable writable var _rma: nullable ReachableMethodAnalysis = null
+
+       # This method will create a file and output all reachable method names in it
+       fun dump_reachable_methods(directory_name: String, algo: String) do
+               var f = new OFStream.open("{directory_name}/{module.name}.reachable_methods.{algo}.log")
+               with_each_methods !action(m) do
+                       if rma.is_method_reachable(m) then
+                               f.write("{m.full_name}\n")
+                       end
+               end
+               f.close
+       end
+
+       # This method will create a file and output all unreachable method names in it
+       fun dump_unreachable_methods(directory_name: String, algo: String) do
+               var f = new OFStream.open("{directory_name}/{module.name}.unreachable_methods.{algo}.log")
+               with_each_methods !action(m) do
+                       if not rma.is_method_reachable(m) then
+                               f.write("{m.full_name}\n")
+                       end
+               end
+               f.close
+       end
 end
 
 # Subclasses of this class would represent an analysis that produces
index f64993d..933d46b 100644 (file)
@@ -137,6 +137,9 @@ special AbstractCompiler
                        if global then
                                p.do_global_analysis
                                p.do_global_optimizations
+                               if opt_log.value then
+                                       p.dump_global_analysis_information(log_directory)
+                               end
                        end
                        p.do_table_computation
                        p.compile_prog_to_c