-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
fix another bug in circular type detection #41516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1487,22 +1487,38 @@ static int equiv_field_types(jl_value_t *old, jl_value_t *ft) | |||||
return 1; | ||||||
} | ||||||
|
||||||
// If a field can reference the same type as a field, then the inlining | ||||||
// recursive depth is not statically bounded for some layouts, so we cannot | ||||||
// inline it. The only way fields can reference this type (due to | ||||||
// syntax-enforced restrictions) is via being passed as a type parameter. Thus | ||||||
// we can conservatively check this by examining only the parameters of the | ||||||
// dependent types. | ||||||
// affects_layout is a hack introduced by #35275 to workaround a problem | ||||||
// introduced by #34223: it checks whether we will need to potentially need to | ||||||
vtjnash marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
// compute the layout of the object before we have fully computed the types of | ||||||
// the fields during recursion over the allocation of the parameters for the | ||||||
// field types (of the concrete subtypes) | ||||||
static int references_name(jl_value_t *p, jl_typename_t *name, int affects_layout) JL_NOTSAFEPOINT | ||||||
{ | ||||||
if (jl_is_uniontype(p)) | ||||||
return references_name(((jl_uniontype_t*)p)->a, name, affects_layout) || | ||||||
references_name(((jl_uniontype_t*)p)->b, name, affects_layout); | ||||||
if (jl_is_unionall(p)) | ||||||
return references_name((jl_value_t*)((jl_unionall_t*)p)->var, name, 0) || | ||||||
return references_name((jl_value_t*)((jl_unionall_t*)p)->var->lb, name, 0) || | ||||||
references_name((jl_value_t*)((jl_unionall_t*)p)->var->ub, name, 0) || | ||||||
references_name(((jl_unionall_t*)p)->body, name, affects_layout); | ||||||
if (jl_is_typevar(p)) | ||||||
return references_name(((jl_tvar_t*)p)->ub, name, 0) || | ||||||
references_name(((jl_tvar_t*)p)->lb, name, 0); | ||||||
return 0; // already checked by unionall, if applicable | ||||||
if (jl_is_datatype(p)) { | ||||||
jl_datatype_t *dp = (jl_datatype_t*)p; | ||||||
if (affects_layout && dp->name == name) | ||||||
return 1; | ||||||
affects_layout = dp->types == NULL || jl_svec_len(dp->types) != 0; | ||||||
// affects_layout checks whether we will need to attempt to layout this | ||||||
// type (based on whether all copies of it have the same layout) in | ||||||
// that case, we still need to check the recursive parameters for | ||||||
// layout recursion happening also, but we know it won't itself cause | ||||||
// problems for the layout computation | ||||||
affects_layout = ((jl_datatype_t*)jl_unwrap_unionall(dp->name->wrapper))->layout == NULL; | ||||||
size_t i, l = jl_nparams(p); | ||||||
for (i = 0; i < l; i++) { | ||||||
if (references_name(jl_tparam(p, i), name, affects_layout)) | ||||||
|
@@ -1537,16 +1553,23 @@ JL_CALLABLE(jl_f__typebody) | |||||
else { | ||||||
dt->types = (jl_svec_t*)ft; | ||||||
jl_gc_wb(dt, ft); | ||||||
if (!dt->name->mutabl) { | ||||||
dt->name->mayinlinealloc = 1; | ||||||
// If a supertype can reference the same type, then we may not be | ||||||
// able to compute the layout of the object before needing to | ||||||
// publish it, so we must assume it cannot be inlined, if that | ||||||
// check passes, then we also still need to check the object | ||||||
|
// check passes, then we also still need to check the object | |
// check passes, then we also still need to check the fields too. |
vtjnash marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
vtjnash marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.