Skip to content

Commit

Permalink
remove runtime system deprecations (#28380)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Aug 4, 2018
1 parent 68cc868 commit a2149f8
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 272 deletions.
11 changes: 3 additions & 8 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,11 @@ function sizeof_tfunc(@nospecialize(x),)
return Int
end
add_tfunc(Core.sizeof, 1, 1, sizeof_tfunc, 0)
old_nfields(@nospecialize x) = length((isa(x, DataType) ? x : typeof(x)).types)
add_tfunc(nfields, 1, 1,
function (@nospecialize(x),)
isa(x, Const) && return Const(old_nfields(x.val))
isa(x, Conditional) && return Const(old_nfields(Bool))
if isType(x)
# TODO: remove with deprecation in builtins.c for nfields(::Type)
p = x.parameters[1]
issingletontype(p) && return Const(old_nfields(p))
elseif isa(x, DataType) && !x.abstract && !(x.name === Tuple.name && isvatuple(x)) && x !== DataType
isa(x, Const) && return Const(nfields(x.val))
isa(x, Conditional) && return Const(0)
if isa(x, DataType) && !x.abstract && !(x.name === Tuple.name && isvatuple(x))
if !(x.name === _NAMEDTUPLE_NAME && !isconcretetype(x))
return Const(length(x.types))
end
Expand Down
66 changes: 1 addition & 65 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,48 +202,7 @@ next(p::Union{Process, ProcessChain}, i::Int) = (getindex(p, i), i + 1)
return i == 1 ? getfield(p, p.openstream) : p
end

# also remove all support machinery in src for current_module when removing this deprecation
# and make Base.include an error
_current_module() = ccall(:jl_get_current_module, Ref{Module}, ())
@noinline function binding_module(s::Symbol)
depwarn("`binding_module(symbol)` is deprecated, use `binding_module(module, symbol)` instead.", :binding_module)
return binding_module(_current_module(), s)
end
export expand
@noinline function expand(@nospecialize(x))
depwarn("`expand(x)` is deprecated, use `Meta.lower(module, x)` instead.", :expand)
return Meta.lower(_current_module(), x)
end
@noinline function macroexpand(@nospecialize(x))
depwarn("`macroexpand(x)` is deprecated, use `macroexpand(module, x)` instead.", :macroexpand)
return macroexpand(_current_module(), x)
end
@noinline function isconst(s::Symbol)
depwarn("`isconst(symbol)` is deprecated, use `isconst(module, symbol)` instead.", :isconst)
return isconst(_current_module(), s)
end
@noinline function include_string(txt::AbstractString, fname::AbstractString)
depwarn("`include_string(string, fname)` is deprecated, use `include_string(module, string, fname)` instead.", :include_string)
return include_string(_current_module(), txt, fname)
end
@noinline function include_string(txt::AbstractString)
depwarn("`include_string(string)` is deprecated, use `include_string(module, string)` instead.", :include_string)
return include_string(_current_module(), txt, "string")
end

"""
current_module() -> Module
Get the *dynamically* current `Module`, which is the `Module` code is currently being read
from. In general, this is not the same as the module containing the call to this function.
DEPRECATED: use `@__MODULE__` instead
"""
@noinline function current_module()
depwarn("`current_module()` is deprecated, use `@__MODULE__` instead.", :current_module)
return _current_module()
end
export current_module
# remove all support machinery in src for current_module

@deprecate_binding colon (:)

Expand Down Expand Up @@ -361,8 +320,6 @@ function OverflowError()
end

@deprecate fieldnames(v) fieldnames(typeof(v))
# nfields(::Type) deprecation in builtins.c: update nfields tfunc in compiler/tfuncs.jl when it is removed.
# also replace `_nfields` with `nfields` in summarysize.c when this is removed.

# PR #22182
@deprecate is_apple Sys.isapple
Expand Down Expand Up @@ -524,24 +481,6 @@ function countnz(x)
return count(t -> t != 0, x)
end

# issue #14470
# TODO: More deprecations must be removed in src/cgutils.cpp:emit_array_nd_index()
# TODO: Re-enable the disabled tests marked PLI
# On the Julia side, this definition will gracefully supersede the new behavior (already coded)
@inline function checkbounds_indices(::Type{Bool}, IA::Tuple{Any,Vararg{Any}}, ::Tuple{})
any(x->unsafe_length(x)==0, IA) && return false
any(x->unsafe_length(x)!=1, IA) && return _depwarn_for_trailing_indices(IA)
return true
end
function _depwarn_for_trailing_indices(n::Integer) # Called by the C boundscheck
depwarn("omitting indices for non-singleton trailing dimensions is deprecated. Add `1`s as trailing indices or use `reshape(A, Val($n))` to make the dimensionality of the array match the number of indices.", (:getindex, :setindex!, :view))
true
end
function _depwarn_for_trailing_indices(t::Tuple)
depwarn("omitting indices for non-singleton trailing dimensions is deprecated. Add `$(join(map(first, t),','))` as trailing indices or use `reshape` to make the dimensionality of the array match the number of indices.", (:getindex, :setindex!, :view))
true
end

# issue #22791
@deprecate select partialsort
@deprecate select! partialsort!
Expand Down Expand Up @@ -774,9 +713,6 @@ findprev(pred::Function, A, i::Integer) = findprev_internal(pred, A, i)
@deprecate parse(str::AbstractString, pos::Int, ; kwargs...) Meta.parse(str, pos; kwargs...)
@deprecate_binding ParseError Meta.ParseError

# issue #20899
# TODO: delete JULIA_HOME deprecation in src/init.c

# cumsum and cumprod have deprecations in multidimensional.jl
# when the message is removed, the `dims` keyword argument should become required.

Expand Down
8 changes: 3 additions & 5 deletions base/summarysize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ struct SummarySize
chargeall::Any
end

_nfields(@nospecialize x) = length(typeof(x).types)

"""
Base.summarysize(obj; exclude=Union{...}, chargeall=Union{...}) -> Int
Expand Down Expand Up @@ -43,7 +41,7 @@ function summarysize(obj;
val = x[i]
end
else
nf = _nfields(x)
nf = nfields(x)
ft = typeof(x).types
if !isbitstype(ft[i]) && isdefined(x, i)
val = getfield(x, i)
Expand All @@ -70,7 +68,7 @@ end
# and so is somewhat approximate.
key = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), obj)
haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true)
if _nfields(obj) > 0
if nfields(obj) > 0
push!(ss.frontier_x, obj)
push!(ss.frontier_i, 1)
end
Expand All @@ -89,7 +87,7 @@ function (ss::SummarySize)(obj::DataType)
key = pointer_from_objref(obj)
haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true)
size::Int = 7 * Core.sizeof(Int) + 6 * Core.sizeof(Int32)
size += 4 * _nfields(obj) + ifelse(Sys.WORD_SIZE == 64, 4, 0)
size += 4 * nfields(obj) + ifelse(Sys.WORD_SIZE == 64, 4, 0)
size += ss(obj.parameters)::Int
size += ss(obj.types)::Int
return size
Expand Down
5 changes: 2 additions & 3 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ function include(path::AbstractString)
elseif INCLUDE_STATE === 2
result = _include(Base, path)
else
# to help users avoid error (accidentally evaluating into Base), this is deprecated
depwarn("Base.include(string) is deprecated, use `include(fname)` or `Base.include(@__MODULE__, fname)` instead.", :include)
result = include_relative(_current_module(), path)
# to help users avoid error (accidentally evaluating into Base), this is not allowed
error("Base.include(string) is discontinued, use `include(fname)` or `Base.include(@__MODULE__, fname)` instead.")
end
result
end
Expand Down
69 changes: 21 additions & 48 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,43 +643,28 @@ JL_CALLABLE(jl_f_isdefined)
{
jl_module_t *m = NULL;
jl_sym_t *s = NULL;
JL_NARGSV(isdefined, 1);
if (nargs == 1) {
JL_TYPECHK(isdefined, symbol, args[0]);
s = (jl_sym_t*)args[0];
}
if (nargs != 2) {
JL_NARGS(isdefined, 1, 1);
jl_depwarn("`isdefined(:symbol)` is deprecated, "
"use `@isdefined symbol` instead",
(jl_value_t*)jl_symbol("isdefined"));
jl_ptls_t ptls = jl_get_ptls_states();
m = ptls->current_module;
}
else {
if (!jl_is_module(args[0])) {
jl_datatype_t *vt = (jl_datatype_t*)jl_typeof(args[0]);
assert(jl_is_datatype(vt));
size_t idx;
if (jl_is_long(args[1])) {
idx = jl_unbox_long(args[1])-1;
if (idx >= jl_datatype_nfields(vt))
return jl_false;
}
else {
JL_TYPECHK(isdefined, symbol, args[1]);
idx = jl_field_index(vt, (jl_sym_t*)args[1], 0);
if ((int)idx == -1)
return jl_false;
}
return jl_field_isdefined(args[0], idx) ? jl_true : jl_false;
JL_NARGS(isdefined, 2, 2);
if (!jl_is_module(args[0])) {
jl_datatype_t *vt = (jl_datatype_t*)jl_typeof(args[0]);
assert(jl_is_datatype(vt));
size_t idx;
if (jl_is_long(args[1])) {
idx = jl_unbox_long(args[1])-1;
if (idx >= jl_datatype_nfields(vt))
return jl_false;
}
else {
JL_TYPECHK(isdefined, symbol, args[1]);
idx = jl_field_index(vt, (jl_sym_t*)args[1], 0);
if ((int)idx == -1)
return jl_false;
}
JL_TYPECHK(isdefined, module, args[0]);
JL_TYPECHK(isdefined, symbol, args[1]);
m = (jl_module_t*)args[0];
s = (jl_sym_t*)args[1];
return jl_field_isdefined(args[0], idx) ? jl_true : jl_false;
}
assert(s);
JL_TYPECHK(isdefined, module, args[0]);
JL_TYPECHK(isdefined, symbol, args[1]);
m = (jl_module_t*)args[0];
s = (jl_sym_t*)args[1];
return jl_boundp(m, s) ? jl_true : jl_false;
}

Expand Down Expand Up @@ -856,12 +841,7 @@ JL_CALLABLE(jl_f_nfields)
{
JL_NARGS(nfields, 1, 1);
jl_value_t *x = args[0];
if (jl_is_datatype(x))
jl_depwarn("`nfields(::DataType)` is deprecated, use `fieldcount` instead",
(jl_value_t*)jl_symbol("nfields"));
else
x = jl_typeof(x);
return jl_box_long(jl_field_count(x));
return jl_box_long(jl_field_count(jl_typeof(x)));
}

// apply_type -----------------------------------------------------------------
Expand Down Expand Up @@ -961,13 +941,6 @@ JL_CALLABLE(jl_f_invoke_kwsorter)
jl_value_t *argtypes = args[3];
jl_value_t *kws = jl_get_keyword_sorter(func);
JL_GC_PUSH1(&argtypes);
if (jl_is_tuple(argtypes)) {
jl_depwarn("`invoke(f, (types...), ...)` is deprecated, "
"use `invoke(f, Tuple{types...}, ...)` instead",
(jl_value_t*)jl_symbol("invoke"));
argtypes = (jl_value_t*)jl_apply_tuple_type_v((jl_value_t**)jl_data_ptr(argtypes),
jl_nfields(argtypes));
}
if (jl_is_tuple_type(argtypes)) {
// construct a tuple type for invoking a keyword sorter by putting the kw container type
// and the type of the function at the front.
Expand Down
17 changes: 2 additions & 15 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1879,8 +1879,6 @@ static Value *emit_array_nd_index(
ctx.builder.CreateCondBr(ctx.builder.CreateICmpULT(last_index, last_dimension), endBB, failBB);
} else {
// There were fewer indices than dimensions; check the last remaining index
BasicBlock *depfailBB = BasicBlock::Create(jl_LLVMContext, "dimsdepfail"); // REMOVE AFTER 0.7
BasicBlock *depwarnBB = BasicBlock::Create(jl_LLVMContext, "dimsdepwarn"); // REMOVE AFTER 0.7
BasicBlock *checktrailingdimsBB = BasicBlock::Create(jl_LLVMContext, "dimsib");
assert(nd >= 0);
Value *last_index = ii;
Expand All @@ -1893,23 +1891,12 @@ static Value *emit_array_nd_index(
for (size_t k = nidxs+1; k < (size_t)nd; k++) {
BasicBlock *dimsokBB = BasicBlock::Create(jl_LLVMContext, "dimsok");
Value *dim = emit_arraysize_for_unsafe_dim(ctx, ainfo, ex, k, nd);
ctx.builder.CreateCondBr(ctx.builder.CreateICmpEQ(dim, ConstantInt::get(T_size, 1)), dimsokBB, depfailBB); // s/depfailBB/failBB/ AFTER 0.7
ctx.builder.CreateCondBr(ctx.builder.CreateICmpEQ(dim, ConstantInt::get(T_size, 1)), dimsokBB, failBB);
ctx.f->getBasicBlockList().push_back(dimsokBB);
ctx.builder.SetInsertPoint(dimsokBB);
}
Value *dim = emit_arraysize_for_unsafe_dim(ctx, ainfo, ex, nd, nd);
ctx.builder.CreateCondBr(ctx.builder.CreateICmpEQ(dim, ConstantInt::get(T_size, 1)), endBB, depfailBB); // s/depfailBB/failBB/ AFTER 0.7

// Remove after 0.7: Ensure no dimensions were 0 and depwarn
ctx.f->getBasicBlockList().push_back(depfailBB);
ctx.builder.SetInsertPoint(depfailBB);
Value *total_length = emit_arraylen(ctx, ainfo);
ctx.builder.CreateCondBr(ctx.builder.CreateICmpULT(i, total_length), depwarnBB, failBB);

ctx.f->getBasicBlockList().push_back(depwarnBB);
ctx.builder.SetInsertPoint(depwarnBB);
ctx.builder.CreateCall(prepare_call(jldepwarnpi_func), ConstantInt::get(T_size, nidxs));
ctx.builder.CreateBr(endBB);
ctx.builder.CreateCondBr(ctx.builder.CreateICmpEQ(dim, ConstantInt::get(T_size, 1)), endBB, failBB);
}

ctx.f->getBasicBlockList().push_back(failBB);
Expand Down
9 changes: 0 additions & 9 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ static Function *box_ssavalue_func;
static Function *expect_func;
static Function *jldlsym_func;
static Function *jltypeassert_func;
static Function *jldepwarnpi_func;
//static Function *jlgetnthfield_func;
static Function *jlgetnthfieldchecked_func;
//static Function *jlsetnthfield_func;
Expand Down Expand Up @@ -7056,14 +7055,6 @@ static void init_julia_llvm_env(Module *m)

jlapply2va_func = jlcall_func_to_llvm("jl_apply_2va", &jl_apply_2va, m);

std::vector<Type*> argsdepwarnpi(0);
argsdepwarnpi.push_back(T_size);
jldepwarnpi_func = Function::Create(FunctionType::get(T_void, argsdepwarnpi, false),
Function::ExternalLinkage,
"jl_depwarn_partial_indexing", m);
add_named_global(jldepwarnpi_func, &jl_depwarn_partial_indexing);


std::vector<Type *> agargs(0);
agargs.push_back(T_pprjlvalue);
agargs.push_back(T_uint32);
Expand Down
9 changes: 0 additions & 9 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,6 @@ static void jl_resolve_sysimg_location(JL_IMAGE_SEARCH rel)
((char*)jl_options.julia_bin)[path_size] = '\0';
if (!jl_options.julia_bindir) {
jl_options.julia_bindir = getenv("JULIA_BINDIR");
if (!jl_options.julia_bindir) {
char *julia_bindir = getenv("JULIA_HOME");
if (julia_bindir) {
jl_depwarn(
"`JULIA_HOME` environment variable is renamed to `JULIA_BINDIR`",
(jl_value_t*)jl_symbol("JULIA_HOME"));
jl_options.julia_bindir = julia_bindir;
}
}
if (!jl_options.julia_bindir) {
jl_options.julia_bindir = dirname(free_path);
}
Expand Down
1 change: 0 additions & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,6 @@ STATIC_INLINE void *jl_get_frame_addr(void)
}

JL_DLLEXPORT jl_array_t *jl_array_cconvert_cstring(jl_array_t *a);
JL_DLLEXPORT void jl_depwarn_partial_indexing(size_t n);
void jl_depwarn(const char *msg, jl_value_t *sym);

// Log `msg` to the current logger by calling CoreLogging.logmsg_shim() on the
Expand Down
13 changes: 0 additions & 13 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,19 +626,6 @@ JL_DLLEXPORT void jl_declare_constant(jl_binding_t *b)
b->constp = 1;
}

JL_DLLEXPORT jl_value_t *jl_get_current_module(void)
{
jl_ptls_t ptls = jl_get_ptls_states();
return (jl_value_t*)ptls->current_module;
}

JL_DLLEXPORT void jl_set_current_module(jl_value_t *m)
{
jl_ptls_t ptls = jl_get_ptls_states();
assert(jl_typeis(m, jl_module_type));
ptls->current_module = (jl_module_t*)m;
}

JL_DLLEXPORT jl_value_t *jl_module_usings(jl_module_t *m)
{
jl_array_t *a = jl_alloc_array_1d(jl_array_any_type, 0);
Expand Down
20 changes: 0 additions & 20 deletions src/rtutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,26 +1112,6 @@ void jl_depwarn(const char *msg, jl_value_t *sym)
JL_GC_POP();
}

JL_DLLEXPORT void jl_depwarn_partial_indexing(size_t n)
{
static jl_value_t *depwarn_func = NULL;
if (!depwarn_func && jl_base_module) {
depwarn_func = jl_get_global(jl_base_module, jl_symbol("_depwarn_for_trailing_indices"));
}
if (!depwarn_func) {
jl_safe_printf("WARNING: omitting indices for non-singleton trailing dimensions is deprecated. Use "
"`reshape(A, Val(%zd))` or add trailing `1` indices to make the dimensionality of the array match "
"the number of indices\n", n);
return;
}
jl_value_t **depwarn_args;
JL_GC_PUSHARGS(depwarn_args, 2);
depwarn_args[0] = depwarn_func;
depwarn_args[1] = jl_box_long(n);
jl_apply(depwarn_args, 2);
JL_GC_POP();
}

#ifdef __cplusplus
}
#endif
Loading

1 comment on commit a2149f8

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

Please sign in to comment.