cvsuser     03/11/12 03:02:34

  Modified:    include/parrot interpreter.h runops_cores.h
               src      dod.c embed.c exceptions.c interpreter.c
                        resources.c runops_cores.c
  Log:
  profiling support for DOD and GC times
  
  Revision  Changes    Path
  1.103     +15 -4     parrot/include/parrot/interpreter.h
  
  Index: interpreter.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/interpreter.h,v
  retrieving revision 1.102
  retrieving revision 1.103
  diff -u -w -r1.102 -r1.103
  --- interpreter.h     4 Nov 2003 07:40:31 -0000       1.102
  +++ interpreter.h     12 Nov 2003 11:02:28 -0000      1.103
  @@ -1,7 +1,7 @@
   /* interpreter.h
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: interpreter.h,v 1.102 2003/11/04 07:40:31 mrjoltcola Exp $
  + *     $Id: interpreter.h,v 1.103 2003/11/12 11:02:28 leo Exp $
    *  Overview:
    *     The interpreter api handles running the operations
    *  Data Structure and Algorithms:
  @@ -83,9 +83,17 @@
   #endif
   
   /*
  - * one entry per op + extra
  + * ProfData have these extra items in front followed by
  + * one entry per op at (op + extra)
    */
  -#define PARROT_PROF_EXTRA 1
  +
  +typedef enum {
  +     PARROT_PROF_DOD,
  +     PARROT_PROF_GC,
  +     PARROT_PROF_EXCEPTION,
  +     PARROT_PROF_EXTRA
  +} profile_extra_enum;
  +
   /*
    * data[op_count] is time spent for exception handling
    */
  @@ -95,8 +103,11 @@
       FLOATVAL time;
   } ProfData;
   
  -typedef struct RunProfile {
  +typedef struct _RunProfile {
       FLOATVAL starttime;
  +    FLOATVAL dod_time;
  +    FLOATVAL gc_time;
  +    opcode_t cur_op;
       ProfData *data;
   } RunProfile;
   
  
  
  
  1.7       +3 -2      parrot/include/parrot/runops_cores.h
  
  Index: runops_cores.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/runops_cores.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- runops_cores.h    21 Jul 2003 18:00:42 -0000      1.6
  +++ runops_cores.h    12 Nov 2003 11:02:28 -0000      1.7
  @@ -1,7 +1,7 @@
   /* runops_cores.h
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: runops_cores.h,v 1.6 2003/07/21 18:00:42 chromatic Exp $
  + *     $Id: runops_cores.h,v 1.7 2003/11/12 11:02:28 leo Exp $
    *  Overview:
    *     Header for runops cores.
    *  Data Structure and Algorithms:
  @@ -23,6 +23,7 @@
   opcode_t *runops_cgoto_core(struct Parrot_Interp *, opcode_t *);
   
   opcode_t *runops_slow_core(struct Parrot_Interp *, opcode_t *);
  +opcode_t *runops_profile_core(struct Parrot_Interp *, opcode_t *);
   
   #endif
   
  
  
  
  1.75      +25 -1     parrot/src/dod.c
  
  Index: dod.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/dod.c,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -w -r1.74 -r1.75
  --- dod.c     27 Oct 2003 15:14:35 -0000      1.74
  +++ dod.c     12 Nov 2003 11:02:33 -0000      1.75
  @@ -1,7 +1,7 @@
   /* dod.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: dod.c,v 1.74 2003/10/27 15:14:35 leo Exp $
  + *     $Id: dod.c,v 1.75 2003/11/12 11:02:33 leo Exp $
    *  Overview:
    *     Handles dead object destruction of the various headers
    *  Data Structure and Algorithms:
  @@ -700,6 +700,26 @@
   }
   #endif
   
  +static PARROT_INLINE void
  +profile_dod_start(Parrot_Interp interpreter)
  +{
  +    if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  +        interpreter->profile->dod_time = Parrot_floatval_time();
  +    }
  +}
  +
  +static PARROT_INLINE void
  +profile_dod_end(Parrot_Interp interpreter)
  +{
  +    if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  +        RunProfile *profile = interpreter->profile;
  +        FLOATVAL now = Parrot_floatval_time();
  +
  +        profile->data[PARROT_PROF_DOD].numcalls++;
  +        profile->data[PARROT_PROF_DOD].time += now - profile->dod_time;
  +        profile->starttime += now - profile->dod_time;
  +    }
  +}
   
   /* See if we can find some unused headers */
   void
  @@ -714,6 +734,8 @@
           return;
       }
       Parrot_block_DOD(interpreter);
  +    if (interpreter->profile)
  +        profile_dod_start(interpreter);
   
   #if ARENA_DOD_FLAGS
       clear_live_counter(interpreter, interpreter->arena_base->pmc_pool);
  @@ -767,6 +789,8 @@
       }
       /* Note it */
       interpreter->dod_runs++;
  +    if (interpreter->profile)
  +        profile_dod_end(interpreter);
       Parrot_unblock_DOD(interpreter);
       return;
   }
  
  
  
  1.94      +19 -5     parrot/src/embed.c
  
  Index: embed.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/embed.c,v
  retrieving revision 1.93
  retrieving revision 1.94
  diff -u -w -r1.93 -r1.94
  --- embed.c   7 Nov 2003 12:12:35 -0000       1.93
  +++ embed.c   12 Nov 2003 11:02:33 -0000      1.94
  @@ -1,7 +1,7 @@
   /* embed.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: embed.c,v 1.93 2003/11/07 12:12:35 boemmels Exp $
  + *     $Id: embed.c,v 1.94 2003/11/12 11:02:33 leo Exp $
    *  Overview:
    *     The Parrot embedding interface.
    *  Data Structure and Algorithms:
  @@ -333,6 +333,22 @@
       return 0;
   }
   
  +static const char *
  +op_name(Parrot_Interp interpreter, int k)
  +{
  +    switch (k) {
  +        case PARROT_PROF_DOD:
  +            return "DOD";
  +        case PARROT_PROF_GC:
  +            return "GC";
  +        case PARROT_PROF_EXCEPTION:
  +            return "EXCEPTION";
  +        default:
  +            break;
  +    }
  +    return interpreter->op_info_table[k - PARROT_PROF_EXTRA].full_name;
  +}
  +
   static void
   print_profile(int status, void *p)
   {
  @@ -365,10 +381,8 @@
   
                   k = interpreter->profile->data[j].op;
                   PIO_printf(interpreter, "  %5d  %-20s  %7vu  %10vf  %10vf\n",
  -                        k,
  -                        k == (int)interpreter->op_count ?
  -                        "Exception" :
  -                        interpreter->op_info_table[k].full_name,
  +                        k - PARROT_PROF_EXTRA,
  +                        op_name(interpreter, k),
                           n,
                           t,
                           (FLOATVAL)(t / n)
  
  
  
  1.41      +7 -6      parrot/src/exceptions.c
  
  Index: exceptions.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/exceptions.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -w -r1.40 -r1.41
  --- exceptions.c      23 Oct 2003 17:48:59 -0000      1.40
  +++ exceptions.c      12 Nov 2003 11:02:33 -0000      1.41
  @@ -1,7 +1,7 @@
   /* exceptions.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: exceptions.c,v 1.40 2003/10/23 17:48:59 robert Exp $
  + *     $Id: exceptions.c,v 1.41 2003/11/12 11:02:33 leo Exp $
    *  Overview:
    *     define the internal interpreter exceptions
    *  Data Structure and Algorithms:
  @@ -362,11 +362,12 @@
        */
       if (interpreter->profile &&
               Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  -        interpreter->profile->data[*interpreter->cur_pc].time +=
  -                Parrot_floatval_time() - interpreter->profile->starttime;
  -        interpreter->cur_pc = (opcode_t*) &interpreter->op_count;
  -        interpreter->profile->starttime = Parrot_floatval_time();
  -        interpreter->profile->data[interpreter->op_count].numcalls++;
  +        RunProfile *profile = interpreter->profile;
  +        FLOATVAL now = Parrot_floatval_time();
  +        profile->data[profile->cur_op].time += now - profile->starttime;
  +        profile->cur_op = PARROT_PROF_EXCEPTION;
  +        profile->starttime = now;
  +        profile->data[PARROT_PROF_EXCEPTION].numcalls++;
       }
   
       /*
  
  
  
  1.227     +11 -6     parrot/src/interpreter.c
  
  Index: interpreter.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/interpreter.c,v
  retrieving revision 1.226
  retrieving revision 1.227
  diff -u -w -r1.226 -r1.227
  --- interpreter.c     28 Oct 2003 03:13:06 -0000      1.226
  +++ interpreter.c     12 Nov 2003 11:02:33 -0000      1.227
  @@ -1,7 +1,7 @@
   /* interpreter.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: interpreter.c,v 1.226 2003/10/28 03:13:06 mrjoltcola Exp $
  + *     $Id: interpreter.c,v 1.227 2003/11/12 11:02:33 leo Exp $
    *  Overview:
    *     The interpreter api handles running the operations
    *  Data Structure and Algorithms:
  @@ -493,9 +493,10 @@
                   core = runops_slow_core;
   
                   if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  +                    core = runops_profile_core;
                       if (interpreter->profile == NULL) {
                           interpreter->profile = (RunProfile *)
  -                            mem_sys_allocate(sizeof(RunProfile));
  +                            mem_sys_allocate_zeroed(sizeof(RunProfile));
                           interpreter->profile->data = (ProfData *)
                               mem_sys_allocate_zeroed((interpreter->op_count +
                                           PARROT_PROF_EXTRA) * sizeof(ProfData));
  @@ -622,10 +623,12 @@
           offset = handle_exception(interpreter);
       }
       if (interpreter->profile &&
  -            interpreter->cur_pc == (opcode_t*)&interpreter->op_count &&
               Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  -        interpreter->profile->data[*interpreter->cur_pc].time +=
  -            Parrot_floatval_time() - interpreter->profile->starttime;
  +        RunProfile *profile = interpreter->profile;
  +        if (profile->cur_op == PARROT_PROF_EXCEPTION) {
  +            profile->data[PARROT_PROF_EXCEPTION].time +=
  +                Parrot_floatval_time() - profile->starttime;
  +        }
       }
   #endif
       runops_ex(interpreter, offset);
  @@ -996,8 +999,10 @@
           Parrot_destroy_vtable(interpreter, Parrot_base_vtables[i]);
       mmd_destroy(interpreter);
   
  -    if (interpreter->profile)
  +    if (interpreter->profile) {
  +        mem_sys_free(interpreter->profile->data);
           mem_sys_free(interpreter->profile);
  +    }
   
       /* deinit op_lib */
       (void) PARROT_CORE_OPLIB_INIT(0);
  
  
  
  1.113     +25 -1     parrot/src/resources.c
  
  Index: resources.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/resources.c,v
  retrieving revision 1.112
  retrieving revision 1.113
  diff -u -w -r1.112 -r1.113
  --- resources.c       24 Oct 2003 19:10:29 -0000      1.112
  +++ resources.c       12 Nov 2003 11:02:34 -0000      1.113
  @@ -1,7 +1,7 @@
   /* resources.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: resources.c,v 1.112 2003/10/24 19:10:29 dan Exp $
  + *     $Id: resources.c,v 1.113 2003/11/12 11:02:34 leo Exp $
    *  Overview:
    *     Allocate and deallocate tracked resources
    *  Data Structure and Algorithms:
  @@ -147,6 +147,26 @@
   }
   
   
  +static PARROT_INLINE void
  +profile_gc_start(Parrot_Interp interpreter)
  +{
  +    if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  +        interpreter->profile->gc_time = Parrot_floatval_time();
  +    }
  +}
  +
  +static PARROT_INLINE void
  +profile_gc_end(Parrot_Interp interpreter)
  +{
  +    if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  +        RunProfile *profile = interpreter->profile;
  +        FLOATVAL now = Parrot_floatval_time();
  +
  +        profile->data[PARROT_PROF_GC].numcalls++;
  +        profile->data[PARROT_PROF_GC].time += now - profile->gc_time;
  +        profile->starttime += now - profile->gc_time;
  +    }
  +}
   
   /** Compaction Code **/
   
  @@ -168,6 +188,8 @@
           return;
       }
       Parrot_block_GC(interpreter);
  +    if (interpreter->profile)
  +        profile_gc_start(interpreter);
   
       /* We're collecting */
       interpreter->mem_allocs_since_last_collect = 0;
  @@ -351,6 +373,8 @@
   
       pool->guaranteed_reclaimable = 0;
       pool->possibly_reclaimable = 0;
  +    if (interpreter->profile)
  +        profile_gc_end(interpreter);
       Parrot_unblock_GC(interpreter);
   
   }
  
  
  
  1.38      +23 -11    parrot/src/runops_cores.c
  
  Index: runops_cores.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/runops_cores.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -w -r1.37 -r1.38
  --- runops_cores.c    24 Oct 2003 21:33:32 -0000      1.37
  +++ runops_cores.c    12 Nov 2003 11:02:34 -0000      1.38
  @@ -1,7 +1,7 @@
   /* runops_cores.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: runops_cores.c,v 1.37 2003/10/24 21:33:32 dan Exp $
  + *     $Id: runops_cores.c,v 1.38 2003/11/12 11:02:34 leo Exp $
    *  Overview:
    *     The switchable runops cores.
    *  Data Structure and Algorithms:
  @@ -62,7 +62,6 @@
   /*=for api interpreter runops_slow_core
    *
    * With tracing.
  - * With profiling.
    * With bounds checking.
    */
   
  @@ -114,10 +113,6 @@
   
       while (pc) {/* && pc >= code_start && pc < code_end) {*/
           interpreter->cur_pc = pc;
  -        if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  -            interpreter->profile->data[*pc].numcalls++;
  -            interpreter->profile->starttime = Parrot_floatval_time();
  -        }
   
           DO_OP(pc, interpreter);
   
  @@ -130,10 +125,6 @@
               trace_op(interpreter, code_start, code_end, pc);
   #endif
           }
  -        if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  -            interpreter->profile->data[*interpreter->cur_pc].time +=
  -                Parrot_floatval_time() - interpreter->profile->starttime;
  -        }
       }
   #ifdef USE_TRACE_INTERP
       if (Interp_flags_TEST(interpreter, PARROT_TRACE_FLAG)) {
  @@ -149,8 +140,29 @@
          "Error: Control left bounds of byte-code block (now at location %d)!\n",
          (int)(pc - code_start));
          }*/
  -#undef code_stat
  +#undef code_start
   #undef code_end
  +    return pc;
  +}
  +
  +opcode_t *
  +runops_profile_core(struct Parrot_Interp *interpreter, opcode_t *pc)
  +{
  +    opcode_t *code_start, *code_end, cur_op;
  +    RunProfile *profile = interpreter->profile;
  +
  +    while (pc) {/* && pc >= code_start && pc < code_end) */
  +        interpreter->cur_pc = pc;
  +        profile->cur_op = cur_op = *pc + PARROT_PROF_EXTRA;
  +        profile->data[cur_op].numcalls++;
  +        profile->starttime = Parrot_floatval_time();
  +
  +        DO_OP(pc, interpreter);
  +
  +        /* profile->cur_op may be different, if exception was thrown */
  +        profile->data[profile->cur_op].time +=
  +            Parrot_floatval_time() - profile->starttime;
  +    }
       return pc;
   }
   
  
  
  

Reply via email to