Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4187,6 +4187,20 @@ function expand_compiler_path(tup)
end
compiler_chi(tup::Tuple) = CacheHeaderIncludes(expand_compiler_path(tup))

"""
isprecompilable(f, argtypes::Tuple{Vararg{Any}})

Check, as far as is possible without actually compiling, if the given
function `f` can be compiled for the argument tuple (of types) `argtypes`.
"""
function isprecompilable(@nospecialize(f), @nospecialize(argtypes::Tuple))
isprecompilable(Tuple{Core.Typeof(f), argtypes...})
end

function isprecompilable(@nospecialize(argt::Type))
ccall(:jl_is_compilable, Int32, (Any,), argt) != 0
end

"""
precompile(f, argtypes::Tuple{Vararg{Any}})

Expand Down
9 changes: 9 additions & 0 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3579,6 +3579,15 @@ JL_DLLEXPORT void jl_compile_method_sig(jl_method_t *m, jl_value_t *types, jl_sv
jl_compile_method_instance(mi, NULL, world);
}

JL_DLLEXPORT int jl_is_compilable(jl_tupletype_t *types)
{
size_t world = jl_atomic_load_acquire(&jl_world_counter);
size_t min_valid = 0;
size_t max_valid = ~(size_t)0;
jl_method_instance_t *mi = jl_get_compile_hint_specialization(types, world, &min_valid, &max_valid, 1);
return mi == NULL ? 0 : 1;
}

JL_DLLEXPORT int jl_compile_hint(jl_tupletype_t *types)
{
size_t world = jl_atomic_load_acquire(&jl_world_counter);
Expand Down
1 change: 1 addition & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
XX(jl_istopmod) \
XX(jl_is_binding_deprecated) \
XX(jl_is_char_signed) \
XX(jl_is_compilable) \
XX(jl_is_const) \
XX(jl_is_assertsbuild) \
XX(jl_is_debugbuild) \
Expand Down