Skip to content

Commit c02f3e6

Browse files
committed
Various fixes
1 parent 6f52a44 commit c02f3e6

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

src/array.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ JL_DLLEXPORT jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data,
199199
a->elsize = elsz;
200200
jl_value_t *ownerty = jl_typeof(owner);
201201
size_t oldelsz = 0, oldalign = 0;
202-
jl_islayout_inline(jl_tparam0(ownerty), &oldelsz, &oldalign);
203-
oldalign = (ownerty == (jl_value_t*)jl_string_type ? 1 : oldalign);
202+
if (ownerty == (jl_value_t*)jl_string_type) {
203+
oldalign = 1;
204+
}
205+
else {
206+
jl_islayout_inline(jl_tparam0(ownerty), &oldelsz, &oldalign);
207+
}
204208
if (oldalign < align)
205209
jl_exceptionf(jl_argumenterror_type,
206210
"reinterpret from alignment %zu bytes to alignment %zu bytes not allowed",

src/codegen.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -2612,14 +2612,13 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
26122612
jl_cgval_t ary = emit_expr(ctx, args[1]);
26132613
ssize_t nd = jl_is_long(ndp) ? jl_unbox_long(ndp) : -1;
26142614
Value *idx = emit_array_nd_index(ctx, ary, args[1], nd, &args[2], nargs - 1);
2615-
if (!isboxed && jl_datatype_size(ety) == 0) {
2616-
assert(jl_is_datatype(ety));
2615+
if (!isboxed && jl_is_datatype(ety) && jl_datatype_size(ety) == 0) {
26172616
assert(((jl_datatype_t*)ety)->instance != NULL);
26182617
*ret = ghostValue(ety);
26192618
}
26202619
else if (!isboxed && jl_is_uniontype(ety)) {
26212620
Value *nbytes = ConstantInt::get(T_size, elsz);
2622-
Value *data = emit_arrayptr(ctx, ary, args[1]);
2621+
Value *data = emit_bitcast(ctx, emit_arrayptr(ctx, ary, args[1]), T_pint8);
26232622
// isbits union selector bytes are stored directly after the last array element
26242623
Value *selidx = ctx.builder.CreateMul(emit_arraylen_prim(ctx, ary), nbytes);
26252624
selidx = ctx.builder.CreateAdd(selidx, idx);
@@ -2668,9 +2667,8 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
26682667
ssize_t nd = jl_is_long(ndp) ? jl_unbox_long(ndp) : -1;
26692668
Value *idx = emit_array_nd_index(ctx, ary, args[1], nd, &args[3], nargs - 2);
26702669
jl_cgval_t rhs = emit_expr(ctx, args[2]);
2671-
if (!isboxed && jl_datatype_size(ety) == 0) {
2672-
// no-op, but emit expr for possible effects
2673-
assert(jl_is_datatype(ety));
2670+
if (!isboxed && jl_is_datatype(ety) && jl_datatype_size(ety) == 0) {
2671+
// no-op
26742672
}
26752673
else {
26762674
PHINode *data_owner = NULL; // owner object against which the write barrier must check
@@ -2709,7 +2707,7 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
27092707
}
27102708
if (jl_is_uniontype(ety)) {
27112709
Value *nbytes = ConstantInt::get(T_size, elsz);
2712-
Value *data = emit_arrayptr(ctx, ary, args[1]);
2710+
Value *data = emit_bitcast(ctx, emit_arrayptr(ctx, ary, args[1]), T_pint8);
27132711
if (!(rhs.typ == jl_bottom_type)) {
27142712
// compute tindex from rhs
27152713
jl_cgval_t rhs_union = convert_julia_type(ctx, rhs, ety);
@@ -2719,8 +2717,8 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
27192717
selidx = ctx.builder.CreateAdd(selidx, idx);
27202718
Value *ptindex = ctx.builder.CreateGEP(T_int8, data, selidx);
27212719
ctx.builder.CreateStore(tindex, ptindex);
2722-
if (jl_datatype_size(vty) == 0) {
2723-
assert(jl_is_datatype(vty));
2720+
if (jl_is_datatype(vty) && jl_datatype_size(vty) == 0) {
2721+
27242722
}
27252723
else {
27262724
// copy data

src/gc.c

+2
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,8 @@ static size_t array_nbytes(jl_array_t *a)
857857
sz = a->elsize * a->maxsize + (a->elsize == 1 ? 1 : 0);
858858
else
859859
sz = a->elsize * jl_array_len(a);
860+
if (!a->flags.ptrarray && jl_is_uniontype(jl_tparam0(jl_typeof(a))))
861+
sz += jl_array_len(a);
860862
return sz;
861863
}
862864

test/spawn.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ if is_unix()
439439
end
440440
catch ex
441441
isa(ex, Base.UVError) || rethrow(ex)
442-
@test ex.code == Base.UV_EMFILE
442+
@test ex.code in (Base.UV_EMFILE, Base.UV_ENFILE)
443443
finally
444444
for p in ps
445445
close(p)

0 commit comments

Comments
 (0)