Skip to content

Commit

Permalink
delete unused code for SOURCE_MODE_FORCE_SOURCE_UNCACHED
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Jun 5, 2024
1 parent 12fb821 commit a4cc6c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
17 changes: 3 additions & 14 deletions base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1065,15 +1065,6 @@ N.B.: The same caching considerations as SOURCE_MODE_ABI apply.
"""
const SOURCE_MODE_FORCE_SOURCE = 0x2

"""
SOURCE_MODE_FORCE_SOURCE_UNCACHED
Like `SOURCE_MODE_FORCE_SOURCE`, but ensures that the resulting code instance is
not part of the cache hierarchy, so the `->inferred` field may be safely used
without the possibility of deletion by the compiler.
"""
const SOURCE_MODE_FORCE_SOURCE_UNCACHED = 0x3

function ci_has_source(code::CodeInstance)
inf = @atomic :monotonic code.inferred
return isa(inf, CodeInfo) || isa(inf, String)
Expand All @@ -1095,7 +1086,6 @@ function ci_meets_requirement(code::CodeInstance, source_mode::UInt8, ci_is_cach
source_mode == SOURCE_MODE_NOT_REQUIRED && return true
source_mode == SOURCE_MODE_ABI && return ci_has_abi(code)
source_mode == SOURCE_MODE_FORCE_SOURCE && return ci_has_source(code)
source_mode == SOURCE_MODE_FORCE_SOURCE_UNCACHED && return (!ci_is_cached && ci_has_source(code))
return false
end

Expand All @@ -1108,7 +1098,7 @@ function typeinf_ext(interp::AbstractInterpreter, mi::MethodInstance, source_mod
code = get(code_cache(interp), mi, nothing)
if code isa CodeInstance
# see if this code already exists in the cache
if source_mode in (SOURCE_MODE_FORCE_SOURCE, SOURCE_MODE_FORCE_SOURCE_UNCACHED) && use_const_api(code)
if source_mode == SOURCE_MODE_FORCE_SOURCE && use_const_api(code)
code = codeinstance_for_const_with_code(interp, code)
ccall(:jl_typeinf_timing_end, Cvoid, (UInt64,), start_time)
return code
Expand All @@ -1130,7 +1120,7 @@ function typeinf_ext(interp::AbstractInterpreter, mi::MethodInstance, source_mod
end
lock_mi_inference(interp, mi)
result = InferenceResult(mi, typeinf_lattice(interp))
frame = InferenceState(result, #=cache_mode=#source_mode == SOURCE_MODE_FORCE_SOURCE_UNCACHED ? :volatile : :global, interp)
frame = InferenceState(result, #=cache_mode=#:global, interp)
frame === nothing && return nothing
typeinf(interp, frame)
ccall(:jl_typeinf_timing_end, Cvoid, (UInt64,), start_time)
Expand All @@ -1149,14 +1139,13 @@ function typeinf_ext(interp::AbstractInterpreter, mi::MethodInstance, source_mod
# store the source in the cache, but the caller wanted it anyway (e.g. for reflection).
# We construct a new CodeInstance for it that is not part of the cache hierarchy.
can_discard_trees = source_mode SOURCE_MODE_FORCE_SOURCE &&
source_mode SOURCE_MODE_FORCE_SOURCE_UNCACHED &&
is_result_constabi_eligible(result)
code = CodeInstance(interp, result; can_discard_trees)

# If the caller cares about the code and this is constabi, still use our synthesis function
# anyway, because we will have not finished inferring the code inside the CodeInstance once
# we realized it was constabi, but we want reflection to pretend that we did.
if use_const_api(code) && source_mode in (SOURCE_MODE_FORCE_SOURCE, SOURCE_MODE_FORCE_SOURCE_UNCACHED)
if use_const_api(code) && source_mode == SOURCE_MODE_FORCE_SOURCE
return codeinstance_for_const_with_code(interp, code)
end
@assert ci_meets_requirement(code, source_mode, false)
Expand Down
1 change: 0 additions & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ typedef union {
#define SOURCE_MODE_NOT_REQUIRED 0x0
#define SOURCE_MODE_ABI 0x1
#define SOURCE_MODE_FORCE_SOURCE 0x2
#define SOURCE_MODE_FORCE_SOURCE_UNCACHED 0x3

JL_DLLEXPORT jl_code_instance_t *jl_type_infer(jl_method_instance_t *li, size_t world, int force, uint8_t source_mode);
JL_DLLEXPORT jl_code_info_t *jl_gdbcodetyped1(jl_method_instance_t *mi, size_t world);
Expand Down

0 comments on commit a4cc6c8

Please sign in to comment.