WIP : Master base sweeping simplified#455
Conversation
|
This branch depends on #454. I will rebase after that PR lands to clean up commits |
|
@marek-safar This branch isn't 100% ready yet. I'm sorting through some final issues that are appearing by running our il2cpp test suite. But it's good enough that it's ready to be reviewed for any major issues. I'm also curious how you feel about the size savings. This does add a decent amount of complexity in exchange for a small savings. |
|
@marek-safar I think it's a bug because
|
|
And I think the other test failure is also a pedump bug for the same reason |
|
I have a prototype of deferring instance method body marking until we know the type is instantiated. Any bodies left over at the end of the MarkStep get changed to So although base sweeping is complex, it does appear to be the largest general purpose source of class library size savings that I have lined up. |
* Build up a type hierarchy table during the TypeMapStep so that a type's base classes are easily accessible during the MarkStep. * Sweep step will now change the base type of any class that does not need it's base to Object. * Add link xml tests * Add preserve depenendecy tests * Add test for ctors without bodies * Don't mess with attributes * Casting will result in type hierarchy being kept * Return types must have type hierarchy kept * Locals must have type hierarchy kept
1fe51f0 to
cccb84c
Compare
In certain situations, such as when a static method on a type is used, the base type can be safely removed. This can then allow for the removal of overrides to abstract methods.
I tried to implement full support for this scenario, but I ran into major complexity with visibility of nested types. Rather implement all of the complex logic to figure out visibility when nested types are involved, I bail and don't try to remove base types when nested types are involved.
This didn't end up being the size saver than I originally had hoped for. An early prototype was reducing the size of mscorlib by
0.8%-1.0%range (I don't recall exact number) for a simpleConsole.WriteLine("Hello World")program. However, after having to give up when nested types are involved and a rather obvious bug where I wasn't taking into account that once a type could be on the stack you need to keep the base classes, the size savings dropped to0.25%.That said, this can help considerably in certain scenarios. For example, if you had a program with just
Then the size can drop dramatically.
That is an artificial case, but real cases could exist on a smaller scale.
Build up a type hierarchy table during the TypeMapStep so that a type's base classes are easily accessible during the MarkStep.
Sweep step will now change the base type of any class that does not need it's base to Object.
Add link xml tests
Add preserve depenendecy tests
Add test for ctors without bodies
Don't mess with attributes
Casting will result in type hierarchy being kept
Return types must have type hierarchy kept
Locals must have type hierarchy kept