Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac0e6e8

Browse files
committed
Merge branch 'main' of github.com:dotnet/runtime into alloc-stack-naot
2 parents 001b01c + 283de5b commit ac0e6e8

File tree

164 files changed

+4991
-1585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+4991
-1585
lines changed

docs/design/datacontracts/SList.md

Lines changed: 0 additions & 78 deletions
This file was deleted.

docs/design/datacontracts/Thread.md

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ enum ThreadState
2828
}
2929

3030
record struct ThreadData (
31-
uint ThreadId;
32-
TargetNUint OsThreadId;
31+
uint Id;
32+
TargetNUInt OSId;
3333
ThreadState State;
3434
bool PreemptiveGCDisabled
3535
TargetPointer AllocContextPointer;
3636
TargetPointer AllocContextLimit;
3737
TargetPointer Frame;
3838
TargetPointer FirstNestedException;
3939
TargetPointer TEB;
40-
DacGCHandle LastThrownObjectHandle;
40+
TargetPointer LastThrownObjectHandle;
4141
TargetPointer NextThread;
4242
);
4343
```
@@ -51,67 +51,81 @@ TargetPointer GetManagedThreadObject(TargetPointer threadPointer);
5151

5252
## Version 1
5353

54+
This contract depends on the following descriptors:
5455

56+
| Data descriptor name |
57+
| --- |
58+
| `GCAllocContext` |
59+
| `RuntimeThreadLocals` |
60+
| `Thread` |
61+
| `ThreadStore` |
5562

56-
``` csharp
57-
SListReader ThreadListReader = Contracts.SList.GetReader("Thread");
63+
| Global name |
64+
| --- |
65+
| `AppDomain` |
66+
| `ThreadStore` |
67+
| `FeatureEHFunclets` |
68+
| `FinalizerThread` |
69+
| `GCThread` |
5870

71+
``` csharp
5972
ThreadStoreData GetThreadStoreData()
6073
{
61-
TargetPointer threadStore = Target.ReadGlobalPointer("s_pThreadStore");
62-
var runtimeThreadStore = new ThreadStore(Target, threadStore);
63-
64-
TargetPointer firstThread = ThreadListReader.GetHead(runtimeThreadStore.SList.Pointer);
74+
TargetPointer threadStore = target.ReadGlobalPointer("ThreadStore");
6575

76+
ulong threadLinkoffset = ... // offset from Thread data descriptor
6677
return new ThreadStoreData(
67-
ThreadCount : runtimeThreadStore.m_ThreadCount,
68-
FirstThread: firstThread,
69-
FinalizerThread: Target.ReadGlobalPointer("g_pFinalizerThread"),
70-
GCThread: Target.ReadGlobalPointer("g_pSuspensionThread"));
78+
ThreadCount: target.Read<int>(threadStore + /* ThreadStore::ThreadCount offset */),
79+
FirstThread: target.ReadPointer(threadStore + /* ThreadStore::FirstThreadLink offset */ - threadLinkoffset),
80+
FinalizerThread: target.ReadGlobalPointer("FinalizerThread"),
81+
GCThread: target.ReadGlobalPointer("GCThread"));
7182
}
7283

7384
DacThreadStoreCounts GetThreadCounts()
7485
{
75-
TargetPointer threadStore = Target.ReadGlobalPointer("s_pThreadStore");
76-
var runtimeThreadStore = new ThreadStore(Target, threadStore);
86+
TargetPointer threadStore = target.ReadGlobalPointer("ThreadStore");
7787

7888
return new ThreadStoreCounts(
79-
ThreadCount : runtimeThreadStore.m_ThreadCount,
80-
UnstartedThreadCount : runtimeThreadStore.m_UnstartedThreadCount,
81-
BackgroundThreadCount : runtimeThreadStore.m_BackgroundThreadCount,
82-
PendingThreadCount : runtimeThreadStore.m_PendingThreadCount,
83-
DeadThreadCount: runtimeThreadStore.m_DeadThreadCount,
89+
UnstartedThreadCount: target.Read<int>(threadStore + /* ThreadStore::UnstartedCount offset */),
90+
BackgroundThreadCount: target.Read<int>(threadStore + /* ThreadStore::BackgroundCount offset */),,
91+
PendingThreadCount: target.Read<int>(threadStore + /* ThreadStore::PendingCount offset */),,
92+
DeadThreadCount: target.Read<int>(threadStore + /* ThreadStore::DeadCount offset */),,
8493
}
8594

86-
ThreadData GetThreadData(TargetPointer threadPointer)
95+
ThreadData GetThreadData(TargetPointer address)
8796
{
8897
var runtimeThread = new Thread(Target, threadPointer);
8998

90-
TargetPointer firstNestedException = TargetPointer.Null;
91-
if (Target.ReadGlobalInt32("FEATURE_EH_FUNCLETS"))
92-
{
93-
if (runtimeThread.m_ExceptionState.m_pCurrentTracker != TargetPointer.Null)
94-
{
95-
firstNestedException = new ExceptionTrackerBase(Target, runtimeThread.m_ExceptionState.m_pCurrentTracker).m_pPrevNestedInfo;
96-
}
97-
}
98-
else
99+
// Exception tracker is a pointer when EH funclets are enabled
100+
TargetPointer exceptionTrackerAddr = _target.ReadGlobal<byte>("FeatureEHFunclets") != 0
101+
? _target.ReadPointer(address + /* Thread::ExceptionTracker offset */)
102+
: address + /* Thread::ExceptionTracker offset */;
103+
TargetPointer firstNestedException = exceptionTrackerAddr != TargetPointer.Null
104+
? target.ReadPointer(exceptionTrackerAddr + /* ExceptionInfo::PreviousNestedInfo offset*/)
105+
: TargetPointer.Null;
106+
107+
TargetPointer allocContextPointer = TargetPointer.Null;
108+
TargetPointer allocContextLimit = TargetPointer.Null;
109+
TargetPointer threadLocals = target.ReadPointer(address + /* Thread::RuntimeThreadLocals offset */);
110+
if (threadLocals != TargetPointer.Null)
99111
{
100-
firstNestedException = runtimeThread.m_ExceptionState.m_currentExInfo.m_pPrevNestedInfo;
112+
allocContextPointer = target.ReadPointer(threadLocals + /* RuntimeThreadLocals::AllocContext offset */ + /* GCAllocContext::Pointer offset */);
113+
allocContextLimit = target.ReadPointer(threadLocals + /* RuntimeThreadLocals::AllocContext offset */ + /* GCAllocContext::Limit offset */);
101114
}
102115

116+
ulong threadLinkoffset = ... // offset from Thread data descriptor
103117
return new ThreadData(
104-
ThreadId : runtimeThread.m_ThreadId,
105-
OsThreadId : (OsThreadId)runtimeThread.m_OSThreadId,
106-
State : (ThreadState)runtimeThread.m_State,
107-
PreemptiveGCDisabled : thread.m_fPreemptiveGCDisabled != 0,
108-
AllocContextPointer : thread.m_alloc_context.alloc_ptr,
109-
AllocContextLimit : thread.m_alloc_context.alloc_limit,
110-
Frame : thread.m_pFrame,
111-
TEB : thread.Has_m_pTEB ? thread.m_pTEB : TargetPointer.Null,
112-
LastThrownObjectHandle : new DacGCHandle(thread.m_LastThrownObjectHandle),
118+
Id: target.Read<uint>(address + /* Thread::Id offset */),
119+
OSId: target.ReadNUInt(address + /* Thread::OSId offset */),
120+
State: target.Read<uint>(address + /* Thread::State offset */),
121+
PreemptiveGCDisabled: (target.Read<uint>(address + /* Thread::PreemptiveGCDisabled offset */) & 0x1) != 0,
122+
AllocContextPointer: allocContextPointer,
123+
AllocContextLimit: allocContextLimit,
124+
Frame: target.ReadPointer(address + /* Thread::Frame offset */),
125+
TEB : /* Has Thread::TEB offset */ ? target.ReadPointer(address + /* Thread::TEB offset */) : TargetPointer.Null,
126+
LastThrownObjectHandle : target.ReadPointer(address + /* Thread::LastThrownObject offset */),
113127
FirstNestedException : firstNestedException,
114-
NextThread : ThreadListReader.GetHead.GetNext(threadPointer)
128+
NextThread: target.ReadPointer(address + /* Thread::LinkNext offset */) - threadLinkOffset;
115129
);
116130
}
117131

docs/tools/illink/error-codes.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,6 +1870,22 @@ void TestMethod()
18701870
}
18711871
```
18721872

1873+
#### `IL2122`: Type 'typeName' is not assembly qualified. Type name strings used for dynamically accessing a type should be assembly qualified.
1874+
1875+
- The type name string passed to a location with `DynamicallyAccessedMembers` requirements was not assembly-qualified, so the trimmer cannot guarantee that the type is preserved. Consider using an assembly-qualified name instead.
1876+
1877+
```C#
1878+
// warning IL2122: Type 'MyClass' is not assembly qualified. Type name strings used for dynamically accessing a type should be assembly qualified.
1879+
GetTypeWrapper("MyClass");
1880+
1881+
class MyClass { }
1882+
1883+
// May be defined in another assembly, so at runtime Type.GetType will look in that assembly for "MyClass".
1884+
void GetTypeWrapper([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string typeName)
1885+
{
1886+
var type = Type.GetType(typeName);
1887+
}
1888+
```
18731889

18741890
## Single-File Warning Codes
18751891

docs/workflow/requirements/windows-requirements.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,33 @@ You can also temporarily add a directory to the PATH environment variable with t
108108
You can make your change to the PATH variable persistent by going to _Control Panel -> System And Security -> System -> Advanced system settings -> Environment Variables_, and select the `Path` variable under `System Variables` (if you want to change it for all users) or `User Variables` (if you only want to change it for the current user).
109109

110110
Simply edit the PATH variable's value and add the directory (with a semicolon separator).
111+
112+
### Windows on Arm64
113+
114+
The Windows on Arm64 development experience has improved substantially over the last few years, however there are still a few steps you should take to improve performance when developing dotnet/runtime on an ARM device.
115+
116+
During preview releases, the repo sources its compilers from the [Microsoft.NET.Compilers.Toolset](https://www.nuget.org/packages/Microsoft.Net.Compilers.Toolset/) package whose bits aren't configured for the ARM64 build of .NET framework. This can result in [suboptimal performance](https://github.com/dotnet/runtime/issues/104548) when working on libraries in Visual Studio. The issue can be worked around by [configuring the registry](https://github.com/dotnet/runtime/issues/104548#issuecomment-2214581797) to run the compiler as Arm64 processes. The proper fix that will make this workaround unnecessary is being worked on in [this PR](https://github.com/dotnet/roslyn/pull/74285).
117+
118+
Using an Administrator Powershell prompt run the script:
119+
120+
```powershell
121+
function SetPreferredMachineToArm64($imageName)
122+
{
123+
$RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\${imageName}"
124+
$Name = "PreferredMachine"
125+
$Value = [convert]::ToInt32("aa64", 16)
126+
127+
# Create the key if it does not exist
128+
If (-NOT (Test-Path $RegistryPath)) {
129+
New-Item -Path $RegistryPath -Force | Out-Null
130+
}
131+
132+
# Now set the value
133+
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType DWORD -Force
134+
}
135+
136+
SetPreferredMachineToArm64('csc.exe')
137+
SetPreferredMachineToArm64('VBCSCompiler.exe')
138+
```
139+
140+
Then restart any open Visual Studio applications.

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<MinorVersion>0</MinorVersion>
88
<PatchVersion>0</PatchVersion>
99
<SdkBandVersion>9.0.100</SdkBandVersion>
10-
<PackageVersionNet8>8.0.5</PackageVersionNet8>
11-
<PackageVersionNet7>7.0.19</PackageVersionNet7>
10+
<PackageVersionNet8>8.0.7</PackageVersionNet8>
11+
<PackageVersionNet7>7.0.20</PackageVersionNet7>
1212
<PackageVersionNet6>6.0.$([MSBuild]::Add($([System.Version]::Parse('$(PackageVersionNet8)').Build),25))</PackageVersionNet6>
1313
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
1414
<PreReleaseVersionIteration>7</PreReleaseVersionIteration>

eng/build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Param(
1111
[switch]$coverage,
1212
[string]$testscope,
1313
[switch]$testnobuild,
14-
[ValidateSet("x86","x64","arm","arm64","wasm")][string[]][Alias('a')]$arch = @([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()),
14+
[ValidateSet("x86","x64","arm","arm64","wasm")][string[]][Alias('a')]$arch = @([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant()),
1515
[switch]$cross = $false,
1616
[string][Alias('s')]$subset,
1717
[ValidateSet("Debug","Release","Checked")][string][Alias('rc')]$runtimeConfiguration,
@@ -31,7 +31,7 @@ function Get-Help() {
3131
Write-Host "Common settings:"
3232
Write-Host " -arch (-a) Target platform: x86, x64, arm, arm64, or wasm."
3333
Write-Host " Pass a comma-separated list to build for multiple architectures."
34-
Write-Host (" [Default: {0} (Depends on your console's architecture.)]" -f [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())
34+
Write-Host " [Default: Your machine's architecture.]"
3535
Write-Host " -binaryLog (-bl) Output binary log."
3636
Write-Host " -configuration (-c) Build configuration: Debug, Release or Checked."
3737
Write-Host " Checked is exclusive to the CLR subset. It is the same as Debug, except code is"

eng/native/configurecompiler.cmake

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -976,27 +976,13 @@ endif()
976976

977977
# Ensure other tools are present
978978
if (CLR_CMAKE_HOST_WIN32)
979-
if(CLR_CMAKE_HOST_ARCH_ARM)
980-
981-
# Explicitly specify the assembler to be used for Arm32 compile
982-
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)
983-
984-
set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
985-
message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")
986-
987-
# Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
988-
# use ml[64].exe as the assembler.
989-
enable_language(ASM)
990-
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
991-
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
992-
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
993-
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
994-
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -g <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
995-
996-
elseif(CLR_CMAKE_HOST_ARCH_ARM64)
997-
979+
if(CLR_CMAKE_HOST_ARCH_ARM64)
998980
# Explicitly specify the assembler to be used for Arm64 compile
999-
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
981+
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
982+
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\Hostarm64\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
983+
else()
984+
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX64\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
985+
endif()
1000986

1001987
set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER})
1002988
message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}")

eng/native/init-vs-env.cmd

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44
:: as an argument, it also initializes VC++ build environment and CMakePath.
55

66
set "__VCBuildArch="
7-
if /i "%~1" == "x86" (set __VCBuildArch=x86)
8-
if /i "%~1" == "x64" (set __VCBuildArch=x86_amd64)
9-
if /i "%~1" == "arm64" (if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" (set __VCBuildArch=arm64) else (set __VCBuildArch=x86_arm64))
10-
if /i "%~1" == "wasm" (if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" (set __VCBuildArch=arm64) else (set __VCBuildArch=x86_amd64))
7+
if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" (
8+
if /i "%~1" == "x64" ( set __VCBuildArch=arm64_amd64 )
9+
if /i "%~1" == "x86" ( set __VCBuildArch=arm64_x86 )
10+
if /i "%~1" == "arm64" ( set __VCBuildArch=arm64 )
11+
if /i "%~1" == "wasm" ( set __VCBuildArch=arm64 )
12+
) else (
13+
if /i "%~1" == "x64" ( set __VCBuildArch=amd64 )
14+
if /i "%~1" == "x86" ( set __VCBuildArch=amd64_x86 )
15+
if /i "%~1" == "arm64" ( set __VCBuildArch=amd64_arm64 )
16+
if /i "%~1" == "wasm" ( set __VCBuildArch=amd64 )
17+
)
1118

1219
:: Default to highest Visual Studio version available that has Visual C++ tools.
1320
::

eng/pipelines/coreclr/templates/helix-queues-setup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ jobs:
7070
# Linux arm64
7171
- ${{ if eq(parameters.platform, 'linux_arm64') }}:
7272
- ${{ if eq(variables['System.TeamProject'], 'public') }}:
73-
- (Ubuntu.1804.Arm64.Open)[email protected]/dotnet-buildtools/prereqs:ubuntu-18.04-helix-arm64v8
73+
- (Ubuntu.2004.Arm64.Open)[email protected]/dotnet-buildtools/prereqs:ubuntu-20.04-helix-arm64v8
7474
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
75-
- (Ubuntu.1804.Arm64)[email protected]/dotnet-buildtools/prereqs:ubuntu-18.04-helix-arm64v8
75+
- (Ubuntu.2004.Arm64)[email protected]/dotnet-buildtools/prereqs:ubuntu-20.04-helix-arm64v8
7676

7777
# Linux musl x64
7878
- ${{ if eq(parameters.platform, 'linux_musl_x64') }}:

eng/testing/tests.mobile.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<PublishTrimmed>true</PublishTrimmed>
3030
<!-- Suppress trimming warnings as these are tests -->
3131
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
32-
<NoWarn>$(NoWarn);IL2103;IL2105;IL2025;IL2111</NoWarn>
32+
<NoWarn>$(NoWarn);IL2103;IL2025;IL2111;IL2122</NoWarn>
3333

3434
<!-- Reduce library test app size by trimming framework library features -->
3535
<DebuggerSupport Condition="'$(DebuggerSupport)' == '' and '$(Configuration)' != 'Debug'">false</DebuggerSupport>

0 commit comments

Comments
 (0)