Remove CoreCLR Reflection.Emit's ceefilegen dependency - #134966
Merged
Merged
Conversation
Store emitted IL and FieldRVA data in loader-owned buffers indexed by the existing dynamic token map. Generalize dynamic field resolution, remove PE section and token relocation bookkeeping, and preserve ILAsm's no-host generator. Add emitted-body, field-data, and diagnostic coverage and update the canonical cDAC descriptor descriptions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke |
Remove the Reflection.Emit exception from the image-backed RVA assertion now that emitted fields use the preceding dynamic-token branch. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to 'size-reduction': @eerhardt, @SamMonoRT |
davidwrighton
approved these changes
Sep 30, 2026
This was referenced Oct 1, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Regenerate browser and WASI call-helper tables after shortening the Reflection.Emit SetMethodIL QCall signature. The missing interpreter thunk caused null-function traps in browser CoreCLR library tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Oct 2, 2026
davidwrighton
approved these changes
Oct 2, 2026
Member
Author
|
/ba-g cdac stress test failures are all recognized, but they still emit a build failure that itself isn't recognized by a KBE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CoreCLR's in-memory Reflection.Emit implementation uses PE-style sections and relocation records just to retain method IL and FieldRVA bytes. Store those bytes directly in loader-owned memory and reuse the existing token-to-address map, so shared and static CoreCLR no longer need to link
ceefgen.Changes
FIELD_OFFSET_DYNAMIC_RVAsentinel and token map, including reflection's fast field-access path.ceefgen_nohostdependency and PE-writing implementation.Existing token-aware diagnostic paths resolve the new storage. Raw
ISOSDacInterface.GetILForModulesupport for Reflection.Emit remains unchanged: it is unsupported by the native DAC.Validation
Windows x64 Release and Checked builds passed. Local coverage includes:
Other runtime architectures and metadata-updater-disabled builds were not run. The pre-existing commented-out EnC
TestAddFieldRVAcase was left unchanged and was not included in the EnC count.Local measurements and trade-off
Dependency-free, ad hoc Windows x64 Release harness; A/B/B/A process order, 18 measurements per operation per host, and tiered compilation disabled for both. These are shared-machine measurements, not BenchmarkDotNet results.
The slowdown below is limited to the non-intrinsic runtime fallback path for FieldRVA data defined by
System.Reflection.Emit. It is not a loss of intrinsic expansion: these benchmark cases use the fallback in both the baseline and changed builds.coreclr.dllsizedotnet.native.wasmsizedotnet.native.wasmBrotli q11 sizedotnet.native.wasmcode sectiondotnet.native.wasmdata sectiondotnet.native.wasmdefined functionsInitializeArray, SRE fieldCreateSpan, SRE fieldModule-creation medians were approximately 0.3%-4.1% lower across four workloads. Process-private-memory growth while retaining emitted modules was approximately 24%-39% lower; this is not a pure native-allocation metric.
The slow benchmark supplies field handles obtained through reflection and reuses an existing array. Its fallback now resolves emitted field data through a locked token-map lookup instead of unlocked section-offset translation. Follow-up disassembly confirmed identical managed fallback instruction sequences in both builds.
Intrinsic-friendly
ldtoken/CreateSpanand constant-sizenewarr/dup/ldtoken/InitializeArraypatterns still expand to direct data access in both builds, with no per-invocation token lookup; the address is resolved at JIT time. Ordinary PE-backed fields also retain their existing lookup path. Follow-up controls for those cases were approximately unchanged, so the slowdown percentages above do not apply to them.Note
This implementation and PR description were prepared with GitHub Copilot.