Conversation
Remove the disabled PSEUDORANDOM_NOP_INSERTION define and all code guarded by it. This was a mitigation for JIT spraying in partial trust scenarios which is no longer relevant. Removed from: - target.h: the commented-out define - emit.h: emitInInstrumentation, emitNextNop, emitRandomNops, emitEnableRandomNops(), emitDisableRandomNops(), emitNextRandomNop() - compiler.h: compChecksum, compRNG - compiler.cpp: adler32(), getMethodBodyChecksum(), compChecksum usage - emit.cpp: nop insertion init, emitNextRandomNop(), random nop logic - instr.cpp: INS_lock nop delay workaround - codegenxarch.cpp, codegenarmarch.cpp, codegenloongarch64.cpp, codegenriscv64.cpp: emitDisableRandomNops() calls in GT_PINVOKE_PROLOG - debug/di/module.cpp: nop sled skipping logic - lower.cpp: outdated comment about random NOPs Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/63c01eec-0aba-480d-82dd-9068f70068fc Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Removes the long-disabled PSEUDORANDOM_NOP_INSERTION JIT-spraying mitigation and its associated dead code paths across the JIT emitter, compiler plumbing, codegen, and debugger-side workarounds.
Changes:
- Deletes the dormant
PSEUDORANDOM_NOP_INSERTIONdefine and removes all remaining conditional code blocks tied to it. - Removes emitter/compiler state and helpers used for pseudorandom NOP insertion (RNG/checksum, scheduling, and insertion logic).
- Cleans up downstream consumers/workarounds (PINVOKE prolog handling disable calls; debugger-side NOP-sled skip logic; stale comment).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/target.h | Removes the commented-out PSEUDORANDOM_NOP_INSERTION define block. |
| src/coreclr/jit/lower.cpp | Removes stale comment that described the random-NOP mitigation behavior. |
| src/coreclr/jit/instr.cpp | Removes xarch INS_lock workaround that depended on random-NOP insertion state. |
| src/coreclr/jit/emit.h | Drops emitter fields/methods used exclusively for random NOP insertion. |
| src/coreclr/jit/emit.cpp | Removes random-NOP initialization and insertion logic in the emitter. |
| src/coreclr/jit/compiler.h | Removes compiler state (compChecksum, compRNG) used for NOP insertion seeding. |
| src/coreclr/jit/compiler.cpp | Removes checksum/RNG seeding computation tied to the feature. |
| src/coreclr/jit/codegenxarch.cpp | Removes emitDisableRandomNops() call for GT_PINVOKE_PROLOG. |
| src/coreclr/jit/codegenarmarch.cpp | Removes emitDisableRandomNops() call for GT_PINVOKE_PROLOG. |
| src/coreclr/jit/codegenloongarch64.cpp | Removes emitDisableRandomNops() call for GT_PINVOKE_PROLOG. |
| src/coreclr/jit/codegenriscv64.cpp | Removes emitDisableRandomNops() call for GT_PINVOKE_PROLOG. |
| src/coreclr/debug/di/module.cpp | Removes debugger-side skip logic for JIT-inserted NOP sleds tied to the feature. |
SingleAccretion
left a comment
There was a problem hiding this comment.
GT_EMITNOP and GT_PINVOKE_EPILOG should be deleted too.
|
@copilot please remove GT_PINVOKE_PROLOG, GT_PINVOKE_EPILOG and GT_EMITNOP. |
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/56d2c478-549a-4ec2-93a8-33402767111e Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Removed all three node types in commit 6bb95d2 — deleted the GTNODE entries from |
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/56d2c478-549a-4ec2-93a8-33402767111e Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
The leg didn't trigger on dotnet#126282 and now it's broken.
The leg didn't trigger on #126282 and now it's broken.
Description
PSEUDORANDOM_NOP_INSERTIONwas a JIT spraying mitigation for partial trust scenarios. The define has been commented out for years and partial trust is not coming back. Remove it and all associated dead code, including the now-unusedGT_PINVOKE_PROLOG,GT_PINVOKE_EPILOG, andGT_EMITNOPGenTree node types.Removed across 18 files:
target.h: The commented-out#defineemit.h/emit.cpp:emitNextNop,emitRandomNops,emitInInstrumentationfields;emitEnableRandomNops()/emitDisableRandomNops()/emitNextRandomNop()methods; random NOP insertion logic inemitAllocAnyInstrcompiler.h/compiler.cpp:compChecksum,compRNGfields;adler32()andgetMethodBodyChecksum()functionsgtlist.h:GT_EMITNOP,GT_PINVOKE_PROLOG,GT_PINVOKE_EPILOGGTNODE definitionslower.cpp:GT_PINVOKE_PROLOGnode creation inLowerNonvirtPinvokeCall; stale comment referencing the featurecodegenxarch.cpp,codegenarmarch.cpp,codegenloongarch64.cpp,codegenriscv64.cpp:GT_PINVOKE_PROLOGcase handlers andemitDisableRandomNops()callscodegenwasm.cpp:GT_PINVOKE_PROLOGcase handlerlsraarm.cpp:GT_PINVOKE_PROLOGfrom BuildSimple case listliveness.cpp:GT_PINVOKE_PROLOGandGT_PINVOKE_EPILOGfrom side-effecting node listgentree.cpp: All three node types fromTryGetUse,UseEdgeIterator, andgtDispLeafswitch statementscompiler.h/compiler.hpp: All three node types from switch case listsinstr.cpp:INS_lockNOP delay workarounddebug/di/module.cpp: NOP sled skipping logic and deadskipBytesvariable🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.
⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.