Open
Description
Function System.CSharpHelpers:.cctor()
starts with a call to new
(this is in R2R code):
call [CORINFO_HELP_READYTORUN_NEW]
mov rsi, rax
mov rcx, rsi
call [System.Collections.Generic.HashSet`1[__Canon][System.__Canon]:.ctor():this]
and then has a long sequence of:
mov rdx, qword ptr [(reloc)]
mov rdx, gword ptr [rdx]
mov rcx, rsi
lea r11, [(reloc)]
cmp dword ptr [rcx], ecx
call [System.Collections.Generic.HashSet`1[__Canon][System.__Canon]:Add(System.__Canon):bool:this]
It seems like only one cmp dword ptr [rcx], ecx
is required; the rest are all doing the same work.
In fact, since rcx
is the result of the call to new
, in this function, it seems like the JIT should know it is non-null, and shouldn't need to do any null checks.
category:cq
theme:null-checks
skill-level:expert
cost:medium