Skip to content

Commit

Permalink
Stash away spesh correlation ID earlier
Browse files Browse the repository at this point in the history
So that it will always be the correct one.
  • Loading branch information
timo authored and jnthn committed Jul 22, 2021
1 parent 48b6f4e commit adfb5cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
16 changes: 10 additions & 6 deletions src/disp/inline_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ static void dispatch_monomorphic(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMDispInlineCacheEntry *seen,
MVMString *id, MVMCallsite *callsite, MVMuint16 *arg_indices,
MVMRegister *source, MVMStaticFrame *sf, MVMuint32 bytecode_offset) {
MVMint32 cid = tc->cur_frame->spesh_correlation_id;
MVMDispProgram *dp = ((MVMDispInlineCacheEntryMonomorphicDispatch *)seen)->dp;
MVMCallStackDispatchRun *record = MVM_callstack_allocate_dispatch_run(tc,
dp->num_temporaries);
Expand All @@ -112,15 +113,16 @@ static void dispatch_monomorphic(MVMThreadContext *tc,
bytecode_offset);
}
else {
if (MVM_spesh_log_is_logging(tc))
MVM_spesh_log_dispatch_resolution(tc, bytecode_offset, 0);
if (MVM_spesh_log_is_logging(tc) && cid)
MVM_spesh_log_dispatch_resolution_for_correlation_id(tc, cid, bytecode_offset, 0);
}
}

static void dispatch_monomorphic_flattening(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMDispInlineCacheEntry *seen,
MVMString *id, MVMCallsite *callsite, MVMuint16 *arg_indices,
MVMRegister *source, MVMStaticFrame *sf, MVMuint32 bytecode_offset) {
MVMint32 cid = tc->cur_frame->spesh_correlation_id;
/* First, perform flattening of the arguments. */
MVMCallStackFlattening *flat_record = MVM_args_perform_flattening(tc, callsite,
source, arg_indices);
Expand All @@ -140,8 +142,8 @@ static void dispatch_monomorphic_flattening(MVMThreadContext *tc,
});
if (outcome) {
/* It matches, so we're ready to continue. */
if (MVM_spesh_log_is_logging(tc))
MVM_spesh_log_dispatch_resolution(tc, bytecode_offset, 0);
if (MVM_spesh_log_is_logging(tc) && cid)
MVM_spesh_log_dispatch_resolution_for_correlation_id(tc, cid, bytecode_offset, 0);
return;
}
else {
Expand All @@ -161,6 +163,7 @@ static void dispatch_polymorphic(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMDispInlineCacheEntry *seen,
MVMString *id, MVMCallsite *callsite, MVMuint16 *arg_indices,
MVMRegister *source, MVMStaticFrame *sf, MVMuint32 bytecode_offset) {
MVMint32 cid = tc->cur_frame->spesh_correlation_id;
/* Set up dispatch run record. */
MVMDispInlineCacheEntryPolymorphicDispatch *entry =
(MVMDispInlineCacheEntryPolymorphicDispatch *)seen;
Expand All @@ -179,7 +182,7 @@ static void dispatch_polymorphic(MVMThreadContext *tc,
});
if (outcome) {
if (MVM_spesh_log_is_logging(tc))
MVM_spesh_log_dispatch_resolution(tc, bytecode_offset, i);
MVM_spesh_log_dispatch_resolution_for_correlation_id(tc, cid, bytecode_offset, i);
return;
}
}
Expand All @@ -195,6 +198,7 @@ static void dispatch_polymorphic_flattening(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMDispInlineCacheEntry *seen,
MVMString *id, MVMCallsite *callsite, MVMuint16 *arg_indices,
MVMRegister *source, MVMStaticFrame *sf, MVMuint32 bytecode_offset) {
MVMint32 cid = tc->cur_frame->spesh_correlation_id;
/* First, perform flattening of the arguments. */
MVMCallStackFlattening *flat_record = MVM_args_perform_flattening(tc, callsite,
source, arg_indices);
Expand All @@ -217,7 +221,7 @@ static void dispatch_polymorphic_flattening(MVMThreadContext *tc,
});
if (outcome) {
if (MVM_spesh_log_is_logging(tc))
MVM_spesh_log_dispatch_resolution(tc, bytecode_offset, i);
MVM_spesh_log_dispatch_resolution_for_correlation_id(tc, cid, bytecode_offset, i);
return;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/spesh/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,9 @@ void MVM_spesh_log_return_to_unlogged(MVMThreadContext *tc) {
}

/* Log the result of a dispatch. */
void MVM_spesh_log_dispatch_resolution(MVMThreadContext *tc, MVMuint32 bytecode_offset,
MVMuint16 result_index) {
void MVM_spesh_log_dispatch_resolution_for_correlation_id(MVMThreadContext *tc,
MVMint32 cid, MVMuint32 bytecode_offset, MVMuint16 result_index) {
MVMSpeshLog *sl = tc->spesh_log;
MVMint32 cid = tc->cur_frame->spesh_correlation_id;
MVMSpeshLogEntry *entry = &(sl->body.entries[sl->body.used]);
entry->kind = MVM_SPESH_LOG_DISPATCH_RESOLUTION;
entry->id = cid;
Expand Down
4 changes: 2 additions & 2 deletions src/spesh/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ void MVM_spesh_log_invoke_target(MVMThreadContext *tc, MVMObject *invoke_target,
MVMuint16 was_multi);
void MVM_spesh_log_return_type(MVMThreadContext *tc, MVMObject *value);
void MVM_spesh_log_return_to_unlogged(MVMThreadContext *tc);
void MVM_spesh_log_dispatch_resolution(MVMThreadContext *tc, MVMuint32 bytecode_offset,
MVMuint16 guard_index);
void MVM_spesh_log_dispatch_resolution_for_correlation_id(MVMThreadContext *tc,
MVMint32 cid, MVMuint32 bytecode_offset, MVMuint16 result_index);

0 comments on commit adfb5cd

Please sign in to comment.