Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2722,12 +2722,14 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
ConstantInt::get(T_size, jl_field_offset(sty, i) + jl_field_size(sty, i) - 1))));
}
}
bool need_wb = false;
// TODO: verify that nargs <= nf (currently handled by front-end)
for (size_t i = 0; i < nargs; i++) {
const jl_cgval_t &rhs = argv[i];
if (jl_field_isptr(sty, i) && !rhs.isboxed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the condition that required this previously? It was pre linear IR so I won't be surprised if it isn't needed anymore but I do remember it was quite non-obvious so I want to make sure it's not needed anymore...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it should be OK now because of linear IR, but I could be wrong. CI seems OK with it.

need_wb = true;
bool need_wb; // set to true if the store might cause the allocation of a box newer than the struct
if (jl_field_isptr(sty, i))
need_wb = !rhs.isboxed;
else
need_wb = false;
emit_typecheck(ctx, rhs, jl_svecref(sty->types, i), "new");
emit_setfield(ctx, sty, strctinfo, i, rhs, false, need_wb);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2334,7 +2334,7 @@ mark: {
}
goto pop;
}
if (!flags.ptrarray || a->data == NULL)
if (!flags.ptrarray || a->data == NULL || jl_array_len(a) == 0)
goto pop;
size_t l = jl_array_len(a);
uintptr_t nptr = (l << 2) | (bits & GC_OLD);
Expand Down