Skip to content

Commit

Permalink
delete unused code from simplevector
Browse files Browse the repository at this point in the history
Circa #45062 and #46975
  • Loading branch information
vtjnash committed Dec 5, 2023
1 parent 2949dd5 commit 1b4f67f
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 79 deletions.
4 changes: 2 additions & 2 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ static inline size_t get_checked_fieldindex(const char *name, jl_datatype_t *st,
}
if (mutabl && jl_field_isconst(st, idx)) {
jl_errorf("%s: const field .%s of type %s cannot be changed", name,
jl_symbol_name((jl_sym_t*)jl_svec_ref(jl_field_names(st), idx)), jl_symbol_name(st->name->name));
jl_symbol_name((jl_sym_t*)jl_svecref(jl_field_names(st), idx)), jl_symbol_name(st->name->name));
}
return idx;
}
Expand Down Expand Up @@ -1767,7 +1767,7 @@ JL_CALLABLE(jl_f__svec_ref)
if (idx < 1 || idx > len) {
jl_bounds_error_int((jl_value_t*)s, idx);
}
return jl_svec_ref(s, idx-1);
return jl_svecref(s, idx-1);
}

static int equiv_field_types(jl_value_t *old, jl_value_t *ft)
Expand Down
57 changes: 0 additions & 57 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ TRANSFORMED_CCALL_STAT(jl_get_current_task);
TRANSFORMED_CCALL_STAT(jl_set_next_task);
TRANSFORMED_CCALL_STAT(jl_sigatomic_begin);
TRANSFORMED_CCALL_STAT(jl_sigatomic_end);
TRANSFORMED_CCALL_STAT(jl_svec_len);
TRANSFORMED_CCALL_STAT(jl_svec_ref);
TRANSFORMED_CCALL_STAT(jl_string_ptr);
TRANSFORMED_CCALL_STAT(jl_symbol_name);
TRANSFORMED_CCALL_STAT(jl_genericmemory_owner);
Expand Down Expand Up @@ -1685,61 +1683,6 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
ctx.builder.SetInsertPoint(contBB);
return ghostValue(ctx, jl_nothing_type);
}
else if (is_libjulia_func(jl_svec_len)) {
++CCALL_STAT(jl_svec_len);
assert(!isVa && !llvmcall && nccallargs == 1);
const jl_cgval_t &svecv = argv[0];
Value *len;
if (svecv.constant && svecv.typ == (jl_value_t*)jl_simplevector_type) {
// Check the type as well before we call
len = ConstantInt::get(ctx.types().T_size, jl_svec_len(svecv.constant));
}
else {
auto ptr = emit_bitcast(ctx, boxed(ctx, svecv), ctx.types().T_size->getPointerTo());
setName(ctx.emission_context, ptr, "svec_len_ptr");
len = ctx.builder.CreateAlignedLoad(ctx.types().T_size, ptr, ctx.types().alignof_ptr);
setName(ctx.emission_context, len, "svec_len");
// Only mark with TBAA if we are sure about the type.
// This could otherwise be in a dead branch
if (svecv.typ == (jl_value_t*)jl_simplevector_type) {
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_const);
ai.decorateInst(cast<Instruction>(len));
}
MDBuilder MDB(ctx.builder.getContext());
auto rng = MDB.createRange(
Constant::getNullValue(ctx.types().T_size), ConstantInt::get(ctx.types().T_size, INTPTR_MAX / sizeof(void*) - 1));
cast<LoadInst>(len)->setMetadata(LLVMContext::MD_range, rng);
}
JL_GC_POP();
return mark_or_box_ccall_result(ctx, len, retboxed, rt, unionall, static_rt);
}
else if (is_libjulia_func(jl_svec_ref) && argv[1].typ == (jl_value_t*)jl_long_type) {
++CCALL_STAT(jl_svec_ref);
assert(lrt == ctx.types().T_prjlvalue);
assert(!isVa && !llvmcall && nccallargs == 2);
const jl_cgval_t &svecv = argv[0];
const jl_cgval_t &idxv = argv[1];
Value *idx = emit_unbox(ctx, ctx.types().T_size, idxv, (jl_value_t*)jl_long_type);
idx = ctx.builder.CreateAdd(idx, ConstantInt::get(ctx.types().T_size, 1));
setName(ctx.emission_context, idx, "svec_idx");
auto ptr = emit_bitcast(ctx, boxed(ctx, svecv), ctx.types().T_pprjlvalue);
setName(ctx.emission_context, ptr, "svec_data_ptr");
Value *slot_addr = ctx.builder.CreateInBoundsGEP(ctx.types().T_prjlvalue,
decay_derived(ctx, ptr), idx);
setName(ctx.emission_context, slot_addr, "svec_slot_addr");
LoadInst *load = ctx.builder.CreateAlignedLoad(ctx.types().T_prjlvalue, slot_addr,
Align(sizeof(void*)));
setName(ctx.emission_context, load, "svec_slot");
load->setAtomic(AtomicOrdering::Unordered);
// Only mark with TBAA if we are sure about the type.
// This could otherwise be in a dead branch
if (svecv.typ == (jl_value_t*)jl_simplevector_type) {
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_const);
ai.decorateInst(load);
}
JL_GC_POP();
return mark_or_box_ccall_result(ctx, load, retboxed, rt, unionall, static_rt);
}
else if (is_libjulia_func(jl_string_ptr)) {
++CCALL_STAT(jl_string_ptr);
assert(lrt == ctx.types().T_size);
Expand Down
4 changes: 2 additions & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void setNameWithField(jl_codegen_params_t &params, Value *V, std::function<Strin
} else {
auto flds = jl_field_names(jt);
if (idx < jl_svec_len(flds)) {
auto name = jl_svec_ref(flds, idx);
auto name = jl_svecref(flds, idx);
assert(jl_is_symbol(name));
V->setName(Twine(GetObjName()) + "." + Twine(jl_symbol_name((jl_sym_t*)name)) + suffix);
return;
Expand Down Expand Up @@ -3521,7 +3521,7 @@ static bool emit_f_opfield(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
}
else if (jl_field_isconst(uty, idx)) {
std::string msg = fname + ": const field ."
+ std::string(jl_symbol_name((jl_sym_t*)jl_svec_ref(jl_field_names(uty), idx)))
+ std::string(jl_symbol_name((jl_sym_t*)jl_svecref(jl_field_names(uty), idx)))
+ " of type "
+ std::string(jl_symbol_name(uty->name->name))
+ " cannot be changed";
Expand Down
2 changes: 1 addition & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ int foreach_mtable_in_module(
{
jl_svec_t *table = jl_atomic_load_relaxed(&m->bindings);
for (size_t i = 0; i < jl_svec_len(table); i++) {
jl_binding_t *b = (jl_binding_t*)jl_svec_ref(table, i);
jl_binding_t *b = (jl_binding_t*)jl_svecref(table, i);
if ((void*)b == jl_nothing)
break;
jl_sym_t *name = b->globalref->name;
Expand Down
1 change: 0 additions & 1 deletion src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@
XX(jl_svec2) \
XX(jl_svec_copy) \
XX(jl_svec_fill) \
XX(jl_svec_ref) \
XX(jl_switch) \
XX(jl_switchto) \
XX(jl_symbol) \
Expand Down
4 changes: 0 additions & 4 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1498,10 +1498,6 @@ void typemap_slurp_search(jl_typemap_entry_t *ml, struct typemap_intersection_en

// -- simplevector.c -- //

// For codegen only.
JL_DLLEXPORT size_t (jl_svec_len)(jl_svec_t *t) JL_NOTSAFEPOINT;
JL_DLLEXPORT jl_value_t *jl_svec_ref(jl_svec_t *t JL_PROPAGATES_ROOT, ssize_t i);

// check whether the specified number of arguments is compatible with the
// specified number of parameters of the tuple type
JL_DLLEXPORT int jl_tupletype_length_compat(jl_value_t *v, size_t nargs) JL_NOTSAFEPOINT;
Expand Down
7 changes: 4 additions & 3 deletions src/module.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license
//

/*
modules and top-level bindings
Expand Down Expand Up @@ -641,7 +642,7 @@ JL_DLLEXPORT void jl_module_using(jl_module_t *to, jl_module_t *from)
// silently override a "using" name. see issue #2054.
jl_svec_t *table = jl_atomic_load_relaxed(&from->bindings);
for (size_t i = 0; i < jl_svec_len(table); i++) {
jl_binding_t *b = (jl_binding_t*)jl_svec_ref(table, i);
jl_binding_t *b = (jl_binding_t*)jl_svecref(table, i);
if ((void*)b == jl_nothing)
break;
if (b->exportp && (jl_atomic_load_relaxed(&b->owner) == b || b->imported)) {
Expand Down Expand Up @@ -939,7 +940,7 @@ JL_DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported)
JL_GC_PUSH1(&a);
jl_svec_t *table = jl_atomic_load_relaxed(&m->bindings);
for (size_t i = 0; i < jl_svec_len(table); i++) {
jl_binding_t *b = (jl_binding_t*)jl_svec_ref(table, i);
jl_binding_t *b = (jl_binding_t*)jl_svecref(table, i);
if ((void*)b == jl_nothing)
break;
jl_sym_t *asname = b->globalref->name;
Expand Down Expand Up @@ -996,7 +997,7 @@ JL_DLLEXPORT void jl_clear_implicit_imports(jl_module_t *m)
JL_LOCK(&m->lock);
jl_svec_t *table = jl_atomic_load_relaxed(&m->bindings);
for (size_t i = 0; i < jl_svec_len(table); i++) {
jl_binding_t *b = (jl_binding_t*)jl_svec_ref(table, i);
jl_binding_t *b = (jl_binding_t*)jl_svecref(table, i);
if ((void*)b == jl_nothing)
break;
if (jl_atomic_load_relaxed(&b->owner) && jl_atomic_load_relaxed(&b->owner) != b && !b->imported)
Expand Down
7 changes: 0 additions & 7 deletions src/simplevector.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,3 @@ JL_DLLEXPORT size_t (jl_svec_len)(jl_svec_t *t) JL_NOTSAFEPOINT
{
return jl_svec_len(t);
}

JL_DLLEXPORT jl_value_t *jl_svec_ref(jl_svec_t *t JL_PROPAGATES_ROOT, ssize_t i)
{
jl_value_t *v = jl_svecref(t, (size_t)i);
assert(v != NULL);
return v;
}
2 changes: 1 addition & 1 deletion src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ static void jl_queue_module_for_serialization(jl_serializer_state *s, jl_module_
if (jl_options.strip_metadata) {
jl_svec_t *table = jl_atomic_load_relaxed(&m->bindings);
for (size_t i = 0; i < jl_svec_len(table); i++) {
jl_binding_t *b = (jl_binding_t*)jl_svec_ref(table, i);
jl_binding_t *b = (jl_binding_t*)jl_svecref(table, i);
if ((void*)b == jl_nothing)
break;
jl_sym_t *name = b->globalref->name;
Expand Down
2 changes: 1 addition & 1 deletion src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static jl_value_t *jl_eval_module_expr(jl_module_t *parent_module, jl_expr_t *ex
size_t i;
jl_svec_t *table = jl_atomic_load_relaxed(&newm->bindings);
for (size_t i = 0; i < jl_svec_len(table); i++) {
jl_binding_t *b = (jl_binding_t*)jl_svec_ref(table, i);
jl_binding_t *b = (jl_binding_t*)jl_svecref(table, i);
if ((void*)b != jl_nothing) {
// remove non-exported macros
if (jl_symbol_name(b->name)[0]=='@' &&
Expand Down

0 comments on commit 1b4f67f

Please sign in to comment.