Skip to content

Instantly share code, notes, and snippets.

@timo
Last active June 29, 2020 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timo/19da667195e0d20417da6ed274991518 to your computer and use it in GitHub Desktop.
Save timo/19da667195e0d20417da6ed274991518 to your computer and use it in GitHub Desktop.
attempt to fix logging dispatch program resolution spesh log, but it doesn't seem to be enough; when we resolve by invoking a frame (like with raku-assign) the entry in the spesh log still says "never invoked"
commit e882e67a6417f4cee3c1dfafbe471e877946fbb7
Author: Timo Paulssen <timonator@perpetuum-immobile.de>
Date: Mon Jun 29 16:16:46 2020 +0200
stash away spesh correlation id early to use in dispatch logging
diff --git a/src/disp/inline_cache.c b/src/disp/inline_cache.c
index 7a10ec31d..c4f88461a 100644
--- a/src/disp/inline_cache.c
+++ b/src/disp/inline_cache.c
@@ -97,6 +97,7 @@ static void dispatch_initial_flattening(MVMThreadContext *tc,
static void dispatch_monomorphic(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMDispInlineCacheEntry *seen,
MVMString *id, MVMCallsite *callsite, MVMuint16 *arg_indices, 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);
@@ -110,14 +111,15 @@ static void dispatch_monomorphic(MVMThreadContext *tc,
dispatch_initial(tc, entry_ptr, seen, id, callsite, arg_indices, 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, 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,
tc->cur_frame->work, arg_indices);
@@ -133,8 +135,8 @@ static void dispatch_monomorphic_flattening(MVMThreadContext *tc,
record->arg_info = flat_record->arg_info;
if (MVM_disp_program_run(tc, dp, record)) {
/* 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 {
@@ -154,6 +156,7 @@ static void dispatch_monomorphic_flattening(MVMThreadContext *tc,
static void dispatch_polymorphic(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMDispInlineCacheEntry *seen,
MVMString *id, MVMCallsite *callsite, MVMuint16 *arg_indices, MVMuint32 bytecode_offset) {
+ MVMint32 cid = tc->cur_frame->spesh_correlation_id;
/* Set up dispatch run record. */
MVMDispInlineCacheEntryPolymorphicDispatch *entry =
(MVMDispInlineCacheEntryPolymorphicDispatch *)seen;
@@ -167,8 +170,8 @@ static void dispatch_polymorphic(MVMThreadContext *tc,
MVMuint32 i;
for (i = 0; i < entry->num_dps; i++) {
if (MVM_disp_program_run(tc, entry->dps[i], record)) {
- if (MVM_spesh_log_is_logging(tc))
- MVM_spesh_log_dispatch_resolution(tc, bytecode_offset, i);
+ if (MVM_spesh_log_is_logging(tc) && cid)
+ MVM_spesh_log_dispatch_resolution_for_correlation_id(tc, cid, bytecode_offset, i);
return;
}
}
@@ -182,6 +185,7 @@ static void dispatch_polymorphic(MVMThreadContext *tc,
static void dispatch_polymorphic_flattening(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMDispInlineCacheEntry *seen,
MVMString *id, MVMCallsite *callsite, MVMuint16 *arg_indices, 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,
tc->cur_frame->work, arg_indices);
@@ -199,8 +203,8 @@ static void dispatch_polymorphic_flattening(MVMThreadContext *tc,
for (i = 0; i < entry->num_dps; i++) {
if (flat_record->arg_info.callsite == entry->flattened_css[i]) {
if (MVM_disp_program_run(tc, entry->dps[i], record)) {
- if (MVM_spesh_log_is_logging(tc))
- MVM_spesh_log_dispatch_resolution(tc, bytecode_offset, i);
+ if (MVM_spesh_log_is_logging(tc) && cid)
+ MVM_spesh_log_dispatch_resolution_for_correlation_id(tc, cid, bytecode_offset, i);
return;
}
}
diff --git a/src/spesh/log.c b/src/spesh/log.c
index 953201337..9a003ef1d 100644
--- a/src/spesh/log.c
+++ b/src/spesh/log.c
@@ -250,3 +250,13 @@ void MVM_spesh_log_dispatch_resolution(MVMThreadContext *tc, MVMuint32 bytecode_
entry->plugin.guard_index = guard_index;
commit_entry(tc, sl);
}
+void MVM_spesh_log_dispatch_resolution_for_correlation_id(MVMThreadContext *tc, MVMint32 cid, MVMuint32 bytecode_offset,
+ MVMuint16 guard_index) {
+ MVMSpeshLog *sl = tc->spesh_log;
+ MVMSpeshLogEntry *entry = &(sl->body.entries[sl->body.used]);
+ entry->kind = MVM_SPESH_LOG_DISPATCH_RESOLUTION;
+ entry->id = cid;
+ entry->plugin.bytecode_offset = bytecode_offset;
+ entry->plugin.guard_index = guard_index;
+ commit_entry(tc, sl);
+}
diff --git a/src/spesh/log.h b/src/spesh/log.h
index fc5b40beb..841c59921 100644
--- a/src/spesh/log.h
+++ b/src/spesh/log.h
@@ -51,3 +51,5 @@ void MVM_spesh_log_plugin_resolution(MVMThreadContext *tc, MVMuint32 bytecode_of
MVMuint16 guard_index);
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 guard_index);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment