Repository navigation
Emit GCDescs - #1212
Emit GCDescs#1212
Conversation
| _numCells = numCells; | ||
| } | ||
|
|
||
| public static GCPointerMap FromInstanceLayout(DefType type) |
There was a problem hiding this comment.
@davidwrighton pointed out we might want to cache value type pointer maps and just blindly apply them when they're needed because of an instance field. This method will have to leave the core type system because we don't have a good place to cache it (unless I can put it on the TypeSystemContext) :(
There was a problem hiding this comment.
For compiler, I doubt that the caching would make a difference. You have to go through all bits at the end anyway, and so this cache would not improve the complexity of the algorithm.
For the eventual runtime case, we may get the GCMap from the value type EETypes that act as natural cache in this case.
There was a problem hiding this comment.
Cool, I pulled out the algorithm part in a side file so that it doesn't get in the way for consumers who don't want it. The type system algorithm will not try to cache then!
|
Pushed an update that attempts to emit GCDescs for normal types. I have some confidence for normal types, but very little confidence for arrays. I feel like I need to spend some time adding a unit test for ILCompiler.Compiler (including yet another unit testing fake base class library(?)) so that I can actually write tests for this. |
| { | ||
| get | ||
| { | ||
| if (GCDescSize == 0) |
There was a problem hiding this comment.
This symbol is not really needed by anything, but not defining a symbol at offset 0 of a Node trips up the object writer. This might be an ObjectWriter bug, but I didn't try to understand what's going on yet.
For reference, the line that gets tripped up is:
// First entry is the node (entry point) name.
_currentNodeName = _offsetToDefName[0][0];I hit this in dotnet#1212 when I started prefixing EEType nodes with GCDesc. We can either emit a useless symbol for the GCDesc, or merge this change.
This includes: * A data structure to hold the pointer map in a compact form. * The algorithm to compute the pointer map for object instances.
Also, remove the part where we adjust for offsets within boxed value types.
|
@jkotas Removed the [WIP] tag. What's still left (and I would like to do in a separate pull request) is refactoring the |
| if (elementType.IsObjRef) | ||
| { | ||
| OutputStandardGCDesc(ref builder, | ||
| new GCPointerMap(new[] { 1 << 2 }, 3), |
There was a problem hiding this comment.
These numbers make little sense to me but it results in an EEType of the same shape that .NET Native for UWP produces for reference type arrays, so meh.
There was a problem hiding this comment.
It would make more sense to me if the map argument is new GCPointerMap(new[] { 1 }, 1) here. Also, this needs a fudge factor for the multidimensional arrays.
Ideally, I would make this OutputArrayGCDesc(new GCPointerMap(new[] { 1 }, 1), multiDimmArrayDelta); and done the check for the shortcut as the first thing in OutputArrayGCDesc - if all bits in the GCDesc are set, use the standard encoding (just emit the right 3 words to make it understandable).
E.g. array of struct Foo {object a,b,c;} can use the standard encoding just fine.
There was a problem hiding this comment.
if all bits in the GCDesc are set, use the standard encoding (just emit the right 3 words to make it understandable).
I would rather avoid trying optimizations that are not present in .NET Native for UWP at this point. I have trouble validating that this code is not bogus as is. Troubleshooting GC holes is the last thing I would want to do.
There was a problem hiding this comment.
Could you please at least structure the code so that enabling this optimization is just about uncommenting a line - and add TODO comment next to it to?
There was a problem hiding this comment.
(We are going to have a bunch of GC holes to trace down either way - one more or less is not going to make a huge difference...)
There was a problem hiding this comment.
Could you please at least structure the code so that enabling this optimization is just about uncommenting a line - and add TODO comment next to it to?
I'm making OutputArrayGCDesc take the extra int argument so that I can do the right thing for MDArrays. That should be enough, I suppose.
There was a problem hiding this comment.
Also, the check for whether the standard desc can be used for arrays should be moved inside OutputArrayGCDesc.
There was a problem hiding this comment.
Moving that there means the computation of GCDescSize becomes more complicated, since it mirrors the structure of OutputGCDesc. My point is trying to avoid the complexities and increasing my test matrix. I can't introduce unit tests for this at this point without making @nattress life miserable.
(Plus for many of these I don't know what the "expected" values are which makes writing tests more complicated. For someone who doesn't know how the GC operates (me), the GCDescs structures are super confusing.)
There was a problem hiding this comment.
Ok, I will take care of it later.
|
You should be able to remove the large GC budget for Windows + RyuJIT codegen as part of this change. |
Can we remove that once we validate we can survive at least one GC? I didn't do any validations around that. |
Uh oh!
There was an error while loading. Please reload this page.