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

update to https://github.com/JuliaLang/julia/pull/41328 #245

Merged
merged 1 commit into from
Sep 1, 2021
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
2 changes: 1 addition & 1 deletion docs/src/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ JET.analyze_task_parallel_code!
```@docs
JET.JET_CACHE
JET.JETCachedResult
JET.jet_inlining_policy
JET.inlining_policy
```


Expand Down
27 changes: 24 additions & 3 deletions src/analyzer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,35 @@ CC.may_compress(analyzer::AbstractAnalyzer) = false
CC.may_discard_trees(analyzer::AbstractAnalyzer) = false
CC.verbose_stmt_info(analyzer::AbstractAnalyzer) = false

# branch on https://github.com/JuliaLang/julia/pull/41328
@static if isdefined(CC, :is_stmt_inline)
@doc """
inlining_policy(analyzer::AbstractAnalyzer, @nospecialize(src), stmt_flag::UInt8) -> source::Any

Implements inlining policy for `AbstractAnalyzer`.
Since `AbstractAnalyzer` works on `InferenceResult` whose `src` field keeps
[`JETResult`](@ref) or [`JETCachedResult`](@ref), this implementation just bypasses
their wrapped source to `inlining_policy(::AbstractInterpreter, ::Any, ::UInt8)`.
"""
jet_inlining_policy(src)
function CC.inlining_policy(analyzer::AbstractAnalyzer, @nospecialize(src), stmt_flag::UInt8)
if isa(src, JETResult)
src = get_source(src)
elseif isa(src, JETCachedResult)
src = get_source(src)
end
return @invoke CC.inlining_policy(analyzer::AbstractInterpreter, @nospecialize(src), stmt_flag::UInt8)
end
else # @static if isdefined(Compiler, :is_stmt_inline)
@doc """
inlining_policy(::AbstractAnalyzer) = jet_inlining_policy
jet_inlining_policy(@nospecialize(src)) -> source::Any

Implements `Core.Compiler.inlining_policy` for `AbstractAnalyzer`.
`jet_inlining_policy` implements `Core.Compiler.inlining_policy` for `AbstractAnalyzer`.
Since `AbstractAnalyzer` works on `InferenceResult` whose `src` field keeps
[`JETResult`](@ref) or [`JETCachedResult`](@ref), `jet_inlining_policy` bypasses
their wrapped source to `Core.Compiler.default_inlining_policy`.
"""
CC.inlining_policy(::AbstractAnalyzer) = jet_inlining_policy
@inline function jet_inlining_policy(@nospecialize(src))
if isa(src, JETResult)
src = get_source(src)
Expand All @@ -495,7 +516,7 @@ their wrapped source to `Core.Compiler.default_inlining_policy`.
end
return default_inlining_policy(src)
end
CC.inlining_policy(::AbstractAnalyzer) = jet_inlining_policy
end # @static if isdefined(Compiler, :is_stmt_inline)

# AbstractAnalyzer
# ----------------
Expand Down