Skip to content

Commit e67f5a3

Browse files
committed
Try fixing the CI failure by adding stack lookup.
1 parent a833691 commit e67f5a3

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

src/jltypes.c

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,26 @@ static jl_value_t *inst_type_w_(jl_value_t *t, jl_value_t **env, size_t n,
19511951
static jl_svec_t *inst_all(jl_svec_t *p, jl_value_t **env, size_t n,
19521952
jl_typestack_t *stack, int check);
19531953

1954+
static jl_value_t*
1955+
lookup_type_stack(jl_typestack_t *stack, jl_datatype_t *tt, size_t ntp,
1956+
jl_value_t **iparams)
1957+
{
1958+
// if an identical instantiation is already in process somewhere
1959+
// up the stack, return it. this computes a fixed point for
1960+
// recursive types.
1961+
jl_typename_t *tn = tt->name;
1962+
while (stack != NULL) {
1963+
if (stack->tt->name == tn &&
1964+
ntp == jl_svec_len(stack->tt->parameters) &&
1965+
typekey_eq(stack->tt, iparams, ntp)) {
1966+
jl_value_t *lkup = (jl_value_t*)stack->tt;
1967+
return lkup == tn->primary ? NULL : lkup;
1968+
}
1969+
stack = stack->prev;
1970+
}
1971+
return NULL;
1972+
}
1973+
19541974
static jl_value_t *inst_datatype(jl_datatype_t *dt, jl_svec_t *p, jl_value_t **iparams, size_t ntp,
19551975
int cacheable, int isabstract, jl_typestack_t *stack,
19561976
jl_value_t **env, size_t n)
@@ -1965,6 +1985,10 @@ static jl_value_t *inst_datatype(jl_datatype_t *dt, jl_svec_t *p, jl_value_t **i
19651985
if (lkup != NULL)
19661986
return lkup;
19671987
}
1988+
jl_value_t *stack_lkup = lookup_type_stack(stack, dt, ntp, iparams);
1989+
if (stack_lkup) {
1990+
return stack_lkup;
1991+
}
19681992

19691993
// always use original type constructor
19701994
if (!istuple) {
@@ -2215,25 +2239,8 @@ static jl_value_t *inst_type_w_(jl_value_t *t, jl_value_t **env, size_t n,
22152239
// if t's parameters are not bound in the environment, return it uncopied (#9378)
22162240
if (!bound && t == tc) { JL_GC_POP(); return (jl_value_t*)t; }
22172241

2218-
// if an identical instantiation is already in process somewhere
2219-
// up the stack, return it. this computes a fixed point for
2220-
// recursive types.
2221-
jl_typestack_t *tmp = stack;
2222-
jl_value_t *lkup = NULL;
2223-
while (tmp != NULL) {
2224-
if (tmp->tt->name==tn && ntp==jl_svec_len(tmp->tt->parameters) &&
2225-
typekey_eq(tmp->tt, iparams, ntp)) {
2226-
lkup = (jl_value_t*)tmp->tt;
2227-
break;
2228-
}
2229-
tmp = tmp->prev;
2230-
}
2231-
if (lkup != NULL && lkup != (jl_value_t*)tc) {
2232-
JL_GC_POP();
2233-
return lkup;
2234-
}
2235-
jl_value_t *result = inst_datatype((jl_datatype_t*)tt, NULL, iparams, ntp, cacheable, isabstract,
2236-
stack, env, n);
2242+
jl_value_t *result = inst_datatype(tt, NULL, iparams, ntp, cacheable,
2243+
isabstract, stack, env, n);
22372244
JL_GC_POP();
22382245
return result;
22392246
}

0 commit comments

Comments
 (0)