-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Call Finalize method directly from the finalization loop. #118660
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
Conversation
A failure in ILC/JitInterface when calling
|
We don't assign a vtable slot for Finalize method in native AOT since it can only be called virtually from IL (or UnsafeAccessor now) and nobody outside the finalizer thread should really do it. This saves 8 bytes per MethodTable in terms of working set and size since everything derived from Object would need to have it, finalizable or not. |
It seems a bit dangerous/observable. It is tempting though to save on an
Won't work though, since methodtable has stuff before slots.
|
I think I will do the change only for CoreCLR for now and we can think if/how it can be done for NativeAOT as well. |
I am not following the reasoning here. I think this is trying to make sure that the following won't print
I would expect that we have a test somewhere for this. |
Yes, I am looking at this right now. I am not sure that can be deleted. But for the finalizer to run we only need to have an object allocated (since GC does not care if either instance or static constructor have run). Now I am a bit puzzled where the NativeAOT counterpart to this code is. |
NativeAOT prints:
|
I think the StackOverflowException is a separate issue. It happens even if |
NativeAOT has a bug. |
Right, GC does not care. This is about compliance with ECMA spec. |
Opened #118913. Any chance you can look into that? It looks like a bug we want to fix for .NET 10. |
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Inspired by #118563
With an
UnsafeAccessor
we can simply callFinalize
, no need to dig for the method slot, etc..Not yet sure if this way is faster. It is certainly simpler.