voidFoo(){vararr=newint[10];varlen=arr.Length;}Codegen:
; Method Program:Foo():thisG_M52879_IG01: 4883EC28 subrsp,40G_M52879_IG02: 48B928E4DFFCF87F0000 movrcx,0x7FF8FCDFE428 ; int[] BA0A000000 movedx,10 E8384A865F call CORINFO_HELP_NEWARR_1_VC 8B4008 moveax, dword ptr [rax+08H] ;; <----G_M52879_IG03: 4883C428 addrsp,40 C3 ret; Total bytes of code: 32
and other patterns where JIT should be able to detect that ARR_LEN/IND is invoked on something known to be non-null, e.g.:
voidFoo(int[]arr){if(arr!=null){var_=arr.Length;}}
Codegen:
and other patterns where JIT should be able to detect that ARR_LEN/IND is invoked on something known to be non-null, e.g.: