-
Notifications
You must be signed in to change notification settings - Fork 0
Expose function to check if precompile
guaranteed to fail (similar to hasmethod
)
#228
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
base: v1.10.2+RAI
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2942,6 +2942,19 @@ JL_DLLEXPORT int jl_compile_hint(jl_tupletype_t *types) | |
return 1; | ||
} | ||
|
||
// true if jl_get_compile_hint_specialization can find a method instance for us to try | ||
// to compile | ||
JL_DLLEXPORT int jl_has_compile_hint_specialization(jl_tupletype_t *types) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just |
||
{ | ||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah interesting. i'm not sure whether that step is generally nullable or not. 🤔 The code you have here, now, roughly matches what i had in mind when you described this idea to me 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kpamnany is going to ask Gabriel about this |
||
if (mi == NULL) | ||
return 0; | ||
return 1; | ||
} | ||
|
||
// add type of `f` to front of argument tuple type | ||
jl_value_t *jl_argtype_with_function(jl_value_t *f, jl_value_t *types0) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1057,3 +1057,17 @@ end | |
@test !Base.ismutationfree(Vector{UInt64}) | ||
|
||
@test Base.ismutationfree(Type{Union{}}) | ||
|
||
module PrecompilableTest | ||
foo(v::AbstractVector) = first(v) +1 | ||
end | ||
@testset "precompilable" begin | ||
@test !Base.precompilable(PrecompilableTest.foo, (AbstractVector,)) | ||
@test !Base.precompilable(PrecompilableTest.foo, (AbstractVector{Int},)) | ||
@test !Base.precompilable(PrecompilableTest.foo, (Vector,)) | ||
@test Base.precompilable(PrecompilableTest.foo, (Vector{Int},)) | ||
@test hasmethod(PrecompilableTest.foo, (AbstractVector,)) | ||
@test hasmethod(PrecompilableTest.foo, (AbstractVector{Int},)) | ||
@test hasmethod(PrecompilableTest.foo, (Vector,)) | ||
@test hasmethod(PrecompilableTest.foo, (Vector{Int},)) | ||
end | ||
Comment on lines
+1061
to
+1073
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to add tests for all the false positive and false negative cases in the PR description? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could call this
has_method_instance_match
?