Skip to content

Commit 61ee70d

Browse files
committed
Remove some leagcy gcroot codegen code
The LLVM pass now figures this out automatically, so we no longer need to put it explicitly into the code. There's more cleanup to be done here, but I want to take this one step at a time, since this legacy code may have been hiding issues in the GC root placement pass.
1 parent 6a1e339 commit 61ee70d

File tree

5 files changed

+45
-66
lines changed

5 files changed

+45
-66
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,9 @@ test: check-whitespace $(JULIA_BUILD_MODE)
551551
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/test default JULIA_BUILD_MODE=$(JULIA_BUILD_MODE)
552552

553553
ifeq ($(JULIA_BUILD_MODE),release)
554-
JULIA_SYSIMG=$(build_private_libdir)/sys$(JULIA_LIBSUFFIX).$(SHLIB_EXT)
554+
JULIA_SYSIMG=$(build_private_libdir)/sys$(JULIA_LIBSUFFIX)$(CPUID_TAG).$(SHLIB_EXT)
555555
else
556-
JULIA_SYSIMG=$(build_private_libdir)/sys-$(JULIA_BUILD_MODE)$(JULIA_LIBSUFFIX).$(SHLIB_EXT)
556+
JULIA_SYSIMG=$(build_private_libdir)/sys-$(JULIA_BUILD_MODE)$(JULIA_LIBSUFFIX)$(CPUID_TAG).$(SHLIB_EXT)
557557
endif
558558
testall: check-whitespace $(JULIA_BUILD_MODE)
559559
cp $(JULIA_SYSIMG) $(BUILDROOT)/local.$(SHLIB_EXT) && $(JULIA_EXECUTABLE) -J $(call cygpath_w,$(BUILDROOT)/local.$(SHLIB_EXT)) -e 'true' && rm $(BUILDROOT)/local.$(SHLIB_EXT)

src/ccall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
14951495
}
14961496
else {
14971497
Value *notany = ctx.builder.CreateICmpNE(
1498-
boxed(ctx, runtime_sp, false),
1498+
boxed(ctx, runtime_sp),
14991499
maybe_decay_untracked(literal_pointer_val(ctx, (jl_value_t*)jl_any_type)));
15001500
error_unless(ctx, notany, "ccall: return type Ref{Any} is invalid. use Ptr{Any} instead.");
15011501
always_error = false;

src/cgutils.cpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,7 @@ static Value *emit_typeptr_addr(jl_codectx_t &ctx, Value *p)
683683
return emit_nthptr_addr(ctx, p, -offset);
684684
}
685685

686-
static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &v, bool gcooted=true);
687-
static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &v, jl_value_t* type) = delete; // C++11 (temporary to prevent rebase error)
686+
static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &v);
688687

689688
static Value* mask_gc_bits(jl_codectx_t &ctx, Value *tag)
690689
{
@@ -713,7 +712,7 @@ static jl_cgval_t emit_typeof(jl_codectx_t &ctx, const jl_cgval_t &p)
713712
if (p.constant)
714713
return mark_julia_const(jl_typeof(p.constant));
715714
if (p.isboxed && !jl_is_leaf_type(p.typ)) {
716-
return mark_julia_type(ctx, emit_typeof(ctx, p.V), true, jl_datatype_type, /*needsroot*/false);
715+
return mark_julia_type(ctx, emit_typeof(ctx, p.V), true, jl_datatype_type);
717716
}
718717
if (p.TIndex) {
719718
Value *tindex = ctx.builder.CreateAnd(p.TIndex, ConstantInt::get(T_int8, 0x7f));
@@ -746,7 +745,7 @@ static jl_cgval_t emit_typeof(jl_codectx_t &ctx, const jl_cgval_t &p)
746745
if (!allunboxed)
747746
datatype = mask_gc_bits(ctx, datatype);
748747
datatype = maybe_decay_untracked(datatype);
749-
return mark_julia_type(ctx, datatype, true, jl_datatype_type, /*needsroot*/false);
748+
return mark_julia_type(ctx, datatype, true, jl_datatype_type);
750749
}
751750
jl_value_t *aty = p.typ;
752751
if (jl_is_type_type(aty)) {
@@ -986,7 +985,7 @@ static void emit_type_error(jl_codectx_t &ctx, const jl_cgval_t &x, Value *type,
986985
Value *msg_val = stringConstPtr(ctx.builder, msg);
987986
ctx.builder.CreateCall(prepare_call(jltypeerror_func),
988987
{ fname_val, msg_val,
989-
maybe_decay_untracked(type), mark_callee_rooted(boxed(ctx, x, false))});
988+
maybe_decay_untracked(type), mark_callee_rooted(boxed(ctx, x))});
990989
}
991990

992991
static std::pair<Value*, bool> emit_isa(jl_codectx_t &ctx, const jl_cgval_t &x, jl_value_t *type, const std::string *msg)
@@ -1080,7 +1079,7 @@ static void emit_typecheck(jl_codectx_t &ctx, const jl_cgval_t &x, jl_value_t *t
10801079
static void emit_leafcheck(jl_codectx_t &ctx, Value *typ, const std::string &msg)
10811080
{
10821081
assert(typ->getType() == T_prjlvalue);
1083-
emit_typecheck(ctx, mark_julia_type(ctx, typ, true, jl_any_type, false), (jl_value_t*)jl_datatype_type, msg);
1082+
emit_typecheck(ctx, mark_julia_type(ctx, typ, true, jl_any_type), (jl_value_t*)jl_datatype_type, msg);
10841083
Value *isleaf;
10851084
isleaf = ctx.builder.CreateConstInBoundsGEP1_32(T_int8, emit_bitcast(ctx, decay_derived(typ), T_pint8), offsetof(jl_datatype_t, isleaftype));
10861085
isleaf = ctx.builder.CreateLoad(isleaf, tbaa_const);
@@ -1205,7 +1204,7 @@ static void typed_store(jl_codectx_t &ctx,
12051204
Value *ptr, Value *idx_0based, const jl_cgval_t &rhs,
12061205
jl_value_t *jltype, MDNode *tbaa,
12071206
Value *parent, // for the write barrier, NULL if no barrier needed
1208-
unsigned alignment = 0, bool root_box = true) // if the value to store needs a box, should we root it ?
1207+
unsigned alignment = 0)
12091208
{
12101209
bool isboxed;
12111210
Type *elty = julia_type_to_llvm(jltype, &isboxed);
@@ -1216,7 +1215,7 @@ static void typed_store(jl_codectx_t &ctx,
12161215
r = emit_unbox(ctx, elty, rhs, jltype);
12171216
}
12181217
else {
1219-
r = maybe_decay_untracked(boxed(ctx, rhs, root_box));
1218+
r = maybe_decay_untracked(boxed(ctx, rhs));
12201219
if (parent != NULL)
12211220
emit_write_barrier(ctx, parent, r);
12221221
}
@@ -1287,7 +1286,7 @@ static bool emit_getfield_unknownidx(jl_codectx_t &ctx,
12871286
maybe_null, minimum_field_size));
12881287
if (maybe_null)
12891288
null_pointer_check(ctx, fld);
1290-
*ret = mark_julia_type(ctx, fld, true, jl_any_type, strct.gcroot || !strct.isimmutable);
1289+
*ret = mark_julia_type(ctx, fld, true, jl_any_type);
12911290
return true;
12921291
}
12931292
else if (is_tupletype_homogeneous(stt->types)) {
@@ -1389,7 +1388,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
13891388
Value *fldv = tbaa_decorate(strct.tbaa, Load);
13901389
if (maybe_null)
13911390
null_pointer_check(ctx, fldv);
1392-
return mark_julia_type(ctx, fldv, true, jfty, strct.gcroot || !strct.isimmutable);
1391+
return mark_julia_type(ctx, fldv, true, jfty);
13931392
}
13941393
else if (jl_is_uniontype(jfty)) {
13951394
int fsz = jl_field_size(jt, idx);
@@ -1982,7 +1981,7 @@ static Value *box_union(jl_codectx_t &ctx, const jl_cgval_t &vinfo, const SmallB
19821981
// this is used to wrap values for generic contexts, where a
19831982
// dynamically-typed value is required (e.g. argument to unknown function).
19841983
// if it's already a pointer it's left alone.
1985-
static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &vinfo, bool gcrooted)
1984+
static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &vinfo)
19861985
{
19871986
jl_value_t *jt = vinfo.typ;
19881987
if (jt == jl_bottom_type || jt == NULL)
@@ -2016,12 +2015,6 @@ static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &vinfo, bool gcrooted)
20162015
box = maybe_decay_untracked(box);
20172016
}
20182017
}
2019-
if (gcrooted) {
2020-
// make a gcroot for the new box
2021-
// (unless the caller explicitly said this was unnecessary)
2022-
Value *froot = emit_local_root(ctx);
2023-
ctx.builder.CreateStore(box, froot);
2024-
}
20252018
return box;
20262019
}
20272020

@@ -2103,7 +2096,7 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, const jl_cgval_t &src
21032096
static void emit_cpointercheck(jl_codectx_t &ctx, const jl_cgval_t &x, const std::string &msg)
21042097
{
21052098
Value *t = emit_typeof_boxed(ctx, x);
2106-
emit_typecheck(ctx, mark_julia_type(ctx, t, true, jl_any_type, false), (jl_value_t*)jl_datatype_type, msg);
2099+
emit_typecheck(ctx, mark_julia_type(ctx, t, true, jl_any_type), (jl_value_t*)jl_datatype_type, msg);
21072100

21082101
Value *istype =
21092102
ctx.builder.CreateICmpEQ(mark_callee_rooted(emit_datatype_name(ctx, t)),
@@ -2185,7 +2178,7 @@ static void emit_setfield(jl_codectx_t &ctx,
21852178
ConstantInt::get(T_size, jl_field_offset(sty, idx0)));
21862179
jl_value_t *jfty = jl_svecref(sty->types, idx0);
21872180
if (jl_field_isptr(sty, idx0)) {
2188-
Value *r = maybe_decay_untracked(boxed(ctx, rhs, false)); // don't need a temporary gcroot since it'll be rooted by strct
2181+
Value *r = maybe_decay_untracked(boxed(ctx, rhs)); // don't need a temporary gcroot since it'll be rooted by strct
21892182
tbaa_decorate(strct.tbaa, ctx.builder.CreateStore(r,
21902183
emit_bitcast(ctx, addr, T_pprjlvalue)));
21912184
if (wb && strct.isboxed)

0 commit comments

Comments
 (0)