Skip to content

Commit f36931f

Browse files
committed
jl_debug_method_invalidation: return a list of instances
1 parent 5c5ab49 commit f36931f

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/gf.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,17 +1485,23 @@ static void update_max_args(jl_methtable_t *mt, jl_value_t *type)
14851485
mt->max_args = na;
14861486
}
14871487

1488-
JL_DLLEXPORT int jl_debug_method_invalidation = 0;
1488+
static jl_array_t *_jl_debug_method_invalidation = NULL;
1489+
JL_DLLEXPORT jl_value_t *jl_debug_method_invalidation(int state)
1490+
{
1491+
if (state) {
1492+
_jl_debug_method_invalidation = jl_alloc_array_1d(jl_array_any_type, 0);
1493+
return (jl_value_t*) _jl_debug_method_invalidation;
1494+
}
1495+
_jl_debug_method_invalidation = NULL;
1496+
return jl_nothing;
1497+
}
14891498

14901499
// recursively invalidate cached methods that had an edge to a replaced method
14911500
static void invalidate_method_instance(jl_method_instance_t *replaced, size_t max_world, int depth)
14921501
{
1493-
if (jl_debug_method_invalidation) {
1494-
int d0 = depth;
1495-
while (d0-- > 0)
1496-
jl_uv_puts(JL_STDOUT, " ", 1);
1497-
jl_static_show(JL_STDOUT, (jl_value_t*)replaced);
1498-
jl_uv_puts(JL_STDOUT, "\n", 1);
1502+
if (_jl_debug_method_invalidation) {
1503+
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)replaced);
1504+
jl_array_ptr_1d_push(_jl_debug_method_invalidation, jl_box_int32(depth));
14991505
}
15001506
if (!jl_is_method(replaced->def.method))
15011507
return; // shouldn't happen, but better to be safe
@@ -1622,10 +1628,9 @@ static int invalidate_mt_cache(jl_typemap_entry_t *oldentry, void *closure0)
16221628
}
16231629
}
16241630
if (intersects) {
1625-
if (jl_debug_method_invalidation) {
1626-
jl_uv_puts(JL_STDOUT, "-- ", 3);
1627-
jl_static_show(JL_STDOUT, (jl_value_t*)mi);
1628-
jl_uv_puts(JL_STDOUT, "\n", 1);
1631+
if (_jl_debug_method_invalidation) {
1632+
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)mi);
1633+
jl_array_ptr_1d_push(_jl_debug_method_invalidation, jl_cstr_to_string("mt"));
16291634
}
16301635
oldentry->max_world = env->max_world;
16311636
}
@@ -1772,12 +1777,8 @@ JL_DLLEXPORT void jl_method_table_insert(jl_methtable_t *mt, jl_method_t *method
17721777
}
17731778
}
17741779
}
1775-
if (invalidated && jl_debug_method_invalidation) {
1776-
jl_uv_puts(JL_STDOUT, ">> ", 3);
1777-
jl_static_show(JL_STDOUT, (jl_value_t*)method);
1778-
jl_uv_puts(JL_STDOUT, " ", 1);
1779-
jl_static_show(JL_STDOUT, (jl_value_t*)type);
1780-
jl_uv_puts(JL_STDOUT, "\n", 1);
1780+
if (invalidated && _jl_debug_method_invalidation) {
1781+
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)method);
17811782
}
17821783
update_max_args(mt, type);
17831784
JL_UNLOCK(&mt->writelock);

0 commit comments

Comments
 (0)