Mon Jun 16 18:13:29 CEST 2003 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Mon, 16 Jun 2003 16:25:58 +0000 (16:25 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Mon, 16 Jun 2003 16:25:58 +0000 (16:25 -0000)
* driver.c, mini-ppc.c, mini-x86.c, mini.c, mini.h: the coverage stuff
is now implemented in the profiling API. Get rid of a couple of
unnecessary global variables.

svn path=/trunk/mono/; revision=15438

mono/mini/ChangeLog
mono/mini/driver.c
mono/mini/mini-ppc.c
mono/mini/mini-x86.c
mono/mini/mini.c
mono/mini/mini.h

index e7b4eff5dad741a412b15a7b9a0093a87116a839..0180d12810b0769ecc3bfd989e1f1624b4b6529d 100644 (file)
@@ -1,3 +1,10 @@
+
+Mon Jun 16 18:13:29 CEST 2003 Paolo Molaro <lupus@ximian.com>
+
+       * driver.c, mini-ppc.c, mini-x86.c, mini.c, mini.h: the coverage stuff
+       is now implemented in the profiling API. Get rid of a couple of
+       unnecessary global variables.
+
 2003-06-15  Nick Drochak <ndrochak@gol.com>
 
        * basic-long.cs: tests for negative values for bigmul, and unsigned.
index fa56fc9ac51879cb40624c248cf89e0449cc68b8..0aad83bdb4f42ad84c77e18b24acab8b0d060db7 100644 (file)
@@ -319,19 +319,6 @@ mini_regression (MonoImage *image, int verbose, int *total_run) {
                                        code_size += cfg->code_len;
                                        mono_destroy_compile (cfg);
 
-                                       if (mono_trace_coverage) {
-                                               MonoCoverageInfo *cov = mono_get_coverage_info (method);
-
-                                               if (cov) {
-                                                       int k;
-                                                       printf ("COVERAGE INFO %s\n", mono_method_full_name (method, TRUE));
-                                               
-                                                       for (k = 0; k < cov->entries; k++) {
-                                                               printf ("  BBLOCK %3d %d\n", cov->data [k].iloffset, cov->data [k].count);
-                                                       }
-                                               }
-                                       }
-
                                } else {
                                        cfailed++;
                                        if (verbose)
@@ -494,7 +481,6 @@ mini_usage (void)
                "Development:\n"
                "    --statfile FILE        Sets the stat file to FILE\n"
                "    --aot                  Compiles the assembly to native code\n"
-               "    --coverage             Performs coverage analysis\n"
                "    --profile[=profiler]   Runs in profiling mode with the specified profiler module\n"
                "    --graph[=TYPE] METHOD  Draws a graph of the specified method:\n");
        
@@ -574,15 +560,11 @@ mono_main (int argc, char* argv[]) {
                        mono_jit_stats.enabled = TRUE;
                } else if (strcmp (argv [i], "--aot") == 0) {
                        mono_compile_aot = TRUE;
-               } else if (strcmp (argv [i], "--coverage") == 0) {
-                       mono_trace_coverage = TRUE;
                } else if (strcmp (argv [i], "--compile-all") == 0) {
                        action = DO_COMPILE;
                } else if (strcmp (argv [i], "--profile") == 0) {
-                       mono_jit_profile = TRUE;
                        mono_profiler_load (NULL);
                } else if (strncmp (argv [i], "--profile=", 10) == 0) {
-                       mono_jit_profile = TRUE;
                        mono_profiler_load (argv [i] + 10);
                } else if (strcmp (argv [i], "--compile") == 0) {
                        mname = argv [++i];
@@ -598,7 +580,7 @@ mono_main (int argc, char* argv[]) {
                } else if (strcmp (argv [i], "--debug") == 0) {
                        enable_debugging = TRUE;
                } else {
-                       fprintf (stderr, "Unknown command line option: %s\n", argv [i]);
+                       fprintf (stderr, "Unknown command line option: '%s'\n", argv [i]);
                        return 1;
                }
        }
index 4bf534277792e1168c38aff32f528a38d44eaaab..d0729dd364b831b06ba3ed94fbf3a7bc56df65f3 100644 (file)
@@ -1869,7 +1869,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 
        cpos = bb->max_offset;
 
-       if (mono_trace_coverage) {
+       if (cfg->prof_options & MONO_PROFILE_COVERAGE) {
                //MonoCoverageInfo *cov = mono_get_coverage_info (cfg->method);
                //g_assert (!mono_compile_aot);
                //cpos += 6;
@@ -2671,7 +2671,7 @@ mono_arch_max_epilog_size (MonoCompile *cfg)
        if (mono_jit_trace_calls)
                max_epilog_size += 50;
 
-       if (mono_jit_profile)
+       if (cfg->prof_options & MONO_PROFILE_ENTER_LEAVE)
                max_epilog_size += 50;
 
        /* count the number of exception infos */
@@ -2772,7 +2772,7 @@ mono_arch_emit_prolog (MonoCompile *cfg)
                        MonoInst *ins = bb->code;
                        bb->max_offset = max_offset;
 
-                       if (mono_trace_coverage)
+                       if (cfg->prof_options & MONO_PROFILE_COVERAGE)
                                max_offset += 6; 
 
                        while (ins) {
index 9391484dbb57e39509c2678278727776ef9ccad7..f7010491eba3b6912376f2a034523227534f4336 100644 (file)
@@ -1948,17 +1948,13 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 
        cpos = bb->max_offset;
 
-       if (mono_trace_coverage) {
-               MonoCoverageInfo *cov = mono_get_coverage_info (cfg->method);
+       if (cfg->prof_options & MONO_PROFILE_COVERAGE) {
+               MonoProfileCoverageInfo *cov = cfg->coverage_info;
                g_assert (!mono_compile_aot);
                cpos += 6;
 
-               // fixme: make this work with inlining
-               g_assert_not_reached ();
-               //if (bb->cil_code)
-               //cov->data [bb->dfn].iloffset = bb->cil_code - cfg->cil_code;
+               cov->data [bb->dfn].cil_code = bb->cil_code;
                /* this is not thread save, but good enough */
-               /* fixme: howto handle overflows? */
                x86_inc_mem (code, &cov->data [bb->dfn].count); 
        }
 
@@ -2257,7 +2253,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        int pos = 0;
 
                        /* FIXME: no tracing support... */
-                       if (mono_jit_profile)
+                       if (cfg->prof_options & MONO_PROFILE_ENTER_LEAVE)
                                code = mono_arch_instrument_epilog (cfg, mono_profiler_method_leave, code, FALSE);
                        /* reset offset to make max_len work */
                        offset = code - cfg->native_code;
@@ -3050,7 +3046,7 @@ mono_arch_max_epilog_size (MonoCompile *cfg)
        if (mono_jit_trace_calls)
                max_epilog_size += 50;
 
-       if (mono_jit_profile)
+       if (cfg->prof_options & MONO_PROFILE_ENTER_LEAVE)
                max_epilog_size += 50;
 
        /* count the number of exception infos */
@@ -3145,7 +3141,7 @@ mono_arch_emit_prolog (MonoCompile *cfg)
                        MonoInst *ins = bb->code;
                        bb->max_offset = max_offset;
 
-                       if (mono_trace_coverage)
+                       if (cfg->prof_options & MONO_PROFILE_COVERAGE)
                                max_offset += 6; 
 
                        while (ins) {
index a47a021602b95f583149c90d5c32231d315a2aa5..dfd7f812b97ebb862c6351e7c9da359814462868 100644 (file)
@@ -93,8 +93,6 @@ guint32 mono_jit_tls_id = 0;
 gboolean mono_jit_trace_calls = FALSE;
 gboolean mono_break_on_exc = FALSE;
 gboolean mono_compile_aot = FALSE;
-gboolean mono_trace_coverage = FALSE;
-gboolean mono_jit_profile = FALSE;
 
 CRITICAL_SECTION *metadata_section = NULL;
 
@@ -502,34 +500,6 @@ print_method_from_ip (void *ip)
                (dest)->inst_right = (el2);     \
        } while (0)
 
-static GHashTable *coverage_hash = NULL;
-
-MonoCoverageInfo *
-mono_allocate_coverage_info (MonoMethod *method, int size)
-{
-       MonoCoverageInfo *res;
-
-       if (!coverage_hash)
-               coverage_hash = g_hash_table_new (NULL, NULL);
-
-       res = g_malloc0 (sizeof (MonoCoverageInfo) + sizeof (int) * size * 2);
-
-       res->entries = size;
-
-       g_hash_table_insert (coverage_hash, method, res);
-
-       return res;
-}
-
-MonoCoverageInfo *
-mono_get_coverage_info (MonoMethod *method)
-{
-       if (!coverage_hash)
-               return NULL;
-
-       return g_hash_table_lookup (coverage_hash, method);
-}
-               
 #if 0
 static gint
 compare_bblock (gconstpointer a, gconstpointer b)
@@ -6134,12 +6104,12 @@ mono_codegen (MonoCompile *cfg)
                mono_arch_local_regalloc (cfg, bb);
        }
 
-       if (mono_trace_coverage)
-               mono_allocate_coverage_info (cfg->method, cfg->num_bblocks);
+       if (cfg->prof_options & MONO_PROFILE_COVERAGE)
+               cfg->coverage_info = mono_profiler_coverage_alloc (cfg->method, cfg->num_bblocks);
 
        code = mono_arch_emit_prolog (cfg);
 
-       if (mono_jit_profile)
+       if (cfg->prof_options & MONO_PROFILE_ENTER_LEAVE)
                code = mono_arch_instrument_prolog (cfg, mono_profiler_method_enter, code, FALSE);
 
        cfg->code_len = code - cfg->native_code;
@@ -6171,7 +6141,7 @@ mono_codegen (MonoCompile *cfg)
 
        cfg->epilog_begin = cfg->code_len;
 
-       if (mono_jit_profile)
+       if (cfg->prof_options & MONO_PROFILE_ENTER_LEAVE)
                code = mono_arch_instrument_epilog (cfg, mono_profiler_method_leave, code, FALSE);
 
        cfg->code_len = code - cfg->native_code;
@@ -6407,13 +6377,14 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, int p
        int dfn = 0, i, code_size_ratio;
 
        mono_jit_stats.methods_compiled++;
-       if (mono_jit_profile)
+       if (mono_profiler_get_events () & MONO_PROFILE_JIT_COMPILATION)
                mono_profiler_method_jit (method);
 
        cfg = g_new0 (MonoCompile, 1);
        cfg->method = method;
        cfg->mempool = mono_mempool_new ();
        cfg->opt = opts;
+       cfg->prof_options = mono_profiler_get_events ();
        cfg->bb_hash = g_hash_table_new (g_direct_hash, NULL);
        cfg->domain = domain;
        cfg->verbose_level = mini_verbose;
@@ -6429,9 +6400,9 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, int p
                g_print ("converting method %s\n", mono_method_full_name (method, TRUE));
 
        if ((i = mono_method_to_ir (cfg, method, NULL, NULL, cfg->locals_start, NULL, NULL, NULL, 0, FALSE)) < 0) {
-               mono_destroy_compile (cfg);
-               if (mono_jit_profile)
+               if (cfg->prof_options & MONO_PROFILE_JIT_COMPILATION)
                        mono_profiler_method_end_jit (method, MONO_PROFILE_FAILED);
+               mono_destroy_compile (cfg);
                return NULL;
        }
 
@@ -6628,7 +6599,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, int p
        }
        mono_jit_stats.native_code_size += cfg->code_len;
 
-       if (mono_jit_profile)
+       if (cfg->prof_options & MONO_PROFILE_JIT_COMPILATION)
                mono_profiler_method_end_jit (method, MONO_PROFILE_OK);
 
        return cfg;
index 8f38f64dd167b803953e29a224eb591fe1b08af9..62876ff08ad272d6b21e70fcbf5b260a42bfd97e 100644 (file)
@@ -84,8 +84,6 @@ extern gboolean mono_jit_trace_calls;
 extern gboolean mono_break_on_exc;
 extern int mono_exc_esp_offset;
 extern gboolean mono_compile_aot;
-extern gboolean mono_trace_coverage;
-extern gboolean mono_jit_profile;
 
 extern CRITICAL_SECTION *metadata_section;
 
@@ -440,6 +438,7 @@ typedef struct {
        guint            epilog_begin;
        guint32          used_int_regs;
        guint32          opt;
+       guint32          prof_options;
        guint32          flags;
        guint32          comp_done;
        guint32          verbose_level;
@@ -450,6 +449,7 @@ typedef struct {
        gboolean         disable_aot;
        gboolean         disable_ssa;
        gpointer         debug_info;
+       gpointer         coverage_info;
        guint16          *intvars;
 } MonoCompile;
 
@@ -458,14 +458,6 @@ typedef enum {
        MONO_CFG_HAS_CALLS  = 1 << 1
 } MonoCompileFlags;
 
-typedef struct {
-       int entries;
-       struct {
-               int iloffset;
-               int count;
-       } data [0];
-} MonoCoverageInfo;
-
 typedef struct {
        gulong methods_compiled;
        gulong methods_aot;
@@ -623,9 +615,6 @@ MonoJitICallInfo *mono_find_jit_icall_by_addr  (gconstpointer addr);
 MonoJitICallInfo *mono_register_jit_icall      (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save);
 gconstpointer     mono_icall_get_wrapper       (MonoJitICallInfo* callinfo);
 
-MonoCoverageInfo *mono_allocate_coverage_info (MonoMethod *method, int size);
-MonoCoverageInfo *mono_get_coverage_info      (MonoMethod *method);
-
 /* methods that must be provided by the arch-specific port */
 guint32   mono_arch_cpu_optimizazions           (guint32 *exclude_mask);
 void      mono_arch_instrument_mem_needs        (MonoMethod *method, int *stack, int *code);