/home/travis/build/MoarVM/MoarVM/src/profiler/profile.c
Line | Count | Source (jump to first uncovered line) |
1 | | #include "moar.h" |
2 | | |
3 | | /* Starts profiling with the specified configuration. */ |
4 | 0 | void MVM_profile_start(MVMThreadContext *tc, MVMObject *config) { |
5 | 0 | if (tc->instance->profiling || MVM_profile_heap_profiling(tc)) |
6 | 0 | MVM_exception_throw_adhoc(tc, "Profiling is already started"); |
7 | 0 |
|
8 | 0 | if (MVM_repr_exists_key(tc, config, tc->instance->str_consts.kind)) { |
9 | 0 | MVMString *kind = MVM_repr_get_str(tc, |
10 | 0 | MVM_repr_at_key_o(tc, config, tc->instance->str_consts.kind)); |
11 | 0 | if (MVM_string_equal(tc, kind, tc->instance->str_consts.instrumented)) |
12 | 0 | MVM_profile_instrumented_start(tc, config); |
13 | 0 | else if (MVM_string_equal(tc, kind, tc->instance->str_consts.heap)) |
14 | 0 | MVM_profile_heap_start(tc, config); |
15 | 0 | else |
16 | 0 | MVM_exception_throw_adhoc(tc, "Unknown profiler specified"); |
17 | 0 | } |
18 | 0 | else { |
19 | 0 | /* Default to instrumented if no profiler kind specified, since that |
20 | 0 | * used to be the only one we supported. */ |
21 | 0 | MVM_profile_instrumented_start(tc, config); |
22 | 0 | } |
23 | 0 | } |
24 | | |
25 | | /* Ends profiling and returns the result data structure. */ |
26 | 0 | MVMObject * MVM_profile_end(MVMThreadContext *tc) { |
27 | 0 | if (tc->instance->profiling) |
28 | 0 | return MVM_profile_instrumented_end(tc); |
29 | 0 | else if (MVM_profile_heap_profiling(tc)) |
30 | 0 | return MVM_profile_heap_end(tc); |
31 | 0 | else |
32 | 0 | MVM_exception_throw_adhoc(tc, "Cannot end profiling if not profiling"); |
33 | 0 | } |