[mono] Convert Environment.CurrentManagedThreadId to an icall (#20313)
commit5d30ccbafc31bdeef1ff88d9c78f773f54d097ce
authormonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 28 Aug 2020 07:09:43 +0000 (28 03:09 -0400)
committerGitHub <noreply@github.com>
Fri, 28 Aug 2020 07:09:43 +0000 (28 10:09 +0300)
tree3010f42a80bc7954cd2704fa63732227f003775f
parentb1b58ccc0d4fa09bf04b2996205c7f8e3e6f7b9e
[mono] Convert Environment.CurrentManagedThreadId to an icall (#20313)

In order to avoid the static Thread initialization (System.Thread.CurrentThread inits a static field) see https://github.com/dotnet/runtime/pull/41360

Benchmark:
```csharp
[Benchmark]
public int CurrentThreadId() => Environment.CurrentManagedThreadId;
```

Mono JIT (benchmarked on a slow machine):
```
       |          Method |     Mean |     Error |    StdDev |
       |---------------- |---------:|----------:|----------:|
master | CurrentThreadId | 7.191 ns | 0.0128 ns | 0.0107 ns |
PR     | CurrentThreadId | 5.034 ns | 0.0395 ns | 0.0350 ns |
```

Co-authored-by: EgorBo <EgorBo@users.noreply.github.com>
mono/metadata/icall-decl.h
mono/metadata/icall-def-netcore.h
mono/metadata/icall.c