diff --git a/base/boot.jl b/base/boot.jl index 88d7ed85972fe..1775bc8312037 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -59,15 +59,19 @@ # name::Symbol #end -#type LambdaInfo -# ast::Expr -# sparams::Tuple -# tfunc -# name::Symbol -# inferred -# file::Symbol -# line::Int -# module::Module +#type Method +#end + +#type MethodInstance +#end + +#type CodeInfo +#end + +#type TypeMapLevel +#end + +#type TypeMapEntry #end #abstract Ref{T} @@ -119,7 +123,7 @@ export Tuple, Type, TypeConstructor, TypeName, TypeVar, Union, Void, SimpleVector, AbstractArray, DenseArray, # special objects - Function, LambdaInfo, Method, MethodTable, TypeMapEntry, TypeMapLevel, + Function, CodeInfo, Method, MethodTable, TypeMapEntry, TypeMapLevel, Module, Symbol, Task, Array, WeakRef, VecElement, # numeric types Number, Real, Integer, Bool, Ref, Ptr, diff --git a/base/deepcopy.jl b/base/deepcopy.jl index 77c7a9118c3d5..b95eb1d094390 100644 --- a/base/deepcopy.jl +++ b/base/deepcopy.jl @@ -7,7 +7,7 @@ deepcopy(x) = deepcopy_internal(x, ObjectIdDict())::typeof(x) -deepcopy_internal(x::Union{Symbol,LambdaInfo,GlobalRef,DataType,Union,Task}, +deepcopy_internal(x::Union{Symbol,Core.MethodInstance,Method,GlobalRef,DataType,Union,Task}, stackdict::ObjectIdDict) = x deepcopy_internal(x::Tuple, stackdict::ObjectIdDict) = ntuple(i->deepcopy_internal(x[i], stackdict), length(x)) diff --git a/base/deprecated.jl b/base/deprecated.jl index 19a4707c5d47e..a9aeb4a304773 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -273,8 +273,6 @@ const call = @eval function(f, args...; kw...) end export call -@deprecate_binding LambdaStaticData LambdaInfo - # Changed issym to issymmetric. #15192 @deprecate issym issymmetric diff --git a/base/essentials.jl b/base/essentials.jl index 1843243014040..dbcf56f27ba75 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license -using Core: SourceInfo +using Core: CodeInfo typealias Callable Union{Function,DataType} diff --git a/base/inference.jl b/base/inference.jl index 486bf4a7ea222..9c85c9e2e2581 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license -import Core: _apply, svec, apply_type, Builtin, IntrinsicFunction, SourceInfo +import Core: _apply, svec, apply_type, Builtin, IntrinsicFunction, MethodInstance #### parameters limiting potentially-infinite types #### const MAX_TYPEUNION_LEN = 3 @@ -48,8 +48,8 @@ type InferenceState currpc::LineNum # info on the state of inference and the linfo - linfo::LambdaInfo # used here for the tuple (specTypes, env, Method) - src::SourceInfo + linfo::MethodInstance # used here for the tuple (specTypes, env, Method) + src::CodeInfo nargs::Int stmt_types::Vector{Any} # return type @@ -78,8 +78,8 @@ type InferenceState cached::Bool inferred::Bool - # src is assumed to be a newly-allocated SourceInfo, that can be modified in-place to contain intermediate results - function InferenceState(linfo::LambdaInfo, src::SourceInfo, optimize::Bool, inlining::Bool, cached::Bool) + # src is assumed to be a newly-allocated CodeInfo, that can be modified in-place to contain intermediate results + function InferenceState(linfo::MethodInstance, src::CodeInfo, optimize::Bool, inlining::Bool, cached::Bool) code = src.code::Array{Any,1} nl = label_counter(code) + 1 toplevel = !isdefined(linfo, :def) @@ -168,10 +168,10 @@ type InferenceState end end -# create copies of the SourceInfo definition, and any fields that type-inference might modify +# create copies of the CodeInfo definition, and any fields that type-inference might modify # TODO: post-inference see if we can swap back to the original arrays -function get_source(li::LambdaInfo) - src = ccall(:jl_copy_source_info, Ref{SourceInfo}, (Any,), li.def.source) +function get_source(li::MethodInstance) + src = ccall(:jl_copy_code_info, Ref{CodeInfo}, (Any,), li.def.source) if isa(src.code, Array{UInt8,1}) src.code = ccall(:jl_uncompress_ast, Any, (Any, Any), li.def, src.code) else @@ -182,8 +182,8 @@ function get_source(li::LambdaInfo) return src end -function get_staged(li::LambdaInfo) - src = ccall(:jl_code_for_staged, Any, (Any,), li)::SourceInfo +function get_staged(li::MethodInstance) + src = ccall(:jl_code_for_staged, Any, (Any,), li)::CodeInfo if isa(src.code, Array{UInt8,1}) src.code = ccall(:jl_uncompress_ast, Any, (Any, Any), li.def, src.code) end @@ -1236,7 +1236,7 @@ function abstract_eval_global(M::Module, s::Symbol) return Any end -function abstract_eval_ssavalue(s::SSAValue, src::SourceInfo) +function abstract_eval_ssavalue(s::SSAValue, src::CodeInfo) typ = src.ssavaluetypes[s.id + 1] if typ === NF return Bottom @@ -1463,19 +1463,19 @@ function newvar!(sv::InferenceState, typ::ANY) return SSAValue(id) end -# create a specialized LambdaInfo from a method +# create a specialized MethodInstance from a method function get_linfo(method::Method, types::ANY, sp::SimpleVector) - return ccall(:jl_specializations_get_linfo, Ref{LambdaInfo}, (Any, Any, Any), method, types, sp) + return ccall(:jl_specializations_get_linfo, Ref{MethodInstance}, (Any, Any, Any), method, types, sp) end inlining_enabled() = (JLOptions().can_inline == 1) coverage_enabled() = (JLOptions().code_coverage != 0) -#### entry points for inferring a LambdaInfo given a type signature #### +#### entry points for inferring a MethodInstance given a type signature #### function typeinf_edge(method::Method, atypes::ANY, sparams::SimpleVector, needtree::Bool, optimize::Bool, cached::Bool, caller) local code = nothing local frame = nothing - if isa(caller, LambdaInfo) + if isa(caller, MethodInstance) code = caller elseif cached && !is(method.specializations, nothing) # check cached specializations @@ -1483,7 +1483,7 @@ function typeinf_edge(method::Method, atypes::ANY, sparams::SimpleVector, needtr code = ccall(:jl_specializations_lookup, Any, (Any, Any), method, atypes) if isa(code, Void) # something completely new - elseif isa(code, LambdaInfo) + elseif isa(code, MethodInstance) # something existing else # sometimes just a return type is stored here. if a full AST @@ -1497,10 +1497,10 @@ function typeinf_edge(method::Method, atypes::ANY, sparams::SimpleVector, needtr end end - if isa(code, LambdaInfo) && isdefined(code, :inferred) + if isa(code, MethodInstance) && isdefined(code, :inferred) if code.jlcall_api == 2 if needtree - tree = ccall(:jl_new_source_info_uninit, Ref{SourceInfo}, ()) + tree = ccall(:jl_new_code_info_uninit, Ref{CodeInfo}, ()) tree.code = Any[ Expr(:return, QuoteNode(code.inferred)) ] tree.slotnames = Any[ compiler_temp_sym for i = 1:method.nargs ] tree.slotflags = UInt8[ 0 for i = 1:method.nargs ] @@ -1513,7 +1513,7 @@ function typeinf_edge(method::Method, atypes::ANY, sparams::SimpleVector, needtr tree = Const(code.inferred) end return (tree, code.rettype, true) - elseif isa(code.inferred, SourceInfo) + elseif isa(code.inferred, CodeInfo) if code.inferred.inferred return (code.inferred, code.rettype, true) end @@ -1557,7 +1557,7 @@ function typeinf_edge(method::Method, atypes::ANY, sparams::SimpleVector, needtr end end - if isa(code, LambdaInfo) + if isa(code, MethodInstance) # reuse the existing code object linfo = code @assert typeseq(linfo.specTypes, atypes) @@ -1602,7 +1602,7 @@ function typeinf_edge(method::Method, atypes::ANY, sparams::SimpleVector, needtr src = get_source(linfo) end linfo.inInference = true - frame = InferenceState(linfo::LambdaInfo, src, optimize, inlining_enabled(), cached) + frame = InferenceState(linfo::MethodInstance, src, optimize, inlining_enabled(), cached) end frame = frame::InferenceState @@ -1640,10 +1640,10 @@ end function typeinf_uncached(method::Method, atypes::ANY, sparams::SimpleVector, optimize::Bool) return typeinf_edge(method, atypes, sparams, true, optimize, false, nothing) end -function typeinf_ext(linfo::LambdaInfo) +function typeinf_ext(linfo::MethodInstance) if isdefined(linfo, :def) # method lambda - infer this specialization via the method cache - if isdefined(linfo, :inferred) && isa(linfo.inferred, SourceInfo) + if isdefined(linfo, :inferred) && isa(linfo.inferred, CodeInfo) return linfo.inferred end (code, typ, inferred) = typeinf_edge(linfo.def, linfo.specTypes, linfo.sparam_vals, true, true, true, linfo) @@ -1891,7 +1891,7 @@ end #### finalize and record the result of running type inference #### -function isinlineable(m::Method, src::SourceInfo) +function isinlineable(m::Method, src::CodeInfo) inlineable = false cost = 1000 if m.module === _topmod(m.module) @@ -1914,7 +1914,7 @@ function isinlineable(m::Method, src::SourceInfo) end # inference completed on `me` -# update the LambdaInfo and notify the edges +# update the MethodInstance and notify the edges function finish(me::InferenceState) for (i,_) in me.edges @assert (i::InferenceState).fixedpoint @@ -2152,7 +2152,7 @@ function _widen_all_consts(x::Expr) end return x end -function widen_all_consts!(src::SourceInfo) +function widen_all_consts!(src::CodeInfo) for i = 1:length(src.ssavaluetypes) src.ssavaluetypes[i] = widenconst(src.ssavaluetypes[i]) end @@ -2217,7 +2217,7 @@ function occurs_more(e::ANY, pred, n) return 0 end -function exprtype(x::ANY, src::SourceInfo, mod::Module) +function exprtype(x::ANY, src::CodeInfo, mod::Module) if isa(x, Expr) return (x::Expr).typ elseif isa(x, SlotNumber) @@ -2261,7 +2261,7 @@ function is_pure_builtin(f::ANY) return false end -function statement_effect_free(e::ANY, src::SourceInfo, mod::Module) +function statement_effect_free(e::ANY, src::CodeInfo, mod::Module) if isa(e, Expr) if e.head === :(=) return !isa(e.args[1], GlobalRef) && effect_free(e.args[2], src, mod, false) @@ -2277,7 +2277,7 @@ end # detect some important side-effect-free calls (allow_volatile=true) # and some affect-free calls (allow_volatile=false) -- affect_free means the call # cannot be affected by previous calls, except assignment nodes -function effect_free(e::ANY, src::SourceInfo, mod::Module, allow_volatile::Bool) +function effect_free(e::ANY, src::CodeInfo, mod::Module, allow_volatile::Bool) if isa(e, GlobalRef) return (isdefined(e.mod, e.name) && (allow_volatile || isconst(e.mod, e.name))) elseif isa(e, Symbol) @@ -2426,7 +2426,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference local spec_hit = nothing local spec_miss = nothing local error_label = nothing - local linfo_var = add_slot!(sv.src, LambdaInfo, false) + local linfo_var = add_slot!(sv.src, MethodInstance, false) local ex = copy(e) local stmts = [] local arg_hoisted = false @@ -2586,7 +2586,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference if isa(src, Const) # in this case function can be inlined to a constant return inline_as_constant(src.val, argexprs, sv) - elseif !isa(src, SourceInfo) || !src.inlineable + elseif !isa(src, CodeInfo) || !src.inlineable return invoke_NF() end ast = src.code @@ -3099,7 +3099,7 @@ end const compiler_temp_sym = Symbol("#temp#") -function add_slot!(src::SourceInfo, typ::ANY, is_sa::Bool, name::Symbol=compiler_temp_sym) +function add_slot!(src::CodeInfo, typ::ANY, is_sa::Bool, name::Symbol=compiler_temp_sym) id = length(src.slotnames) + 1 push!(src.slotnames, name) push!(src.slottypes, typ) @@ -3107,7 +3107,7 @@ function add_slot!(src::SourceInfo, typ::ANY, is_sa::Bool, name::Symbol=compiler return SlotNumber(id) end -function is_known_call(e::Expr, func::ANY, src::SourceInfo, mod::Module) +function is_known_call(e::Expr, func::ANY, src::CodeInfo, mod::Module) if e.head !== :call return false end @@ -3115,7 +3115,7 @@ function is_known_call(e::Expr, func::ANY, src::SourceInfo, mod::Module) return isa(f, Const) && f.val === func end -function is_known_call_p(e::Expr, pred::ANY, src::SourceInfo, mod::Module) +function is_known_call_p(e::Expr, pred::ANY, src::CodeInfo, mod::Module) if e.head !== :call return false end @@ -3123,14 +3123,14 @@ function is_known_call_p(e::Expr, pred::ANY, src::SourceInfo, mod::Module) return isa(f, Const) && pred(f.val) end -function delete_var!(src::SourceInfo, id, T) +function delete_var!(src::CodeInfo, id, T) filter!(x->!(isa(x,Expr) && (x.head === :(=) || x.head === :const) && isa(x.args[1],T) && x.args[1].id == id), src.code) return src end -function slot_replace!(src::SourceInfo, id, rhs, T) +function slot_replace!(src::CodeInfo, id, rhs, T) for i = 1:length(src.code) src.code[i] = _slot_replace!(src.code[i], id, rhs, T) end @@ -3157,7 +3157,7 @@ is_argument(nargs::Int, v::Slot) = v.id <= nargs # remove all single-assigned vars v in "v = x" where x is an argument. # "sa" is the result of find_sa_vars # T: Slot or SSAValue -function remove_redundant_temp_vars(src::SourceInfo, nargs::Int, sa, T) +function remove_redundant_temp_vars(src::CodeInfo, nargs::Int, sa, T) flags = src.slotflags ssavalue_types = src.ssavaluetypes bexpr = Expr(:block) @@ -3185,7 +3185,7 @@ function remove_redundant_temp_vars(src::SourceInfo, nargs::Int, sa, T) end # compute set of slots assigned once -function find_sa_vars(src::SourceInfo, nargs::Int) +function find_sa_vars(src::CodeInfo, nargs::Int) body = src.code av = ObjectIdDict() av2 = ObjectIdDict() diff --git a/base/linalg/ldlt.jl b/base/linalg/ldlt.jl index 15ea8de561301..8c2ee742ad580 100644 --- a/base/linalg/ldlt.jl +++ b/base/linalg/ldlt.jl @@ -88,4 +88,4 @@ convert(::Type{AbstractMatrix}, F::LDLt) = convert(SymTridiagonal, F) convert(::Type{AbstractArray}, F::LDLt) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::LDLt) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::LDLt) = convert(Matrix, F) -full(F::LDLt) = convert(Array, F) \ No newline at end of file +full(F::LDLt) = convert(Array, F) diff --git a/base/linalg/lu.jl b/base/linalg/lu.jl index 5201decd46fc6..1416a12a2a189 100644 --- a/base/linalg/lu.jl +++ b/base/linalg/lu.jl @@ -477,4 +477,4 @@ convert{T}(::Type{AbstractMatrix}, F::Base.LinAlg.LU{T,Tridiagonal{T}}) = conver convert{T}(::Type{AbstractArray}, F::Base.LinAlg.LU{T,Tridiagonal{T}}) = convert(AbstractMatrix, F) convert{T}(::Type{Matrix}, F::Base.LinAlg.LU{T,Tridiagonal{T}}) = convert(Array, convert(AbstractArray, F)) convert{T}(::Type{Array}, F::Base.LinAlg.LU{T,Tridiagonal{T}}) = convert(Matrix, F) -full{T}(F::Base.LinAlg.LU{T,Tridiagonal{T}}) = convert(Array, F) \ No newline at end of file +full{T}(F::Base.LinAlg.LU{T,Tridiagonal{T}}) = convert(Array, F) diff --git a/base/linalg/svd.jl b/base/linalg/svd.jl index f5d7d1fa77726..f3596b6b3096a 100644 --- a/base/linalg/svd.jl +++ b/base/linalg/svd.jl @@ -241,4 +241,4 @@ convert(::Type{AbstractMatrix}, F::SVD) = (F.U * Diagonal(F.S)) * F.Vt convert(::Type{AbstractArray}, F::SVD) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::SVD) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::SVD) = convert(Matrix, F) -full(F::SVD) = convert(Array, F) \ No newline at end of file +full(F::SVD) = convert(Array, F) diff --git a/base/reflection.jl b/base/reflection.jl index e6cac2c2ee1bb..d9cb9d33fc3ea 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -479,9 +479,9 @@ end isempty(mt::MethodTable) = (mt.defs === nothing) uncompressed_ast(m::Method) = uncompressed_ast(m, m.source) -function uncompressed_ast(m::Method, s::SourceInfo) +function uncompressed_ast(m::Method, s::CodeInfo) if isa(s.code, Array{UInt8,1}) - s = ccall(:jl_copy_source_info, Ref{SourceInfo}, (Any,), s) + s = ccall(:jl_copy_code_info, Ref{CodeInfo}, (Any,), s) s.code = ccall(:jl_uncompress_ast, Array{Any,1}, (Any, Any), m, s.code) end return s @@ -493,7 +493,7 @@ function _dump_function(f::ANY, t::ANY, native::Bool, wrapper::Bool, strip_ir_me if isa(f, Core.Builtin) throw(ArgumentError("argument is not a generic function")) end - # get the LambdaInfo for the method match + # get the MethodInstance for the method match meth = which(f, t) t = to_tuple_type(t) ft = isa(f, Type) ? Type{f} : typeof(f) @@ -501,12 +501,12 @@ function _dump_function(f::ANY, t::ANY, native::Bool, wrapper::Bool, strip_ir_me (ti, env) = ccall(:jl_match_method, Any, (Any, Any, Any), tt, meth.sig, meth.tvars)::SimpleVector meth = func_for_method_checked(meth, tt) - linfo = ccall(:jl_specializations_get_linfo, Ref{LambdaInfo}, (Any, Any, Any), meth, tt, env) + linfo = ccall(:jl_specializations_get_linfo, Ref{Core.MethodInstance}, (Any, Any, Any), meth, tt, env) # get the code for it return _dump_function(linfo, native, wrapper, strip_ir_metadata, dump_module) end -function _dump_function(linfo::LambdaInfo, native::Bool, wrapper::Bool, strip_ir_metadata::Bool, dump_module::Bool) +function _dump_function(linfo::Core.MethodInstance, native::Bool, wrapper::Bool, strip_ir_metadata::Bool, dump_module::Bool) if native llvmf = ccall(:jl_get_llvmf_decl, Ptr{Void}, (Any, Bool), linfo, wrapper) else @@ -658,7 +658,7 @@ Get the name of a generic `Function` as a symbol, or `:anonymous`. """ function_name(f::Function) = typeof(f).name.mt.name -functionloc(m::LambdaInfo) = functionloc(m.def) +functionloc(m::Core.MethodInstance) = functionloc(m.def) """ functionloc(m::Method) diff --git a/base/serialize.jl b/base/serialize.jl index 4fba24a5e2597..039722a719421 100644 --- a/base/serialize.jl +++ b/base/serialize.jl @@ -29,7 +29,7 @@ const TAGS = Any[ #LongSymbol, LongTuple, LongExpr, Symbol, Tuple, Expr, # dummy entries, intentionally shadowed by earlier ones LineNumberNode, Slot, LabelNode, GotoNode, - QuoteNode, Core.SourceInfo, TypeVar, Core.Box, LambdaInfo, + QuoteNode, CodeInfo, TypeVar, Core.Box, Core.MethodInstance, Module, #=UndefRefTag=#Symbol, Task, String, Float16, SimpleVector, #=BackrefTag=#Symbol, Method, GlobalRef, @@ -81,7 +81,7 @@ const BACKREF_TAG = Int32(sertag(SimpleVector)+1) const EXPR_TAG = sertag(Expr) const LONGEXPR_TAG = Int32(sertag(Expr)+3) const MODULE_TAG = sertag(Module) -const LAMBDAINFO_TAG = sertag(LambdaInfo) +const METHODINSTANCE_TAG = sertag(Core.MethodInstance) const METHOD_TAG = sertag(Method) const TASK_TAG = sertag(Task) const DATATYPE_TAG = sertag(DataType) @@ -348,10 +348,10 @@ function serialize(s::AbstractSerializer, meth::Method) nothing end -function serialize(s::AbstractSerializer, linfo::LambdaInfo) +function serialize(s::AbstractSerializer, linfo::Core.MethodInstance) serialize_cycle(s, linfo) && return - isdefined(linfo, :def) && error("can only serialize toplevel LambdaInfo objects") - writetag(s.io, LAMBDAINFO_TAG) + isdefined(linfo, :def) && error("can only serialize toplevel MethodInstance objects") + writetag(s.io, METHODINSTANCE_TAG) serialize(s, linfo.inferred) serialize(s, linfo.sparam_vals) serialize(s, linfo.rettype) @@ -623,7 +623,7 @@ function deserialize(s::AbstractSerializer, ::Type{Method}) nargs = deserialize(s)::Int32 isva = deserialize(s)::Bool isstaged = deserialize(s)::Bool - template = deserialize(s)::Core.SourceInfo + template = deserialize(s)::CodeInfo if makenew meth.module = mod meth.name = name @@ -638,7 +638,7 @@ function deserialize(s::AbstractSerializer, ::Type{Method}) meth.isva = isva # TODO: compress template if isstaged - linfo = ccall(:jl_new_lambda_info_uninit, Ref{LambdaInfo}, ()) + linfo = ccall(:jl_new_method_instance_uninit, Ref{Core.MethodInstance}, ()) linfo.specTypes = Tuple linfo.inferred = template meth.unspecialized = linfo @@ -650,10 +650,10 @@ function deserialize(s::AbstractSerializer, ::Type{Method}) return meth end -function deserialize(s::AbstractSerializer, ::Type{LambdaInfo}) - linfo = ccall(:jl_new_lambda_info_uninit, Ref{LambdaInfo}, (Ptr{Void},), C_NULL) +function deserialize(s::AbstractSerializer, ::Type{Core.MethodInstance}) + linfo = ccall(:jl_new_method_instance_uninit, Ref{Core.MethodInstance}, (Ptr{Void},), C_NULL) deserialize_cycle(s, linfo) - linfo.inferred = deserialize(s)::Core.SourceInfo + linfo.inferred = deserialize(s)::CodeInfo linfo.sparam_vals = deserialize(s)::SimpleVector linfo.rettype = deserialize(s) linfo.specTypes = deserialize(s) diff --git a/base/show.jl b/base/show.jl index 1b59abcff2541..e9e6455e7f618 100644 --- a/base/show.jl +++ b/base/show.jl @@ -272,7 +272,7 @@ function show(io::IO, m::Module) end end -function sourceinfo_slotnames(src::SourceInfo) +function sourceinfo_slotnames(src::CodeInfo) slotnames = src.slotnames isa(slotnames, Array) || return String[] names = Dict{String,Int}() @@ -292,23 +292,23 @@ function sourceinfo_slotnames(src::SourceInfo) return printnames end -function show(io::IO, l::LambdaInfo) +function show(io::IO, l::Core.MethodInstance) if isdefined(l, :def) if l.def.isstaged && l === l.def.unspecialized - print(io, "LambdaInfo generator for ") + print(io, "MethodInstance generator for ") show(io, l.def) else - print(io, "LambdaInfo for ") + print(io, "MethodInstance for ") show_lambda_types(io, l) end else - print(io, "Toplevel LambdaInfo thunk") + print(io, "Toplevel MethodInstance thunk") end end -function show(io::IO, src::SourceInfo) +function show(io::IO, src::CodeInfo) # Fix slot names and types in function body - print(io, "SourceInfo(") + print(io, "CodeInfo(") if isa(src.code, Array{Any,1}) lambda_io = IOContext(io, :SOURCEINFO => src) if src.slotnames !== nothing @@ -611,8 +611,8 @@ function show_unquoted(io::IO, ex::Slot, ::Int, ::Int) typ = isa(ex,TypedSlot) ? ex.typ : Any slotid = ex.id src = get(io, :SOURCEINFO, false) - if isa(src, SourceInfo) - slottypes = (src::SourceInfo).slottypes + if isa(src, CodeInfo) + slottypes = (src::CodeInfo).slottypes if isa(slottypes, Array) && slotid <= length(slottypes::Array) slottype = slottypes[slotid] # The Slot in assignment can somehow have an Any type @@ -1026,7 +1026,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int) nothing end -function show_lambda_types(io::IO, li::LambdaInfo) +function show_lambda_types(io::IO, li::Core.MethodInstance) # print a method signature tuple for a lambda definition if li.specTypes === Tuple print(io, li.def.name, "(...)") diff --git a/base/stacktraces.jl b/base/stacktraces.jl index dbc64382e540a..7f92db5995b0b 100644 --- a/base/stacktraces.jl +++ b/base/stacktraces.jl @@ -17,9 +17,9 @@ Stack information representing execution context, with the following fields: The name of the function containing the execution context. -- `linfo::Nullable{LambdaInfo}` +- `linfo::Nullable{Core.MethodInstance}` - The LambdaInfo containing the execution context (if it could be found). + The MethodInstance containing the execution context (if it could be found). - `file::Symbol` @@ -49,8 +49,8 @@ immutable StackFrame # this type should be kept platform-agnostic so that profil file::Symbol "the line number in the file containing the execution context" line::Int - "the LambdaInfo containing the execution context (if it could be found)" - linfo::Nullable{LambdaInfo} + "the MethodInstance containing the execution context (if it could be found)" + linfo::Nullable{Core.MethodInstance} "true if the code is from C" from_c::Bool "true if the code is from an inlined frame" @@ -59,7 +59,7 @@ immutable StackFrame # this type should be kept platform-agnostic so that profil pointer::UInt64 # Large enough to be read losslessly on 32- and 64-bit machines. end -StackFrame(func, file, line) = StackFrame(func, file, line, Nullable{LambdaInfo}(), false, false, 0) +StackFrame(func, file, line) = StackFrame(func, file, line, Nullable{Core.MethodInstance}(), false, false, 0) """ StackTrace @@ -70,7 +70,7 @@ An alias for `Vector{StackFrame}` provided for convenience; returned by calls to typealias StackTrace Vector{StackFrame} const empty_sym = Symbol("") -const UNKNOWN = StackFrame(empty_sym, empty_sym, -1, Nullable{LambdaInfo}(), true, false, 0) # === lookup(C_NULL) +const UNKNOWN = StackFrame(empty_sym, empty_sym, -1, Nullable{Core.MethodInstance}(), true, false, 0) # === lookup(C_NULL) #= @@ -110,7 +110,7 @@ function deserialize(s::AbstractSerializer, ::Type{StackFrame}) from_c = read(s.io, Bool) inlined = read(s.io, Bool) pointer = read(s.io, UInt64) - return StackFrame(func, file, line, Nullable{LambdaInfo}(), from_c, inlined, pointer) + return StackFrame(func, file, line, Nullable{Core.MethodInstance}(), from_c, inlined, pointer) end @@ -123,12 +123,12 @@ inlined at that point, innermost function first. """ function lookup(pointer::Ptr{Void}) infos = ccall(:jl_lookup_code_address, Any, (Ptr{Void}, Cint), pointer - 1, false) - isempty(infos) && return [StackFrame(empty_sym, empty_sym, -1, Nullable{LambdaInfo}(), true, false, convert(UInt64, pointer))] + isempty(infos) && return [StackFrame(empty_sym, empty_sym, -1, Nullable{Core.MethodInstance}(), true, false, convert(UInt64, pointer))] res = Array{StackFrame}(length(infos)) for i in 1:length(infos) info = infos[i] @assert(length(info) == 7) - li = info[4] === nothing ? Nullable{LambdaInfo}() : Nullable{LambdaInfo}(info[4]) + li = info[4] === nothing ? Nullable{Core.MethodInstance}() : Nullable{Core.MethodInstance}(info[4]) res[i] = StackFrame(info[1], info[2], info[3], li, info[5], info[6], info[7]) end return res diff --git a/doc/devdocs/ast.rst b/doc/devdocs/ast.rst index 642705101d57b..a2673a0022d77 100644 --- a/doc/devdocs/ast.rst +++ b/doc/devdocs/ast.rst @@ -34,11 +34,11 @@ The following data types exist in lowered form: Both types have an integer-valued ``id`` field giving the slot index. Most slots have the same type at all uses, and so are represented with ``SlotNumber``. The types of these slots are found in the ``slottypes`` - field of their ``LambdaInfo`` object. + field of their ``MethodInstance`` object. Slots that require per-use type annotations are represented with ``TypedSlot``, which has a ``typ`` field. -``SourceInfo`` +``CodeInfo`` wraps the IR of a method. ``LineNumberNode`` @@ -78,7 +78,7 @@ These symbols appear in the ``head`` field of ``Expr``\s in lowered form. ``args[2:end]`` are the arguments. ``invoke`` - function call (static dispatch). ``args[1]`` is the LambdaInfo to call, + function call (static dispatch). ``args[1]`` is the MethodInstance to call, ``args[2:end]`` are the arguments (including the function that is being called, at ``args[2]``). ``static_parameter`` @@ -121,7 +121,7 @@ These symbols appear in the ``head`` field of ``Expr``\s in lowered form. ``SimpleVector`` of type variables corresponding to the method's static parameters. - ``args[3]`` - a ``SourceInfo`` of the method itself. For "out of scope" + ``args[3]`` - a ``CodeInfo`` of the method itself. For "out of scope" method definitions (adding a method to a function that also has methods defined in different scopes) this is an expression that evaluates to a ``:lambda`` expression. @@ -194,7 +194,7 @@ A unique'd container describing the shared metadata for a single (unspecialized) ``ambig`` - Cache of other methods that may be ambiguous with this one -``specializations`` - Cache of all LambdaInfo ever created for this Method, +``specializations`` - Cache of all MethodInstance ever created for this Method, used to ensure uniqueness. Uniqueness is required for efficiency, especially for incremental precompile and tracking of method invalidation. @@ -206,21 +206,21 @@ A unique'd container describing the shared metadata for a single (unspecialized) ``nargs``, ``isva``, ``called``, ``isstaged`` - Descriptive bit-fields for the source code of this Method. -LambdaInfo -~~~~~~~~~~ +MethodInstance +~~~~~~~~~~~~~~ A unique'd container describing a single callable signature for a Method. See especially :ref:`devdocs-locks` for important details on how to modify these fields safely. -``specTypes`` - The primary key for this LambdaInfo. +``specTypes`` - The primary key for this MethodInstance. Uniqueness is guaranteed through a ``def.specializations`` lookup. ``def`` - The ``Method`` that this function describes a specialization of. Or ``#undef``, if this is a top-level Lambda that is not part of a Method. ``sparam_vals`` - The values of the static parameters in specTypes - indexed by ``def.sparam_syms``. For the ``LambdaInfo`` at ``Method.unspecialized``, - this is the empty ``SimpleVector``. But for a runtime ``LambdaInfo`` from the ``MethodTable`` cache, + indexed by ``def.sparam_syms``. For the ``MethodInstance`` at ``Method.unspecialized``, + this is the empty ``SimpleVector``. But for a runtime ``MethodInstance`` from the ``MethodTable`` cache, this will always be defined and indexable. ``rettype`` - The inferred return type for the ``specFunctionObject`` field, @@ -239,8 +239,8 @@ See especially :ref:`devdocs-locks` for important details on how to modify these - 2 - constant (stored in ``inferred``) -SourceInfo -~~~~~~~~~~ +CodeInfo +~~~~~~~~ A temporary container for holding lowered source code. diff --git a/doc/devdocs/debuggingtips.rst b/doc/devdocs/debuggingtips.rst index 153e8003399e4..7842e1960b38a 100644 --- a/doc/devdocs/debuggingtips.rst +++ b/doc/devdocs/debuggingtips.rst @@ -70,7 +70,7 @@ It's particularly helpful to back up to the ``jl_apply`` frame, from which you c (gdb) call jl_(args[0]) -Another useful frame is ``to_function(jl_lambda_info_t *li, bool cstyle)``. The ``jl_lambda_info_t*`` argument is a struct with a reference to the final AST sent into the compiler. However, the AST at this point will usually be compressed; to view the AST, call ``jl_uncompress_ast`` and then pass the result to ``jl_``:: +Another useful frame is ``to_function(jl_method_instance_t *li, bool cstyle)``. The ``jl_method_instance_t*`` argument is a struct with a reference to the final AST sent into the compiler. However, the AST at this point will usually be compressed; to view the AST, call ``jl_uncompress_ast`` and then pass the result to ``jl_``:: #2 0x00007ffff7928bf7 in to_function (li=0x2812060, cstyle=false) at codegen.cpp:584 584 abort(); diff --git a/doc/devdocs/eval.rst b/doc/devdocs/eval.rst index 9d944838c0d28..3f07e159989b0 100644 --- a/doc/devdocs/eval.rst +++ b/doc/devdocs/eval.rst @@ -150,7 +150,7 @@ Codegen is the process of turning a Julia AST into native machine code. The JIT environment is initialized by an early call to `jl_init_codegen in codegen.cpp `_. -On demand, a Julia method is converted into a native function by the function :c:func:`emit_function(jl_lambda_info_t*) `. +On demand, a Julia method is converted into a native function by the function :c:func:`emit_function(jl_method_instance_t*) `. (note, when using the MCJIT (in LLVM v3.4+), each function must be JIT into a new module.) This function recursively calls :c:func:`emit_expr` until the entire function has been emitted. diff --git a/doc/devdocs/locks.rst b/doc/devdocs/locks.rst index 457f34995428b..1034128b95e8c 100644 --- a/doc/devdocs/locks.rst +++ b/doc/devdocs/locks.rst @@ -105,7 +105,7 @@ Module serializer : toplevel lock JIT & type-inference : codegen lock -LambdaInfo updates : codegen lock +MethodInstance updates : codegen lock - These fields are generally lazy initialized, using the test-and-test-and-set pattern. diff --git a/doc/devdocs/object.rst b/doc/devdocs/object.rst index 99137ea5be094..add317bfd2120 100644 --- a/doc/devdocs/object.rst +++ b/doc/devdocs/object.rst @@ -136,10 +136,10 @@ Symbols:: jl_sym_t *jl_symbol(const char *str); -Functions and LambdaInfo:: +Functions and MethodInstance:: jl_function_t *jl_new_generic_function(jl_sym_t *name); - jl_lambda_info_t *jl_new_lambda_info(jl_value_t *ast, jl_tuple_t *sparams); + jl_method_instance_t *jl_new_method_instance(jl_value_t *ast, jl_tuple_t *sparams); Arrays:: diff --git a/doc/devdocs/reflection.rst b/doc/devdocs/reflection.rst index 22d053413e362..1e91c73a97a41 100644 --- a/doc/devdocs/reflection.rst +++ b/doc/devdocs/reflection.rst @@ -106,7 +106,7 @@ variable assignments: julia> expand( :(f() = 1) ) :(begin $(Expr(:method, :f)) - $(Expr(:method, :f, :((Core.svec)((Core.apply_type)(Tuple,(Core.Typeof)(f)),(Core.svec)())), Toplevel LambdaInfo thunk, false)) + $(Expr(:method, :f, :((Core.svec)((Core.apply_type)(Tuple,(Core.Typeof)(f)),(Core.svec)())), Toplevel MethodInstance thunk, false)) return f end) diff --git a/doc/manual/modules.rst b/doc/manual/modules.rst index 9ccc2276a6695..2f0799ecaad11 100644 --- a/doc/manual/modules.rst +++ b/doc/manual/modules.rst @@ -445,7 +445,7 @@ A few other points to be aware of: (this will be fixed in an upcoming release). 5. It is usually best to avoid capturing references to instances of internal metadata objects such as - Method, LambdaInfo, MethodTable, TypeMapLevel, TypeMapEntry + Method, MethodInstance, MethodTable, TypeMapLevel, TypeMapEntry and fields of those objects, as this can confuse the serializer and may not lead to the outcome you desire. It is not necessarily an error to do this, diff --git a/doc/manual/stacktraces.rst b/doc/manual/stacktraces.rst index 32b14abef18a1..f55bbabf67144 100644 --- a/doc/manual/stacktraces.rst +++ b/doc/manual/stacktraces.rst @@ -86,7 +86,7 @@ Each :obj:`StackFrame` contains the function name, file name, line number, lambd 234 julia> top_frame.linfo - Nullable{LambdaInfo}(LambdaInfo for eval(::Module, ::Any)) + Nullable{MethodInstance}(MethodInstance for eval(::Module, ::Any)) julia> top_frame.inlined false diff --git a/doc/stdlib/stacktraces.rst b/doc/stdlib/stacktraces.rst index 1cc87e89aac3d..f8af24f1d8627 100644 --- a/doc/stdlib/stacktraces.rst +++ b/doc/stdlib/stacktraces.rst @@ -17,9 +17,9 @@ * ``func::Symbol`` The name of the function containing the execution context. - * ``linfo::Nullable{LambdaInfo}`` + * ``linfo::Nullable{MethodInstance}`` - The LambdaInfo containing the execution context (if it could be found). + The MethodInstance containing the execution context (if it could be found). * ``file::Symbol`` The path to the file containing the execution context. diff --git a/src/alloc.c b/src/alloc.c index 020d5687f7842..61066a8a65809 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -42,8 +42,8 @@ jl_datatype_t *jl_method_type; jl_datatype_t *jl_methtable_type; jl_datatype_t *jl_typemap_entry_type; jl_datatype_t *jl_typemap_level_type; -jl_datatype_t *jl_lambda_info_type; -jl_datatype_t *jl_source_info_type; +jl_datatype_t *jl_method_instance_type; +jl_datatype_t *jl_code_info_type; jl_datatype_t *jl_module_type; jl_datatype_t *jl_errorexception_type=NULL; jl_datatype_t *jl_argumenterror_type; @@ -331,9 +331,9 @@ jl_value_t *jl_resolve_globals(jl_value_t *expr, jl_module_t *module) return expr; } -// copy a :lambda Expr into its SourceInfo representation, +// copy a :lambda Expr into its CodeInfo representation, // including popping of known meta nodes -static void jl_source_info_set_ast(jl_source_info_t *li, jl_expr_t *ast) +static void jl_code_info_set_ast(jl_code_info_t *li, jl_expr_t *ast) { assert(jl_is_expr(ast)); jl_expr_t *bodyex = (jl_expr_t*)jl_exprarg(ast, 2); @@ -399,12 +399,12 @@ static void jl_source_info_set_ast(jl_source_info_t *li, jl_expr_t *ast) } } -JL_DLLEXPORT jl_lambda_info_t *jl_new_lambda_info_uninit(void) +JL_DLLEXPORT jl_method_instance_t *jl_new_method_instance_uninit(void) { jl_ptls_t ptls = jl_get_ptls_states(); - jl_lambda_info_t *li = - (jl_lambda_info_t*)jl_gc_alloc(ptls, sizeof(jl_lambda_info_t), - jl_lambda_info_type); + jl_method_instance_t *li = + (jl_method_instance_t*)jl_gc_alloc(ptls, sizeof(jl_method_instance_t), + jl_method_instance_type); li->inferred = NULL; li->rettype = (jl_value_t*)jl_any_type; li->sparam_vals = jl_emptysvec; @@ -420,12 +420,12 @@ JL_DLLEXPORT jl_lambda_info_t *jl_new_lambda_info_uninit(void) return li; } -JL_DLLEXPORT jl_source_info_t *jl_new_source_info_uninit(void) +JL_DLLEXPORT jl_code_info_t *jl_new_code_info_uninit(void) { jl_ptls_t ptls = jl_get_ptls_states(); - jl_source_info_t *src = - (jl_source_info_t*)jl_gc_alloc(ptls, sizeof(jl_source_info_t), - jl_source_info_type); + jl_code_info_t *src = + (jl_code_info_t*)jl_gc_alloc(ptls, sizeof(jl_code_info_t), + jl_code_info_type); src->code = NULL; src->slotnames = NULL; src->slotflags = NULL; @@ -438,25 +438,25 @@ JL_DLLEXPORT jl_source_info_t *jl_new_source_info_uninit(void) return src; } -jl_source_info_t *jl_new_source_info_from_ast(jl_expr_t *ast) +jl_code_info_t *jl_new_code_info_from_ast(jl_expr_t *ast) { - jl_source_info_t *src = NULL; + jl_code_info_t *src = NULL; JL_GC_PUSH1(&src); - src = jl_new_source_info_uninit(); - jl_source_info_set_ast(src, ast); + src = jl_new_code_info_uninit(); + jl_code_info_set_ast(src, ast); JL_GC_POP(); return src; } // invoke (compiling if necessary) the jlcall function pointer for a method template -STATIC_INLINE jl_value_t *jl_call_staged(jl_svec_t *sparam_vals, jl_lambda_info_t *generator, +STATIC_INLINE jl_value_t *jl_call_staged(jl_svec_t *sparam_vals, jl_method_instance_t *generator, jl_value_t **args, uint32_t nargs) { jl_generic_fptr_t fptr; fptr.fptr = generator->fptr; fptr.jlcall_api = generator->jlcall_api; if (__unlikely(fptr.fptr == NULL || fptr.jlcall_api == 0)) { - void *F = jl_compile_linfo(generator, (jl_source_info_t*)generator->inferred).functionObject; + void *F = jl_compile_linfo(generator, (jl_code_info_t*)generator->inferred).functionObject; fptr = jl_generate_fptr(generator, F); } assert(jl_svec_len(generator->def->sparam_syms) == jl_svec_len(sparam_vals)); @@ -468,9 +468,9 @@ STATIC_INLINE jl_value_t *jl_call_staged(jl_svec_t *sparam_vals, jl_lambda_info_ abort(); // shouldn't have inferred any other calling convention } -// return a newly allocated SourceInfo for the function signature +// return a newly allocated CodeInfo for the function signature // effectively described by the tuple (specTypes, env, Method) inside linfo -JL_DLLEXPORT jl_source_info_t *jl_code_for_staged(jl_lambda_info_t *linfo) +JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo) { JL_TIMING(STAGED_FUNCTION); jl_tupletype_t *tt = linfo->specTypes; @@ -479,10 +479,10 @@ JL_DLLEXPORT jl_source_info_t *jl_code_for_staged(jl_lambda_info_t *linfo) jl_expr_t *ex = NULL; jl_value_t *linenum = NULL; jl_svec_t *sparam_vals = env; - jl_lambda_info_t *generator = linfo->def->unspecialized; + jl_method_instance_t *generator = linfo->def->unspecialized; assert(linfo != generator); assert(linfo->def->isstaged); - jl_source_info_t *func = NULL; + jl_code_info_t *func = NULL; JL_GC_PUSH4(&ex, &linenum, &sparam_vals, &func); jl_ptls_t ptls = jl_get_ptls_states(); int last_in = ptls->in_pure_callback; @@ -495,7 +495,7 @@ JL_DLLEXPORT jl_source_info_t *jl_code_for_staged(jl_lambda_info_t *linfo) jl_array_t *argnames = jl_alloc_vec_any(nargs); jl_array_ptr_set(ex->args, 0, argnames); for (i = 0; i < nargs; i++) - jl_array_ptr_set(argnames, i, jl_array_ptr_ref(((jl_source_info_t*)generator->inferred)->slotnames, i)); + jl_array_ptr_set(argnames, i, jl_array_ptr_ref(((jl_code_info_t*)generator->inferred)->slotnames, i)); jl_expr_t *scopeblock = jl_exprn(jl_symbol("scope-block"), 1); jl_array_ptr_set(ex->args, 1, scopeblock); @@ -523,8 +523,8 @@ JL_DLLEXPORT jl_source_info_t *jl_code_for_staged(jl_lambda_info_t *linfo) } // need to eval macros in the right module, but not give a warning for the `eval` call unless that results in a call to `eval` - func = (jl_source_info_t*)jl_toplevel_eval_in_warn(linfo->def->module, (jl_value_t*)ex, 1); - assert(jl_is_source_info(func)); + func = (jl_code_info_t*)jl_toplevel_eval_in_warn(linfo->def->module, (jl_value_t*)ex, 1); + assert(jl_is_code_info(func)); jl_array_t *stmts = (jl_array_t*)func->code; for (i = 0, l = jl_array_len(stmts); i < l; i++) { @@ -540,28 +540,28 @@ JL_DLLEXPORT jl_source_info_t *jl_code_for_staged(jl_lambda_info_t *linfo) return func; } -JL_DLLEXPORT jl_source_info_t *jl_copy_source_info(jl_source_info_t *src) +JL_DLLEXPORT jl_code_info_t *jl_copy_code_info(jl_code_info_t *src) { jl_ptls_t ptls = jl_get_ptls_states(); - jl_source_info_t *newsrc = - (jl_source_info_t*)jl_gc_alloc(ptls, sizeof(jl_source_info_t), - jl_source_info_type); + jl_code_info_t *newsrc = + (jl_code_info_t*)jl_gc_alloc(ptls, sizeof(jl_code_info_t), + jl_code_info_type); *newsrc = *src; return newsrc; } // return a new lambda-info that has some extra static parameters merged in -jl_lambda_info_t *jl_get_specialized(jl_method_t *m, jl_tupletype_t *types, jl_svec_t *sp) +jl_method_instance_t *jl_get_specialized(jl_method_t *m, jl_tupletype_t *types, jl_svec_t *sp) { assert(jl_svec_len(m->sparam_syms) == jl_svec_len(sp) || sp == jl_emptysvec); - jl_lambda_info_t *new_linfo = jl_new_lambda_info_uninit(); + jl_method_instance_t *new_linfo = jl_new_method_instance_uninit(); new_linfo->def = m; new_linfo->specTypes = types; new_linfo->sparam_vals = sp; return new_linfo; } -JL_DLLEXPORT void jl_method_set_source(jl_method_t *m, jl_source_info_t *src) +JL_DLLEXPORT void jl_method_set_source(jl_method_t *m, jl_code_info_t *src) { uint8_t j; uint8_t called = 0; @@ -596,7 +596,7 @@ JL_DLLEXPORT void jl_method_set_source(jl_method_t *m, jl_source_info_t *src) jl_array_ptr_set(copy, i, st); } copy = jl_compress_ast(m, copy); - m->source = jl_copy_source_info(src); + m->source = jl_copy_code_info(src); jl_gc_wb(m, m->source); m->source->code = copy; JL_GC_POP(); @@ -630,7 +630,7 @@ JL_DLLEXPORT jl_method_t *jl_new_method_uninit(void) return m; } -jl_method_t *jl_new_method(jl_source_info_t *definition, +jl_method_t *jl_new_method(jl_code_info_t *definition, jl_sym_t *name, jl_tupletype_t *sig, size_t nargs, diff --git a/src/anticodegen.c b/src/anticodegen.c index 1ba10ceb6e3b9..552ae552e5911 100644 --- a/src/anticodegen.c +++ b/src/anticodegen.c @@ -25,7 +25,7 @@ JL_DLLEXPORT void *jl_LLVMCreateDisasm(const char *TripleName, void *DisInfo, in JL_DLLEXPORT size_t jl_LLVMDisasmInstruction(void *DC, uint8_t *Bytes, uint64_t BytesSize, uint64_t PC, char *OutString, size_t OutStringSize) UNAVAILABLE void jl_init_codegen(void) { } -void jl_fptr_to_llvm(jl_fptr_t fptr, jl_lambda_info_t *lam, int specsig) +void jl_fptr_to_llvm(jl_fptr_t fptr, jl_method_instance_t *lam, int specsig) { if (!specsig) lam->fptr = fptr; @@ -36,15 +36,15 @@ int jl_getFunctionInfo(jl_frame_t **frames, uintptr_t pointer, int skipC, int no return 0; } -void jl_register_fptrs(uint64_t sysimage_base, void **fptrs, jl_lambda_info_t **linfos, size_t n) +void jl_register_fptrs(uint64_t sysimage_base, void **fptrs, jl_method_instance_t **linfos, size_t n) { (void)sysimage_base; (void)fptrs; (void)linfos; (void)n; } -void jl_compile_linfo(jl_lambda_info_t *li) { } +void jl_compile_linfo(jl_method_instance_t *li) { } -jl_value_t *jl_interpret_call(jl_lambda_info_t *lam, jl_value_t **args, uint32_t nargs); -void jl_generate_fptr(jl_lambda_info_t *li) +jl_value_t *jl_interpret_call(jl_method_instance_t *lam, jl_value_t **args, uint32_t nargs); +void jl_generate_fptr(jl_method_instance_t *li) { li->fptr = (jl_fptr_t)&jl_interpret_call; li->jlcall_api = 4; diff --git a/src/ast.c b/src/ast.c index 547caea26a90c..8bcf0b31a48b4 100644 --- a/src/ast.c +++ b/src/ast.c @@ -141,7 +141,7 @@ value_t fl_invoke_julia_macro(fl_context_t *fl_ctx, value_t *args, uint32_t narg jl_ptls_t ptls = jl_get_ptls_states(); if (nargs < 1) argcount(fl_ctx, "invoke-julia-macro", nargs, 1); - jl_lambda_info_t *mfunc = NULL; + jl_method_instance_t *mfunc = NULL; jl_value_t **margs; // Reserve one more slot for the result JL_GC_PUSHARGS(margs, nargs + 1); @@ -515,7 +515,7 @@ static jl_value_t *scm_to_julia_(fl_context_t *fl_ctx, value_t e, int eo) e = cdr_(e); } if (sym == lambda_sym) - ex = (jl_value_t*)jl_new_source_info_from_ast((jl_expr_t*)ex); + ex = (jl_value_t*)jl_new_code_info_from_ast((jl_expr_t*)ex); JL_GC_POP(); if (sym == list_sym) return (jl_value_t*)((jl_expr_t*)ex)->args; @@ -813,12 +813,12 @@ JL_DLLEXPORT jl_value_t *jl_macroexpand(jl_value_t *expr) } // wrap expr in a thunk AST -jl_source_info_t *jl_wrap_expr(jl_value_t *expr) +jl_code_info_t *jl_wrap_expr(jl_value_t *expr) { // `(lambda () (() () () ()) ,expr) jl_expr_t *le=NULL, *bo=NULL; jl_value_t *vi=NULL; jl_value_t *mt = jl_an_empty_vec_any; - jl_source_info_t *src = NULL; + jl_code_info_t *src = NULL; JL_GC_PUSH4(&le, &vi, &bo, &src); le = jl_exprn(lambda_sym, 3); jl_array_ptr_set(le->args, 0, mt); @@ -836,7 +836,7 @@ jl_source_info_t *jl_wrap_expr(jl_value_t *expr) expr = (jl_value_t*)bo; } jl_array_ptr_set(le->args, 2, expr); - src = jl_new_source_info_from_ast(le); + src = jl_new_code_info_from_ast(le); JL_GC_POP(); return src; } diff --git a/src/builtins.c b/src/builtins.c index 9005d67727d51..ab42d879286fc 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -1187,8 +1187,8 @@ void jl_init_primitives(void) add_builtin("IntrinsicFunction", (jl_value_t*)jl_intrinsic_type); add_builtin("Function", (jl_value_t*)jl_function_type); add_builtin("Builtin", (jl_value_t*)jl_builtin_type); - add_builtin("LambdaInfo", (jl_value_t*)jl_lambda_info_type); - add_builtin("SourceInfo", (jl_value_t*)jl_source_info_type); + add_builtin("MethodInstance", (jl_value_t*)jl_method_instance_type); + add_builtin("CodeInfo", (jl_value_t*)jl_code_info_type); add_builtin("Ref", (jl_value_t*)jl_ref_type); add_builtin("Ptr", (jl_value_t*)jl_pointer_type); add_builtin("Task", (jl_value_t*)jl_task_type); @@ -1260,8 +1260,8 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt n += jl_static_show_x(out, (jl_value_t*)m->module, depth); n += jl_printf(out, ".%s(...)", jl_symbol_name(m->name)); } - else if (vt == jl_lambda_info_type) { - jl_lambda_info_t *li = (jl_lambda_info_t*)v; + else if (vt == jl_method_instance_type) { + jl_method_instance_t *li = (jl_method_instance_t*)v; if (li->def) { n += jl_static_show_x(out, (jl_value_t*)li->def->module, depth); if (li->specTypes) { diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 532604c140431..039188ef55776 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -88,7 +88,7 @@ static DIType julia_type_to_di(jl_value_t *jt, DIBuilder *dbuilder, bool isboxed if (jl_is_abstracttype(jt) || !jl_is_datatype(jt) || jl_is_array_type(jt) || jt == (jl_value_t*)jl_sym_type || jt == (jl_value_t*)jl_module_type || jt == (jl_value_t*)jl_simplevector_type || jt == (jl_value_t*)jl_datatype_type || - jt == (jl_value_t*)jl_lambda_info_type) + jt == (jl_value_t*)jl_method_instance_type) return jl_pvalue_dillvmt; if (jl_is_typector(jt) || jl_is_typevar(jt)) return jl_pvalue_dillvmt; @@ -246,8 +246,8 @@ static Value *literal_pointer_val(jl_value_t *p) // functions are prefixed with a - return julia_gv("-", m->name, m->module, p); } - if (jl_is_lambda_info(p)) { - jl_lambda_info_t *linfo = (jl_lambda_info_t*)p; + if (jl_is_method_instance(p)) { + jl_method_instance_t *linfo = (jl_method_instance_t*)p; // Type-inferred functions are also prefixed with a - if (linfo->def) return julia_gv("-", linfo->def->name, linfo->def->module, p); @@ -1439,7 +1439,7 @@ static Value *call_with_unsigned(Function *ufunc, Value *v) return Call; } -static void jl_add_linfo_root(jl_lambda_info_t *li, jl_value_t *val); +static void jl_add_method_root(jl_method_instance_t *li, jl_value_t *val); static Value *as_value(Type *t, const jl_cgval_t &v) { @@ -1476,7 +1476,7 @@ static Value *boxed(const jl_cgval_t &vinfo, jl_codectx_t *ctx, bool gcrooted) if (Constant *c = dyn_cast(v)) { jl_value_t *s = static_constant_instance(c, jt); if (s) { - jl_add_linfo_root(ctx->linfo, s); + jl_add_method_root(ctx->linfo, s); return literal_pointer_val(s); } } diff --git a/src/codegen.cpp b/src/codegen.cpp index 7db741934ec1d..79e7902857064 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -522,8 +522,8 @@ typedef struct { std::vector ssavalue_assigned; std::map *arrayvars; jl_module_t *module; - jl_lambda_info_t *linfo; - jl_source_info_t *source; + jl_method_instance_t *linfo; + jl_code_info_t *source; jl_array_t *code; const char *name; StringRef file; @@ -784,18 +784,18 @@ void jl_dump_compiles(void *s) // --- entry point --- //static int n_emit=0; -static std::unique_ptr emit_function(jl_lambda_info_t *lam, jl_source_info_t *src, jl_llvm_functions_t *declarations); -void jl_add_linfo_in_flight(StringRef name, jl_lambda_info_t *linfo, const DataLayout &DL); +static std::unique_ptr emit_function(jl_method_instance_t *lam, jl_code_info_t *src, jl_llvm_functions_t *declarations); +void jl_add_linfo_in_flight(StringRef name, jl_method_instance_t *linfo, const DataLayout &DL); // this generates llvm code for the lambda info // and adds the result to the jitlayers // (and the shadow module), but doesn't yet compile // or generate object code for it extern "C" -jl_llvm_functions_t jl_compile_linfo(jl_lambda_info_t *li, jl_source_info_t *src) +jl_llvm_functions_t jl_compile_linfo(jl_method_instance_t *li, jl_code_info_t *src) { JL_TIMING(CODEGEN); - assert(jl_is_lambda_info(li)); + assert(jl_is_method_instance(li)); jl_llvm_functions_t decls = {}; // Step 1. See if it is already compiled, // Get the codegen lock, @@ -816,9 +816,9 @@ jl_llvm_functions_t jl_compile_linfo(jl_lambda_info_t *li, jl_source_info_t *src } // see if it is inferred - src = (jl_source_info_t*)li->inferred; + src = (jl_code_info_t*)li->inferred; if (src) { - if (!jl_is_source_info(src)) { + if (!jl_is_code_info(src)) { src = jl_type_infer(li, 0); } if (!src || li->jlcall_api == 2) { @@ -847,7 +847,7 @@ jl_llvm_functions_t jl_compile_linfo(jl_lambda_info_t *li, jl_source_info_t *src } } JL_GC_PUSH1(&src); - assert(jl_is_source_info(src)); + assert(jl_is_code_info(src)); // Step 2: setup global state BasicBlock *old = nested_compile ? builder.GetInsertBlock() : NULL; @@ -904,8 +904,8 @@ jl_llvm_functions_t jl_compile_linfo(jl_lambda_info_t *li, jl_source_info_t *src if (li->jlcall_api != 2) { // if not inlineable, code won't be needed again if (JL_DELETE_NON_INLINEABLE && jl_options.debug_level <= 1 && - li->def && li->inferred && jl_is_source_info(li->inferred) && - !((jl_source_info_t*)li->inferred)->inlineable && + li->def && li->inferred && jl_is_code_info(li->inferred) && + !((jl_code_info_t*)li->inferred)->inlineable && li != li->def->unspecialized && !imaging_mode) { li->inferred = jl_nothing; } @@ -1011,7 +1011,7 @@ uint64_t jl_get_llvm_fptr(llvm::Function *llvmf) return addr; } -static jl_lambda_info_t *jl_get_unspecialized(jl_lambda_info_t *method) +static jl_method_instance_t *jl_get_unspecialized(jl_method_instance_t *method) { // one unspecialized version of a function can be shared among all cached specializations jl_method_t *def = method->def; @@ -1058,7 +1058,7 @@ static jl_lambda_info_t *jl_get_unspecialized(jl_lambda_info_t *method) // this compiles li and emits fptr extern "C" -jl_generic_fptr_t jl_generate_fptr(jl_lambda_info_t *li, void *_F) +jl_generic_fptr_t jl_generate_fptr(jl_method_instance_t *li, void *_F) { Function *F = (Function*)_F; jl_generic_fptr_t fptr; @@ -1079,7 +1079,7 @@ jl_generic_fptr_t jl_generate_fptr(jl_lambda_info_t *li, void *_F) JL_UNLOCK(&codegen_lock); return fptr; } - jl_lambda_info_t *unspec = NULL; + jl_method_instance_t *unspec = NULL; if (li->def && !li->def->isstaged && li->def->unspecialized) { unspec = li->def->unspecialized; } @@ -1089,7 +1089,7 @@ jl_generic_fptr_t jl_generate_fptr(jl_lambda_info_t *li, void *_F) // and return its fptr instead if (!unspec) unspec = jl_get_unspecialized(li); // get-or-create the unspecialized version to cache the result - jl_source_info_t *src = unspec->def->isstaged ? jl_code_for_staged(unspec) : unspec->def->source; + jl_code_info_t *src = unspec->def->isstaged ? jl_code_for_staged(unspec) : unspec->def->source; fptr.fptr = unspec->fptr; fptr.jlcall_api = unspec->jlcall_api; if (fptr.fptr && fptr.jlcall_api) { @@ -1214,16 +1214,16 @@ void jl_extern_c(jl_function_t *f, jl_value_t *rt, jl_value_t *argt, char *name) // this is paired with jl_dump_function_ir and jl_dump_function_asm in particular ways: // misuse will leak memory or cause read-after-free extern "C" JL_DLLEXPORT -void *jl_get_llvmf_defn(jl_lambda_info_t *linfo, bool getwrapper) +void *jl_get_llvmf_defn(jl_method_instance_t *linfo, bool getwrapper) { if (linfo->def && linfo->def->source == NULL) { // not a generic function return NULL; } - jl_source_info_t *src = (jl_source_info_t*)linfo->inferred; + jl_code_info_t *src = (jl_code_info_t*)linfo->inferred; JL_GC_PUSH1(&src); - if (!src || !jl_is_source_info(src)) { + if (!src || !jl_is_code_info(src)) { src = jl_type_infer(linfo, 0); if (!src) src = linfo->def->isstaged ? jl_code_for_staged(linfo) : linfo->def->source; @@ -1293,7 +1293,7 @@ void *jl_get_llvmf_defn(jl_lambda_info_t *linfo, bool getwrapper) extern "C" JL_DLLEXPORT -void *jl_get_llvmf_decl(jl_lambda_info_t *linfo, bool getwrapper) +void *jl_get_llvmf_decl(jl_method_instance_t *linfo, bool getwrapper) { if (linfo->def && linfo->def->source == NULL) { // not a generic function @@ -1309,7 +1309,7 @@ void *jl_get_llvmf_decl(jl_lambda_info_t *linfo, bool getwrapper) JL_LOCK(&codegen_lock); decls = linfo->functionObjectsDecls; if (decls.functionObject == NULL) { - jl_source_info_t *src = NULL; + jl_code_info_t *src = NULL; src = jl_type_infer(linfo, 0); if (!src) { src = linfo->def->isstaged ? jl_code_for_staged(linfo) : linfo->def->source; @@ -1330,7 +1330,7 @@ void *jl_get_llvmf_decl(jl_lambda_info_t *linfo, bool getwrapper) extern "C" JL_DLLEXPORT void *jl_get_llvmf(jl_tupletype_t *tt, bool getwrapper, bool getdeclarations) { // DEPRECATED - jl_lambda_info_t *linfo = NULL, *temp = NULL; + jl_method_instance_t *linfo = NULL, *temp = NULL; JL_GC_PUSH3(&linfo, &temp, &tt); if (tt != NULL) { linfo = jl_get_specialization1(tt); @@ -1753,7 +1753,7 @@ static jl_value_t *static_eval(jl_value_t *ex, jl_codectx_t *ctx, int sparams=tr } if (jl_is_quotenode(ex)) return jl_fieldref(ex, 0); - if (jl_is_lambda_info(ex)) + if (jl_is_method_instance(ex)) return NULL; jl_module_t *m = NULL; jl_sym_t *s = NULL; @@ -2036,7 +2036,7 @@ static Value *make_jlcall(ArrayRef args, jl_codectx_t *ctx) return largs; } -static void jl_add_linfo_root(jl_lambda_info_t *li, jl_value_t *val) +static void jl_add_method_root(jl_method_instance_t *li, jl_value_t *val) { if (jl_is_leaf_type(val) || jl_is_bool(val) || jl_is_symbol(val)) return; @@ -2757,7 +2757,7 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args, if (ty!=NULL && jl_is_leaf_type(ty)) { if (jl_has_typevars(ty)) { // add root for types not cached. issue #7065 - jl_add_linfo_root(ctx->linfo, ty); + jl_add_method_root(ctx->linfo, ty); } *ret = mark_julia_const(ty); JL_GC_POP(); @@ -2798,7 +2798,7 @@ static Value *emit_jlcall(Value *theFptr, Value *theF, jl_value_t **args, return result; } -static jl_cgval_t emit_call_function_object(jl_lambda_info_t *li, const jl_cgval_t &theF, jl_llvm_functions_t decls, +static jl_cgval_t emit_call_function_object(jl_method_instance_t *li, const jl_cgval_t &theF, jl_llvm_functions_t decls, jl_value_t **args, size_t nargs, jl_value_t *callexpr, jl_codectx_t *ctx) { Value *theFptr = (Value*)decls.functionObject; @@ -2874,8 +2874,8 @@ static jl_cgval_t emit_invoke(jl_expr_t *ex, jl_codectx_t *ctx) jl_cgval_t lival = emit_expr(args[0], ctx); if (lival.constant) { - jl_lambda_info_t *li = (jl_lambda_info_t*)lival.constant; - assert(jl_is_lambda_info(li)); + jl_method_instance_t *li = (jl_method_instance_t*)lival.constant; + assert(jl_is_method_instance(li)); jl_llvm_functions_t decls = jl_compile_linfo(li, NULL); if (li->jlcall_api == 2) { assert(li->inferred); @@ -3331,7 +3331,7 @@ static jl_cgval_t emit_expr(jl_value_t *expr, jl_codectx_t *ctx) } } if (needroot && ctx->linfo->def) { // toplevel exprs and some integers are already rooted - jl_add_linfo_root(ctx->linfo, expr); + jl_add_method_root(ctx->linfo, expr); } return mark_julia_const(expr); } @@ -3349,7 +3349,7 @@ static jl_cgval_t emit_expr(jl_value_t *expr, jl_codectx_t *ctx) if (ctx->linfo->def) { // don't bother codegen constant-folding for toplevel jl_value_t *c = static_eval(expr, ctx, true, true); if (c) { - jl_add_linfo_root(ctx->linfo, c); + jl_add_method_root(ctx->linfo, c); return mark_julia_const(c); } } @@ -3527,12 +3527,12 @@ static Function *gen_cfun_wrapper(jl_function_t *ff, jl_value_t *jlrettype, jl_t const char *name = "cfunction"; // try to look up this function for direct invoking - jl_lambda_info_t *lam = jl_get_specialization1((jl_tupletype_t*)sigt); + jl_method_instance_t *lam = jl_get_specialization1((jl_tupletype_t*)sigt); jl_value_t *astrt = (jl_value_t*)jl_any_type; // infer it first, if necessary if (lam) { name = jl_symbol_name(lam->def->name); - jl_source_info_t *src = NULL; + jl_code_info_t *src = NULL; if (!lam->inferred) // TODO: this isn't ideal to be unconditionally calling type inference from here src = jl_type_infer(lam, 0); jl_compile_linfo(lam, src); @@ -3908,7 +3908,7 @@ static Function *jl_cfunction_object(jl_function_t *ff, jl_value_t *declrt, jl_t } // generate a julia-callable function that calls f (AKA lam) -static Function *gen_jlcall_wrapper(jl_lambda_info_t *lam, Function *f, bool sret, Module *M) +static Function *gen_jlcall_wrapper(jl_method_instance_t *lam, Function *f, bool sret, Module *M) { std::stringstream funcName; const std::string &fname = f->getName().str(); @@ -3988,7 +3988,7 @@ static Function *gen_jlcall_wrapper(jl_lambda_info_t *lam, Function *f, bool sre } // Compile to LLVM IR, using a specialized signature if applicable. -static std::unique_ptr emit_function(jl_lambda_info_t *lam, jl_source_info_t *src, jl_llvm_functions_t *declarations) +static std::unique_ptr emit_function(jl_method_instance_t *lam, jl_code_info_t *src, jl_llvm_functions_t *declarations) { jl_ptls_t ptls = jl_get_ptls_states(); assert(declarations && "Capturing declarations is always required"); @@ -5101,7 +5101,7 @@ static Function *jlcall_func_to_llvm(const std::string &cname, jl_fptr_t addr, M return f; } -extern "C" void jl_fptr_to_llvm(jl_fptr_t fptr, jl_lambda_info_t *lam, int specsig) +extern "C" void jl_fptr_to_llvm(jl_fptr_t fptr, jl_method_instance_t *lam, int specsig) { if (imaging_mode) { if (!specsig) { diff --git a/src/debuginfo.cpp b/src/debuginfo.cpp index 418159b789afb..3ec064ee0f182 100644 --- a/src/debuginfo.cpp +++ b/src/debuginfo.cpp @@ -86,7 +86,7 @@ struct FuncInfo { const Function *func; size_t lengthAdr; std::vector lines; - jl_lambda_info_t *linfo; + jl_method_instance_t *linfo; }; #else struct ObjectInfo { @@ -105,7 +105,7 @@ struct ObjectInfo { // Maintain a mapping of unrealized function names -> linfo objects // so that when we see it get emitted, we can add a link back to the linfo // that it came from (providing name, type signature, file info, etc.) -static StringMap linfo_in_flight; +static StringMap linfo_in_flight; static std::string mangle(const std::string &Name, const DataLayout &DL) { #if defined(USE_MCJIT) || defined(USE_ORCJIT) @@ -119,7 +119,7 @@ static std::string mangle(const std::string &Name, const DataLayout &DL) return Name; #endif } -void jl_add_linfo_in_flight(StringRef name, jl_lambda_info_t *linfo, const DataLayout &DL) +void jl_add_linfo_in_flight(StringRef name, jl_method_instance_t *linfo, const DataLayout &DL) { linfo_in_flight[mangle(name, DL)] = linfo; } @@ -216,14 +216,14 @@ struct strrefcomp { #endif extern "C" tracer_cb jl_linfo_tracer; -static std::vector triggered_linfos; +static std::vector triggered_linfos; void jl_callback_triggered_linfos(void) { if (triggered_linfos.empty()) return; if (jl_linfo_tracer) { - std::vector to_process(std::move(triggered_linfos)); - for (jl_lambda_info_t *linfo : to_process) + std::vector to_process(std::move(triggered_linfos)); + for (jl_method_instance_t *linfo : to_process) jl_call_tracer(jl_linfo_tracer, (jl_value_t*)linfo); } } @@ -234,7 +234,7 @@ class JuliaJITEventListener: public JITEventListener std::map info; #else std::map objectmap; - std::map, revcomp> linfomap; + std::map, revcomp> linfomap; #endif public: @@ -251,8 +251,8 @@ class JuliaJITEventListener: public JITEventListener int8_t gc_state = jl_gc_safe_enter(ptls); uv_rwlock_wrlock(&threadsafe); StringRef sName = F.getName(); - StringMap::iterator linfo_it = linfo_in_flight.find(sName); - jl_lambda_info_t *linfo = NULL; + StringMap::iterator linfo_it = linfo_in_flight.find(sName); + jl_method_instance_t *linfo = NULL; if (linfo_it != linfo_in_flight.end()) { linfo = linfo_it->second; linfo_in_flight.erase(linfo_it); @@ -285,7 +285,7 @@ class JuliaJITEventListener: public JITEventListener #endif // ifndef USE_MCJIT #ifdef USE_MCJIT - jl_lambda_info_t *lookupLinfo(size_t pointer) + jl_method_instance_t *lookupLinfo(size_t pointer) { auto linfo = linfomap.lower_bound(pointer); if (linfo != linfomap.end() && pointer < linfo->first + linfo->second.first) @@ -485,8 +485,8 @@ class JuliaJITEventListener: public JITEventListener (uint8_t*)(uintptr_t)Addr, (size_t)Size, sName, (uint8_t*)(uintptr_t)SectionLoadAddr, (size_t)SectionSize, UnwindData); #endif - StringMap::iterator linfo_it = linfo_in_flight.find(sName); - jl_lambda_info_t *linfo = NULL; + StringMap::iterator linfo_it = linfo_in_flight.find(sName); + jl_method_instance_t *linfo = NULL; if (linfo_it != linfo_in_flight.end()) { linfo = linfo_it->second; if (linfo->compile_traced) @@ -570,8 +570,8 @@ class JuliaJITEventListener: public JITEventListener (uint8_t*)(uintptr_t)Addr, (size_t)Size, sName, (uint8_t*)(uintptr_t)SectionLoadAddr, (size_t)SectionSize, UnwindData); #endif - StringMap::iterator linfo_it = linfo_in_flight.find(sName); - jl_lambda_info_t *linfo = NULL; + StringMap::iterator linfo_it = linfo_in_flight.find(sName); + jl_method_instance_t *linfo = NULL; if (linfo_it != linfo_in_flight.end()) { linfo = linfo_it->second; linfo_in_flight.erase(linfo_it); @@ -963,9 +963,9 @@ openDebugInfo(StringRef debuginfopath, const debug_link_info &info) static uint64_t jl_sysimage_base; static void **sysimg_fvars; -static jl_lambda_info_t **sysimg_fvars_linfo; +static jl_method_instance_t **sysimg_fvars_linfo; static size_t sysimg_fvars_n; -extern "C" void jl_register_fptrs(uint64_t sysimage_base, void **fptrs, jl_lambda_info_t **linfos, size_t n) +extern "C" void jl_register_fptrs(uint64_t sysimage_base, void **fptrs, jl_method_instance_t **linfos, size_t n) { jl_sysimage_base = (uintptr_t)sysimage_base; sysimg_fvars = fptrs; @@ -1563,12 +1563,12 @@ int jl_getFunctionInfo(jl_frame_t **frames_out, size_t pointer, int skipC, int n return jl_getDylibFunctionInfo(frames_out, pointer, skipC, noInline); } -extern "C" jl_lambda_info_t *jl_gdblookuplinfo(void *p) +extern "C" jl_method_instance_t *jl_gdblookuplinfo(void *p) { #ifndef USE_MCJIT std::map &info = jl_jit_events->getMap(); std::map::iterator it = info.lower_bound((size_t)p); - jl_lambda_info_t *li = NULL; + jl_method_instance_t *li = NULL; if (it != info.end() && (uintptr_t)(*it).first + (*it).second.lengthAdr >= (uintptr_t)p) li = (*it).second.linfo; uv_rwlock_rdunlock(&threadsafe); diff --git a/src/dump.c b/src/dump.c index 71c5956ce3e72..9a8dba06a150a 100644 --- a/src/dump.c +++ b/src/dump.c @@ -103,7 +103,7 @@ typedef enum _DUMP_MODES { MODE_INVALID = 0, // jl_uncompress_ast - // compressing / decompressing an AST Expr in a LambdaInfo + // compressing / decompressing an AST Expr in a MethodInstance MODE_AST, // jl_restore_system_image @@ -384,7 +384,7 @@ static void jl_deserialize_gv_others(jl_serializer_state *s) } static struct delayed_fptrs_t { - jl_lambda_info_t *li; + jl_method_instance_t *li; int32_t func; int32_t cfunc; } *delayed_fptrs = NULL; @@ -392,7 +392,7 @@ static size_t delayed_fptrs_n = 0; static size_t delayed_fptrs_max = 0; static size_t sysimg_fvars_max = 0; -static void jl_delayed_fptrs(jl_lambda_info_t *li, int32_t func, int32_t cfunc) +static void jl_delayed_fptrs(jl_method_instance_t *li, int32_t func, int32_t cfunc) { // can't restore the fptrs until after the system image is fully restored, // since it will try to decompress the function AST to determine the argument types @@ -416,7 +416,7 @@ static void jl_delayed_fptrs(jl_lambda_info_t *li, int32_t func, int32_t cfunc) } } -void jl_register_fptrs(uint64_t sysimage_base, void **fptrs, jl_lambda_info_t **linfos, size_t n); +void jl_register_fptrs(uint64_t sysimage_base, void **fptrs, jl_method_instance_t **linfos, size_t n); static void jl_update_all_fptrs(void) { @@ -428,9 +428,9 @@ static void jl_update_all_fptrs(void) sysimg_gvars = NULL; sysimg_fvars = NULL; size_t i; - jl_lambda_info_t **linfos = (jl_lambda_info_t**)malloc(sizeof(jl_lambda_info_t*) * sysimg_fvars_max); + jl_method_instance_t **linfos = (jl_method_instance_t**)malloc(sizeof(jl_method_instance_t*) * sysimg_fvars_max); for (i = 0; i < delayed_fptrs_n; i++) { - jl_lambda_info_t *li = delayed_fptrs[i].li; + jl_method_instance_t *li = delayed_fptrs[i].li; int32_t func = delayed_fptrs[i].func - 1; if (func >= 0) { jl_fptr_to_llvm((jl_fptr_t)fvars[func], li, 0); @@ -906,9 +906,9 @@ static void jl_serialize_value_(jl_serializer_state *s, jl_value_t *v) jl_serialize_value(s, (jl_value_t*)m->invokes.unknown); write_int8(s->s, m->needs_sparam_vals_ducttape); } - else if (jl_is_lambda_info(v)) { - writetag(s->s, jl_lambda_info_type); - jl_lambda_info_t *li = (jl_lambda_info_t*)v; + else if (jl_is_method_instance(v)) { + writetag(s->s, jl_method_instance_type); + jl_method_instance_t *li = (jl_method_instance_t*)v; jl_serialize_value(s, (jl_value_t*)li->specTypes); if (s->mode == MODE_MODULE || s->mode == MODE_MODULE_POSTWORK) { int external = li->def && !module_in_worklist(li->def->module); @@ -1544,10 +1544,10 @@ static jl_value_t *jl_deserialize_value_(jl_serializer_state *s, jl_value_t *vta m->roots = (jl_array_t*)jl_deserialize_value(s, (jl_value_t**)&m->roots); if (m->roots) jl_gc_wb(m, m->roots); - m->source = (jl_source_info_t*)jl_deserialize_value(s, (jl_value_t**)&m->source); + m->source = (jl_code_info_t*)jl_deserialize_value(s, (jl_value_t**)&m->source); if (m->source) jl_gc_wb(m, m->source); - m->unspecialized = (jl_lambda_info_t*)jl_deserialize_value(s, (jl_value_t**)&m->unspecialized); + m->unspecialized = (jl_method_instance_t*)jl_deserialize_value(s, (jl_value_t**)&m->unspecialized); if (m->unspecialized) jl_gc_wb(m, m->unspecialized); m->invokes.unknown = jl_deserialize_value(s, (jl_value_t**)&m->invokes); @@ -1557,11 +1557,11 @@ static jl_value_t *jl_deserialize_value_(jl_serializer_state *s, jl_value_t *vta JL_MUTEX_INIT(&m->writelock); return (jl_value_t*)m; } - else if (vtag == (jl_value_t*)jl_lambda_info_type) { - jl_lambda_info_t *li = - (jl_lambda_info_t*)jl_gc_alloc(ptls, sizeof(jl_lambda_info_t), - jl_lambda_info_type); - memset(li, 0, sizeof(jl_lambda_info_t)); + else if (vtag == (jl_value_t*)jl_method_instance_type) { + jl_method_instance_t *li = + (jl_method_instance_t*)jl_gc_alloc(ptls, sizeof(jl_method_instance_t), + jl_method_instance_type); + memset(li, 0, sizeof(jl_method_instance_t)); uintptr_t pos = backref_list.len; if (usetable) arraylist_push(&backref_list, li); @@ -2433,9 +2433,9 @@ static void jl_recache_types(void) int offs = (int)(intptr_t)flagref_list.items[i++]; jl_value_t *v, *o = loc ? *loc : (jl_value_t*)backref_list.items[offs]; jl_datatype_t *dt, *t; - if (jl_is_lambda_info(o)) { - // lookup the real LambdaInfo based on the placeholder specTypes - jl_lambda_info_t *li = (jl_lambda_info_t*)o; + if (jl_is_method_instance(o)) { + // lookup the real MethodInstance based on the placeholder specTypes + jl_method_instance_t *li = (jl_method_instance_t*)o; jl_datatype_t *argtypes = jl_recache_type(li->specTypes, i, NULL); jl_datatype_t *ftype = jl_first_argument_datatype((jl_value_t*)argtypes); jl_methtable_t *mt = ftype->name->mt; @@ -2608,7 +2608,7 @@ void jl_init_serializer(void) (void*)LongExpr_tag, (void*)LiteralVal_tag, (void*)SmallInt64_tag, (void*)SmallDataType_tag, (void*)Int32_tag, (void*)Array1d_tag, (void*)Singleton_tag, - jl_module_type, jl_tvar_type, jl_lambda_info_type, jl_method_type, + jl_module_type, jl_tvar_type, jl_method_instance_type, jl_method_type, (void*)CommonSym_tag, (void*)NearbyGlobal_tag, jl_globalref_type, // everything above here represents a class of object rather than only a literal @@ -2658,7 +2658,7 @@ void jl_init_serializer(void) jl_type_type, jl_bottom_type, jl_ref_type, jl_pointer_type, jl_vararg_type, jl_abstractarray_type, jl_densearray_type, jl_void_type, jl_function_type, - jl_typector_type, jl_typename_type, jl_builtin_type, jl_source_info_type, + jl_typector_type, jl_typename_type, jl_builtin_type, jl_code_info_type, jl_task_type, jl_uniontype_type, jl_typetype_type, jl_typetype_tvar, jl_ANY_flag, jl_array_any_type, jl_intrinsic_type, jl_abstractslot_type, jl_methtable_type, jl_typemap_level_type, jl_typemap_entry_type, @@ -2671,7 +2671,7 @@ void jl_init_serializer(void) jl_expr_type->name, jl_typename_type->name, jl_type_type->name, jl_methtable_type->name, jl_typemap_level_type->name, jl_typemap_entry_type->name, jl_tvar_type->name, jl_abstractarray_type->name, jl_vararg_type->name, - jl_densearray_type->name, jl_void_type->name, jl_lambda_info_type->name, jl_method_type->name, + jl_densearray_type->name, jl_void_type->name, jl_method_instance_type->name, jl_method_type->name, jl_module_type->name, jl_function_type->name, jl_typedslot_type->name, jl_abstractslot_type->name, jl_slotnumber_type->name, jl_typector_type->name, jl_intrinsic_type->name, jl_task_type->name, diff --git a/src/gf.c b/src/gf.c index 2112280fb1ece..4c82b1aec4c69 100644 --- a/src/gf.c +++ b/src/gf.c @@ -24,7 +24,7 @@ extern "C" { #endif -JL_DLLEXPORT jl_value_t *jl_invoke(jl_lambda_info_t *meth, jl_value_t **args, uint32_t nargs) +JL_DLLEXPORT jl_value_t *jl_invoke(jl_method_instance_t *meth, jl_value_t **args, uint32_t nargs) { return jl_call_method_internal(meth, args, nargs); } @@ -49,20 +49,20 @@ JL_DLLEXPORT void jl_untrace_method(jl_method_t *m) m->traced = 0; } -JL_DLLEXPORT void jl_trace_linfo(jl_lambda_info_t *linfo) +JL_DLLEXPORT void jl_trace_linfo(jl_method_instance_t *linfo) { - assert(jl_is_lambda_info(linfo)); + assert(jl_is_method_instance(linfo)); linfo->compile_traced = 1; } -JL_DLLEXPORT void jl_untrace_linfo(jl_lambda_info_t *linfo) +JL_DLLEXPORT void jl_untrace_linfo(jl_method_instance_t *linfo) { - assert(jl_is_lambda_info(linfo)); + assert(jl_is_method_instance(linfo)); linfo->compile_traced = 0; } static tracer_cb jl_method_tracer = NULL; -JL_DLLEXPORT void jl_register_method_tracer(void (*callback)(jl_lambda_info_t *tracee)) +JL_DLLEXPORT void jl_register_method_tracer(void (*callback)(jl_method_instance_t *tracee)) { jl_method_tracer = (tracer_cb)callback; } @@ -74,7 +74,7 @@ JL_DLLEXPORT void jl_register_newmeth_tracer(void (*callback)(jl_method_t *trace } tracer_cb jl_linfo_tracer = NULL; -JL_DLLEXPORT void jl_register_linfo_tracer(void (*callback)(jl_lambda_info_t *tracee)) +JL_DLLEXPORT void jl_register_linfo_tracer(void (*callback)(jl_method_instance_t *tracee)) { jl_linfo_tracer = (tracer_cb)callback; } @@ -103,7 +103,7 @@ const struct jl_typemap_info method_defs = { 0, &jl_method_type }; const struct jl_typemap_info lambda_cache = { - 0, &jl_lambda_info_type + 0, &jl_method_instance_type }; const struct jl_typemap_info tfunc_cache = { 1, &jl_any_type @@ -116,16 +116,16 @@ static int8_t jl_cachearg_offset(jl_methtable_t *mt) /// ----- Insertion logic for special entries ----- /// -// get or create the LambdaInfo for a specialization -JL_DLLEXPORT jl_lambda_info_t *jl_specializations_get_linfo(jl_method_t *m, jl_tupletype_t *type, jl_svec_t *sparams) +// get or create the MethodInstance for a specialization +JL_DLLEXPORT jl_method_instance_t *jl_specializations_get_linfo(jl_method_t *m, jl_tupletype_t *type, jl_svec_t *sparams) { JL_LOCK(&m->writelock); jl_typemap_entry_t *sf = jl_typemap_assoc_by_type(m->specializations, type, NULL, 2, /*subtype*/0, /*offs*/0); - if (sf && jl_is_lambda_info(sf->func.value)) { + if (sf && jl_is_method_instance(sf->func.value)) { JL_UNLOCK(&m->writelock); - return (jl_lambda_info_t*)sf->func.value; + return (jl_method_instance_t*)sf->func.value; } - jl_lambda_info_t *li = jl_get_specialized(m, type, sparams); + jl_method_instance_t *li = jl_get_specialized(m, type, sparams); JL_GC_PUSH1(&li); // TODO: fuse lookup and insert steps jl_typemap_insert(&m->specializations, (jl_value_t*)m, type, jl_emptysvec, NULL, jl_emptysvec, (jl_value_t*)li, 0, &tfunc_cache, NULL); @@ -150,7 +150,7 @@ JL_DLLEXPORT jl_value_t *jl_methtable_lookup(jl_methtable_t *mt, jl_tupletype_t return sf->func.value; } -// ----- LambdaInfo specialization instantiation ----- // +// ----- MethodInstance specialization instantiation ----- // JL_DLLEXPORT jl_method_t *jl_new_method_uninit(void); static jl_function_t *jl_new_generic_function_with_supertype(jl_sym_t *name, jl_module_t *module, jl_datatype_t *st, int iskw); @@ -162,7 +162,7 @@ void jl_mk_builtin_func(jl_datatype_t *dt, const char *name, jl_fptr_t fptr) jl_set_const(jl_core_module, sname, f); dt = (jl_datatype_t*)jl_typeof(f); } - jl_lambda_info_t *li = jl_new_lambda_info_uninit(); + jl_method_instance_t *li = jl_new_method_instance_uninit(); li->fptr = fptr; li->jlcall_api = 1; li->specTypes = jl_anytuple_type; @@ -183,7 +183,7 @@ void jl_mk_builtin_func(jl_datatype_t *dt, const char *name, jl_fptr_t fptr) // run type inference on lambda "li" for given argument types. // returns the inferred source, and may cache the result in li // if inference doesn't occur (or can't finish), returns NULL instead -jl_source_info_t *jl_type_infer(jl_lambda_info_t *li, int force) +jl_code_info_t *jl_type_infer(jl_method_instance_t *li, int force) { JL_TIMING(INFERENCE); if (jl_typeinf_func == NULL) @@ -194,7 +194,7 @@ jl_source_info_t *jl_type_infer(jl_lambda_info_t *li, int force) mod = li->def->module; static int inInference = 0; int lastIn = inInference; - jl_source_info_t *src = NULL; + jl_code_info_t *src = NULL; inInference = 1; if (force || (mod != jl_gf_mtable(jl_typeinf_func)->module && @@ -208,7 +208,7 @@ jl_source_info_t *jl_type_infer(jl_lambda_info_t *li, int force) jl_static_show_func_sig(JL_STDERR, (jl_value_t*)li->specTypes); jl_printf(JL_STDERR, "\n"); #endif - src = (jl_source_info_t *)jl_apply(fargs, 2); + src = (jl_code_info_t *)jl_apply(fargs, 2); if (src == (void*)jl_nothing) src = NULL; assert(li->def || li->inInference == 0); // if this is toplevel expr, make sure inference finished @@ -218,7 +218,7 @@ jl_source_info_t *jl_type_infer(jl_lambda_info_t *li, int force) return src; } -JL_DLLEXPORT void jl_set_lambda_rettype(jl_lambda_info_t *li, jl_value_t *rettype, jl_value_t *const_api, jl_value_t *inferred) +JL_DLLEXPORT void jl_set_lambda_rettype(jl_method_instance_t *li, jl_value_t *rettype, jl_value_t *const_api, jl_value_t *inferred) { // changing rettype changes the llvm signature, // so clear all of the llvm state at the same time @@ -234,18 +234,18 @@ JL_DLLEXPORT void jl_set_lambda_rettype(jl_lambda_info_t *li, jl_value_t *rettyp li->jlcall_api = 2; } -static int jl_is_uninferred(jl_lambda_info_t *li) +static int jl_is_uninferred(jl_method_instance_t *li) { if (!li->inferred) return 1; - if (jl_is_source_info(li->inferred) && !((jl_source_info_t*)li->inferred)->inferred) + if (jl_is_code_info(li->inferred) && !((jl_code_info_t*)li->inferred)->inferred) return 1; return 0; } static int get_spec_unspec_list(jl_typemap_entry_t *l, void *closure) { - if (jl_is_lambda_info(l->func.value) && jl_is_uninferred(l->func.linfo)) + if (jl_is_method_instance(l->func.value) && jl_is_uninferred(l->func.linfo)) jl_array_ptr_1d_push((jl_array_t*)closure, l->func.value); return 1; } @@ -299,7 +299,7 @@ JL_DLLEXPORT void jl_set_typeinf_func(jl_value_t *f) jl_reset_mt_caches(jl_main_module, unspec); size_t i, l; for (i = 0, l = jl_array_len(unspec); i < l; i++) { - jl_lambda_info_t *li = (jl_lambda_info_t*)jl_array_ptr_ref(unspec, i); + jl_method_instance_t *li = (jl_method_instance_t*)jl_array_ptr_ref(unspec, i); if (jl_is_uninferred(li)) jl_type_infer(li, 1); } @@ -609,7 +609,7 @@ JL_DLLEXPORT int jl_is_cacheable_sig( return 1; } -static jl_lambda_info_t *cache_method(jl_methtable_t *mt, union jl_typemap_t *cache, jl_value_t *parent, +static jl_method_instance_t *cache_method(jl_methtable_t *mt, union jl_typemap_t *cache, jl_value_t *parent, jl_tupletype_t *type, // the specialized type signature for type lambda jl_tupletype_t *tt, // the original tupletype of the signature jl_typemap_entry_t *m, @@ -622,7 +622,7 @@ static jl_lambda_info_t *cache_method(jl_methtable_t *mt, union jl_typemap_t *ca jl_value_t *temp = NULL; jl_value_t *temp2 = NULL; jl_value_t *temp3 = NULL; - jl_lambda_info_t *newmeth = NULL; + jl_method_instance_t *newmeth = NULL; jl_svec_t *newparams = NULL; JL_GC_PUSH5(&temp, &temp2, &temp3, &newmeth, &newparams); @@ -806,7 +806,7 @@ static jl_lambda_info_t *cache_method(jl_methtable_t *mt, union jl_typemap_t *ca return newmeth; } -static jl_lambda_info_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype_t *tt, int cache, int inexact, int allow_exec) +static jl_method_instance_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype_t *tt, int cache, int inexact, int allow_exec) { // caller must hold the mt->writelock jl_typemap_entry_t *entry = NULL; @@ -827,7 +827,7 @@ static jl_lambda_info_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype_t * return NULL; } sig = join_tsig(tt, entry->sig); - jl_lambda_info_t *nf; + jl_method_instance_t *nf; if (!cache) { nf = jl_get_specialized(m, sig, env); // TODO: should be jl_specializations_get_linfo } @@ -1145,7 +1145,7 @@ jl_tupletype_t *arg_type_tuple(jl_value_t **args, size_t nargs) return tt; } -jl_lambda_info_t *jl_method_lookup_by_type(jl_methtable_t *mt, jl_tupletype_t *types, +jl_method_instance_t *jl_method_lookup_by_type(jl_methtable_t *mt, jl_tupletype_t *types, int cache, int inexact, int allow_exec) { jl_typemap_entry_t *entry = jl_typemap_assoc_by_type(mt->cache, types, NULL, 0, 1, jl_cachearg_offset(mt)); @@ -1159,7 +1159,7 @@ jl_lambda_info_t *jl_method_lookup_by_type(jl_methtable_t *mt, jl_tupletype_t *t } if (jl_is_leaf_type((jl_value_t*)types)) cache = 1; - jl_lambda_info_t *sf = jl_mt_assoc_by_type(mt, types, cache, inexact, allow_exec); + jl_method_instance_t *sf = jl_mt_assoc_by_type(mt, types, cache, inexact, allow_exec); if (cache) { JL_UNLOCK(&mt->writelock); } @@ -1176,7 +1176,7 @@ JL_DLLEXPORT int jl_method_exists(jl_methtable_t *mt, jl_tupletype_t *types) return jl_method_lookup_by_type(mt, types, 0, 0, 1) != NULL; } -jl_lambda_info_t *jl_method_lookup(jl_methtable_t *mt, jl_value_t **args, size_t nargs, int cache) +jl_method_instance_t *jl_method_lookup(jl_methtable_t *mt, jl_value_t **args, size_t nargs, int cache) { jl_typemap_entry_t *entry = jl_typemap_assoc_exact(mt->cache, args, nargs, jl_cachearg_offset(mt)); if (entry) @@ -1189,7 +1189,7 @@ jl_lambda_info_t *jl_method_lookup(jl_methtable_t *mt, jl_value_t **args, size_t return entry->func.linfo; } jl_tupletype_t *tt = arg_type_tuple(args, nargs); - jl_lambda_info_t *sf = NULL; + jl_method_instance_t *sf = NULL; JL_GC_PUSH2(&tt, &sf); sf = jl_mt_assoc_by_type(mt, tt, cache, 0, 1); if (cache) { @@ -1206,7 +1206,7 @@ jl_lambda_info_t *jl_method_lookup(jl_methtable_t *mt, jl_value_t **args, size_t JL_DLLEXPORT jl_value_t *jl_matching_methods(jl_tupletype_t *types, int lim, int include_ambiguous); -jl_llvm_functions_t jl_compile_for_dispatch(jl_lambda_info_t *li) +jl_llvm_functions_t jl_compile_for_dispatch(jl_method_instance_t *li) { if (li->jlcall_api == 2) return li->functionObjectsDecls; @@ -1241,7 +1241,7 @@ jl_llvm_functions_t jl_compile_for_dispatch(jl_lambda_info_t *li) if (decls.functionObject != NULL || li->jlcall_api == 2) return decls; - jl_source_info_t *src = NULL; + jl_code_info_t *src = NULL; if (li->def && jl_is_uninferred(li) && !li->inInference && jl_symbol_name(li->def->name)[0] != '@') { // don't bother with typeinf on macros or toplevel thunks @@ -1256,7 +1256,7 @@ jl_llvm_functions_t jl_compile_for_dispatch(jl_lambda_info_t *li) } // compile-time method lookup -jl_lambda_info_t *jl_get_specialization1(jl_tupletype_t *types) +jl_method_instance_t *jl_get_specialization1(jl_tupletype_t *types) { JL_TIMING(METHOD_LOOKUP_COMPILE); assert(jl_nparams(types) > 0); @@ -1283,7 +1283,7 @@ jl_lambda_info_t *jl_get_specialization1(jl_tupletype_t *types) // most of the time sf is rooted in mt, but if the method is staged it may // not be the case // TODO: the above should be false, but better safe than sorry? - jl_lambda_info_t *sf = jl_method_lookup_by_type(mt, types, 1, 1, 1); + jl_method_instance_t *sf = jl_method_lookup_by_type(mt, types, 1, 1, 1); JL_GC_PUSH1(&sf); if (sf != NULL && jl_has_call_ambiguities(types, sf->def)) { sf = NULL; @@ -1294,10 +1294,10 @@ jl_lambda_info_t *jl_get_specialization1(jl_tupletype_t *types) JL_DLLEXPORT int jl_compile_hint(jl_tupletype_t *types) { - jl_lambda_info_t *li = jl_get_specialization1(types); + jl_method_instance_t *li = jl_get_specialization1(types); if (li == NULL) return 0; - jl_source_info_t *src = NULL; + jl_code_info_t *src = NULL; if (jl_is_uninferred(li)) src = jl_type_infer(li, 0); if (li->jlcall_api != 2) @@ -1307,7 +1307,7 @@ JL_DLLEXPORT int jl_compile_hint(jl_tupletype_t *types) JL_DLLEXPORT jl_value_t *jl_get_spec_lambda(jl_tupletype_t *types) { - jl_lambda_info_t *li = jl_get_specialization1(types); + jl_method_instance_t *li = jl_get_specialization1(types); return li ? (jl_value_t*)li : jl_nothing; } @@ -1508,15 +1508,15 @@ static void _compile_all_deq(jl_array_t *found) { int found_i, found_l = jl_array_len(found); jl_printf(JL_STDERR, "found %d uncompiled methods for compile-all\n", (int)found_l); - jl_lambda_info_t *linfo = NULL; - jl_source_info_t *src = NULL; + jl_method_instance_t *linfo = NULL; + jl_code_info_t *src = NULL; JL_GC_PUSH2(&linfo, &src); for (found_i = 0; found_i < found_l; found_i++) { if (found_i % (1 + found_l / 300) == 0 || found_i == found_l - 1) // show 300 progress steps, to show progress without overwhelming log files jl_printf(JL_STDERR, " %d / %d\r", found_i + 1, found_l); jl_typemap_entry_t *ml = (jl_typemap_entry_t*)jl_array_ptr_ref(found, found_i); jl_method_t *m = ml->func.method; - jl_lambda_info_t *linfo = m->unspecialized; + jl_method_instance_t *linfo = m->unspecialized; if (!linfo) { // XXX: use computed env rather than empty svec linfo = jl_specializations_get_linfo(m, ml->sig, jl_emptysvec); @@ -1567,7 +1567,7 @@ static int _compile_all_enq(jl_typemap_entry_t *ml, void *env) static void _compile_all_enq_module(jl_module_t *m, jl_array_t *found) { // scan through all types reachable from 'v' and - // record all jl_lambda_info_t objects and signatures in their method tables + // record all jl_method_instance_t objects and signatures in their method tables size_t i, sz = m->bindings.size; for(i=1; i < sz; i+=2) { if (m->bindings.table[i] != HT_NOTFOUND) { @@ -1598,7 +1598,7 @@ static void _compile_all_enq_module(jl_module_t *m, jl_array_t *found) static void jl_compile_all_defs(void) { // this "found" array will contain - // TypeMapEntries for Methods and LambdaInfos that need to be compiled + // TypeMapEntries for Methods and MethodInstances that need to be compiled jl_array_t *m = jl_alloc_vec_any(0); JL_GC_PUSH1(&m); while (1) { @@ -1614,7 +1614,7 @@ static void jl_compile_all_defs(void) static int _precompile_enq_tfunc(jl_typemap_entry_t *l, void *closure) { - if (jl_is_lambda_info(l->func.value) && + if (jl_is_method_instance(l->func.value) && l->func.linfo->functionObjectsDecls.functionObject == NULL && l->func.linfo->jlcall_api != 2) jl_array_ptr_1d_push((jl_array_t*)closure, (jl_value_t*)l->sig); @@ -1816,7 +1816,7 @@ JL_DLLEXPORT jl_value_t *jl_apply_generic(jl_value_t **args, uint32_t nargs) } } - jl_lambda_info_t *mfunc = NULL; + jl_method_instance_t *mfunc = NULL; if (entry) { mfunc = entry->func.linfo; } @@ -1894,7 +1894,7 @@ jl_value_t *jl_gf_invoke(jl_tupletype_t *types0, jl_value_t **args, size_t nargs // next look for or create a specialization of this definition. jl_method_t *method = entry->func.method; - jl_lambda_info_t *mfunc = NULL; + jl_method_instance_t *mfunc = NULL; jl_typemap_entry_t *tm = NULL; if (method->invokes.unknown != NULL) tm = jl_typemap_assoc_exact(method->invokes, args, nargs, jl_cachearg_offset(mt)); diff --git a/src/interpreter.c b/src/interpreter.c index 7205c7bfc9001..c04fac2498c43 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -15,7 +15,7 @@ extern "C" { #endif typedef struct { - jl_source_info_t *src; + jl_code_info_t *src; jl_module_t *module; jl_value_t **locals; jl_svec_t *sparam_vals; @@ -33,7 +33,7 @@ jl_value_t *jl_interpret_toplevel_expr(jl_value_t *e) } JL_DLLEXPORT jl_value_t *jl_interpret_toplevel_expr_in(jl_module_t *m, jl_value_t *e, - jl_source_info_t *src, + jl_code_info_t *src, jl_svec_t *sparam_vals) { jl_ptls_t ptls = jl_get_ptls_states(); @@ -80,8 +80,8 @@ static jl_value_t *do_invoke(jl_value_t **args, size_t nargs, interpreter_state size_t i; for (i = 1; i < nargs; i++) argv[i - 1] = eval(args[i], s); - jl_lambda_info_t *meth = (jl_lambda_info_t*)args[0]; - assert(jl_is_lambda_info(meth) && !meth->inInference); + jl_method_instance_t *meth = (jl_method_instance_t*)args[0]; + assert(jl_is_method_instance(meth) && !meth->inInference); jl_value_t *result = jl_call_method_internal(meth, argv, nargs - 1); JL_GC_POP(); return result; @@ -155,12 +155,12 @@ void jl_set_datatype_super(jl_datatype_t *tt, jl_value_t *super) jl_gc_wb(tt, tt->super); } -static int jl_source_nslots(jl_source_info_t *src) +static int jl_source_nslots(jl_code_info_t *src) { return jl_array_len(src->slotflags); } -static int jl_source_nssavalues(jl_source_info_t *src) +static int jl_source_nssavalues(jl_code_info_t *src) { return jl_is_long(src->ssavaluetypes) ? jl_unbox_long(src->ssavaluetypes) : jl_array_len(src->ssavaluetypes); } @@ -168,7 +168,7 @@ static int jl_source_nssavalues(jl_source_info_t *src) static jl_value_t *eval(jl_value_t *e, interpreter_state *s) { jl_ptls_t ptls = jl_get_ptls_states(); - jl_source_info_t *src = s==NULL ? NULL : s->src; + jl_code_info_t *src = s==NULL ? NULL : s->src; if (jl_is_ssavalue(e)) { ssize_t id = ((jl_ssavalue_t*)e)->id; if (id >= jl_source_nssavalues(src) || id < 0 || s->locals == NULL) @@ -266,7 +266,7 @@ static jl_value_t *eval(jl_value_t *e, interpreter_state *s) JL_GC_PUSH2(&atypes, &meth); atypes = eval(args[1], s); meth = eval(args[2], s); - jl_method_def((jl_svec_t*)atypes, (jl_source_info_t*)meth, args[3]); + jl_method_def((jl_svec_t*)atypes, (jl_code_info_t*)meth, args[3]); JL_GC_POP(); return jl_nothing; } @@ -570,9 +570,9 @@ static jl_value_t *eval_body(jl_array_t *stmts, interpreter_state *s, int start, return NULL; } -jl_value_t *jl_interpret_call(jl_lambda_info_t *lam, jl_value_t **args, uint32_t nargs) +jl_value_t *jl_interpret_call(jl_method_instance_t *lam, jl_value_t **args, uint32_t nargs) { - jl_source_info_t *src = lam->inferred; + jl_code_info_t *src = lam->inferred; if (src == NULL) src = lam->def->source; jl_array_t *stmts = src->code; @@ -597,7 +597,7 @@ jl_value_t *jl_interpret_call(jl_lambda_info_t *lam, jl_value_t **args, uint32_t return r; } -jl_value_t *jl_interpret_toplevel_thunk(jl_source_info_t *src) +jl_value_t *jl_interpret_toplevel_thunk(jl_code_info_t *src) { jl_ptls_t ptls = jl_get_ptls_states(); jl_array_t *stmts = src->code; diff --git a/src/jltypes.c b/src/jltypes.c index 75316ce67f8ae..a5f6fa6bd82a3 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -3851,8 +3851,8 @@ void jl_init_types(void) jl_svecset(jl_typename_type->types, 1, jl_module_type); jl_svecset(jl_methtable_type->types, 5, jl_module_type); - jl_source_info_type = - jl_new_datatype(jl_symbol("SourceInfo"), + jl_code_info_type = + jl_new_datatype(jl_symbol("CodeInfo"), jl_any_type, jl_emptysvec, jl_svec(9, jl_symbol("code"), @@ -3908,8 +3908,8 @@ void jl_init_types(void) jl_any_type, // Union{Array, Void} jl_any_type, jl_simplevector_type, - jl_source_info_type, - jl_any_type, // jl_lambda_info_type + jl_code_info_type, + jl_any_type, // jl_method_instance_type jl_array_any_type, jl_any_type, jl_int32_type, @@ -3919,8 +3919,8 @@ void jl_init_types(void) jl_bool_type), 0, 1, 9); - jl_lambda_info_type = - jl_new_datatype(jl_symbol("LambdaInfo"), + jl_method_instance_type = + jl_new_datatype(jl_symbol("MethodInstance"), jl_any_type, jl_emptysvec, jl_svec(12, jl_symbol("specTypes"), @@ -4007,11 +4007,11 @@ void jl_init_types(void) jl_svecset(jl_methtable_type->types, 6, jl_int32_type); // DWORD #endif jl_svecset(jl_methtable_type->types, 7, jl_int32_type); // uint32_t - jl_svecset(jl_method_type->types, 10, jl_lambda_info_type); - jl_svecset(jl_lambda_info_type->types, 8, jl_voidpointer_type); - jl_svecset(jl_lambda_info_type->types, 9, jl_voidpointer_type); - jl_svecset(jl_lambda_info_type->types, 10, jl_voidpointer_type); - jl_svecset(jl_lambda_info_type->types, 11, jl_voidpointer_type); + jl_svecset(jl_method_type->types, 10, jl_method_instance_type); + jl_svecset(jl_method_instance_type->types, 8, jl_voidpointer_type); + jl_svecset(jl_method_instance_type->types, 9, jl_voidpointer_type); + jl_svecset(jl_method_instance_type->types, 10, jl_voidpointer_type); + jl_svecset(jl_method_instance_type->types, 11, jl_voidpointer_type); jl_compute_field_offsets(jl_datatype_type); jl_compute_field_offsets(jl_typename_type); @@ -4024,7 +4024,7 @@ void jl_init_types(void) jl_compute_field_offsets(jl_gotonode_type); jl_compute_field_offsets(jl_quotenode_type); jl_compute_field_offsets(jl_module_type); - jl_compute_field_offsets(jl_lambda_info_type); + jl_compute_field_offsets(jl_method_instance_type); jl_compute_field_offsets(jl_typector_type); jl_compute_field_offsets(jl_simplevector_type); jl_compute_field_offsets(jl_sym_type); diff --git a/src/julia.h b/src/julia.h index 2026c41527300..0c72dd0dd0703 100644 --- a/src/julia.h +++ b/src/julia.h @@ -168,7 +168,7 @@ STATIC_INLINE int jl_array_ndimwords(uint32_t ndims) } typedef struct _jl_datatype_t jl_tupletype_t; -struct _jl_lambda_info_t; +struct _jl_method_instance_t; // TypeMap is an implicitly defined type // that can consist of any of the following nodes: @@ -188,7 +188,7 @@ union jl_typemap_t { // This defines the default ABI used by compiled julia functions. typedef jl_value_t *(*jl_fptr_t)(jl_value_t*, jl_value_t**, uint32_t); typedef jl_value_t *(*jl_fptr_sparam_t)(jl_svec_t*, jl_value_t*, jl_value_t**, uint32_t); -typedef jl_value_t *(*jl_fptr_linfo_t)(struct _jl_lambda_info_t*, jl_value_t**, uint32_t, jl_svec_t*); +typedef jl_value_t *(*jl_fptr_linfo_t)(struct _jl_method_instance_t*, jl_value_t**, uint32_t, jl_svec_t*); typedef struct { union { @@ -207,7 +207,7 @@ typedef struct _jl_llvm_functions_t { } jl_llvm_functions_t; // This type describes a single function body -typedef struct _jl_source_info_t { +typedef struct _jl_code_info_t { jl_array_t *code; // compressed uint8 array, or Any array of statements jl_value_t *slottypes; // types of variable slots (or `nothing`) jl_value_t *ssavaluetypes; // types of ssa values (or count of them) @@ -217,7 +217,7 @@ typedef struct _jl_source_info_t { uint8_t inlineable; uint8_t propagate_inbounds; uint8_t pure; -} jl_source_info_t; +} jl_code_info_t; // This type describes a single method definition, and stores data // shared by the specializations of a function. @@ -241,9 +241,9 @@ typedef struct _jl_method_t { // sparams are the symbols in the tvars vector jl_svec_t *sparam_syms; // the code AST template - jl_source_info_t *source; // null for builtins and staged functions + jl_code_info_t *source; // null for builtins and staged functions // unspecialized executable thunk (for isstaged, code for the generator), or null - struct _jl_lambda_info_t *unspecialized; + struct _jl_method_instance_t *unspecialized; jl_array_t *roots; // pointers in generated code (shared to reduce memory), or null // cache of specializations of this method for invoke(), i.e. @@ -267,12 +267,12 @@ typedef struct _jl_method_t { } jl_method_t; // This type caches the data for a specType signature specialization of a Method -typedef struct _jl_lambda_info_t { +typedef struct _jl_method_instance_t { JL_DATA_TYPE jl_tupletype_t *specTypes; // argument types this was specialized for jl_value_t *rettype; // return type for fptr jl_svec_t *sparam_vals; // the values for the tvars, indexed by def->sparam_syms - jl_value_t *inferred; // inferred jl_source_info_t, or value of the function if jlcall_api == 2, or null + jl_value_t *inferred; // inferred jl_code_info_t, or value of the function if jlcall_api == 2, or null jl_method_t *def; // method this is specialized from, null if this is a toplevel thunk uint8_t inInference; // flags to tell if inference is running on this function uint8_t jlcall_api; // the c-abi for fptr; 0 = jl_fptr_t, 1 = jl_fptr_sparam_t, 2 = constval @@ -285,7 +285,7 @@ typedef struct _jl_lambda_info_t { // with the same name as the generated functions for this linfo, suitable // for referencing in LLVM IR jl_llvm_functions_t functionObjectsDecls; -} jl_lambda_info_t; +} jl_method_instance_t; // all values are callable as Functions typedef jl_value_t jl_function_t; @@ -424,7 +424,7 @@ typedef struct _jl_typemap_entry_t { jl_svec_t *guardsigs; union { jl_value_t *value; - jl_lambda_info_t *linfo; // [nullable] for guard entries + jl_method_instance_t *linfo; // [nullable] for guard entries jl_method_t *method; } func; // memoized properties of sig: @@ -498,8 +498,8 @@ extern JL_DLLEXPORT jl_datatype_t *jl_uniontype_type; extern JL_DLLEXPORT jl_datatype_t *jl_datatype_type; extern JL_DLLEXPORT jl_value_t *jl_bottom_type; -extern JL_DLLEXPORT jl_datatype_t *jl_lambda_info_type; -extern JL_DLLEXPORT jl_datatype_t *jl_source_info_type; +extern JL_DLLEXPORT jl_datatype_t *jl_method_instance_type; +extern JL_DLLEXPORT jl_datatype_t *jl_code_info_type; extern JL_DLLEXPORT jl_datatype_t *jl_method_type; extern JL_DLLEXPORT jl_datatype_t *jl_module_type; extern JL_DLLEXPORT jl_datatype_t *jl_abstractarray_type; @@ -856,8 +856,8 @@ static inline uint32_t jl_fielddesc_size(int8_t fielddesc_type) #define jl_is_quotenode(v) jl_typeis(v,jl_quotenode_type) #define jl_is_newvarnode(v) jl_typeis(v,jl_newvarnode_type) #define jl_is_linenode(v) jl_typeis(v,jl_linenumbernode_type) -#define jl_is_lambda_info(v) jl_typeis(v,jl_lambda_info_type) -#define jl_is_source_info(v) jl_typeis(v,jl_source_info_type) +#define jl_is_method_instance(v) jl_typeis(v,jl_method_instance_type) +#define jl_is_code_info(v) jl_typeis(v,jl_code_info_type) #define jl_is_method(v) jl_typeis(v,jl_method_type) #define jl_is_module(v) jl_typeis(v,jl_module_type) #define jl_is_mtable(v) jl_typeis(v,jl_methtable_type) @@ -1003,7 +1003,7 @@ JL_DLLEXPORT jl_value_t *jl_new_struct(jl_datatype_t *type, ...); JL_DLLEXPORT jl_value_t *jl_new_structv(jl_datatype_t *type, jl_value_t **args, uint32_t na); JL_DLLEXPORT jl_value_t *jl_new_struct_uninit(jl_datatype_t *type); -JL_DLLEXPORT jl_lambda_info_t *jl_new_lambda_info_uninit(void); +JL_DLLEXPORT jl_method_instance_t *jl_new_method_instance_uninit(void); JL_DLLEXPORT jl_svec_t *jl_svec(size_t n, ...); JL_DLLEXPORT jl_svec_t *jl_svec1(void *a); JL_DLLEXPORT jl_svec_t *jl_svec2(void *a, void *b); @@ -1021,9 +1021,9 @@ JL_DLLEXPORT jl_sym_t *jl_get_root_symbol(void); JL_DLLEXPORT jl_value_t *jl_generic_function_def(jl_sym_t *name, jl_value_t **bp, jl_value_t *bp_owner, jl_binding_t *bnd); -JL_DLLEXPORT void jl_method_def(jl_svec_t *argdata, jl_source_info_t *f, jl_value_t *isstaged); -JL_DLLEXPORT jl_source_info_t *jl_code_for_staged(jl_lambda_info_t *linfo); -JL_DLLEXPORT jl_source_info_t *jl_copy_source_info(jl_source_info_t *src); +JL_DLLEXPORT void jl_method_def(jl_svec_t *argdata, jl_code_info_t *f, jl_value_t *isstaged); +JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo); +JL_DLLEXPORT jl_code_info_t *jl_copy_code_info(jl_code_info_t *src); JL_DLLEXPORT jl_function_t *jl_get_kwsorter(jl_typename_t *tn); JL_DLLEXPORT jl_value_t *jl_box_bool(int8_t x); JL_DLLEXPORT jl_value_t *jl_box_int8(int8_t x); @@ -1340,10 +1340,10 @@ JL_DLLEXPORT jl_module_t *jl_base_relative_to(jl_module_t *m); // tracing JL_DLLEXPORT void jl_trace_method(jl_method_t *m); JL_DLLEXPORT void jl_untrace_method(jl_method_t *m); -JL_DLLEXPORT void jl_trace_linfo(jl_lambda_info_t *linfo); -JL_DLLEXPORT void jl_untrace_linfo(jl_lambda_info_t *linfo); -JL_DLLEXPORT void jl_register_linfo_tracer(void (*callback)(jl_lambda_info_t *tracee)); -JL_DLLEXPORT void jl_register_method_tracer(void (*callback)(jl_lambda_info_t *tracee)); +JL_DLLEXPORT void jl_trace_linfo(jl_method_instance_t *linfo); +JL_DLLEXPORT void jl_untrace_linfo(jl_method_instance_t *linfo); +JL_DLLEXPORT void jl_register_linfo_tracer(void (*callback)(jl_method_instance_t *tracee)); +JL_DLLEXPORT void jl_register_method_tracer(void (*callback)(jl_method_instance_t *tracee)); JL_DLLEXPORT void jl_register_newmeth_tracer(void (*callback)(jl_method_t *tracee)); // AST access @@ -1368,7 +1368,7 @@ STATIC_INLINE int jl_vinfo_usedundef(uint8_t vi) // calling into julia --------------------------------------------------------- JL_DLLEXPORT jl_value_t *jl_apply_generic(jl_value_t **args, uint32_t nargs); -JL_DLLEXPORT jl_value_t *jl_invoke(jl_lambda_info_t *meth, jl_value_t **args, uint32_t nargs); +JL_DLLEXPORT jl_value_t *jl_invoke(jl_method_instance_t *meth, jl_value_t **args, uint32_t nargs); STATIC_INLINE jl_value_t *jl_apply(jl_value_t **args, uint32_t nargs) diff --git a/src/julia_internal.h b/src/julia_internal.h index ba33e92ee7cd2..de3e6fd8b8c20 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -165,13 +165,13 @@ STATIC_INLINE void *jl_gc_alloc_buf(jl_ptls_t ptls, size_t sz) return jl_gc_alloc(ptls, sz, (void*)jl_buff_tag); } -jl_source_info_t *jl_type_infer(jl_lambda_info_t *li, int force); -jl_generic_fptr_t jl_generate_fptr(jl_lambda_info_t *li, void *F); -jl_llvm_functions_t jl_compile_linfo(jl_lambda_info_t *li, jl_source_info_t *src); -jl_llvm_functions_t jl_compile_for_dispatch(jl_lambda_info_t *li); +jl_code_info_t *jl_type_infer(jl_method_instance_t *li, int force); +jl_generic_fptr_t jl_generate_fptr(jl_method_instance_t *li, void *F); +jl_llvm_functions_t jl_compile_linfo(jl_method_instance_t *li, jl_code_info_t *src); +jl_llvm_functions_t jl_compile_for_dispatch(jl_method_instance_t *li); JL_DLLEXPORT int jl_compile_hint(jl_tupletype_t *types); -jl_source_info_t *jl_new_source_info_from_ast(jl_expr_t *ast); -jl_method_t *jl_new_method(jl_source_info_t *definition, +jl_code_info_t *jl_new_code_info_from_ast(jl_expr_t *ast); +jl_method_t *jl_new_method(jl_code_info_t *definition, jl_sym_t *name, jl_tupletype_t *sig, size_t nargs, @@ -180,7 +180,7 @@ jl_method_t *jl_new_method(jl_source_info_t *definition, int isstaged); // invoke (compiling if necessary) the jlcall function pointer for a method -STATIC_INLINE jl_value_t *jl_call_method_internal(jl_lambda_info_t *meth, jl_value_t **args, uint32_t nargs) +STATIC_INLINE jl_value_t *jl_call_method_internal(jl_method_instance_t *meth, jl_value_t **args, uint32_t nargs) { jl_generic_fptr_t fptr; fptr.fptr = meth->fptr; @@ -327,25 +327,25 @@ jl_value_t *jl_toplevel_eval_flex(jl_value_t *e, int fast, int expanded); jl_value_t *jl_toplevel_eval_in_warn(jl_module_t *m, jl_value_t *ex, int delay_warn); -jl_source_info_t *jl_wrap_expr(jl_value_t *expr); +jl_code_info_t *jl_wrap_expr(jl_value_t *expr); jl_value_t *jl_eval_global_var(jl_module_t *m, jl_sym_t *e); jl_value_t *jl_parse_eval_all(const char *fname, const char *content, size_t contentlen); -jl_value_t *jl_interpret_toplevel_thunk(jl_source_info_t *src); +jl_value_t *jl_interpret_toplevel_thunk(jl_code_info_t *src); jl_value_t *jl_interpret_toplevel_expr(jl_value_t *e); jl_value_t *jl_interpret_toplevel_expr_in(jl_module_t *m, jl_value_t *e, - jl_source_info_t *src, + jl_code_info_t *src, jl_svec_t *sparam_vals); int jl_is_toplevel_only_expr(jl_value_t *e); jl_value_t *jl_call_scm_on_ast(const char *funcname, jl_value_t *expr); -jl_lambda_info_t *jl_method_lookup_by_type(jl_methtable_t *mt, jl_tupletype_t *types, +jl_method_instance_t *jl_method_lookup_by_type(jl_methtable_t *mt, jl_tupletype_t *types, int cache, int inexact, int allow_exec); -jl_lambda_info_t *jl_method_lookup(jl_methtable_t *mt, jl_value_t **args, size_t nargs, int cache); +jl_method_instance_t *jl_method_lookup(jl_methtable_t *mt, jl_value_t **args, size_t nargs, int cache); jl_value_t *jl_gf_invoke(jl_tupletype_t *types, jl_value_t **args, size_t nargs); jl_datatype_t *jl_first_argument_datatype(jl_value_t *argtypes); -int jl_has_intrinsics(jl_lambda_info_t *li, jl_value_t *v, jl_module_t *m); +int jl_has_intrinsics(jl_method_instance_t *li, jl_value_t *v, jl_module_t *m); jl_value_t *jl_nth_slot_type(jl_tupletype_t *sig, size_t i); void jl_compute_field_offsets(jl_datatype_t *st); @@ -456,12 +456,12 @@ int32_t jl_jlcall_api(/*llvm::Function*/const void *function); JL_DLLEXPORT jl_array_t *jl_idtable_rehash(jl_array_t *a, size_t newsz); JL_DLLEXPORT jl_methtable_t *jl_new_method_table(jl_sym_t *name, jl_module_t *module); -jl_lambda_info_t *jl_get_specialization1(jl_tupletype_t *types); +jl_method_instance_t *jl_get_specialization1(jl_tupletype_t *types); JL_DLLEXPORT int jl_has_call_ambiguities(jl_tupletype_t *types, jl_method_t *m); -jl_lambda_info_t *jl_get_specialized(jl_method_t *m, jl_tupletype_t *types, jl_svec_t *sp); +jl_method_instance_t *jl_get_specialized(jl_method_t *m, jl_tupletype_t *types, jl_svec_t *sp); uint32_t jl_module_next_counter(jl_module_t *m); -void jl_fptr_to_llvm(jl_fptr_t fptr, jl_lambda_info_t *lam, int specsig); +void jl_fptr_to_llvm(jl_fptr_t fptr, jl_method_instance_t *lam, int specsig); jl_tupletype_t *arg_type_tuple(jl_value_t **args, size_t nargs); int jl_has_meta(jl_array_t *body, jl_sym_t *sym); @@ -471,7 +471,7 @@ typedef struct { char *func_name; char *file_name; int line; - jl_lambda_info_t *linfo; + jl_method_instance_t *linfo; int fromC; int inlined; } jl_frame_t; @@ -515,7 +515,7 @@ void jl_critical_error(int sig, bt_context_t *context, uintptr_t *bt_data, size_ JL_DLLEXPORT void jl_raise_debugger(void); int jl_getFunctionInfo(jl_frame_t **frames, uintptr_t pointer, int skipC, int noInline); JL_DLLEXPORT void jl_gdblookup(uintptr_t ip); -jl_value_t *jl_uncompress_ast_(jl_lambda_info_t*, jl_value_t*, int); +jl_value_t *jl_uncompress_ast_(jl_method_instance_t*, jl_value_t*, int); // *to is NULL or malloc'd pointer, from is allowed to be NULL STATIC_INLINE char *jl_copy_str(char **to, const char *from) { diff --git a/src/toplevel.c b/src/toplevel.c index afaaba2fbe9a2..afe4b85121c63 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -267,7 +267,7 @@ JL_DLLEXPORT jl_module_t *jl_base_relative_to(jl_module_t *m) // remove this once jl_has_intrinsics is deleted extern jl_value_t *jl_builtin_getfield; static jl_value_t *jl_static_eval(jl_value_t *ex, jl_module_t *mod, - jl_lambda_info_t *linfo, int sparams) + jl_method_instance_t *linfo, int sparams) { if (jl_is_symbol(ex)) { jl_sym_t *sym = (jl_sym_t*)ex; @@ -281,7 +281,7 @@ static jl_value_t *jl_static_eval(jl_value_t *ex, jl_module_t *mod, return NULL; if (jl_is_quotenode(ex)) return jl_fieldref(ex, 0); - if (jl_is_lambda_info(ex)) + if (jl_is_method_instance(ex)) return NULL; jl_module_t *m = NULL; jl_sym_t *s = NULL; @@ -324,7 +324,7 @@ static jl_value_t *jl_static_eval(jl_value_t *ex, jl_module_t *mod, } -int jl_has_intrinsics(jl_lambda_info_t *li, jl_value_t *v, jl_module_t *m) +int jl_has_intrinsics(jl_method_instance_t *li, jl_value_t *v, jl_module_t *m) { if (!jl_is_expr(v)) return 0; jl_expr_t *e = (jl_expr_t*)v; @@ -355,7 +355,7 @@ int jl_has_intrinsics(jl_lambda_info_t *li, jl_value_t *v, jl_module_t *m) // heuristic for whether a top-level input should be evaluated with // the compiler or the interpreter. -static int jl_eval_with_compiler_p(jl_source_info_t *src, jl_array_t *body, int compileloops, jl_module_t *m) +static int jl_eval_with_compiler_p(jl_code_info_t *src, jl_array_t *body, int compileloops, jl_module_t *m) { size_t i, maxlabl=0; // compile if there are backwards branches @@ -505,9 +505,9 @@ int jl_is_toplevel_only_expr(jl_value_t *e) ((jl_expr_t*)e)->head == toplevel_sym); } -static jl_lambda_info_t *jl_new_thunk(jl_source_info_t *src) +static jl_method_instance_t *jl_new_thunk(jl_code_info_t *src) { - jl_lambda_info_t *li = jl_new_lambda_info_uninit(); + jl_method_instance_t *li = jl_new_method_instance_uninit(); li->inferred = (jl_value_t*)src; li->specTypes = (jl_tupletype_t*)jl_typeof(jl_emptytuple); return li; @@ -586,7 +586,7 @@ jl_value_t *jl_toplevel_eval_flex(jl_value_t *e, int fast, int expanded) jl_value_t *thunk = NULL; jl_value_t *result; - jl_source_info_t *thk = NULL; + jl_code_info_t *thk = NULL; int ewc = 0; JL_GC_PUSH3(&thunk, &thk, &ex); @@ -607,8 +607,8 @@ jl_value_t *jl_toplevel_eval_flex(jl_value_t *e, int fast, int expanded) } if (head == thunk_sym) { - thk = (jl_source_info_t*)jl_exprarg(ex,0); - assert(jl_is_source_info(thk)); + thk = (jl_code_info_t*)jl_exprarg(ex,0); + assert(jl_is_code_info(thk)); assert(jl_typeis(thk->code, jl_array_any_type)); ewc = jl_eval_with_compiler_p(thk, (jl_array_t*)thk->code, fast, ptls->current_module); } @@ -633,7 +633,7 @@ jl_value_t *jl_toplevel_eval_flex(jl_value_t *e, int fast, int expanded) } if (ewc) { - jl_lambda_info_t *li = jl_new_thunk(thk); + jl_method_instance_t *li = jl_new_thunk(thk); jl_type_infer(li, 0); jl_value_t *dummy_f_arg = NULL; result = jl_call_method_internal(li, &dummy_f_arg, 1); @@ -708,7 +708,7 @@ void print_func_loc(JL_STREAM *s, jl_method_t *m); void jl_check_static_parameter_conflicts(jl_method_t *m, jl_svec_t *t) { - jl_source_info_t *src = m->isstaged ? (jl_source_info_t*)m->unspecialized->inferred : m->source; + jl_code_info_t *src = m->isstaged ? (jl_code_info_t*)m->unspecialized->inferred : m->source; size_t nvars = jl_array_len(src->slotnames); size_t i, n = jl_svec_len(t); @@ -798,7 +798,7 @@ jl_datatype_t *jl_first_argument_datatype(jl_value_t *argtypes) extern tracer_cb jl_newmeth_tracer; JL_DLLEXPORT void jl_method_def(jl_svec_t *argdata, - jl_source_info_t *f, + jl_code_info_t *f, jl_value_t *isstaged) { // argdata is svec(svec(types...), svec(typevars...)) @@ -817,14 +817,14 @@ JL_DLLEXPORT void jl_method_def(jl_svec_t *argdata, jl_tupletype_t *argtype = jl_apply_tuple_type(atypes); JL_GC_PUSH3(&f, &m, &argtype); - if (!jl_is_source_info(f)) { + if (!jl_is_code_info(f)) { // this occurs when there is a closure being added to an out-of-scope function // the user should only do this at the toplevel // the result is that the closure variables get interpolated directly into the AST - f = jl_new_source_info_from_ast((jl_expr_t*)f); + f = jl_new_code_info_from_ast((jl_expr_t*)f); } - assert(jl_is_source_info(f)); + assert(jl_is_code_info(f)); jl_datatype_t *ftype = jl_first_argument_datatype((jl_value_t*)argtype); if (ftype == NULL || !(jl_is_type_type((jl_value_t*)ftype) || diff --git a/test/compile.jl b/test/compile.jl index 95dd14d1d38bd..4e377126138ac 100644 --- a/test/compile.jl +++ b/test/compile.jl @@ -90,7 +90,7 @@ try let some_method = @which Base.include("string") # global const some_method // FIXME: support for serializing a direct reference to an external Method not implemented global const some_linfo = - ccall(:jl_specializations_get_linfo, Ref{LambdaInfo}, (Any, Any, Any), + ccall(:jl_specializations_get_linfo, Ref{MethodInstance}, (Any, Any, Any), some_method, Tuple{typeof(Base.include), String}, Core.svec()) end end @@ -156,9 +156,9 @@ try 0:25) some_method = @which Base.include("string") some_linfo = - ccall(:jl_specializations_get_linfo, Ref{LambdaInfo}, (Any, Any, Any), + ccall(:jl_specializations_get_linfo, Ref{MethodInstance}, (Any, Any, Any), some_method, Tuple{typeof(Base.include), String}, Core.svec()) - @test Foo.some_linfo::Core.LambdaInfo === some_linfo + @test Foo.some_linfo::Core.MethodInstance === some_linfo end Baz_file = joinpath(dir, "Baz.jl") diff --git a/test/core.jl b/test/core.jl index 8c42188232bc2..e920d418106fd 100644 --- a/test/core.jl +++ b/test/core.jl @@ -4067,7 +4067,7 @@ function count_expr_push(ex::Expr, head::Symbol, counter) return false end -function metadata_matches(ast::Core.SourceInfo) +function metadata_matches(ast::CodeInfo) inbounds_cnt = Ref(0) boundscheck_cnt = Ref(0) for ex in ast.code::Array{Any,1} diff --git a/test/parse.jl b/test/parse.jl index 5f4bfe710fe7d..9e49b05984f51 100644 --- a/test/parse.jl +++ b/test/parse.jl @@ -674,7 +674,7 @@ end # Issue #16578 (Lowering) mismatch between push_loc and pop_loc module TestMeta_16578 using Base.Test -function get_expr_list(ex::Core.SourceInfo) +function get_expr_list(ex::CodeInfo) return ex.code::Array{Any,1} end function get_expr_list(ex::Expr) diff --git a/test/reflection.jl b/test/reflection.jl index 758297c43cbda..d1a1825dcf18e 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -413,7 +413,7 @@ function test_typed_ast_printing(f::ANY, types::ANY, must_used_vars) end end end - # Make sure printing an AST outside SourceInfo still works. + # Make sure printing an AST outside CodeInfo still works. str = sprint(show, src.code) # Check that we are printing the slot numbers when we don't have the context # Use the variable names that we know should be present in the optimized AST @@ -431,13 +431,13 @@ test_typed_ast_printing(g15714, Tuple{Vector{Float32}}, @test used_dup_var_tested15714 @test used_unique_var_tested15714 -let li = typeof(getfield).name.mt.cache.func::LambdaInfo, +let li = typeof(getfield).name.mt.cache.func::Core.MethodInstance, lrepr = string(li), mrepr = string(li.def), lmime = stringmime("text/plain", li), mmime = stringmime("text/plain", li.def) - @test lrepr == lmime == "LambdaInfo for getfield(...)" + @test lrepr == lmime == "MethodInstance for getfield(...)" @test mrepr == mmime == "getfield(...)" end @@ -445,7 +445,7 @@ end # Linfo Tracing test tracefoo(x, y) = x+y didtrace = false -tracer(x::Ptr{Void}) = (@test isa(unsafe_pointer_to_objref(x), LambdaInfo); global didtrace = true; nothing) +tracer(x::Ptr{Void}) = (@test isa(unsafe_pointer_to_objref(x), Core.MethodInstance); global didtrace = true; nothing) ccall(:jl_register_method_tracer, Void, (Ptr{Void},), cfunction(tracer, Void, (Ptr{Void},))) meth = which(tracefoo,Tuple{Any,Any}) ccall(:jl_trace_method, Void, (Any,), meth) @@ -541,8 +541,8 @@ end let a = @code_typed 1 + 1 b = @code_lowered 1 + 1 - @test isa(a, Pair{Core.SourceInfo, DataType}) - @test isa(b, Core.SourceInfo) + @test isa(a, Pair{CodeInfo, DataType}) + @test isa(b, CodeInfo) @test isa(a[1].code, Array{Any,1}) @test isa(b.code, Array{Any,1}) diff --git a/test/stacktraces.jl b/test/stacktraces.jl index 8345ac7ed65e2..8f2400662f0f0 100644 --- a/test/stacktraces.jl +++ b/test/stacktraces.jl @@ -99,17 +99,17 @@ for (frame, func, inlined) in zip(trace, [g,h,f], (can_inline, can_inline, false end end -let src = expand(quote let x = 1 end end).args[1]::Core.SourceInfo, - li = ccall(:jl_new_lambda_info_uninit, Ref{LambdaInfo}, ()), +let src = expand(quote let x = 1 end end).args[1]::CodeInfo, + li = ccall(:jl_new_method_instance_uninit, Ref{Core.MethodInstance}, ()), sf li.inferred = src li.specTypes = Tuple{} sf = StackFrame(:a, :b, 3, li, false, false, 0) repr = string(sf) - @test repr == " in Toplevel LambdaInfo thunk at b:3" + @test repr == " in Toplevel MethodInstance thunk at b:3" end -let li = typeof(getfield).name.mt.cache.func::LambdaInfo, +let li = typeof(getfield).name.mt.cache.func::Core.MethodInstance, sf = StackFrame(:a, :b, 3, li, false, false, 0), repr = string(sf) @test repr == " in getfield(...) at b:3"