Skip to content

Include the thumb bit in symbol definitions for method code nodes in crossgen2#128235

Open
jtschuster wants to merge 4 commits into
dotnet:mainfrom
jtschuster:ThumbBit
Open

Include the thumb bit in symbol definitions for method code nodes in crossgen2#128235
jtschuster wants to merge 4 commits into
dotnet:mainfrom
jtschuster:ThumbBit

Conversation

@jtschuster
Copy link
Copy Markdown
Member

Example of what code would look like if crossgen2 emitted the thumb bit into method symbols.

The differences in output are in the DelayLoadMethodCallThunks table and ExceptionInfo. Both of these currently have fields that are RVA's of methods, not PCode, and are not used to jump into the method code, so they don't have the thumb bit. If we make this change, we'd either need to update the name and expectation, and maybe use PCode instead of PInstr for the fields, or create a new node type to represent the RVA of the method code rather that a pointer to the method code. I don't yet have a preference or intuition on what would be better.

Copilot AI review requested due to automatic review settings May 14, 2026 23:02
@github-actions github-actions Bot added the area-crossgen2-coreclr only use for closed issues label May 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Proof-of-concept that makes crossgen2 emit ARM method symbols with the thumb bit already set (matching ILC/runtime behavior), removing the workarounds where the JIT and R2R nodes had to add the thumb bit (CodeDelta) on a per-relocation basis. Tables that store RVAs of methods (DelayLoadMethodCallThunks, ExceptionInfo, RuntimeFunctions) now compensate by subtracting CodeDelta since they don't want the thumb bit.

Changes:

  • JIT (emitarm.cpp, emit.cpp): drop ARM thumb-bit/R2R special cases for movw/movt and async resumption stubs; rely on compReloc and on symbols already carrying the thumb bit.
  • R2R object writer nodes: stop adding factory.Target.CodeDelta in DelayLoadHelperImport, MethodGCInfoNode (personality), ResumptionStubEntryPointSignature, and RuntimeFunctionsTableNode; subtract it in ExceptionInfoLookupTableNode to keep RVAs thumb-bit-free.
  • ObjectWriter.cs: remove the !READYTORUN guard so crossgen2 also sets the thumb bit on ARM method symbols.

Reviewed changes

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

Show a summary per file
File Description
src/coreclr/tools/Common/Compiler/ObjectWriter/ObjectWriter.cs Always set thumb bit on ARM method symbols, including for R2R.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/.../RuntimeFunctionsTableNode.cs Remove CodeDelta from runtime-function RVA reloc.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/.../ResumptionStubEntryPointSignature.cs Drop CodeDelta from resumption stub entry-point reloc.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/.../MethodGCInfoNode.cs Drop CodeDelta on personality routine reloc; whitespace cleanups.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/.../ExceptionInfoLookupTableNode.cs Subtract CodeDelta to keep EH method entries as RVAs without thumb bit.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/.../DelayLoadHelperImport.cs Drop CodeDelta from delay-load helper reloc; whitespace cleanups.
src/coreclr/jit/emitarm.cpp Use compReloc instead of IsNativeAot() to decide whether to add thumb bit to movw/movt literal.
src/coreclr/jit/emit.cpp Remove R2R-specific +1 addend workaround for async resume stub relocs.

@jtschuster jtschuster changed the title Proof of concept for including thumb bit in R2R symbols Include the thumb bit in symbol definitions for method code nodes in ReadyToRun May 15, 2026
@jtschuster jtschuster changed the title Include the thumb bit in symbol definitions for method code nodes in ReadyToRun Include the thumb bit in symbol definitions for method code nodes in crossgen2 May 15, 2026
@jtschuster
Copy link
Copy Markdown
Member Author

/azp run runtime-coreclr

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

@jtschuster
Copy link
Copy Markdown
Member Author

/azp run runtime-coreclr crossgen2

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 18, 2026 21:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

int entries = 0;
for (int index = 0; index < count; index++, offset += runtimeFunctionSize)
{
int startRva = BitConverter.ToInt32(reader.Image, offset);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

BinaryPrimitives.ReadBlahBlah is better practice than BitConverter.

Comment thread src/coreclr/jit/emitarm.cpp
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jtschuster
Copy link
Copy Markdown
Member Author

Full CI validation is dependent on #128170.

However, the tests in ILCompiler.ReadyToRun.Tests give us some confidence that the changes are correct.

@jtschuster jtschuster marked this pull request as ready for review May 19, 2026 16:31
Copilot AI review requested due to automatic review settings May 19, 2026 16:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Copy link
Copy Markdown
Member

@davidwrighton davidwrighton left a comment

Choose a reason for hiding this comment

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

Approved modulo getting a successful validation run.

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

Labels

area-crossgen2-coreclr only use for closed issues

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants