Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-1.9: Backports for julia 1.9.0-alpha2 / 1.9.0-beta1 #47602

Merged
merged 57 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
05c8f3b
Limit initial OpenBLAS thread count (#46844)
staticfloat Nov 15, 2022
9606388
fix #46778, precompile() for abstract but compileable signatures (#47…
JeffBezanson Nov 16, 2022
0e17295
fix #47410, syntax error with anonfn inside `elseif` and short-circui…
JeffBezanson Nov 16, 2022
9dfd76b
ensure bindings handle write barriers for ty and globalref (#47580)
vtjnash Nov 16, 2022
d85e9ac
Turn on Intel jitevents by default on Linux (#47586)
vchuravy Nov 20, 2022
b5d6b03
Doc: The default sorting alg. is stable from 1.9 (#47579)
petvana Nov 21, 2022
3bc94a9
update MPFR (#47659)
simonbyrne Nov 21, 2022
f8f0c63
Add compat note for `sortperm(x; dims)` (#47657)
mcabbott Nov 22, 2022
382661c
build: add get-lld target (#47589)
petvana Nov 23, 2022
0f271d7
Print the detailed type on heap snapshot (#47503)
gbaraldi Nov 23, 2022
c615a49
Remove typeinfer lock altogether (#46825)
pchintalapudi Nov 23, 2022
3b414c6
Fix regression in generic_bitcast with Union{} arguments. (#47605)
maleadt Nov 24, 2022
aba112c
Filesystem: `rm(; recursive=true)` should ignore `UV_EACCES` (#47668)
staticfloat Nov 24, 2022
24505fc
Fix overflow in pow5 (#47511)
LilithHafner Nov 26, 2022
6fb45be
Fix GCExt test (#47699)
vchuravy Nov 27, 2022
0865ae0
Fix REPL keybinding CTRL-Q for stdlib methods (#47637)
rashidrafeek Nov 28, 2022
cfbb86a
fix 5-arg `mul!` for vectors of vectors (#47665)
ranocha Nov 28, 2022
93587d7
Add support for "package extensions" to code loading (#47695)
KristofferC Dec 7, 2022
dc1369e
🤖 Bump the Pkg stdlib from ed6a5497e to 5d8b9ddb8 (#47828)
DilumAluthgeBot Dec 7, 2022
9b9a703
Fix and simplify inference timing logic (#47711)
pchintalapudi Nov 26, 2022
1b85c1f
Fix nth_methtable tparam of -1 when n==0 (#47666)
apaz-cli Nov 28, 2022
81f8582
Fix generator-invocation legality check for varargs generators (#47739)
Keno Nov 29, 2022
9da50d2
Bump libuv. (#47707)
maleadt Nov 30, 2022
fcf02e8
Provider cycleclock() for 32bit ARM targets (#47358)
fingolfin Nov 30, 2022
628c953
strengthen setglobal to default to release-consume ordering (#47742)
vtjnash Nov 30, 2022
dfec160
fix unescaping in `global` expressions (#47719)
simeonschaub Dec 1, 2022
d8cbffd
Refactor and document sorting dispatch (#47383)
LilithHafner Dec 3, 2022
930314e
Comment out test in subtype that causes hang due to StackOverflow(#47…
vchuravy Dec 3, 2022
01ae8b7
Prioritize build_dir for generated headers (#47783)
vchuravy Dec 4, 2022
dba443d
Set `OPENBLAS_NUM_THREADS=1` on local Distributed workers (#47803)
staticfloat Dec 5, 2022
ce7a372
Add native julia fmod (#47501)
gbaraldi Dec 6, 2022
712a123
Fix libjulia install name and libjulia-internal rpath on OS X (#47220)
jonathan-conder-sm Dec 7, 2022
d561447
Replace the `.ji` serialization with sysimage format
timholy Feb 7, 2022
f8a5cd6
Allow re-initialization and caching of foreign types (#47407)
vchuravy Nov 27, 2022
12a4863
Fix physical_memory exports. (#47859)
maleadt Dec 10, 2022
2866e26
Fix missing GC root in Symbol construction (#47865)
Keno Dec 11, 2022
0b845b1
TOML: print: handle mixed vector of dicts and non-dicts (#47876)
fonsp Dec 12, 2022
3d80653
Fixups for #47383 (fixes `runbenchmarks("sort")`) (#47822)
LilithHafner Dec 13, 2022
a548ee3
fixes for jl_rewrap_unionall
vtjnash Nov 30, 2022
31df7c8
call specialized method instance when encountering unspecialized sparams
vtjnash Nov 19, 2022
9827f1d
ensure sparams are cached correctly for widened methods
vtjnash Nov 21, 2022
a506f43
ensure types are UnionAll wrapped are cached correctly for widened Va…
vtjnash Nov 22, 2022
3e1373e
add back wordaround for `Slot objects should not occur in an AST` in …
KristofferC Dec 14, 2022
5848e99
Reduce invalidations when loading JuliaData packages (#47889)
timholy Dec 15, 2022
86e8ef9
intersect: fix a minor soundness issue with supertypes (#47813)
vtjnash Dec 16, 2022
8432d4f
make Ctrl-C during sleeping work better (#47901)
JeffBezanson Dec 16, 2022
eba98e5
revert promotions of abstract arrays inside other arrays (#47893)
KristofferC Dec 19, 2022
a16ffd6
Revert "Emit safepoints at function entry (#41616)"
Dec 20, 2022
5a684f0
Revert "improve performance issue of `@nospecialize`-d keyword func c…
Dec 20, 2022
327e081
only load extensions once dependencies have finished loading (#47927)
KristofferC Dec 19, 2022
95cb3a8
Precompile cache: always add worklist CIs (#47924)
timholy Dec 20, 2022
f17d1df
put back the old QuickSort, PartialQuickSort, and MergeSort algorithm…
LilithHafner Dec 20, 2022
3ea7f6c
add bounds check to Slices indexing (#47622)
mcabbott Dec 20, 2022
22789c0
Reduce codegen lock scope (#46836)
pchintalapudi Dec 13, 2022
9a592dd
Implement support for object caching through pkgimages (#47184)
vchuravy Dec 27, 2022
7880930
Apply `InitialOptimizations` more consistently in sorting & fix dispa…
LilithHafner Dec 22, 2022
6adc428
Restore libgcc_s symlinkin in !macOS (#47986)
antonio-rojas Dec 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ensure sparams are cached correctly for widened methods
Follow-up issue found while working on #47476

(cherry picked from commit 71ab5fa)
  • Loading branch information
vtjnash authored and KristofferC committed Dec 14, 2022
commit 9827f1db2203c01b424215c295b97efd2dc4f908
2 changes: 1 addition & 1 deletion base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function maybe_compress_codeinfo(interp::AbstractInterpreter, linfo::MethodInsta
return ci
end
if may_discard_trees(interp)
cache_the_tree = ci.inferred && (is_inlineable(ci) || isa_compileable_sig(linfo.specTypes, def))
cache_the_tree = ci.inferred && (is_inlineable(ci) || isa_compileable_sig(linfo.specTypes, linfo.sparam_vals, def))
else
cache_the_tree = true
end
Expand Down
11 changes: 8 additions & 3 deletions base/compiler/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ function get_compileable_sig(method::Method, @nospecialize(atype), sparams::Simp
mt, atype, sparams, method)
end

isa_compileable_sig(@nospecialize(atype), method::Method) =
!iszero(ccall(:jl_isa_compileable_sig, Int32, (Any, Any), atype, method))
isa_compileable_sig(@nospecialize(atype), sparams::SimpleVector, method::Method) =
!iszero(ccall(:jl_isa_compileable_sig, Int32, (Any, Any, Any), atype, sparams, method))

# eliminate UnionAll vars that might be degenerate due to having identical bounds,
# or a concrete upper bound and appearing covariantly.
Expand Down Expand Up @@ -200,7 +200,12 @@ function specialize_method(method::Method, @nospecialize(atype), sparams::Simple
if compilesig
new_atype = get_compileable_sig(method, atype, sparams)
new_atype === nothing && return nothing
atype = new_atype
if atype !== new_atype
sp_ = ccall(:jl_type_intersection_with_env, Any, (Any, Any), new_atype, method.sig)::SimpleVector
if sparams === sp_[2]::SimpleVector
atype = new_atype
end
end
end
if preexisting
# check cached specializations
Expand Down
98 changes: 59 additions & 39 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,14 @@ static void jl_compilation_sig(
for (i = 0; i < np; i++) {
jl_value_t *elt = jl_tparam(tt, i);
jl_value_t *decl_i = jl_nth_slot_type(decl, i);
jl_value_t *type_i = jl_rewrap_unionall(decl_i, decl);
size_t i_arg = (i < nargs - 1 ? i : nargs - 1);

if (jl_is_kind(decl_i)) {
if (jl_is_kind(type_i)) {
// if we can prove the match was against the kind (not a Type)
// we want to put that in the cache instead
if (!*newparams) *newparams = jl_svec_copy(tt->parameters);
elt = decl_i;
elt = type_i;
jl_svecset(*newparams, i, elt);
}
else if (jl_is_type_type(elt)) {
Expand All @@ -652,7 +653,7 @@ static void jl_compilation_sig(
// and the result of matching the type signature
// needs to be restricted to the concrete type 'kind'
jl_value_t *kind = jl_typeof(jl_tparam0(elt));
if (jl_subtype(kind, decl_i) && !jl_subtype((jl_value_t*)jl_type_type, decl_i)) {
if (jl_subtype(kind, type_i) && !jl_subtype((jl_value_t*)jl_type_type, type_i)) {
// if we can prove the match was against the kind (not a Type)
// it's simpler (and thus better) to put that cache instead
if (!*newparams) *newparams = jl_svec_copy(tt->parameters);
Expand All @@ -664,7 +665,7 @@ static void jl_compilation_sig(
// not triggered for isdispatchtuple(tt), this attempts to handle
// some cases of adapting a random signature into a compilation signature
// if we get a kind, where we don't expect to accept one, widen it to something more expected (Type{T})
if (!(jl_subtype(elt, decl_i) && !jl_subtype((jl_value_t*)jl_type_type, decl_i))) {
if (!(jl_subtype(elt, type_i) && !jl_subtype((jl_value_t*)jl_type_type, type_i))) {
if (!*newparams) *newparams = jl_svec_copy(tt->parameters);
elt = (jl_value_t*)jl_type_type;
jl_svecset(*newparams, i, elt);
Expand Down Expand Up @@ -703,7 +704,7 @@ static void jl_compilation_sig(
jl_svecset(*newparams, i, jl_type_type);
}
else if (jl_is_type_type(elt)) { // elt isa Type{T}
if (very_general_type(decl_i)) {
if (!jl_has_free_typevars(decl_i) && very_general_type(type_i)) {
/*
Here's a fairly simple heuristic: if this argument slot's
declared type is general (Type or Any),
Expand Down Expand Up @@ -742,15 +743,13 @@ static void jl_compilation_sig(
*/
if (!*newparams) *newparams = jl_svec_copy(tt->parameters);
if (i < nargs || !definition->isva) {
jl_value_t *di = jl_type_intersection(decl_i, (jl_value_t*)jl_type_type);
jl_value_t *di = jl_type_intersection(type_i, (jl_value_t*)jl_type_type);
assert(di != (jl_value_t*)jl_bottom_type);
// issue #11355: DataType has a UID and so would take precedence in the cache
if (jl_is_kind(di))
jl_svecset(*newparams, i, (jl_value_t*)jl_type_type);
else
jl_svecset(*newparams, i, di);
// TODO: recompute static parameter values, so in extreme cases we
// can give `T=Type` instead of `T=Type{Type{Type{...`. /* make editors happy:}}} */
}
else {
jl_svecset(*newparams, i, (jl_value_t*)jl_type_type);
Expand All @@ -759,14 +758,15 @@ static void jl_compilation_sig(
}

int notcalled_func = (i_arg > 0 && i_arg <= 8 && !(definition->called & (1 << (i_arg - 1))) &&
!jl_has_free_typevars(decl_i) &&
jl_subtype(elt, (jl_value_t*)jl_function_type));
if (notcalled_func && (decl_i == (jl_value_t*)jl_any_type ||
decl_i == (jl_value_t*)jl_function_type ||
(jl_is_uniontype(decl_i) && // Base.Callable
((((jl_uniontype_t*)decl_i)->a == (jl_value_t*)jl_function_type &&
((jl_uniontype_t*)decl_i)->b == (jl_value_t*)jl_type_type) ||
(((jl_uniontype_t*)decl_i)->b == (jl_value_t*)jl_function_type &&
((jl_uniontype_t*)decl_i)->a == (jl_value_t*)jl_type_type))))) {
if (notcalled_func && (type_i == (jl_value_t*)jl_any_type ||
type_i == (jl_value_t*)jl_function_type ||
(jl_is_uniontype(type_i) && // Base.Callable
((((jl_uniontype_t*)type_i)->a == (jl_value_t*)jl_function_type &&
((jl_uniontype_t*)type_i)->b == (jl_value_t*)jl_type_type) ||
(((jl_uniontype_t*)type_i)->b == (jl_value_t*)jl_function_type &&
((jl_uniontype_t*)type_i)->a == (jl_value_t*)jl_type_type))))) {
// and attempt to despecialize types marked Function, Callable, or Any
// when called with a subtype of Function but is not called
if (!*newparams) *newparams = jl_svec_copy(tt->parameters);
Expand Down Expand Up @@ -833,6 +833,7 @@ static void jl_compilation_sig(
// compute whether this type signature is a possible return value from jl_compilation_sig given a concrete-type for `tt`
JL_DLLEXPORT int jl_isa_compileable_sig(
jl_tupletype_t *type,
jl_svec_t *sparams,
jl_method_t *definition)
{
jl_value_t *decl = definition->sig;
Expand Down Expand Up @@ -886,6 +887,7 @@ JL_DLLEXPORT int jl_isa_compileable_sig(
for (i = 0; i < np; i++) {
jl_value_t *elt = jl_tparam(type, i);
jl_value_t *decl_i = jl_nth_slot_type((jl_value_t*)decl, i);
jl_value_t *type_i = jl_rewrap_unionall(decl_i, decl);
size_t i_arg = (i < nargs - 1 ? i : nargs - 1);

if (jl_is_vararg(elt)) {
Expand Down Expand Up @@ -919,25 +921,26 @@ JL_DLLEXPORT int jl_isa_compileable_sig(

if (jl_is_kind(elt)) {
// kind slots always get guard entries (checking for subtypes of Type)
if (jl_subtype(elt, decl_i) && !jl_subtype((jl_value_t*)jl_type_type, decl_i))
if (jl_subtype(elt, type_i) && !jl_subtype((jl_value_t*)jl_type_type, type_i))
continue;
// TODO: other code paths that could reach here
return 0;
}
else if (jl_is_kind(decl_i)) {
else if (jl_is_kind(type_i)) {
return 0;
}

if (jl_is_type_type(jl_unwrap_unionall(elt))) {
int iscalled = i_arg > 0 && i_arg <= 8 && (definition->called & (1 << (i_arg - 1)));
int iscalled = (i_arg > 0 && i_arg <= 8 && (definition->called & (1 << (i_arg - 1)))) ||
jl_has_free_typevars(decl_i);
if (jl_types_equal(elt, (jl_value_t*)jl_type_type)) {
if (!iscalled && very_general_type(decl_i))
if (!iscalled && very_general_type(type_i))
continue;
if (i >= nargs && definition->isva)
continue;
return 0;
}
if (!iscalled && very_general_type(decl_i))
if (!iscalled && very_general_type(type_i))
return 0;
if (!jl_is_datatype(elt))
return 0;
Expand All @@ -949,7 +952,7 @@ JL_DLLEXPORT int jl_isa_compileable_sig(
jl_value_t *kind = jl_typeof(jl_tparam0(elt));
if (kind == jl_bottom_type)
return 0; // Type{Union{}} gets normalized to typeof(Union{})
if (jl_subtype(kind, decl_i) && !jl_subtype((jl_value_t*)jl_type_type, decl_i))
if (jl_subtype(kind, type_i) && !jl_subtype((jl_value_t*)jl_type_type, type_i))
return 0; // gets turned into a kind

else if (jl_is_type_type(jl_tparam0(elt)) &&
Expand All @@ -963,7 +966,7 @@ JL_DLLEXPORT int jl_isa_compileable_sig(
this can be determined using a type intersection.
*/
if (i < nargs || !definition->isva) {
jl_value_t *di = jl_type_intersection(decl_i, (jl_value_t*)jl_type_type);
jl_value_t *di = jl_type_intersection(type_i, (jl_value_t*)jl_type_type);
JL_GC_PUSH1(&di);
assert(di != (jl_value_t*)jl_bottom_type);
if (jl_is_kind(di)) {
Expand All @@ -984,14 +987,15 @@ JL_DLLEXPORT int jl_isa_compileable_sig(
}

int notcalled_func = (i_arg > 0 && i_arg <= 8 && !(definition->called & (1 << (i_arg - 1))) &&
!jl_has_free_typevars(decl_i) &&
jl_subtype(elt, (jl_value_t*)jl_function_type));
if (notcalled_func && (decl_i == (jl_value_t*)jl_any_type ||
decl_i == (jl_value_t*)jl_function_type ||
(jl_is_uniontype(decl_i) && // Base.Callable
((((jl_uniontype_t*)decl_i)->a == (jl_value_t*)jl_function_type &&
((jl_uniontype_t*)decl_i)->b == (jl_value_t*)jl_type_type) ||
(((jl_uniontype_t*)decl_i)->b == (jl_value_t*)jl_function_type &&
((jl_uniontype_t*)decl_i)->a == (jl_value_t*)jl_type_type))))) {
if (notcalled_func && (type_i == (jl_value_t*)jl_any_type ||
type_i == (jl_value_t*)jl_function_type ||
(jl_is_uniontype(type_i) && // Base.Callable
((((jl_uniontype_t*)type_i)->a == (jl_value_t*)jl_function_type &&
((jl_uniontype_t*)type_i)->b == (jl_value_t*)jl_type_type) ||
(((jl_uniontype_t*)type_i)->b == (jl_value_t*)jl_function_type &&
((jl_uniontype_t*)type_i)->a == (jl_value_t*)jl_type_type))))) {
// and attempt to despecialize types marked Function, Callable, or Any
// when called with a subtype of Function but is not called
if (elt == (jl_value_t*)jl_function_type)
Expand Down Expand Up @@ -1087,7 +1091,7 @@ static jl_method_instance_t *cache_method(
// cache miss. Alternatively, we may use the original signature in the
// cache, but use this return for compilation.
//
// In most cases `!jl_isa_compileable_sig(tt, definition)`,
// In most cases `!jl_isa_compileable_sig(tt, sparams, definition)`,
// although for some cases, (notably Varargs)
// we might choose a replacement type that's preferable but not strictly better
int issubty;
Expand All @@ -1099,7 +1103,7 @@ static jl_method_instance_t *cache_method(
}
newparams = NULL;
}
// TODO: maybe assert(jl_isa_compileable_sig(compilationsig, definition));
// TODO: maybe assert(jl_isa_compileable_sig(compilationsig, sparams, definition));
newmeth = jl_specializations_get_linfo(definition, (jl_value_t*)compilationsig, sparams);

jl_tupletype_t *cachett = tt;
Expand Down Expand Up @@ -2280,9 +2284,21 @@ JL_DLLEXPORT jl_value_t *jl_normalize_to_compilable_sig(jl_methtable_t *mt, jl_t
jl_methtable_t *kwmt = mt == jl_kwcall_mt ? jl_kwmethod_table_for(m->sig) : mt;
intptr_t nspec = (kwmt == NULL || kwmt == jl_type_type_mt || kwmt == jl_nonfunction_mt || kwmt == jl_kwcall_mt ? m->nargs + 1 : kwmt->max_args + 2 + 2 * (mt == jl_kwcall_mt));
jl_compilation_sig(ti, env, m, nspec, &newparams);
tt = (newparams ? jl_apply_tuple_type(newparams) : ti);
int is_compileable = ((jl_datatype_t*)ti)->isdispatchtuple ||
jl_isa_compileable_sig(tt, m);
int is_compileable = ((jl_datatype_t*)ti)->isdispatchtuple;
if (newparams) {
tt = jl_apply_tuple_type(newparams);
if (!is_compileable) {
// compute new env, if used below
jl_value_t *ti = jl_type_intersection_env((jl_value_t*)tt, (jl_value_t*)m->sig, &newparams);
assert(ti != jl_bottom_type); (void)ti;
env = newparams;
}
}
else {
tt = ti;
}
if (!is_compileable)
is_compileable = jl_isa_compileable_sig(tt, env, m);
JL_GC_POP();
return is_compileable ? (jl_value_t*)tt : jl_nothing;
}
Expand All @@ -2300,7 +2316,7 @@ jl_method_instance_t *jl_normalize_to_compilable_mi(jl_method_instance_t *mi JL_
return mi;
jl_svec_t *env = NULL;
JL_GC_PUSH2(&compilationsig, &env);
jl_value_t *ti = jl_type_intersection_env((jl_value_t*)mi->specTypes, (jl_value_t*)def->sig, &env);
jl_value_t *ti = jl_type_intersection_env((jl_value_t*)compilationsig, (jl_value_t*)def->sig, &env);
assert(ti != jl_bottom_type); (void)ti;
mi = jl_specializations_get_linfo(def, (jl_value_t*)compilationsig, env);
JL_GC_POP();
Expand All @@ -2317,7 +2333,7 @@ jl_method_instance_t *jl_method_match_to_mi(jl_method_match_t *match, size_t wor
if (jl_is_datatype(ti)) {
jl_methtable_t *mt = jl_method_get_table(m);
if ((jl_value_t*)mt != jl_nothing) {
// get the specialization without caching it
// get the specialization, possibly also caching it
if (mt_cache && ((jl_datatype_t*)ti)->isdispatchtuple) {
// Since we also use this presence in the cache
// to trigger compilation when producing `.ji` files,
Expand All @@ -2329,11 +2345,15 @@ jl_method_instance_t *jl_method_match_to_mi(jl_method_match_t *match, size_t wor
}
else {
jl_value_t *tt = jl_normalize_to_compilable_sig(mt, ti, env, m);
JL_GC_PUSH1(&tt);
if (tt != jl_nothing) {
JL_GC_PUSH2(&tt, &env);
if (!jl_egal(tt, (jl_value_t*)ti)) {
jl_value_t *ti = jl_type_intersection_env((jl_value_t*)tt, (jl_value_t*)m->sig, &env);
assert(ti != jl_bottom_type); (void)ti;
}
mi = jl_specializations_get_linfo(m, (jl_value_t*)tt, env);
JL_GC_POP();
}
JL_GC_POP();
}
}
}
Expand Down Expand Up @@ -2396,7 +2416,7 @@ jl_method_instance_t *jl_get_compile_hint_specialization(jl_tupletype_t *types J
size_t count = 0;
for (i = 0; i < n; i++) {
jl_method_match_t *match1 = (jl_method_match_t*)jl_array_ptr_ref(matches, i);
if (jl_isa_compileable_sig(types, match1->method))
if (jl_isa_compileable_sig(types, match1->sparams, match1->method))
jl_array_ptr_set(matches, count++, (jl_value_t*)match1);
}
jl_array_del_end((jl_array_t*)matches, n - count);
Expand Down
2 changes: 1 addition & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ STATIC_INLINE int jl_is_concrete_type(jl_value_t *v) JL_NOTSAFEPOINT
return jl_is_datatype(v) && ((jl_datatype_t*)v)->isconcretetype;
}

JL_DLLEXPORT int jl_isa_compileable_sig(jl_tupletype_t *type, jl_method_t *definition);
JL_DLLEXPORT int jl_isa_compileable_sig(jl_tupletype_t *type, jl_svec_t *sparams, jl_method_t *definition);

// type constructors
JL_DLLEXPORT jl_typename_t *jl_new_typename_in(jl_sym_t *name, jl_module_t *inmodule, int abstract, int mutabl);
Expand Down
4 changes: 2 additions & 2 deletions src/precompile.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static void jl_compile_all_defs(jl_array_t *mis)
size_t i, l = jl_array_len(allmeths);
for (i = 0; i < l; i++) {
jl_method_t *m = (jl_method_t*)jl_array_ptr_ref(allmeths, i);
if (jl_isa_compileable_sig((jl_tupletype_t*)m->sig, m)) {
if (jl_is_datatype(m->sig) && jl_isa_compileable_sig((jl_tupletype_t*)m->sig, jl_emptysvec, m)) {
// method has a single compilable specialization, e.g. its definition
// signature is concrete. in this case we can just hint it.
jl_compile_hint((jl_tupletype_t*)m->sig);
Expand Down Expand Up @@ -354,7 +354,7 @@ static void *jl_precompile_(jl_array_t *m)
mi = (jl_method_instance_t*)item;
size_t min_world = 0;
size_t max_world = ~(size_t)0;
if (mi != jl_atomic_load_relaxed(&mi->def.method->unspecialized) && !jl_isa_compileable_sig((jl_tupletype_t*)mi->specTypes, mi->def.method))
if (mi != jl_atomic_load_relaxed(&mi->def.method->unspecialized) && !jl_isa_compileable_sig((jl_tupletype_t*)mi->specTypes, mi->sparam_vals, mi->def.method))
mi = jl_get_specialization1((jl_tupletype_t*)mi->specTypes, jl_atomic_load_acquire(&jl_world_counter), &min_world, &max_world, 0);
if (mi)
jl_array_ptr_1d_push(m2, (jl_value_t*)mi);
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Random/src/Random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ rand(rng::AbstractRNG, ::UniformT{T}) where {T} = rand(rng, T)
rand(rng::AbstractRNG, X) = rand(rng, Sampler(rng, X, Val(1)))
# this is needed to disambiguate
rand(rng::AbstractRNG, X::Dims) = rand(rng, Sampler(rng, X, Val(1)))
rand(rng::AbstractRNG=default_rng(), ::Type{X}=Float64) where {X} = rand(rng, Sampler(rng, X, Val(1)))::X
rand(rng::AbstractRNG=default_rng(), ::Type{X}=Float64) where {X} = rand(rng, Sampler(rng, X, Val(1)))::X

rand(X) = rand(default_rng(), X)
rand(::Type{X}) where {X} = rand(default_rng(), X)
Expand Down
2 changes: 1 addition & 1 deletion test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ f11366(x::Type{Ref{T}}) where {T} = Ref{x}


let f(T) = Type{T}
@test Base.return_types(f, Tuple{Type{Int}}) == [Type{Type{Int}}]
@test Base.return_types(f, Tuple{Type{Int}}) == Any[Type{Type{Int}}]
end

# issue #9222
Expand Down
4 changes: 4 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7885,3 +7885,7 @@ code_typed(f47476, (Int, Int, Int, Vararg{Union{Int, NTuple{2,Int}}},))
code_typed(f47476, (Int, Int, Int, Int, Vararg{Union{Int, NTuple{2,Int}}},))
@test f47476(1, 2, 3, 4, 5, 6, (7, 8)) === 2
@test_throws UndefVarError(:N) f47476(1, 2, 3, 4, 5, 6, 7)

vect47476(::Type{T}) where {T} = T
@test vect47476(Type{Type{Type{Int32}}}) === Type{Type{Type{Int32}}}
@test vect47476(Type{Type{Type{Int64}}}) === Type{Type{Type{Int64}}}
4 changes: 2 additions & 2 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1493,8 +1493,8 @@ end
f(x, y) = x + y
f(x::Int, y) = 2x + y
end
precompile(M.f, (Int, Any))
precompile(M.f, (AbstractFloat, Any))
@test precompile(M.f, (Int, Any))
@test precompile(M.f, (AbstractFloat, Any))
mis = map(methods(M.f)) do m
m.specializations[1]
end
Expand Down