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

cotto at svn.parrot.org cotto at svn.parrot.org
Mon Oct 4 03:41:35 UTC 2010


Author: cotto
Date: Mon Oct  4 03:41:35 2010
New Revision: 49434
URL: https://trac.parrot.org/parrot/changeset/49434

Log:
break some profiling code off into separate functions

Modified:
   trunk/src/runcore/profiling.c

Modified: trunk/src/runcore/profiling.c
==============================================================================
--- trunk/src/runcore/profiling.c	Mon Oct  4 03:19:11 2010	(r49433)
+++ trunk/src/runcore/profiling.c	Mon Oct  4 03:41:35 2010	(r49434)
@@ -79,6 +79,20 @@
         __attribute__nonnull__(2)
         __attribute__nonnull__(3);
 
+static void store_cli(PARROT_INTERP,
+    ARGIN(Parrot_profiling_runcore_t *runcore),
+    ARGIN(PPROF_DATA* pprof_data),
+    ARGIN(PMC* argv))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4);
+
+static void store_postop_time(PARROT_INTERP,
+    ARGIN(Parrot_profiling_runcore_t *runcore))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
 #define ASSERT_ARGS_add_bogus_parent_runloop __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(runcore))
 #define ASSERT_ARGS_init_profiling_core __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -95,6 +109,14 @@
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(runcore) \
     , PARROT_ASSERT_ARG(pc))
+#define ASSERT_ARGS_store_cli __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(runcore) \
+    , PARROT_ASSERT_ARG(pprof_data) \
+    , PARROT_ASSERT_ARG(argv))
+#define ASSERT_ARGS_store_postop_time __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(runcore))
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: static */
 
@@ -272,41 +294,14 @@
     runcore->runcore_start = Parrot_hires_get_time();
 
     /* if we're in a nested runloop, */
-    if (runcore->level != 0) {
-
-        if (runcore->level >= runcore->time_size) {
-            runcore->time_size *= 2;
-            runcore->time = mem_gc_realloc_n_typed(interp,
-                    runcore->time, runcore->time_size + 1, UHUGEINTVAL);
-        }
-
-        /* store the time between DO_OP and the start of this runcore in this
-         * op's running total */
-        runcore->time[runcore->level] =
-             runcore->runcore_start - runcore->op_start;
-    }
+    if (runcore->level != 0) 
+        store_postop_time(interp, runcore);
 
     argv = VTABLE_get_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_ARGV_LIST);
 
     /* argv isn't initialized until after :init (etc) subs are executed */
     if (argv && !Profiling_have_printed_cli_TEST(runcore)) {
-
-        char   *cli_cstr;
-        STRING *space, *cli_args, *cli_exe, *cli_str;
-        PMC    *exe_name = VTABLE_get_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE);
-
-        space    = CONST_STRING(interp, " ");
-        cli_args = Parrot_str_join(interp, space, argv);
-        cli_exe  = VTABLE_get_string(interp, exe_name);
-        cli_str  = Parrot_sprintf_c(interp, "%Ss %Ss", cli_exe, cli_args);
-        cli_cstr = Parrot_str_to_cstring(interp, cli_str);
-
-        /* CLI line won't reflect any options passed to the parrot binary. */
-        pprof_data[PPROF_DATA_CLI] = (PPROF_DATA) cli_cstr;
-        runcore->output_fn(runcore, pprof_data, PPROF_LINE_CLI);
-
-        Parrot_str_free_cstring(cli_cstr);
-
+        store_cli(interp, runcore, &pprof_data, argv);
         Profiling_have_printed_cli_SET(runcore);
     }
 
@@ -476,6 +471,48 @@
     return pc;
 }
 
+static void
+store_postop_time(PARROT_INTERP, ARGIN(Parrot_profiling_runcore_t *runcore))
+{
+
+    ASSERT_ARGS(store_postop_time)
+
+    if (runcore->level >= runcore->time_size) {
+        runcore->time_size *= 2;
+        runcore->time = mem_gc_realloc_n_typed(interp,
+                runcore->time, runcore->time_size + 1, UHUGEINTVAL);
+    }
+
+    /* store the time between DO_OP and the start of this runcore in this
+     *          * op's running total */
+    runcore->time[runcore->level] = runcore->runcore_start - runcore->op_start;
+}
+
+static void
+store_cli(PARROT_INTERP, ARGIN(Parrot_profiling_runcore_t *runcore), ARGIN(PPROF_DATA* pprof_data),
+ARGIN(PMC* argv))
+{
+
+    ASSERT_ARGS(store_cli)
+
+    char   *cli_cstr;
+    STRING *space, *cli_args, *cli_exe, *cli_str;
+    PMC    *exe_name = VTABLE_get_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE);
+
+    space    = CONST_STRING(interp, " ");
+    cli_args = Parrot_str_join(interp, space, argv);
+    cli_exe  = VTABLE_get_string(interp, exe_name);
+    cli_str  = Parrot_sprintf_c(interp, "%Ss %Ss", cli_exe, cli_args);
+    cli_cstr = Parrot_str_to_cstring(interp, cli_str);
+
+    /* CLI line won't reflect any options passed to the parrot binary. */
+    pprof_data[PPROF_DATA_CLI] = (PPROF_DATA) cli_cstr;
+    runcore->output_fn(runcore, pprof_data, PPROF_LINE_CLI);
+
+    Parrot_str_free_cstring(cli_cstr);
+}
+
+
 /*
 
 =item C<static void add_bogus_parent_runloop(Parrot_profiling_runcore_t *


More information about the parrot-commits mailing list