1 /* runcore_subprof.h 2 * Copyright (C) 2001-2012, Parrot Foundation. 3 * Overview: 4 * Functions and macros to dispatch opcodes. 5 */ 6 7 #ifndef PARROT_RUNCORE_SUBPROF_H_GUARD 8 #define PARROT_RUNCORE_SUBPROF_H_GUARD 9 10 11 #include "pmc/pmc_sub.h" 12 13 typedef struct subprofile subprofile; 14 typedef struct callinfo callinfo; 15 typedef struct lineinfo lineinfo; 16 typedef struct subprofiledata subprofiledata; 17 typedef struct subprof_runcore_t Parrot_subprof_runcore_t; 18 19 struct callinfo { 20 /* which sub we called */ 21 subprofile *callee; 22 /* how often it was called */ 23 UINTVAL count; 24 /* how many ops where executed in it (including subcalls) */ 25 UINTVAL ops; 26 /* how many ticks where spent in it (including subcalls) */ 27 UHUGEINTVAL ticks; 28 }; 29 30 struct lineinfo { 31 /* start op of this line */ 32 size_t op_offs; 33 /* calls made from this line */ 34 callinfo *calls; 35 /* number of ops executed in this line */ 36 UINTVAL ops; 37 /* number of CPU ticks spent in this line */ 38 UHUGEINTVAL ticks; 39 }; 40 41 struct subprofile { 42 /* next subprofile according to recursion */ 43 subprofile *rnext; 44 /* recursion level of this subprofile */ 45 int rcnt; 46 47 /* the Sub PMC being profiled by this subprofile* */ 48 PMC *subpmc; 49 /* the ATTRs of subpmc */ 50 Parrot_Sub_attributes *subattrs; 51 /* first op of segment */ 52 opcode_t *code_ops; 53 54 INTVAL srcline; 55 char *srcfile; 56 57 lineinfo *lines; 58 int nlines; 59 60 /* call chain info */ 61 /* which sub called us */ 62 subprofile *caller; 63 /* where the call was done */ 64 callinfo *callerci; 65 /* the active Context for the Sub being profiled */ 66 PMC *ctx; 67 68 /* ops/ticks we need to distribute to the caller */ 69 UINTVAL callerops; 70 UHUGEINTVAL callerticks; 71 }; 72 73 #define SUBPROF_TYPE_SUB 1 74 #define SUBPROF_TYPE_HLL 2 75 #define SUBPROF_TYPE_OPS 3 76 77 struct subprofiledata { 78 /* the interpreter we're profiling */ 79 Interp *interp; 80 /* type of profile */ 81 int profile_type; 82 /* the collected data, maps subpmc -> subprofile */ 83 Hash *sphash; 84 /* all the pmcs we have to mark */ 85 PMC *markpmcs; 86 87 /* the root call data */ 88 lineinfo rootline; 89 90 /* maps to expanded debug data */ 91 Hash *seg2debug; 92 93 /* the current context */ 94 PMC *cursubpmc; 95 PMC *curctx; 96 subprofile *cursp; 97 98 /* ticks are added at the end of the op */ 99 UHUGEINTVAL *tickadd; 100 UHUGEINTVAL *tickadd2; 101 UHUGEINTVAL starttick; 102 }; 103 104 struct subprof_runcore_t { 105 STRING *name; 106 int id; 107 oplib_init_f opinit; 108 Parrot_runcore_runops_fn_t runops; 109 Parrot_runcore_destroy_fn_t destroy; 110 Parrot_runcore_prepare_fn_t prepare_run; 111 INTVAL flags; 112 113 subprofiledata *spdata; 114 }; 115 116 117 118 /* HEADERIZER BEGIN: src/runcore/subprof.c */ 119 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 120 121 void Parrot_runcore_subprof_init(PARROT_INTERP) 122 __attribute__nonnull__(1); 123 124 #define ASSERT_ARGS_Parrot_runcore_subprof_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 125 PARROT_ASSERT_ARG(interp)) 126 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 127 /* HEADERIZER END: src/runcore/subprof.c */ 128 129 #endif /* PARROT_RUNCORE_SUBPROF_H_GUARD */ 130 131 /* 132 * Local variables: 133 * c-file-style: "parrot" 134 * End: 135 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' : 136 */ 137