-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NativeAOT] Fix GCDesc computation (#88927)
* Fix GCDesc computation #86877 appears to have introduced a bug in the GCDesc computation. Consider the following structure layout (we are on 32 bit): struct { int X1; int X2; Object Obj; int X3; } Crucially, the object reference in this struct is placed at a non-zero offset, which means that in an array GCDesc, sizeof(X1 + X2) aka 8 will be added to the "base size" of the object. Since we have one and only series (of GC pointers), it will also be the last. Its "skip" was computed as: bitfield.Count (4) - last (3) = 1 Which is clearly incorrect, as we need to skip 3 pointers when considering the shifted array layout: <Obj, X3][X1, X2, Obj, X3][X1, X2, Obj, X3]... | | [Correct skip] In effect, for the last series, we must consider the skip to include the delta we have included into the base size, which code before #86877 did, although wrongly - for MD arrays - as well. This change restores a fixed version of it. * Add a test Verified to fail (hit a GC assert) before and pass after. * (actually make it compile)
- Loading branch information
1 parent
4ebb3ea
commit 6bd93db
Showing
3 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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