-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issuePerformance related issue
Milestone
Description
If you look at the callers of Interlocked.Exchange<T>(ref T, T)
, you'll notice that a large number of them pass nullptr as for the second parameter.
The method currently always results in a call to the native runtime, where the thread is notified of object assignment and the card table is updated if needed. However, if the value is known at JIT time to be nullptr, both of these steps can be skipped. This would allow the JIT to emit an xchg
instruction directly into the codegen, avoiding the call back into the runtime. There's a similar optimization in place today when assigning a known-nullptr value to a field; the JIT emits the mov
instruction directly without bouncing through the internal "volatile write & update card table" helper.
SupinePandora43, samsosa, stephentoub, MichalPetryka, GSPP and 2 more
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issuePerformance related issue