Skip to content

Commit c5d78af

Browse files
committed
Merge pull request #15735 from JuliaLang/ob/yichaoroots
avoid rooting in some cases
2 parents 7f177aa + 6fddaea commit c5d78af

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/cgutils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static jl_cgval_t typed_load(Value *ptr, Value *idx_0based, jl_value_t *jltype,
793793
static void typed_store(Value *ptr, Value *idx_0based, const jl_cgval_t &rhs,
794794
jl_value_t *jltype, jl_codectx_t *ctx, MDNode *tbaa,
795795
Value *parent, // for the write barrier, NULL if no barrier needed
796-
size_t alignment = 0)
796+
size_t alignment = 0, bool root_box = true) // if the value to store needs a box, should we root it ?
797797
{
798798
Type *elty = julia_type_to_llvm(jltype);
799799
assert(elty != NULL);
@@ -807,7 +807,7 @@ static void typed_store(Value *ptr, Value *idx_0based, const jl_cgval_t &rhs,
807807
r = emit_unbox(elty, rhs, jltype);
808808
}
809809
else {
810-
r = boxed(rhs, ctx);
810+
r = boxed(rhs, ctx, root_box);
811811
if (parent != NULL) emit_write_barrier(ctx, parent, r);
812812
}
813813
Value *data;

src/codegen.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args,
24352435
emit_expr(args[2], ctx);
24362436
}
24372437
else {
2438-
jl_cgval_t v = (ety == (jl_value_t*)jl_any_type ? emit_expr(args[2], ctx) : emit_expr(args[2], ctx));
2438+
jl_cgval_t v = emit_expr(args[2], ctx);
24392439
PHINode *data_owner = NULL; // owner object against which the write barrier must check
24402440
if (isboxed) { // if not boxed we don't need a write barrier
24412441
assert(ary.isboxed);
@@ -2477,7 +2477,8 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args,
24772477
data_owner->addIncoming(own_ptr, ownedBB);
24782478
}
24792479
typed_store(emit_arrayptr(ary,args[1],ctx), idx, v,
2480-
ety, ctx, tbaa_user, data_owner);
2480+
ety, ctx, tbaa_user, data_owner, 0,
2481+
false); // don't need to root the box if we had to make one since it's being stored in the array immediatly
24812482
}
24822483
*ret = ary;
24832484
JL_GC_POP();
@@ -2977,7 +2978,8 @@ static jl_cgval_t emit_local(int sl, jl_codectx_t *ctx)
29772978
Value *bp = vi.memloc;
29782979
if (vi.isArgument || !vi.usedUndef) { // arguments are always defined
29792980
Instruction *v = builder.CreateLoad(bp, vi.isVolatile);
2980-
return mark_julia_type(v, true, vi.value.typ, ctx);
2981+
return mark_julia_type(v, true, vi.value.typ, ctx,
2982+
vi.isAssigned); // means it's an argument so don't need an additional root
29812983
}
29822984
else {
29832985
jl_cgval_t v = emit_checked_var(bp, sym, ctx, vi.isVolatile);

0 commit comments

Comments
 (0)