Skip to content

Commit a2149f8

Browse files
authored
remove runtime system deprecations (#28380)
1 parent 68cc868 commit a2149f8

File tree

17 files changed

+80
-272
lines changed

17 files changed

+80
-272
lines changed

base/compiler/tfuncs.jl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,11 @@ function sizeof_tfunc(@nospecialize(x),)
329329
return Int
330330
end
331331
add_tfunc(Core.sizeof, 1, 1, sizeof_tfunc, 0)
332-
old_nfields(@nospecialize x) = length((isa(x, DataType) ? x : typeof(x)).types)
333332
add_tfunc(nfields, 1, 1,
334333
function (@nospecialize(x),)
335-
isa(x, Const) && return Const(old_nfields(x.val))
336-
isa(x, Conditional) && return Const(old_nfields(Bool))
337-
if isType(x)
338-
# TODO: remove with deprecation in builtins.c for nfields(::Type)
339-
p = x.parameters[1]
340-
issingletontype(p) && return Const(old_nfields(p))
341-
elseif isa(x, DataType) && !x.abstract && !(x.name === Tuple.name && isvatuple(x)) && x !== DataType
334+
isa(x, Const) && return Const(nfields(x.val))
335+
isa(x, Conditional) && return Const(0)
336+
if isa(x, DataType) && !x.abstract && !(x.name === Tuple.name && isvatuple(x))
342337
if !(x.name === _NAMEDTUPLE_NAME && !isconcretetype(x))
343338
return Const(length(x.types))
344339
end

base/deprecated.jl

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -202,48 +202,7 @@ next(p::Union{Process, ProcessChain}, i::Int) = (getindex(p, i), i + 1)
202202
return i == 1 ? getfield(p, p.openstream) : p
203203
end
204204

205-
# also remove all support machinery in src for current_module when removing this deprecation
206-
# and make Base.include an error
207-
_current_module() = ccall(:jl_get_current_module, Ref{Module}, ())
208-
@noinline function binding_module(s::Symbol)
209-
depwarn("`binding_module(symbol)` is deprecated, use `binding_module(module, symbol)` instead.", :binding_module)
210-
return binding_module(_current_module(), s)
211-
end
212-
export expand
213-
@noinline function expand(@nospecialize(x))
214-
depwarn("`expand(x)` is deprecated, use `Meta.lower(module, x)` instead.", :expand)
215-
return Meta.lower(_current_module(), x)
216-
end
217-
@noinline function macroexpand(@nospecialize(x))
218-
depwarn("`macroexpand(x)` is deprecated, use `macroexpand(module, x)` instead.", :macroexpand)
219-
return macroexpand(_current_module(), x)
220-
end
221-
@noinline function isconst(s::Symbol)
222-
depwarn("`isconst(symbol)` is deprecated, use `isconst(module, symbol)` instead.", :isconst)
223-
return isconst(_current_module(), s)
224-
end
225-
@noinline function include_string(txt::AbstractString, fname::AbstractString)
226-
depwarn("`include_string(string, fname)` is deprecated, use `include_string(module, string, fname)` instead.", :include_string)
227-
return include_string(_current_module(), txt, fname)
228-
end
229-
@noinline function include_string(txt::AbstractString)
230-
depwarn("`include_string(string)` is deprecated, use `include_string(module, string)` instead.", :include_string)
231-
return include_string(_current_module(), txt, "string")
232-
end
233-
234-
"""
235-
current_module() -> Module
236-
237-
Get the *dynamically* current `Module`, which is the `Module` code is currently being read
238-
from. In general, this is not the same as the module containing the call to this function.
239-
240-
DEPRECATED: use `@__MODULE__` instead
241-
"""
242-
@noinline function current_module()
243-
depwarn("`current_module()` is deprecated, use `@__MODULE__` instead.", :current_module)
244-
return _current_module()
245-
end
246-
export current_module
205+
# remove all support machinery in src for current_module
247206

248207
@deprecate_binding colon (:)
249208

@@ -361,8 +320,6 @@ function OverflowError()
361320
end
362321

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

367324
# PR #22182
368325
@deprecate is_apple Sys.isapple
@@ -524,24 +481,6 @@ function countnz(x)
524481
return count(t -> t != 0, x)
525482
end
526483

527-
# issue #14470
528-
# TODO: More deprecations must be removed in src/cgutils.cpp:emit_array_nd_index()
529-
# TODO: Re-enable the disabled tests marked PLI
530-
# On the Julia side, this definition will gracefully supersede the new behavior (already coded)
531-
@inline function checkbounds_indices(::Type{Bool}, IA::Tuple{Any,Vararg{Any}}, ::Tuple{})
532-
any(x->unsafe_length(x)==0, IA) && return false
533-
any(x->unsafe_length(x)!=1, IA) && return _depwarn_for_trailing_indices(IA)
534-
return true
535-
end
536-
function _depwarn_for_trailing_indices(n::Integer) # Called by the C boundscheck
537-
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))
538-
true
539-
end
540-
function _depwarn_for_trailing_indices(t::Tuple)
541-
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))
542-
true
543-
end
544-
545484
# issue #22791
546485
@deprecate select partialsort
547486
@deprecate select! partialsort!
@@ -774,9 +713,6 @@ findprev(pred::Function, A, i::Integer) = findprev_internal(pred, A, i)
774713
@deprecate parse(str::AbstractString, pos::Int, ; kwargs...) Meta.parse(str, pos; kwargs...)
775714
@deprecate_binding ParseError Meta.ParseError
776715

777-
# issue #20899
778-
# TODO: delete JULIA_HOME deprecation in src/init.c
779-
780716
# cumsum and cumprod have deprecations in multidimensional.jl
781717
# when the message is removed, the `dims` keyword argument should become required.
782718

base/summarysize.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ struct SummarySize
88
chargeall::Any
99
end
1010

11-
_nfields(@nospecialize x) = length(typeof(x).types)
12-
1311
"""
1412
Base.summarysize(obj; exclude=Union{...}, chargeall=Union{...}) -> Int
1513
@@ -43,7 +41,7 @@ function summarysize(obj;
4341
val = x[i]
4442
end
4543
else
46-
nf = _nfields(x)
44+
nf = nfields(x)
4745
ft = typeof(x).types
4846
if !isbitstype(ft[i]) && isdefined(x, i)
4947
val = getfield(x, i)
@@ -70,7 +68,7 @@ end
7068
# and so is somewhat approximate.
7169
key = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), obj)
7270
haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true)
73-
if _nfields(obj) > 0
71+
if nfields(obj) > 0
7472
push!(ss.frontier_x, obj)
7573
push!(ss.frontier_i, 1)
7674
end
@@ -89,7 +87,7 @@ function (ss::SummarySize)(obj::DataType)
8987
key = pointer_from_objref(obj)
9088
haskey(ss.seen, key) ? (return 0) : (ss.seen[key] = true)
9189
size::Int = 7 * Core.sizeof(Int) + 6 * Core.sizeof(Int32)
92-
size += 4 * _nfields(obj) + ifelse(Sys.WORD_SIZE == 64, 4, 0)
90+
size += 4 * nfields(obj) + ifelse(Sys.WORD_SIZE == 64, 4, 0)
9391
size += ss(obj.parameters)::Int
9492
size += ss(obj.types)::Int
9593
return size

base/sysimg.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ function include(path::AbstractString)
3737
elseif INCLUDE_STATE === 2
3838
result = _include(Base, path)
3939
else
40-
# to help users avoid error (accidentally evaluating into Base), this is deprecated
41-
depwarn("Base.include(string) is deprecated, use `include(fname)` or `Base.include(@__MODULE__, fname)` instead.", :include)
42-
result = include_relative(_current_module(), path)
40+
# to help users avoid error (accidentally evaluating into Base), this is not allowed
41+
error("Base.include(string) is discontinued, use `include(fname)` or `Base.include(@__MODULE__, fname)` instead.")
4342
end
4443
result
4544
end

src/builtins.c

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -643,43 +643,28 @@ JL_CALLABLE(jl_f_isdefined)
643643
{
644644
jl_module_t *m = NULL;
645645
jl_sym_t *s = NULL;
646-
JL_NARGSV(isdefined, 1);
647-
if (nargs == 1) {
648-
JL_TYPECHK(isdefined, symbol, args[0]);
649-
s = (jl_sym_t*)args[0];
650-
}
651-
if (nargs != 2) {
652-
JL_NARGS(isdefined, 1, 1);
653-
jl_depwarn("`isdefined(:symbol)` is deprecated, "
654-
"use `@isdefined symbol` instead",
655-
(jl_value_t*)jl_symbol("isdefined"));
656-
jl_ptls_t ptls = jl_get_ptls_states();
657-
m = ptls->current_module;
658-
}
659-
else {
660-
if (!jl_is_module(args[0])) {
661-
jl_datatype_t *vt = (jl_datatype_t*)jl_typeof(args[0]);
662-
assert(jl_is_datatype(vt));
663-
size_t idx;
664-
if (jl_is_long(args[1])) {
665-
idx = jl_unbox_long(args[1])-1;
666-
if (idx >= jl_datatype_nfields(vt))
667-
return jl_false;
668-
}
669-
else {
670-
JL_TYPECHK(isdefined, symbol, args[1]);
671-
idx = jl_field_index(vt, (jl_sym_t*)args[1], 0);
672-
if ((int)idx == -1)
673-
return jl_false;
674-
}
675-
return jl_field_isdefined(args[0], idx) ? jl_true : jl_false;
646+
JL_NARGS(isdefined, 2, 2);
647+
if (!jl_is_module(args[0])) {
648+
jl_datatype_t *vt = (jl_datatype_t*)jl_typeof(args[0]);
649+
assert(jl_is_datatype(vt));
650+
size_t idx;
651+
if (jl_is_long(args[1])) {
652+
idx = jl_unbox_long(args[1])-1;
653+
if (idx >= jl_datatype_nfields(vt))
654+
return jl_false;
655+
}
656+
else {
657+
JL_TYPECHK(isdefined, symbol, args[1]);
658+
idx = jl_field_index(vt, (jl_sym_t*)args[1], 0);
659+
if ((int)idx == -1)
660+
return jl_false;
676661
}
677-
JL_TYPECHK(isdefined, module, args[0]);
678-
JL_TYPECHK(isdefined, symbol, args[1]);
679-
m = (jl_module_t*)args[0];
680-
s = (jl_sym_t*)args[1];
662+
return jl_field_isdefined(args[0], idx) ? jl_true : jl_false;
681663
}
682-
assert(s);
664+
JL_TYPECHK(isdefined, module, args[0]);
665+
JL_TYPECHK(isdefined, symbol, args[1]);
666+
m = (jl_module_t*)args[0];
667+
s = (jl_sym_t*)args[1];
683668
return jl_boundp(m, s) ? jl_true : jl_false;
684669
}
685670

@@ -856,12 +841,7 @@ JL_CALLABLE(jl_f_nfields)
856841
{
857842
JL_NARGS(nfields, 1, 1);
858843
jl_value_t *x = args[0];
859-
if (jl_is_datatype(x))
860-
jl_depwarn("`nfields(::DataType)` is deprecated, use `fieldcount` instead",
861-
(jl_value_t*)jl_symbol("nfields"));
862-
else
863-
x = jl_typeof(x);
864-
return jl_box_long(jl_field_count(x));
844+
return jl_box_long(jl_field_count(jl_typeof(x)));
865845
}
866846

867847
// apply_type -----------------------------------------------------------------
@@ -961,13 +941,6 @@ JL_CALLABLE(jl_f_invoke_kwsorter)
961941
jl_value_t *argtypes = args[3];
962942
jl_value_t *kws = jl_get_keyword_sorter(func);
963943
JL_GC_PUSH1(&argtypes);
964-
if (jl_is_tuple(argtypes)) {
965-
jl_depwarn("`invoke(f, (types...), ...)` is deprecated, "
966-
"use `invoke(f, Tuple{types...}, ...)` instead",
967-
(jl_value_t*)jl_symbol("invoke"));
968-
argtypes = (jl_value_t*)jl_apply_tuple_type_v((jl_value_t**)jl_data_ptr(argtypes),
969-
jl_nfields(argtypes));
970-
}
971944
if (jl_is_tuple_type(argtypes)) {
972945
// construct a tuple type for invoking a keyword sorter by putting the kw container type
973946
// and the type of the function at the front.

src/cgutils.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,8 +1879,6 @@ static Value *emit_array_nd_index(
18791879
ctx.builder.CreateCondBr(ctx.builder.CreateICmpULT(last_index, last_dimension), endBB, failBB);
18801880
} else {
18811881
// There were fewer indices than dimensions; check the last remaining index
1882-
BasicBlock *depfailBB = BasicBlock::Create(jl_LLVMContext, "dimsdepfail"); // REMOVE AFTER 0.7
1883-
BasicBlock *depwarnBB = BasicBlock::Create(jl_LLVMContext, "dimsdepwarn"); // REMOVE AFTER 0.7
18841882
BasicBlock *checktrailingdimsBB = BasicBlock::Create(jl_LLVMContext, "dimsib");
18851883
assert(nd >= 0);
18861884
Value *last_index = ii;
@@ -1893,23 +1891,12 @@ static Value *emit_array_nd_index(
18931891
for (size_t k = nidxs+1; k < (size_t)nd; k++) {
18941892
BasicBlock *dimsokBB = BasicBlock::Create(jl_LLVMContext, "dimsok");
18951893
Value *dim = emit_arraysize_for_unsafe_dim(ctx, ainfo, ex, k, nd);
1896-
ctx.builder.CreateCondBr(ctx.builder.CreateICmpEQ(dim, ConstantInt::get(T_size, 1)), dimsokBB, depfailBB); // s/depfailBB/failBB/ AFTER 0.7
1894+
ctx.builder.CreateCondBr(ctx.builder.CreateICmpEQ(dim, ConstantInt::get(T_size, 1)), dimsokBB, failBB);
18971895
ctx.f->getBasicBlockList().push_back(dimsokBB);
18981896
ctx.builder.SetInsertPoint(dimsokBB);
18991897
}
19001898
Value *dim = emit_arraysize_for_unsafe_dim(ctx, ainfo, ex, nd, nd);
1901-
ctx.builder.CreateCondBr(ctx.builder.CreateICmpEQ(dim, ConstantInt::get(T_size, 1)), endBB, depfailBB); // s/depfailBB/failBB/ AFTER 0.7
1902-
1903-
// Remove after 0.7: Ensure no dimensions were 0 and depwarn
1904-
ctx.f->getBasicBlockList().push_back(depfailBB);
1905-
ctx.builder.SetInsertPoint(depfailBB);
1906-
Value *total_length = emit_arraylen(ctx, ainfo);
1907-
ctx.builder.CreateCondBr(ctx.builder.CreateICmpULT(i, total_length), depwarnBB, failBB);
1908-
1909-
ctx.f->getBasicBlockList().push_back(depwarnBB);
1910-
ctx.builder.SetInsertPoint(depwarnBB);
1911-
ctx.builder.CreateCall(prepare_call(jldepwarnpi_func), ConstantInt::get(T_size, nidxs));
1912-
ctx.builder.CreateBr(endBB);
1899+
ctx.builder.CreateCondBr(ctx.builder.CreateICmpEQ(dim, ConstantInt::get(T_size, 1)), endBB, failBB);
19131900
}
19141901

19151902
ctx.f->getBasicBlockList().push_back(failBB);

src/codegen.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ static Function *box_ssavalue_func;
327327
static Function *expect_func;
328328
static Function *jldlsym_func;
329329
static Function *jltypeassert_func;
330-
static Function *jldepwarnpi_func;
331330
//static Function *jlgetnthfield_func;
332331
static Function *jlgetnthfieldchecked_func;
333332
//static Function *jlsetnthfield_func;
@@ -7056,14 +7055,6 @@ static void init_julia_llvm_env(Module *m)
70567055

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

7059-
std::vector<Type*> argsdepwarnpi(0);
7060-
argsdepwarnpi.push_back(T_size);
7061-
jldepwarnpi_func = Function::Create(FunctionType::get(T_void, argsdepwarnpi, false),
7062-
Function::ExternalLinkage,
7063-
"jl_depwarn_partial_indexing", m);
7064-
add_named_global(jldepwarnpi_func, &jl_depwarn_partial_indexing);
7065-
7066-
70677058
std::vector<Type *> agargs(0);
70687059
agargs.push_back(T_pprjlvalue);
70697060
agargs.push_back(T_uint32);

src/init.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,6 @@ static void jl_resolve_sysimg_location(JL_IMAGE_SEARCH rel)
558558
((char*)jl_options.julia_bin)[path_size] = '\0';
559559
if (!jl_options.julia_bindir) {
560560
jl_options.julia_bindir = getenv("JULIA_BINDIR");
561-
if (!jl_options.julia_bindir) {
562-
char *julia_bindir = getenv("JULIA_HOME");
563-
if (julia_bindir) {
564-
jl_depwarn(
565-
"`JULIA_HOME` environment variable is renamed to `JULIA_BINDIR`",
566-
(jl_value_t*)jl_symbol("JULIA_HOME"));
567-
jl_options.julia_bindir = julia_bindir;
568-
}
569-
}
570561
if (!jl_options.julia_bindir) {
571562
jl_options.julia_bindir = dirname(free_path);
572563
}

src/julia_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,6 @@ STATIC_INLINE void *jl_get_frame_addr(void)
923923
}
924924

925925
JL_DLLEXPORT jl_array_t *jl_array_cconvert_cstring(jl_array_t *a);
926-
JL_DLLEXPORT void jl_depwarn_partial_indexing(size_t n);
927926
void jl_depwarn(const char *msg, jl_value_t *sym);
928927

929928
// Log `msg` to the current logger by calling CoreLogging.logmsg_shim() on the

src/module.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -626,19 +626,6 @@ JL_DLLEXPORT void jl_declare_constant(jl_binding_t *b)
626626
b->constp = 1;
627627
}
628628

629-
JL_DLLEXPORT jl_value_t *jl_get_current_module(void)
630-
{
631-
jl_ptls_t ptls = jl_get_ptls_states();
632-
return (jl_value_t*)ptls->current_module;
633-
}
634-
635-
JL_DLLEXPORT void jl_set_current_module(jl_value_t *m)
636-
{
637-
jl_ptls_t ptls = jl_get_ptls_states();
638-
assert(jl_typeis(m, jl_module_type));
639-
ptls->current_module = (jl_module_t*)m;
640-
}
641-
642629
JL_DLLEXPORT jl_value_t *jl_module_usings(jl_module_t *m)
643630
{
644631
jl_array_t *a = jl_alloc_array_1d(jl_array_any_type, 0);

0 commit comments

Comments
 (0)