Skip to content

Conversation

@vtjnash
Copy link
Member

@vtjnash vtjnash commented May 25, 2021

This allows code to assume that ->layout will be assigned when
analyzing a type in codegen if the type is mapped to C. The ABI code
often assumes this, and it is also just much generally easier that the
jl_struct_to_llvm code can share the jl_compute_field_offsets results.

@vtjnash vtjnash requested a review from JeffBezanson May 25, 2021 22:43
This allows code to assume that `->layout` will be assigned when
analyzing a type in codegen if the type is mapped to C. The ABI code
often assumes this, and it is also just much generally easier that the
jl_struct_to_llvm code can share the jl_compute_field_offsets results.
@vtjnash vtjnash force-pushed the jn/layout-general branch from fc9d6ed to 802658d Compare May 26, 2021 19:09
if (ty->layout->npointers > 0) {
if (pointerfree)
return 0;
if (ty->ninitialized != jl_svec_len(ty->types))
Copy link
Member

Choose a reason for hiding this comment

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

No need to do it now, but it occurs to me ninitialized can move to TypeName as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good observation. I can make it n_uninitialized, then it would be shared. I'll do that once this is merged. I've also thought about removing ->names, since that is always shared too.

Copy link
Member

Choose a reason for hiding this comment

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

names isn't shared for NamedTuples. I guess if we wanted we could fetch it out of the parameters in that case though.

jl_datatype_t *jst = (jl_datatype_t*)ty;
return jst->layout || jl_has_fixed_layout(jst);
}
if (jl_is_tuple_type(jl_unwrap_unionall(ty)))
Copy link
Member

Choose a reason for hiding this comment

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

Why are tuple types a special case here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would need to forward a covariant flag through jl_has_fixed_layout, and it just seemed unnecessary initially. People probably aren't trying to pass in abstract Tuples by value to ccall very often.

@vtjnash vtjnash merged commit 5dbf45a into master May 28, 2021
@vtjnash vtjnash deleted the jn/layout-general branch May 28, 2021 16:47
shirodkara pushed a commit to shirodkara/julia that referenced this pull request Jun 9, 2021
This allows code to assume that `->layout` will be assigned when
analyzing a type in codegen if the type is mapped to C. The ABI code
often assumes this, and it is also just much generally easier that the
jl_struct_to_llvm code can share the jl_compute_field_offsets results.
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
This allows code to assume that `->layout` will be assigned when
analyzing a type in codegen if the type is mapped to C. The ABI code
often assumes this, and it is also just much generally easier that the
jl_struct_to_llvm code can share the jl_compute_field_offsets results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants