[svn:parrot] r49448 - trunk/src/runcore

cotto at svn.parrot.org cotto at svn.parrot.org
Tue Oct 5 03:04:35 UTC 2010


Author: cotto
Date: Tue Oct  5 03:04:34 2010
New Revision: 49448
URL: https://trac.parrot.org/parrot/changeset/49448

Log:
[profiling] move some stat collection in front of op execution

Modified:
   trunk/src/runcore/profiling.c

Modified: trunk/src/runcore/profiling.c
==============================================================================
--- trunk/src/runcore/profiling.c	Mon Oct  4 23:31:44 2010	(r49447)
+++ trunk/src/runcore/profiling.c	Tue Oct  5 03:04:34 2010	(r49448)
@@ -389,7 +389,7 @@
 
     while (pc) {
         Parrot_Context *preop_ctx;
-        INTVAL          preop_line;
+        INTVAL          preop_line_num;
         PMC            *preop_ctx_pmc;
 
         if (pc < code_start || pc >= code_end)
@@ -401,6 +401,15 @@
         preop_ctx->current_pc = pc;
         preop_pc              = pc;
         preop_opname          = interp->code->op_info_table[*pc]->name;
+        preop_line_num        = get_line_num_from_cache(interp, runcore, preop_ctx_pmc);
+
+        /* Occasionally the ctx stays the same while the sub changes, e.g.
+         * with a call to a subclass' method. */
+        if ((runcore->prev_ctx != preop_ctx) || runcore->prev_sub != preop_ctx->current_sub)
+            update_ctx_info(interp, runcore, (PPROF_DATA *) &pprof_data, preop_ctx_pmc, preop_pc);
+
+        if (Profiling_report_annotations_TEST(runcore) && interp->code->annotations)
+            record_annotations(interp, runcore, (PPROF_DATA *) &pprof_data, pc);
 
         ++runcore->level;
         Profiling_exit_check_CLEAR(runcore);
@@ -419,24 +428,12 @@
 
         --runcore->level;
 
-        /* if current context changed since the last printing of a CS line... */
-        /* Occasionally the ctx stays the same while the sub changes, possible
-         * with a call to a subclass' method. */
-
-        if ((runcore->prev_ctx != preop_ctx) || runcore->prev_sub != preop_ctx->current_sub)
-            update_ctx_info(interp, runcore, (PPROF_DATA *) &pprof_data, preop_ctx_pmc, preop_pc);
-
-        preop_line = get_line_num_from_cache(interp, runcore, preop_ctx_pmc);
-
-        if (Profiling_report_annotations_TEST(runcore) && interp->code->annotations)
-            record_annotations(interp, runcore, (PPROF_DATA *) &pprof_data, pc);
-
         if (Profiling_canonical_output_TEST(runcore))
             pprof_data[PPROF_DATA_TIME] = 1;
         else
             pprof_data[PPROF_DATA_TIME] = op_time;
 
-        pprof_data[PPROF_DATA_LINE]   = preop_line;
+        pprof_data[PPROF_DATA_LINE]   = preop_line_num;
         pprof_data[PPROF_DATA_OPNAME] = (PPROF_DATA) preop_opname;
         runcore->output_fn(runcore, pprof_data, PPROF_LINE_OP);
     }
@@ -529,7 +526,7 @@
     if (line_num == 0) {
         line_num = Parrot_Sub_get_line_from_pc(interp,
                 Parrot_pcc_get_sub(interp, ctx_pmc), ctx->current_pc);
-        parrot_hash_put(interp, runcore->line_cache, ctx->current_pc, line_num);
+        parrot_hash_put(interp, runcore->line_cache, ctx->current_pc, (void *) line_num);
     }
     return line_num;
 }


More information about the parrot-commits mailing list