Skip to content

Commit

Permalink
Move some code - fix some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Feb 10, 2021
1 parent a4eae3c commit 310ac38
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion base/compiler/typelattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ end
widenconst(m::MaybeUndef) = widenconst(m.typ)
widenconst(c::PartialTypeVar) = TypeVar
widenconst(t::PartialStruct) = t.typ
widenconst(t::PartialOpaque) = t.t
widenconst(t::PartialOpaque) = t.typ
widenconst(t::Type) = t
widenconst(t::TypeVar) = t
widenconst(t::Core.TypeofVararg) = t
Expand Down
42 changes: 21 additions & 21 deletions base/compiler/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,6 @@ function invoke_api(li::CodeInstance)
return ccall(:jl_invoke_api, Cint, (Any,), li)
end

function get_staged(li::MethodInstance)
may_invoke_generator(li) || return nothing
try
# user code might throw errors – ignore them
return ccall(:jl_code_for_staged, Any, (Any,), li)::CodeInfo
catch
return nothing
end
end

function has_opaque_closure(c::CodeInfo)
for i = 1:length(c.code)
stmt = c.code[i]
Expand All @@ -122,21 +112,31 @@ function has_opaque_closure(c::CodeInfo)
return false
end

function get_staged(mi::MethodInstance)
may_invoke_generator(mi) || return nothing
if isdefined(mi, :uninferred)
return copy(mi.uninferred::CodeInfo)
end
try
# user code might throw errors – ignore them
ci = ccall(:jl_code_for_staged, Any, (Any,), mi)::CodeInfo
if has_opaque_closure(mi)
# For opaque closures, cache the generated code info to make sure
# that OpaqueClosure method identity is stable
mi.uninferred = copy(ci)
end
return ci
catch
return nothing
end
end

function retrieve_code_info(linfo::MethodInstance)
m = linfo.def::Method
c = nothing
if isdefined(m, :generator)
if isdefined(linfo, :uninferred)
c = copy(linfo.uninferred::CodeInfo)
else
# user code might throw errors – ignore them
c = get_staged(linfo)
# For opaque closures, cache the generated code info to make sure
# that Opaque Closure method identity remains stable.
if c !== nothing && has_opaque_closure(c)
linfo.uninferred = copy(c)
end
end
# user code might throw errors – ignore them
c = get_staged(linfo)
end
if c === nothing && isdefined(m, :source)
src = m.source
Expand Down
2 changes: 1 addition & 1 deletion src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static void jl_serialize_module(jl_serializer_state *s, jl_module_t *m)
write_uint8(s->s, m->infer);
}

static inline int jl_serialize_generic(jl_serializer_state *s, jl_value_t *v) JL_GC_DISABLED
static int jl_serialize_generic(jl_serializer_state *s, jl_value_t *v) JL_GC_DISABLED
{
if (v == NULL) {
write_uint8(s->s, TAG_NULL);
Expand Down

0 comments on commit 310ac38

Please sign in to comment.