Skip to content

Commit

Permalink
Merge pull request #15735 from JuliaLang/ob/yichaoroots
Browse files Browse the repository at this point in the history
avoid rooting in some cases
  • Loading branch information
vtjnash committed Apr 2, 2016
2 parents 7f177aa + 6fddaea commit c5d78af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ static jl_cgval_t typed_load(Value *ptr, Value *idx_0based, jl_value_t *jltype,
static void typed_store(Value *ptr, Value *idx_0based, const jl_cgval_t &rhs,
jl_value_t *jltype, jl_codectx_t *ctx, MDNode *tbaa,
Value *parent, // for the write barrier, NULL if no barrier needed
size_t alignment = 0)
size_t alignment = 0, bool root_box = true) // if the value to store needs a box, should we root it ?
{
Type *elty = julia_type_to_llvm(jltype);
assert(elty != NULL);
Expand All @@ -807,7 +807,7 @@ static void typed_store(Value *ptr, Value *idx_0based, const jl_cgval_t &rhs,
r = emit_unbox(elty, rhs, jltype);
}
else {
r = boxed(rhs, ctx);
r = boxed(rhs, ctx, root_box);
if (parent != NULL) emit_write_barrier(ctx, parent, r);
}
Value *data;
Expand Down
8 changes: 5 additions & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,7 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args,
emit_expr(args[2], ctx);
}
else {
jl_cgval_t v = (ety == (jl_value_t*)jl_any_type ? emit_expr(args[2], ctx) : emit_expr(args[2], ctx));
jl_cgval_t v = emit_expr(args[2], ctx);
PHINode *data_owner = NULL; // owner object against which the write barrier must check
if (isboxed) { // if not boxed we don't need a write barrier
assert(ary.isboxed);
Expand Down Expand Up @@ -2477,7 +2477,8 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args,
data_owner->addIncoming(own_ptr, ownedBB);
}
typed_store(emit_arrayptr(ary,args[1],ctx), idx, v,
ety, ctx, tbaa_user, data_owner);
ety, ctx, tbaa_user, data_owner, 0,
false); // don't need to root the box if we had to make one since it's being stored in the array immediatly
}
*ret = ary;
JL_GC_POP();
Expand Down Expand Up @@ -2977,7 +2978,8 @@ static jl_cgval_t emit_local(int sl, jl_codectx_t *ctx)
Value *bp = vi.memloc;
if (vi.isArgument || !vi.usedUndef) { // arguments are always defined
Instruction *v = builder.CreateLoad(bp, vi.isVolatile);
return mark_julia_type(v, true, vi.value.typ, ctx);
return mark_julia_type(v, true, vi.value.typ, ctx,
vi.isAssigned); // means it's an argument so don't need an additional root
}
else {
jl_cgval_t v = emit_checked_var(bp, sym, ctx, vi.isVolatile);
Expand Down

0 comments on commit c5d78af

Please sign in to comment.