Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Skip Null check and zero length checks of Pointers #541

@Anderman

Description

@Anderman

pointers to byte arrays are use as
fixed(byte* ptr arr)
the code generated will check if this is an null or zero length array

To skip these tests the statement can be written as
fixed(byte* ptr &arr[0])

see generated code

fixed(byte* ptr arr)

000007FF622857AB  mov         rax,rcx  
000007FF622857AE  test        rax,rax  
000007FF622857B1  je          000007FF622857BA  
000007FF622857B3  mov         ecx,dword ptr [rax+8]  
000007FF622857B6  test        ecx,ecx  
000007FF622857B8  jne         000007FF622857C3  
000007FF622857BA  xor         ecx,ecx  
000007FF622857BC  mov         qword ptr [rsp+20h],rcx  
000007FF622857C1  jmp         000007FF622857D1  
000007FF622857C3  cmp         ecx,0  
000007FF622857C6  jbe         000007FF622857FE  
000007FF622857C8  add         rax,10h  
000007FF622857CC  mov         qword ptr [rsp+20h],rax 

fixed(byte* ptr &arr[0])

000007FF6228582B  cmp         dword ptr [rcx+8],0  
000007FF6228582F  jbe         000007FF62285867  
000007FF62285831  add         rcx,10h  
000007FF62285835  mov         qword ptr [rsp+20h],rcx 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions