@@ -985,20 +985,22 @@ static jl_array_t *jl_verify_methods(jl_array_t *edges, jl_array_t *maxvalids)
985985 int32_t * idxs = (int32_t * )jl_array_data (callee_ids );
986986 size_t j ;
987987 maxvalids2_data [i ] = ~(size_t )0 ;
988- for (j = 0 ; j < idxs [0 ]; j ++ ) {
989- int32_t idx = idxs [j + 1 ];
990- size_t max_valid = ((size_t * )(jl_array_data (maxvalids )))[idx ];
991- if (max_valid != ~(size_t )0 && _jl_debug_method_invalidation ) {
992- jl_array_ptr_1d_push (_jl_debug_method_invalidation , (jl_value_t * )caller );
993- loctag = jl_cstr_to_string ("verify_methods" );
994- jl_array_ptr_1d_push (_jl_debug_method_invalidation , loctag );
995- loctag = jl_box_int32 ((int32_t )idx );
996- jl_array_ptr_1d_push (_jl_debug_method_invalidation , loctag );
988+ if (jl_array_len (callee_ids ) > 0 ) {
989+ for (j = 0 ; j < idxs [0 ]; j ++ ) {
990+ int32_t idx = idxs [j + 1 ];
991+ size_t max_valid = ((size_t * )(jl_array_data (maxvalids )))[idx ];
992+ if (max_valid != ~(size_t )0 && _jl_debug_method_invalidation ) {
993+ jl_array_ptr_1d_push (_jl_debug_method_invalidation , (jl_value_t * )caller );
994+ loctag = jl_cstr_to_string ("verify_methods" );
995+ jl_array_ptr_1d_push (_jl_debug_method_invalidation , loctag );
996+ loctag = jl_box_int32 ((int32_t )idx );
997+ jl_array_ptr_1d_push (_jl_debug_method_invalidation , loctag );
998+ }
999+ if (max_valid < maxvalids2_data [i ])
1000+ maxvalids2_data [i ] = max_valid ;
1001+ if (max_valid == 0 )
1002+ break ;
9971003 }
998- if (max_valid < maxvalids2_data [i ])
999- maxvalids2_data [i ] = max_valid ;
1000- if (max_valid == 0 )
1001- break ;
10021004 }
10031005 }
10041006 //jl_static_show((JL_STREAM*)ios_stderr, (jl_value_t*)caller);
@@ -1138,23 +1140,25 @@ static void jl_insert_backedges(jl_array_t *edges, jl_array_t *ext_targets, jl_a
11381140 if (maxvalid == ~(size_t )0 ) {
11391141 // if this callee is still valid, add all the backedges
11401142 jl_array_t * callee_ids = (jl_array_t * )jl_array_ptr_ref (edges , 2 * i + 1 );
1141- int32_t * idxs = (int32_t * )jl_array_data (callee_ids );
1142- for (size_t j = 0 ; j < idxs [0 ]; j ++ ) {
1143- int32_t idx = idxs [j + 1 ];
1144- jl_value_t * invokesig = jl_array_ptr_ref (ext_targets , idx * 3 );
1145- jl_value_t * callee = jl_array_ptr_ref (ext_targets , idx * 3 + 1 );
1146- if (callee && jl_is_method_instance (callee )) {
1147- jl_method_instance_add_backedge ((jl_method_instance_t * )callee , invokesig , caller );
1148- }
1149- else {
1150- jl_value_t * sig = callee == NULL ? invokesig : callee ;
1151- jl_methtable_t * mt = jl_method_table_for (sig );
1152- // FIXME: rarely, `callee` has an unexpected `Union` signature,
1153- // see https://github.com/JuliaLang/julia/pull/43990#issuecomment-1030329344
1154- // Fix the issue and turn this back into an `assert((jl_value_t*)mt != jl_nothing)`
1155- // This workaround exposes us to (rare) 265-violations.
1156- if ((jl_value_t * )mt != jl_nothing )
1157- jl_method_table_add_backedge (mt , sig , (jl_value_t * )caller );
1143+ if (jl_array_len (callee_ids ) > 0 ) {
1144+ int32_t * idxs = (int32_t * )jl_array_data (callee_ids );
1145+ for (size_t j = 0 ; j < idxs [0 ]; j ++ ) {
1146+ int32_t idx = idxs [j + 1 ];
1147+ jl_value_t * invokesig = jl_array_ptr_ref (ext_targets , idx * 3 );
1148+ jl_value_t * callee = jl_array_ptr_ref (ext_targets , idx * 3 + 1 );
1149+ if (callee && jl_is_method_instance (callee )) {
1150+ jl_method_instance_add_backedge ((jl_method_instance_t * )callee , invokesig , caller );
1151+ }
1152+ else {
1153+ jl_value_t * sig = callee == NULL ? invokesig : callee ;
1154+ jl_methtable_t * mt = jl_method_table_for (sig );
1155+ // FIXME: rarely, `callee` has an unexpected `Union` signature,
1156+ // see https://github.com/JuliaLang/julia/pull/43990#issuecomment-1030329344
1157+ // Fix the issue and turn this back into an `assert((jl_value_t*)mt != jl_nothing)`
1158+ // This workaround exposes us to (rare) 265-violations.
1159+ if ((jl_value_t * )mt != jl_nothing )
1160+ jl_method_table_add_backedge (mt , sig , (jl_value_t * )caller );
1161+ }
11581162 }
11591163 }
11601164 }
0 commit comments