Skip to content

Commit

Permalink
Start adapting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Nov 19, 2023
1 parent 05aa560 commit 1990bfb
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 165 deletions.
2 changes: 1 addition & 1 deletion base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ function CodeInstance(interp::AbstractInterpreter, result::InferenceResult,
end
end
# relocatability = isa(inferred_result, String) ? inferred_result[end] : UInt8(0)
return CodeInstance(result.linfo, nothing,
return CodeInstance(result.linfo, cache_owner(interp),
widenconst(result_type), rettype_const, inferred_result,
const_flags, first(valid_worlds), last(valid_worlds),
# TODO: Actually do something with non-IPO effects
Expand Down
2 changes: 2 additions & 0 deletions base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ the following methods to satisfy the `AbstractInterpreter` API requirement:
- `OptimizationParams(interp::NewInterpreter)` - return an `OptimizationParams` instance
- `get_world_counter(interp::NewInterpreter)` - return the world age for this interpreter
- `get_inference_cache(interp::NewInterpreter)` - return the local inference cache
- `cache_owner(interp::NewInterpreter)` - return the owner of any new cache entries
- `code_cache(interp::NewInterpreter)` - return the global inference cache
"""
:(AbstractInterpreter)
Expand Down Expand Up @@ -403,6 +404,7 @@ InferenceParams(interp::NativeInterpreter) = interp.inf_params
OptimizationParams(interp::NativeInterpreter) = interp.opt_params
get_world_counter(interp::NativeInterpreter) = interp.world
get_inference_cache(interp::NativeInterpreter) = interp.inf_cache
cache_owner(interp::NativeInterpreter) = nothing
code_cache(interp::NativeInterpreter) = WorldView(GLOBAL_CI_CACHE, get_world_counter(interp))

"""
Expand Down
5 changes: 5 additions & 0 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,11 @@ static void jl_insert_into_serialization_queue(jl_serializer_state *s, jl_value_
if (s->incremental && jl_is_code_instance(v)) {
jl_code_instance_t *ci = (jl_code_instance_t*)v;
// make sure we don't serialize other reachable cache entries of foreign methods
// Should this now be:
// if (ci !in ci->defs->cache)
// record_field_change((jl_value_t**)&ci->next, NULL);
// Why are we checking that the method/module this orignates from is in_image?
// and then disconnect this CI?
if (jl_object_in_image((jl_value_t*)ci->def->def.value)) {
// TODO: if (ci in ci->defs->cache)
record_field_change((jl_value_t**)&ci->next, NULL);
Expand Down
2 changes: 2 additions & 0 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ function find_start_brace(s::AbstractString; c_start='(', c_end=')')
return (startind:lastindex(s), method_name_end)
end

const REPLCacheOwner = :REPL # For now symbol (or even type is fine)
struct REPLInterpreterCache
dict::IdDict{MethodInstance,CodeInstance}
end
Expand Down Expand Up @@ -517,6 +518,7 @@ CC.InferenceParams(interp::REPLInterpreter) = interp.inf_params
CC.OptimizationParams(interp::REPLInterpreter) = interp.opt_params
CC.get_world_counter(interp::REPLInterpreter) = interp.world
CC.get_inference_cache(interp::REPLInterpreter) = interp.inf_cache
CC.cache_owner(::REPLInterpreter) = REPLCacheOwner
CC.code_cache(interp::REPLInterpreter) = CC.WorldView(interp.code_cache, CC.WorldRange(interp.world))
CC.get(wvc::CC.WorldView{REPLInterpreterCache}, mi::MethodInstance, default) = get(wvc.cache.dict, mi, default)
CC.getindex(wvc::CC.WorldView{REPLInterpreterCache}, mi::MethodInstance) = getindex(wvc.cache.dict, mi)
Expand Down
Loading

0 comments on commit 1990bfb

Please sign in to comment.