Skip to content
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

Change metadata handle split to 7-bit handle type #111222

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MichalStrehovsky
Copy link
Member

Fixes dotnet/runtimelab#1581

This allows addressing up to 32 MB of metadata. This should cover all known cases where people hit this in the past.

Granted, none of the user hits are for scenarios where it would be advisable to use native AOT. If one needs to reflection-root 60+ MB of IL, it's inadvisable to use native AOT or trim in general since the possible (small) savings will never outweigh (huge) reliability/predictabillity loss caused by the 60 MB of trim unsafe code.)

Fixes dotnet/runtimelab#1581

This allows addressing up to 32 MB of metadata. This should cover all known cases where people hit this in the past.

Granted, none of the user hits are for scenarios where it would be advisable to use native AOT. If one needs to reflection-root 60+ MB of IL, it's inadvisable to use native AOT or trim in general since the possible (small) savings will never outweigh (huge) reliability/predictabillity loss caused by the 60 MB of trim unsafe code.)
@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 6 out of 11 changed files in this pull request and generated no comments.

Files not reviewed (5)
  • src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs: Evaluated as low risk
  • src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.FieldAccess.cs: Evaluated as low risk
  • src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs: Evaluated as low risk
  • src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/MetadataReaderExtensions.cs: Evaluated as low risk
  • src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/ReaderGen.cs: Evaluated as low risk
@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Comment on lines +350 to +351
Debug.Assert((command & StackTraceDataCommand.IsStackTraceHidden) != 0 ||
currentOwningType.HandleType is HandleType.TypeDefinition or HandleType.TypeReference or HandleType.TypeSpecification);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is non-obvious: if TypeDef/TypeSpec/TypeRef handles have their highest bit set, we'd compare them as negative numbers when sorting and StackTraceHidden records (that don't bother filing out owning type) will sort after them. We don't currently see UpdateOwningType command for those since they sort before everything else and owning type == 0 is the initial assumption in the code above (and also in the emitter).

@@ -719,7 +719,7 @@ private unsafe bool TryGetMethodForOriginalLdFtnResult_InvokeMap_Inner(NativeFor
QTypeDefinition qTypeDefinition = GetMetadataForNamedType(declaringTypeHandleDefinition);

MethodHandle nativeFormatMethodHandle =
(((int)HandleType.Method << 24) | (int)entryMethodHandleOrNameAndSigRaw).AsMethodHandle();
(((int)HandleType.Method << 25) | (int)entryMethodHandleOrNameAndSigRaw).AsMethodHandle();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have 25 defined as a constant somewhere so that it is not hardcoded in so many places?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Increase the range of allowable native metadata handles
2 participants