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

Move UMEntryThunk to StubPrecode infrastructure #112460

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

davidwrighton
Copy link
Member

@davidwrighton davidwrighton commented Feb 12, 2025

  • Use the StubPrecode logic to create UMEntryThunk instances
  • Allocate them all on the Global LoaderAllocator
  • Unify the creation of UMEntryThunks between the C++/CLI fixup generation path and the delegate creation path
  • Remove ThunkHeapStubManager as it is now subsumed by RangeSectionStubManager
  • Tweak code paths around all of this so that we don't have unnecessary indirections (This change will add 2 memory loads to the UMEntryThunk path on x86/x64, but that should be fairly immaterial compared to the cost of an actual reverse p/invoke)

- Use the StubPrecode logic to create UMEntryThunk instances
- Allocate them all on the Global LoaderAllocator
- Unify the creation of UMEntryThunks between the C++/CLI fixup generation path and the delegate creation path
- Remove ThunkHeapStubManager as it is now subsumed by RangeSectionStubManager
- Tweak code paths around all of this so that we don't have unnecessary indirections (This change will add 2 memory loads to the UMEntryThunk path on x86/x64, but that should be fairly immaterial compared to the cost of an actual reverse p/invoke)
@davidwrighton davidwrighton marked this pull request as ready for review February 25, 2025 23:28
@Copilot Copilot bot review requested due to automatic review settings February 25, 2025 23:28

Choose a reason for hiding this comment

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

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

@davidwrighton davidwrighton changed the title [DRAFT] Move UMEntryThunk to StubPrecode infrastructure Move UMEntryThunk to StubPrecode infrastructure Feb 25, 2025
Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

Looks great to me! I love the reuse of the StubPrecode.

case PRECODE_STUB:
case PRECODE_NDIRECT_IMPORT:
#ifdef FEATURE_INTERPRETER
case PRECODE_INTERPRETER:
Copy link
Member

Choose a reason for hiding this comment

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

The interpreter precode actually doesn't store MethodDesc there, but rather the IR bytecode address. It is possible to get the MethodDesc via the CodeHeader stored right before the bytecode, but we should not come down this path for the interpreter precode, so I'd rather assert here and return nullptr for that case.


#ifdef PROFILING_SUPPORTED
#ifdef PROFILING_SUPPORTED
Copy link
Member

Choose a reason for hiding this comment

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

A nit - I guess the #ifdef / #endif were indented by accident, right?

PCODE Target;
BYTE Type;
TADDR Type;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need TADDR here? It doesn't matter from the size perspective, but I was thinking we might possibly find some use for the remaining 3 bytes. But I am fine with having TADDR there.

pUMEntryThunk = pPrecode->AsUMEntryThunk();
}
}


// Lookup the callsite in the hash, if found, we can map this call back to its managed function.
Copy link
Member

Choose a reason for hiding this comment

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

This comment needs updating. There is no lookup in the hash anymore.

}
}
}
#endif // !DACCESS_COMPILE

OBJECTHANDLE GetObjectHandleSpeculative() const
Copy link
Member

Choose a reason for hiding this comment

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

What is the situation that the Speculative version allows that the non-speculative version does not allow?

Copy link
Member

Choose a reason for hiding this comment

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

(It is not obvious to me why we need the speculative variant.)

@@ -175,9 +175,6 @@ End
Crst DbgTransport
End

Crst DelegateToFPtrHash
Copy link
Member

@jkotas jkotas Feb 26, 2025

Choose a reason for hiding this comment

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

Renerate crsttypes_generated.h

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.

3 participants