Skip to content

Commit

Permalink
Bump level until after instrumenting
Browse files Browse the repository at this point in the history
Rather than before, which can lead to various races. This fixes a whole
range of different problems in both debugging and profiling of apps that
are multi-threaded.
  • Loading branch information
jnthn committed Jul 18, 2019
1 parent ab7bac5 commit c3c9d7d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/frame.c
Expand Up @@ -81,6 +81,9 @@ static void prepare_and_verify_static_frame(MVMThreadContext *tc, MVMStaticFrame
MVM_ASSIGN_REF(tc, &(static_frame->common.header), static_frame_body->spesh,
MVM_repr_alloc_init(tc, tc->instance->StaticFrameSpesh));
MVM_gc_allocate_gen2_default_clear(tc);

/* We now have at least instrumentation level 1. */
static_frame->body.instrumentation_level = 1;
}

/* Unlock, now we're finished. */
Expand All @@ -103,9 +106,6 @@ static void instrumentation_level_barrier(MVMThreadContext *tc, MVMStaticFrame *

/* Re-check instrumentation level in case of races. */
if (static_frame->body.instrumentation_level != tc->instance->instrumentation_level) {
/* Mark frame as being at the current instrumentation level. */
static_frame->body.instrumentation_level = tc->instance->instrumentation_level;

/* Add profiling instrumentation if needed. */
if (tc->instance->profiling)
MVM_profile_instrument(tc, static_frame);
Expand All @@ -120,6 +120,9 @@ static void instrumentation_level_barrier(MVMThreadContext *tc, MVMStaticFrame *
* woes. If you add an instrumentation that has to be "turned off"
* again at some point, a solution for this problem must be found. */
MVM_profile_ensure_uninstrumented(tc, static_frame);

/* Mark frame as being at the current instrumentation level. */
static_frame->body.instrumentation_level = tc->instance->instrumentation_level;
}

/* Release the lock. */
Expand Down

0 comments on commit c3c9d7d

Please sign in to comment.