Skip to content

Commit

Permalink
Include dispatcher name in full inline cache log
Browse files Browse the repository at this point in the history
To make it much easier to work out which ones are in need of adding a
megamorphic dispatch handler.
  • Loading branch information
jnthn committed Oct 18, 2021
1 parent ba7df1b commit b80ad65
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/core/callstack.h
Expand Up @@ -164,6 +164,9 @@ struct MVMCallStackDispatchRecord {
* derived and guards established. */
MVMDispProgramRecording rec;

/* The initial dispatcher (the one declared at the callsite). */
MVMDispDefinition *initial_disp;

/* The current dispatcher that we're running. */
MVMDispDefinition *current_disp;

Expand Down
13 changes: 10 additions & 3 deletions src/disp/inline_cache.c
Expand Up @@ -285,7 +285,8 @@ static void gc_barrier_program(MVMThreadContext *tc, MVMStaticFrame *root,
}
MVMuint32 MVM_disp_inline_cache_transition(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMDispInlineCacheEntry *entry,
MVMStaticFrame *root, MVMCallsite *initial_cs, MVMDispProgram *dp) {
MVMStaticFrame *root, MVMDispDefinition *initial_disp,
MVMCallsite *initial_cs, MVMDispProgram *dp) {
/* Ensure that the entry is current (this is re-checked when we actaully
* update it, but this ensures we won't dereference a dangling pointer
* below; safe as we know there's not a GC safepoint between here and
Expand Down Expand Up @@ -363,8 +364,11 @@ MVMuint32 MVM_disp_inline_cache_transition(MVMThreadContext *tc,
(MVMDispInlineCacheEntryPolymorphicDispatch *)entry;
if (prev_entry->num_dps == MVM_INLINE_CACHE_MAX_POLY) {
#if DUMP_FULL_CACHES
fprintf(stderr, "\n\nFull polymorphic dispatch inline cache at:\n");
char *disp_id = MVM_string_utf8_encode_C_string(tc, initial_disp->id);
fprintf(stderr, "\n\nFull polymorphic dispatch inline cache for %s at:\n",
disp_id);
MVM_dump_backtrace(tc);
MVM_free(disp_id);
#endif
return 0;
}
Expand All @@ -386,8 +390,11 @@ MVMuint32 MVM_disp_inline_cache_transition(MVMThreadContext *tc,
(MVMDispInlineCacheEntryPolymorphicDispatchFlattening *)entry;
if (prev_entry->num_dps == MVM_INLINE_CACHE_MAX_POLY) {
#if DUMP_FULL_CACHES
fprintf(stderr, "\n\nFull polymorphic flattening dispatch inline cache at:\n");
char *disp_id = MVM_string_utf8_encode_C_string(tc, initial_disp->id);
fprintf(stderr, "\n\nFull polymorphic flattening dispatch inline cache for %s at:\n",
disp_id);
MVM_dump_backtrace(tc);
MVM_free(disp_id);
#endif
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion src/disp/inline_cache.h
Expand Up @@ -102,7 +102,8 @@ MVMuint32 MVM_disp_inline_cache_get_slot(MVMThreadContext *tc, MVMStaticFrame *s
MVMuint32 bytecode_offset);
MVMuint32 MVM_disp_inline_cache_transition(MVMThreadContext *tc,
MVMDispInlineCacheEntry **entry_ptr, MVMDispInlineCacheEntry *entry,
MVMStaticFrame *root, MVMCallsite *initial_cs, MVMDispProgram *dp);
MVMStaticFrame *root, MVMDispDefinition *initial_disp,
MVMCallsite *initial_cs, MVMDispProgram *dp);
void MVM_disp_inline_cache_destroy(MVMThreadContext *tc, MVMDispInlineCache *cache);
MVMuint32 MVM_disp_inline_cache_get_kind(MVMThreadContext *tc, MVMDispInlineCacheEntry *entry);
MVMint32 MVM_disp_inline_cache_try_get_kind(MVMThreadContext *tc, MVMDispInlineCacheEntry *entry);
3 changes: 2 additions & 1 deletion src/disp/program.c
Expand Up @@ -583,6 +583,7 @@ void MVM_disp_program_run_dispatch(MVMThreadContext *tc, MVMDispDefinition *disp
record->rec.initial_capture.capture = capture;
record->rec.inline_cache_size = inline_cache_size;
record->rec.do_not_install = 0;
record->initial_disp = disp;
record->ic_entry_ptr = ic_entry_ptr;
record->ic_entry = ic_entry;
record->update_sf = update_sf;
Expand Down Expand Up @@ -2730,7 +2731,7 @@ static void process_recording(MVMThreadContext *tc, MVMCallStackDispatchRecord *
MVMuint32 installed = record->rec.do_not_install
? 0
: MVM_disp_inline_cache_transition(tc, record->ic_entry_ptr,
record->ic_entry, record->update_sf,
record->ic_entry, record->update_sf, record->initial_disp,
((MVMCapture *)record->rec.initial_capture.capture)->body.callsite,
dp);

Expand Down

0 comments on commit b80ad65

Please sign in to comment.