Skip to content

Commit

Permalink
fix verify-edges added in JuliaLang#35188 (JuliaLang#35352)
Browse files Browse the repository at this point in the history
The `valid` parameter was initialized wrong, leading to no edges ever
being saved.
  • Loading branch information
vtjnash authored and ztultrebor committed Apr 14, 2020
1 parent 075cf69 commit dcaf505
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1248,19 +1248,16 @@ static void jl_collect_backedges(jl_array_t *s, jl_array_t *t)
callees = jl_alloc_array_1d(jl_array_int32_type, 0);
void **pc = all_callees.table;
size_t j;
int valid = 0;
int valid = 1;
for (j = 0; valid && j < all_callees.size; j += 2) {
if (pc[j + 1] != HT_NOTFOUND) {
jl_value_t *callee = (jl_value_t*)pc[j];
void *target = ptrhash_get(&all_targets, (void*)callee);
if (target == HT_NOTFOUND) {
jl_method_instance_t *callee_mi = (jl_method_instance_t*)callee;
//jl_method_t *callee_m = NULL;
jl_value_t *sig;
if (jl_is_method_instance(callee)) {
sig = callee_mi->specTypes;
//callee_m = callee_mi->def.method;
//assert(jl_is_method(callee_m) && !module_in_worklist(callee_m->module));
}
else {
sig = callee;
Expand Down Expand Up @@ -1318,7 +1315,7 @@ static void write_mod_list(ios_t *s, jl_array_t *a)
}

// "magic" string and version header of .ji file
static const int JI_FORMAT_VERSION = 10;
static const int JI_FORMAT_VERSION = 11;
static const char JI_MAGIC[] = "\373jli\r\n\032\n"; // based on PNG signature
static const uint16_t BOM = 0xFEFF; // byte-order marker
static void write_header(ios_t *s)
Expand Down Expand Up @@ -2297,12 +2294,9 @@ static void jl_verify_edges(jl_array_t *targets, jl_array_t **pvalids)
for (i = 0; i < l; i++) {
jl_value_t *callee = jl_array_ptr_ref(targets, i * 2);
jl_method_instance_t *callee_mi = (jl_method_instance_t*)callee;
jl_method_t *callee_m = NULL;
jl_value_t *sig;
if (jl_is_method_instance(callee)) {
sig = callee_mi->specTypes;
//callee_m = callee_mi->def.method;
//assert(jl_is_method(callee_m) && !module_in_worklist(callee_m->module));
}
else {
sig = callee;
Expand All @@ -2313,17 +2307,21 @@ static void jl_verify_edges(jl_array_t *targets, jl_array_t **pvalids)
size_t min_valid = 0;
size_t max_valid = ~(size_t)0;
jl_value_t *matches = jl_matching_methods((jl_tupletype_t*)sig, -1, 0, jl_world_counter, &min_valid, &max_valid);
if (matches == jl_false || jl_array_len(matches) != jl_array_len(expected) + !!callee_m) {
if (matches == jl_false || jl_array_len(matches) != jl_array_len(expected)) {
valid = 0;
}
else {
size_t j, k;
for (j = 0, k = 0; k < jl_array_len(matches); k++) {
size_t j, k, l = jl_array_len(expected);
for (k = 0; k < jl_array_len(matches); k++) {
jl_method_t *m = (jl_method_t*)jl_svecref(jl_array_ptr_ref(matches, k), 2);
if (m != callee_m && m != (jl_method_t*)jl_array_ptr_ref(expected, j++)) {
for (j = 0; j < l; j++) {
if (m == (jl_method_t*)jl_array_ptr_ref(expected, j))
break;
}
if (j == l) {
// intersection has a new method or a method was
// deleted--this is now probably no good, just invalidate
// everything now
// everything about it now
valid = 0;
break;
}
Expand Down

0 comments on commit dcaf505

Please sign in to comment.