Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Mar 25, 2022
1 parent 1d3d47f commit fce6d41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions iseq.c
Expand Up @@ -119,10 +119,14 @@ iseq_clear_ic_references_i(VALUE *code, VALUE insn, size_t index, void *data)

switch (insn) {
case BIN(opt_getinlinecache): {
fprintf(stderr, "// I FOUND AN INLINE CACHE!\n");

ic_data->ic = (IC) code[index + 2];
return true;
}
case BIN(getconstant): {
fprintf(stderr, "// I FOUND A GETCONSTANT!\n");

ID id = (ID) code[index + 1];
rb_vm_t *vm = GET_VM();
st_table *ics;
Expand All @@ -139,6 +143,8 @@ iseq_clear_ic_references_i(VALUE *code, VALUE insn, size_t index, void *data)
return true;
}
case BIN(opt_setinlinecache): {
fprintf(stderr, "// I FOUND A SETINLINECACHE!\n");

ic_data->ic = NULL;
return true;
}
Expand All @@ -154,8 +160,13 @@ iseq_clear_ic_references_i(VALUE *code, VALUE insn, size_t index, void *data)
static void
iseq_clear_ic_references(const rb_iseq_t *iseq)
{
fprintf(stderr, "// ====================================\n");
fprintf(stderr, "// CLEANING UP IC REFERENCES IN ISEQ\n");

struct iseq_clear_ic_references_data data = { .ic = NULL };
rb_iseq_each(iseq, 0, iseq_clear_ic_references_i, (void *) &data);

fprintf(stderr, "// ====================================\n");
}

void
Expand Down
6 changes: 6 additions & 0 deletions vm_method.c
Expand Up @@ -139,14 +139,20 @@ void rb_clear_constant_cache(void) {}
void
rb_clear_constant_cache_for_id(ID id)
{
fprintf(stderr, "// ====================================\n");
fprintf(stderr, "// CLEARING CONSTANT CACHE FOR ID: %s\n", rb_id2name(id));

rb_vm_t *vm = GET_VM();
st_table *ics;

if (rb_id_table_lookup(vm->constant_cache, id, (VALUE *) &ics)) {
st_foreach(ics, rb_clear_constant_cache_for_id_i, (st_data_t) NULL);
}

printf("// NOTIFYING YJIT\n");
rb_yjit_constant_state_changed();

fprintf(stderr, "// ====================================\n");
}

static void
Expand Down

0 comments on commit fce6d41

Please sign in to comment.