Skip to content

Commit

Permalink
reorg: move code related to static compilation to precompile.c
Browse files Browse the repository at this point in the history
also fix compile=all for jb/subtype
  • Loading branch information
JeffBezanson authored and vtjnash committed Apr 3, 2017
1 parent ceb0674 commit 7d19a23
Show file tree
Hide file tree
Showing 8 changed files with 447 additions and 443 deletions.
9 changes: 7 additions & 2 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1930,8 +1930,12 @@ function abstract_eval(e::ANY, vtypes::VarTable, sv::InferenceState)
if isdefined(sv.linfo, :def)
spsig = sv.linfo.def.sig
if isa(spsig, UnionAll)
env = data_pointer_from_objref(sv.linfo.sparam_vals) + sizeof(Ptr{Void})
rt = ccall(:jl_instantiate_type_in_env, Any, (Any, Any, Ptr{Any}), e.args[2], spsig, env)
if !isempty(sv.linfo.sparam_vals)
env = data_pointer_from_objref(sv.linfo.sparam_vals) + sizeof(Ptr{Void})
rt = ccall(:jl_instantiate_type_in_env, Any, (Any, Any, Ptr{Any}), e.args[2], spsig, env)
else
rt = rewrap_unionall(e.args[2], spsig)
end
end
end
abstract_eval(e.args[1], vtypes, sv)
Expand Down Expand Up @@ -3290,6 +3294,7 @@ function substitute!(e::ANY, na::Int, argexprs::Vector{Any}, spsig::ANY, spvals:
if head === :static_parameter
return spvals[e.args[1]]
elseif head === :foreigncall
@assert !isa(spsig,UnionAll) || !isempty(spvals)
for i = 1:length(e.args)
if i == 2
e.args[2] = ccall(:jl_instantiate_type_in_env, Any, (Any, Any, Ptr{Any}), e.args[2], spsig, spvals)
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endif
SRCS := \
jltypes gf typemap ast builtins module interpreter symbol \
dlload sys init task array dump toplevel jl_uv datatype \
simplevector APInt-C runtime_intrinsics runtime_ccall \
simplevector APInt-C runtime_intrinsics runtime_ccall precompile \
threadgroup threading stackwalk gc gc-debug gc-pages method \
jlapi signal-handling safepoint jloptions timing subtype rtutils

Expand Down
5 changes: 3 additions & 2 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ static const std::string verify_ccall_sig(size_t nargs, jl_value_t *&rt, jl_valu
}
else {
static_rt = retboxed || !jl_has_typevar_from_unionall(rt, unionall_env);
if (!static_rt && sparam_vals != NULL) {
if (!static_rt && sparam_vals != NULL && jl_svec_len(sparam_vals) > 0) {
rt = jl_instantiate_type_in_env(rt, unionall_env, jl_svec_data(sparam_vals));
// `rt` is gc-rooted by the caller
static_rt = true;
Expand Down Expand Up @@ -1875,7 +1875,8 @@ jl_cgval_t function_sig_t::emit_a_ccall(
// if we know the function sparams, try to fill those in now
// so that the julia_to_native type checks are more likely to be doable (e.g. leaf types) at compile-time
jl_value_t *jargty_in_env = jargty;
if (ctx->spvals_ptr == NULL && !toboxed && unionall_env && jl_has_typevar_from_unionall(jargty, unionall_env)) {
if (ctx->spvals_ptr == NULL && !toboxed && unionall_env && jl_has_typevar_from_unionall(jargty, unionall_env) &&
jl_svec_len(ctx->linfo->sparam_vals) > 0) {
jargty_in_env = jl_instantiate_type_in_env(jargty_in_env, unionall_env, jl_svec_data(ctx->linfo->sparam_vals));
if (jargty_in_env != jargty)
jl_add_method_root(ctx, jargty_in_env);
Expand Down
Loading

0 comments on commit 7d19a23

Please sign in to comment.