Skip to content
This repository
Browse code

move global subprofdata into the runcore data for now. dump profile d…

…ata in the runcore's destroy callback.
  • Loading branch information...
commit f5358a86ce3c8aaf305783c6c84349b8e8eaaa2a 1 parent 22ad8af
Michael Schroeder mlschroe authored
63 include/parrot/runcore_subprof.h
@@ -15,6 +15,7 @@ typedef struct subprofile subprofile;
15 15 typedef struct callinfo callinfo;
16 16 typedef struct lineinfo lineinfo;
17 17 typedef struct subprofiledata subprofiledata;
  18 +typedef struct subprof_runcore_t Parrot_subprof_runcore_t;
18 19
19 20 struct callinfo {
20 21 /* which sub we called */
@@ -29,13 +30,13 @@ struct callinfo {
29 30
30 31 struct lineinfo {
31 32 /* start op of this line */
32   - size_t op_offs;
  33 + size_t op_offs;
33 34 /* calls made from this line */
34 35 callinfo *calls;
35 36 /* number of ops executed in this line */
36   - UINTVAL ops;
  37 + UINTVAL ops;
37 38 /* number of CPU ticks spent in this line */
38   - UHUGEINTVAL ticks;
  39 + UHUGEINTVAL ticks;
39 40 };
40 41
41 42 struct subprofile {
@@ -51,11 +52,11 @@ struct subprofile {
51 52 /* first op of segment */
52 53 opcode_t *code_ops;
53 54
54   - INTVAL srcline;
  55 + INTVAL srcline;
55 56 char *srcfile;
56 57
57 58 lineinfo *lines;
58   - int nlines;
  59 + int nlines;
59 60
60 61 /* call chain info */
61 62 /* which sub called us */
@@ -66,8 +67,8 @@ struct subprofile {
66 67 PMC *ctx;
67 68
68 69 /* ops/ticks we need to distribute to the caller */
69   - UINTVAL callerops;
70   - UHUGEINTVAL callerticks;
  70 + UINTVAL callerops;
  71 + UHUGEINTVAL callerticks;
71 72 };
72 73
73 74 #define SUBPROF_TYPE_SUB 1
@@ -75,37 +76,46 @@ struct subprofile {
75 76 #define SUBPROF_TYPE_OPS 3
76 77
77 78 struct subprofiledata {
  79 + /* the interpreter we're profiling */
  80 + Interp *interp;
78 81 /* type of profile */
79   - int profile_type;
  82 + int profile_type;
80 83 /* the collected data, maps subpmc -> subprofile */
81   - Hash *sphash;
  84 + Hash *sphash;
82 85
83 86 /* the root call data */
84   - lineinfo rootline;
  87 + lineinfo rootline;
85 88
86 89 /* maps to expanded debug data */
87   - Hash *seg2debug;
  90 + Hash *seg2debug;
88 91
89 92 /* the current context */
90   - PMC *cursubpmc;
91   - PMC *curctx;
92   - subprofile *cursp;
  93 + PMC *cursubpmc;
  94 + PMC *curctx;
  95 + subprofile *cursp;
93 96
94 97 /* ticks are added at the end of the op */
95 98 UHUGEINTVAL *tickadd;
96 99 UHUGEINTVAL *tickadd2;
97   - UHUGEINTVAL starttick;
  100 + UHUGEINTVAL starttick;
98 101 };
99 102
  103 +struct subprof_runcore_t {
  104 + STRING *name;
  105 + int id;
  106 + oplib_init_f opinit;
  107 + Parrot_runcore_runops_fn_t runops;
  108 + Parrot_runcore_destroy_fn_t destroy;
  109 + Parrot_runcore_prepare_fn_t prepare_run;
  110 + INTVAL flags;
100 111
101   -/* HEADERIZER BEGIN: src/runcore/subprof.c */
102   -/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
  112 + subprofiledata *spdata;
  113 +};
103 114
104   -void dump_profile_data(PARROT_INTERP)
105   - __attribute__nonnull__(1);
106 115
107   -void mark_profile_data(PARROT_INTERP)
108   - __attribute__nonnull__(1);
  116 +
  117 +/* HEADERIZER BEGIN: src/runcore/subprof.c */
  118 +/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
109 119
110 120 void Parrot_runcore_subprof_hll_init(PARROT_INTERP)
111 121 __attribute__nonnull__(1);
@@ -116,10 +126,10 @@ void Parrot_runcore_subprof_ops_init(PARROT_INTERP)
116 126 void Parrot_runcore_subprof_sub_init(PARROT_INTERP)
117 127 __attribute__nonnull__(1);
118 128
119   -#define ASSERT_ARGS_dump_profile_data __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
120   - PARROT_ASSERT_ARG(interp))
121   -#define ASSERT_ARGS_mark_profile_data __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
122   - PARROT_ASSERT_ARG(interp))
  129 +void runops_subprof_mark(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore))
  130 + __attribute__nonnull__(1)
  131 + __attribute__nonnull__(2);
  132 +
123 133 #define ASSERT_ARGS_Parrot_runcore_subprof_hll_init \
124 134 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
125 135 PARROT_ASSERT_ARG(interp))
@@ -129,6 +139,9 @@ void Parrot_runcore_subprof_sub_init(PARROT_INTERP)
129 139 #define ASSERT_ARGS_Parrot_runcore_subprof_sub_init \
130 140 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
131 141 PARROT_ASSERT_ARG(interp))
  142 +#define ASSERT_ARGS_runops_subprof_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
  143 + PARROT_ASSERT_ARG(interp) \
  144 + , PARROT_ASSERT_ARG(runcore))
132 145 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
133 146 /* HEADERIZER END: src/runcore/subprof.c */
134 147
3  src/embed/api.c
@@ -190,7 +190,7 @@ Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
190 190 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "fast"));
191 191 else if (STREQ(corename, "subprof_sub"))
192 192 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "subprof_sub"));
193   - else if (STREQ(corename, "subprof_hll"))
  193 + else if (STREQ(corename, "subprof_hll") || STREQ(corename, "subprof"))
194 194 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "subprof_hll"));
195 195 else if (STREQ(corename, "subprof_ops"))
196 196 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "subprof_ops"));
@@ -318,7 +318,6 @@ Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
318 318 if (_oldtop == NULL)
319 319 interp->lo_var_ptr = &_oldtop;
320 320 interp->api_jmp_buf = &env;
321   - dump_profile_data(interp);
322 321 Parrot_destroy(interp);
323 322 Parrot_x_exit(interp, 0);
324 323 /* Never reached, x_exit calls longjmp */
3  src/gc/mark_sweep.c
@@ -254,7 +254,8 @@ mark_interp(PARROT_INTERP)
254 254 if (!PMC_IS_NULL(interp->final_exception))
255 255 Parrot_gc_mark_PMC_alive(interp, interp->final_exception);
256 256
257   - mark_profile_data(interp);
  257 + if (interp->run_core)
  258 + runops_subprof_mark(interp, interp->run_core);
258 259
259 260 if (interp->parent_interpreter)
260 261 mark_interp(interp->parent_interpreter);
167 src/runcore/subprof.c
@@ -49,6 +49,10 @@ static void createlines(PARROT_INTERP,
49 49 __attribute__nonnull__(2)
50 50 __attribute__nonnull__(3);
51 51
  52 +static void dump_profile_data(PARROT_INTERP, ARGIN(subprofiledata *spdata))
  53 + __attribute__nonnull__(1)
  54 + __attribute__nonnull__(2);
  55 +
52 56 PARROT_CAN_RETURN_NULL
53 57 static opcode_t * findlineannotations(PARROT_INTERP,
54 58 ARGIN(subprofiledata *spdata),
@@ -64,6 +68,15 @@ static void finishcallchain(PARROT_INTERP, ARGIN(subprofiledata *spdata))
64 68 __attribute__nonnull__(1)
65 69 __attribute__nonnull__(2);
66 70
  71 +PARROT_WARN_UNUSED_RESULT
  72 +PARROT_CANNOT_RETURN_NULL
  73 +static subprofiledata * get_subprofiledata(PARROT_INTERP,
  74 + ARGIN(Parrot_runcore_t *runcore),
  75 + int type)
  76 + __attribute__nonnull__(1)
  77 + __attribute__nonnull__(2);
  78 +
  79 +static UHUGEINTVAL getticks(void);
67 80 static void popcallchain(PARROT_INTERP, ARGIN(subprofiledata *spdata))
68 81 __attribute__nonnull__(1)
69 82 __attribute__nonnull__(2);
@@ -75,28 +88,36 @@ static void printspname(PARROT_INTERP,
75 88 __attribute__nonnull__(2)
76 89 __attribute__nonnull__(3);
77 90
  91 +static void runops_subprof_destroy(PARROT_INTERP,
  92 + ARGIN(Parrot_runcore_t *runcore))
  93 + __attribute__nonnull__(1)
  94 + __attribute__nonnull__(2);
  95 +
78 96 PARROT_WARN_UNUSED_RESULT
79 97 PARROT_CAN_RETURN_NULL
80 98 static opcode_t * runops_subprof_hll_core(PARROT_INTERP,
81   - Parrot_runcore_t *runcore,
  99 + ARGIN(Parrot_runcore_t *runcore),
82 100 ARGIN(opcode_t *pc))
83 101 __attribute__nonnull__(1)
  102 + __attribute__nonnull__(2)
84 103 __attribute__nonnull__(3);
85 104
86 105 PARROT_WARN_UNUSED_RESULT
87 106 PARROT_CAN_RETURN_NULL
88 107 static opcode_t * runops_subprof_ops_core(PARROT_INTERP,
89   - Parrot_runcore_t *runcore,
  108 + ARGIN(Parrot_runcore_t *runcore),
90 109 ARGIN(opcode_t *pc))
91 110 __attribute__nonnull__(1)
  111 + __attribute__nonnull__(2)
92 112 __attribute__nonnull__(3);
93 113
94 114 PARROT_WARN_UNUSED_RESULT
95 115 PARROT_CAN_RETURN_NULL
96 116 static opcode_t * runops_subprof_sub_core(PARROT_INTERP,
97   - Parrot_runcore_t *runcore,
  117 + ARGIN(Parrot_runcore_t *runcore),
98 118 ARGIN(opcode_t *pc))
99 119 __attribute__nonnull__(1)
  120 + __attribute__nonnull__(2)
100 121 __attribute__nonnull__(3);
101 122
102 123 PARROT_CANNOT_RETURN_NULL
@@ -143,6 +164,9 @@ static lineinfo * sync_hll_linechange(PARROT_INTERP,
143 164 PARROT_ASSERT_ARG(interp) \
144 165 , PARROT_ASSERT_ARG(spdata) \
145 166 , PARROT_ASSERT_ARG(sp))
  167 +#define ASSERT_ARGS_dump_profile_data __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
  168 + PARROT_ASSERT_ARG(interp) \
  169 + , PARROT_ASSERT_ARG(spdata))
146 170 #define ASSERT_ARGS_findlineannotations __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
147 171 PARROT_ASSERT_ARG(interp) \
148 172 , PARROT_ASSERT_ARG(spdata) \
@@ -151,6 +175,10 @@ static lineinfo * sync_hll_linechange(PARROT_INTERP,
151 175 #define ASSERT_ARGS_finishcallchain __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
152 176 PARROT_ASSERT_ARG(interp) \
153 177 , PARROT_ASSERT_ARG(spdata))
  178 +#define ASSERT_ARGS_get_subprofiledata __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
  179 + PARROT_ASSERT_ARG(interp) \
  180 + , PARROT_ASSERT_ARG(runcore))
  181 +#define ASSERT_ARGS_getticks __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
154 182 #define ASSERT_ARGS_popcallchain __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
155 183 PARROT_ASSERT_ARG(interp) \
156 184 , PARROT_ASSERT_ARG(spdata))
@@ -158,14 +186,20 @@ static lineinfo * sync_hll_linechange(PARROT_INTERP,
158 186 PARROT_ASSERT_ARG(interp) \
159 187 , PARROT_ASSERT_ARG(spdata) \
160 188 , PARROT_ASSERT_ARG(sp))
  189 +#define ASSERT_ARGS_runops_subprof_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
  190 + PARROT_ASSERT_ARG(interp) \
  191 + , PARROT_ASSERT_ARG(runcore))
161 192 #define ASSERT_ARGS_runops_subprof_hll_core __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
162 193 PARROT_ASSERT_ARG(interp) \
  194 + , PARROT_ASSERT_ARG(runcore) \
163 195 , PARROT_ASSERT_ARG(pc))
164 196 #define ASSERT_ARGS_runops_subprof_ops_core __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
165 197 PARROT_ASSERT_ARG(interp) \
  198 + , PARROT_ASSERT_ARG(runcore) \
166 199 , PARROT_ASSERT_ARG(pc))
167 200 #define ASSERT_ARGS_runops_subprof_sub_core __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
168 201 PARROT_ASSERT_ARG(interp) \
  202 + , PARROT_ASSERT_ARG(runcore) \
169 203 , PARROT_ASSERT_ARG(pc))
170 204 #define ASSERT_ARGS_sptodebug __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
171 205 PARROT_ASSERT_ARG(interp) \
@@ -189,8 +223,6 @@ static lineinfo * sync_hll_linechange(PARROT_INTERP,
189 223 /* HEADERIZER END: static */
190 224
191 225
192   -static subprofiledata _spdata;
193   -
194 226 /*
195 227
196 228 =item *C<static INTVAL *sptodebug(...)>
@@ -634,10 +666,9 @@ profile to stderr.
634 666 */
635 667
636 668
637   -void
638   -dump_profile_data(PARROT_INTERP)
  669 +static void
  670 +dump_profile_data(PARROT_INTERP, ARGIN(subprofiledata *spdata))
639 671 {
640   - subprofiledata *spdata = &_spdata;
641 672 int h;
642 673 size_t off;
643 674
@@ -743,24 +774,16 @@ dump_profile_data(PARROT_INTERP)
743 774 fprintf(stderr, "\ntotals: %d %lld\n", totalops, totalticks);
744 775 }
745 776
746   -void
747   -mark_profile_data(PARROT_INTERP)
748   -{
749   - subprofiledata *spdata = &_spdata;
750   - if (!spdata->profile_type || !spdata->sphash)
751   - return;
752   - Parrot_hash_mark(interp, spdata->sphash);
753   -}
754   -
755   -
756 777 #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
757   -static __inline__ UHUGEINTVAL getticks(void) {
  778 +static __inline__ UHUGEINTVAL
  779 +getticks(void) {
758 780 uint32_t lo, hi;
759 781 __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
760 782 return (UHUGEINTVAL)hi << 32 | lo;
761 783 }
762 784 #else
763   -static UHUGEINTVAL getticks(void) {
  785 +static UHUGEINTVAL
  786 +getticks(void) {
764 787 return Parrot_hires_get_time();
765 788 }
766 789 #endif
@@ -845,6 +868,27 @@ sync_hll_linechange(PARROT_INTERP, ARGIN(subprofiledata *spdata), ARGIN_NULLOK(o
845 868 return li;
846 869 }
847 870
  871 +PARROT_WARN_UNUSED_RESULT
  872 +PARROT_CANNOT_RETURN_NULL
  873 +static subprofiledata *
  874 +get_subprofiledata(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore), int type)
  875 +{
  876 + Parrot_subprof_runcore_t *core = (Parrot_subprof_runcore_t *)runcore;
  877 + subprofiledata *spdata = core->spdata;
  878 + if (!spdata) {
  879 + spdata = (subprofiledata *)calloc(1, sizeof(subprofiledata));
  880 + spdata->profile_type = type;
  881 + spdata->interp = interp;
  882 + core->spdata = spdata;
  883 + }
  884 + if (spdata->profile_type != type)
  885 + Parrot_ex_throw_from_c_args(interp, NULL, 1, "illegal profile type change while profiling");
  886 + if (spdata->interp != interp)
  887 + Parrot_ex_throw_from_c_args(interp, NULL, 1, "illegal interpreter change while profiling");
  888 + return core->spdata;
  889 +}
  890 +
  891 +
848 892 #ifdef code_start
849 893 # undef code_start
850 894 #endif
@@ -855,6 +899,24 @@ sync_hll_linechange(PARROT_INTERP, ARGIN(subprofiledata *spdata), ARGIN_NULLOK(o
855 899 #define code_start interp->code->base.data
856 900 #define code_end (interp->code->base.data + interp->code->base.size)
857 901
  902 +/*
  903 +=item C<static void runops_subprof_destroy(PARROT_INTERP, Parrot_runcore_t
  904 +*runcore)>
  905 +
  906 +Destroy callback. We use it to print the profile data.
  907 +
  908 +*/
  909 +
  910 +static void
  911 +runops_subprof_destroy(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore))
  912 +{
  913 + Parrot_subprof_runcore_t *core = (Parrot_subprof_runcore_t *)runcore;
  914 + if (core->spdata) {
  915 + dump_profile_data(interp, core->spdata);
  916 + free(core->spdata);
  917 + core->spdata = NULL;
  918 + }
  919 +}
858 920
859 921 /*
860 922 =item C<static opcode_t * runops_subprof_hll_core(PARROT_INTERP,
@@ -870,17 +932,12 @@ operations, with sub-level profiling and bounds checking enabled.
870 932 PARROT_WARN_UNUSED_RESULT
871 933 PARROT_CAN_RETURN_NULL
872 934 static opcode_t *
873   -runops_subprof_sub_core(PARROT_INTERP, SHIM(Parrot_runcore_t *runcore), ARGIN(opcode_t *pc))
  935 +runops_subprof_sub_core(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore), ARGIN(opcode_t *pc))
874 936 {
875   - subprofiledata *spdata = &_spdata;
  937 + subprofiledata *spdata = get_subprofiledata(interp, runcore, SUBPROF_TYPE_SUB);
876 938 subprofile *sp = spdata->cursp;
877 939 PMC *ctx, *subpmc;
878 940
879   - if (spdata->profile_type && spdata->profile_type != SUBPROF_TYPE_SUB)
880   - Parrot_ex_throw_from_c_args(interp, NULL, 1,
881   - "illegal profile type change");
882   - spdata->profile_type = SUBPROF_TYPE_SUB;
883   -
884 941 while (pc) {
885 942 if (pc < code_start || pc >= code_end)
886 943 Parrot_ex_throw_from_c_args(interp, NULL, 1,
@@ -935,18 +992,18 @@ Registers the subprof_sub runcore with Parrot.
935 992 void
936 993 Parrot_runcore_subprof_sub_init(PARROT_INTERP)
937 994 {
938   - Parrot_runcore_t * const coredata = mem_gc_allocate_zeroed_typed(interp, Parrot_runcore_t);
  995 + Parrot_subprof_runcore_t * const coredata = mem_gc_allocate_zeroed_typed(interp, Parrot_subprof_runcore_t);
939 996 coredata->name = CONST_STRING(interp, "subprof_sub");
940 997 coredata->id = PARROT_SLOW_CORE;
941 998 coredata->opinit = PARROT_CORE_OPLIB_INIT;
942 999 coredata->runops = runops_subprof_sub_core;
943 1000 coredata->prepare_run = NULL;
944   - coredata->destroy = NULL;
  1001 + coredata->destroy = runops_subprof_destroy;
945 1002 coredata->flags = 0;
946 1003
947 1004 PARROT_RUNCORE_FUNC_TABLE_SET(coredata);
948 1005
949   - Parrot_runcore_register(interp, coredata);
  1006 + Parrot_runcore_register(interp, (Parrot_runcore_t *)coredata);
950 1007 }
951 1008
952 1009
@@ -966,20 +1023,15 @@ operations, with sub-level profiling and bounds checking enabled.
966 1023 PARROT_WARN_UNUSED_RESULT
967 1024 PARROT_CAN_RETURN_NULL
968 1025 static opcode_t *
969   -runops_subprof_hll_core(PARROT_INTERP, SHIM(Parrot_runcore_t *runcore), ARGIN(opcode_t *pc))
  1026 +runops_subprof_hll_core(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore), ARGIN(opcode_t *pc))
970 1027 {
971   - subprofiledata *spdata = &_spdata;
  1028 + subprofiledata *spdata = get_subprofiledata(interp, runcore, SUBPROF_TYPE_HLL);
972 1029 subprofile *sp = spdata->cursp;
973 1030 PMC *ctx, *subpmc;
974 1031 lineinfo *curline = sp ? sp->lines : 0;
975 1032 opcode_t *startop = 0;
976 1033 opcode_t *endop = 0; /* triggers pc >= endop below */
977 1034
978   - if (spdata->profile_type && spdata->profile_type != SUBPROF_TYPE_HLL)
979   - Parrot_ex_throw_from_c_args(interp, NULL, 1,
980   - "illegal profile type change");
981   - spdata->profile_type = SUBPROF_TYPE_HLL;
982   -
983 1035 while (pc) {
984 1036 if (pc < code_start || pc >= code_end)
985 1037 Parrot_ex_throw_from_c_args(interp, NULL, 1,
@@ -1073,18 +1125,18 @@ Registers the subprof_hll runcore with Parrot.
1073 1125 void
1074 1126 Parrot_runcore_subprof_hll_init(PARROT_INTERP)
1075 1127 {
1076   - Parrot_runcore_t * const coredata = mem_gc_allocate_zeroed_typed(interp, Parrot_runcore_t);
  1128 + Parrot_subprof_runcore_t * const coredata = mem_gc_allocate_zeroed_typed(interp, Parrot_subprof_runcore_t);
1077 1129 coredata->name = CONST_STRING(interp, "subprof_hll");
1078 1130 coredata->id = PARROT_SLOW_CORE;
1079 1131 coredata->opinit = PARROT_CORE_OPLIB_INIT;
1080 1132 coredata->runops = runops_subprof_hll_core;
1081 1133 coredata->prepare_run = NULL;
1082   - coredata->destroy = NULL;
  1134 + coredata->destroy = runops_subprof_destroy;
1083 1135 coredata->flags = 0;
1084 1136
1085 1137 PARROT_RUNCORE_FUNC_TABLE_SET(coredata);
1086 1138
1087   - Parrot_runcore_register(interp, coredata);
  1139 + Parrot_runcore_register(interp, (Parrot_runcore_t *)coredata);
1088 1140 }
1089 1141
1090 1142
@@ -1102,19 +1154,14 @@ operations, with sub-level profiling and bounds checking enabled.
1102 1154 PARROT_WARN_UNUSED_RESULT
1103 1155 PARROT_CAN_RETURN_NULL
1104 1156 static opcode_t *
1105   -runops_subprof_ops_core(PARROT_INTERP, SHIM(Parrot_runcore_t *runcore), ARGIN(opcode_t *pc))
  1157 +runops_subprof_ops_core(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore), ARGIN(opcode_t *pc))
1106 1158 {
1107   - PMC *ctx, *subpmc;
1108   - subprofiledata *spdata = &_spdata;
  1159 + subprofiledata *spdata = get_subprofiledata(interp, runcore, SUBPROF_TYPE_OPS);
1109 1160 subprofile *sp = spdata->cursp;
  1161 + PMC *ctx, *subpmc;
1110 1162 opcode_t *startop = sp ? sp->code_ops + sp->subattrs->start_offs : 0;
1111 1163 UHUGEINTVAL tick;
1112 1164
1113   - if (spdata->profile_type && spdata->profile_type != SUBPROF_TYPE_OPS)
1114   - Parrot_ex_throw_from_c_args(interp, NULL, 1,
1115   - "illegal profile type change");
1116   - spdata->profile_type = SUBPROF_TYPE_OPS;
1117   -
1118 1165 while (pc) {
1119 1166 if (pc < code_start || pc >= code_end)
1120 1167 Parrot_ex_throw_from_c_args(interp, NULL, 1,
@@ -1170,21 +1217,39 @@ Registers the subprof_ops runcore with Parrot.
1170 1217 void
1171 1218 Parrot_runcore_subprof_ops_init(PARROT_INTERP)
1172 1219 {
1173   - Parrot_runcore_t * const coredata = mem_gc_allocate_zeroed_typed(interp, Parrot_runcore_t);
  1220 + Parrot_subprof_runcore_t * const coredata = mem_gc_allocate_zeroed_typed(interp, Parrot_subprof_runcore_t);
1174 1221 coredata->name = CONST_STRING(interp, "subprof_ops");
1175 1222 coredata->id = PARROT_SLOW_CORE;
1176 1223 coredata->opinit = PARROT_CORE_OPLIB_INIT;
1177 1224 coredata->runops = runops_subprof_ops_core;
1178 1225 coredata->prepare_run = NULL;
1179   - coredata->destroy = NULL;
  1226 + coredata->destroy = runops_subprof_destroy;
1180 1227 coredata->flags = 0;
1181 1228
1182 1229 PARROT_RUNCORE_FUNC_TABLE_SET(coredata);
1183 1230
1184   - Parrot_runcore_register(interp, coredata);
  1231 + Parrot_runcore_register(interp, (Parrot_runcore_t *)coredata);
1185 1232 }
1186 1233
1187 1234
  1235 +
  1236 +void
  1237 +runops_subprof_mark(PARROT_INTERP, ARGIN(Parrot_runcore_t *runcore))
  1238 +{
  1239 + Parrot_subprof_runcore_t *core;
  1240 + subprofiledata *spdata;
  1241 +
  1242 + if (runcore->destroy != runops_subprof_destroy)
  1243 + return;
  1244 + core = (Parrot_subprof_runcore_t *)runcore;
  1245 + spdata = core->spdata;
  1246 + if (!spdata || !spdata->profile_type || !spdata->sphash)
  1247 + return;
  1248 + Parrot_hash_mark(interp, spdata->sphash);
  1249 +}
  1250 +
  1251 +
  1252 +
1188 1253 /*
1189 1254
1190 1255 =back

0 comments on commit f5358a8

Please sign in to comment.
Something went wrong with that request. Please try again.