Skip to content

Commit

Permalink
Merge branch 'main' into wasi_sdk22
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed Jul 9, 2024
2 parents 52e14b3 + 5b5d791 commit 50b756a
Show file tree
Hide file tree
Showing 518 changed files with 20,919 additions and 9,103 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
<NoTargetFrameworkFiltering>true</NoTargetFrameworkFiltering>

<NativeBuildPartitionPropertiesToRemove>ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrILToolsSubset;ClrNativeAotSubset;ClrSpmiSubset;ClrCrossComponentsSubset;ClrDebugSubset;HostArchitecture;PgoInstrument;NativeOptimizationDataSupported;CMakeArgs;CxxStandardLibrary;CxxStandardLibraryStatic;CxxAbiLibrary</NativeBuildPartitionPropertiesToRemove>
<UseSystemZlib Condition="'$(TargetsAppleMobile)' == 'true' or '$(TargetOS)' == 'android' or '$(TargetArchitecture)' == 'armv6'">true</UseSystemZlib>
</PropertyGroup>

<!-- RepositoryEngineeringDir isn't set when Installer tests import this file. -->
Expand Down
2 changes: 1 addition & 1 deletion docs/area-owners.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Note: Editing this file doesn't update the mapping used by `@msftbot` for area-s
| area-UWP | @tommcdon | @dotnet/area-uwp | UWP-specific issues including Microsoft.NETCore.UniversalWindowsPlatform and Microsoft.Net.UWPCoreRuntimeSdk |
| area-VM-coreclr | @mangod9 | @mangod9 | |
| area-VM-meta-mono | @steveisok | @lambdageek | |
| area-VM-reflection-mono | @mangod9 | @lambdageek | MonoVM-specific reflection and reflection-emit issues |
| area-VM-reflection-mono | @steveisok | @lambdageek | MonoVM-specific reflection and reflection-emit issues |
| area-VM-threading-mono | @mangod9 | @lambdageek | |
| area-Workloads | @lewing | @dotnet/net-sdk-workload-contributors | |

Expand Down
224 changes: 224 additions & 0 deletions docs/design/datacontracts/RuntimeTypeSystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
# Contract RuntimeTypeSystem

This contract is for exploring the properties of the runtime types of values on the managed heap or on the stack in a .NET process.

## APIs of contract

A `MethodTable` is the runtime representation of the type information about a value. Given a `TargetPointer` address, the `RuntimeTypeSystem` contract provides a `MethodTableHandle` for querying the `MethodTable`.

``` csharp
struct MethodTableHandle
{
// no public properties or constructors
internal TargetPointer Address { get; }
}
```

``` csharp
#region MethodTable inspection APIs
public virtual MethodTableHandle GetMethodTableHandle(TargetPointer targetPointer);

public virtual TargetPointer GetModule(MethodTableHandle methodTable);
// A canonical method table is either the MethodTable itself, or in the case of a generic instantiation, it is the
// MethodTable of the prototypical instance.
public virtual TargetPointer GetCanonicalMethodTable(MethodTableHandle methodTable);
public virtual TargetPointer GetParentMethodTable(MethodTableHandle methodTable);

public virtual uint GetBaseSize(MethodTableHandle methodTable);
// The component size is only available for strings and arrays. It is the size of the element type of the array, or the size of an ECMA 335 character (2 bytes)
public virtual uint GetComponentSize(MethodTableHandle methodTable);

// True if the MethodTable is the sentinel value associated with unallocated space in the managed heap
public virtual bool IsFreeObjectMethodTable(MethodTableHandle methodTable);
public virtual bool IsString(MethodTableHandle methodTable);
// True if the MethodTable represents a type that contains managed references
public virtual bool ContainsGCPointers(MethodTableHandle methodTable);
public virtual bool IsDynamicStatics(MethodTableHandle methodTable);
public virtual ushort GetNumMethods(MethodTableHandle methodTable);
public virtual ushort GetNumInterfaces(MethodTableHandle methodTable);

// Returns an ECMA-335 TypeDef table token for this type, or for its generic type definition if it is a generic instantiation
public virtual uint GetTypeDefToken(MethodTableHandle methodTable);
// Returns the ECMA 335 TypeDef table Flags value (a bitmask of TypeAttributes) for this type,
// or for its generic type definition if it is a generic instantiation
public virtual uint GetTypeDefTypeAttributes(MethodTableHandle methodTable);
#endregion MethodTable inspection APIs
```

## Version 1

The `MethodTable` inspection APIs are implemented in terms of the following flags on the runtime `MethodTable` structure:

``` csharp
internal partial struct RuntimeTypeSystem_1
{
// The lower 16-bits of the MTFlags field are used for these flags,
// if WFLAGS_HIGH.HasComponentSize is unset
[Flags]
internal enum WFLAGS_LOW : uint
{
GenericsMask = 0x00000030,
GenericsMask_NonGeneric = 0x00000000, // no instantiation
StringArrayValues = GenericsMask_NonGeneric,
}

// Upper bits of MTFlags
[Flags]
internal enum WFLAGS_HIGH : uint
{
Category_Mask = 0x000F0000,
Category_Array = 0x00080000,
Category_Array_Mask = 0x000C0000,
Category_Interface = 0x000C0000,
ContainsGCPointers = 0x01000000,
HasComponentSize = 0x80000000, // This is set if lower 16 bits is used for the component size,
// otherwise the lower bits are used for WFLAGS_LOW
}

[Flags]
internal enum WFLAGS2_ENUM : uint
{
DynamicStatics = 0x0002,
}

// Encapsulates the MethodTable flags v1 uses
internal struct MethodTableFlags
{
public uint MTFlags { get; }
public uint MTFlags2 { get; }
public uint BaseSize { get; }

public WFLAGS_LOW GetFlag(WFLAGS_LOW mask) { ... /* mask & lower 16 bits of MTFlags */ }
public WFLAGS_HIGH GetFlag(WFLAGS_HIGH mask) { ... /* mask & upper 16 bits of MTFlags */ }

public WFLAGS2_ENUM GetFlag(WFLAGS2_ENUM mask) { ... /* mask & MTFlags2*/ }

private bool TestFlagWithMask(WFLAGS_LOW mask, WFLAGS_LOW flag)
{
if (IsStringOrArray)
{
return (WFLAGS_LOW.StringArrayValues & mask) == flag;
}
else
{
return (FlagsLow & mask) == flag;
}
}

public ushort ComponentSizeBits => (ushort)(MTFlags & 0x0000ffff); // only meaningful if HasComponentSize is set
public bool HasComponentSize => GetFlag(WFLAGS_HIGH.HasComponentSize) != 0;
public bool IsInterface => GetFlag(WFLAGS_HIGH.Category_Mask) == WFLAGS_HIGH.Category_Interface;
public bool IsString => HasComponentSize && !IsArray && ComponentSizeBits == 2;
public bool IsArray => GetFlag(WFLAGS_HIGH.Category_Array_Mask) == WFLAGS_HIGH.Category_Array;
public bool IsStringOrArray => HasComponentSize;
public ushort ComponentSize => HasComponentSize ? ComponentSizeBits : (ushort)0;
public bool HasInstantiation => !TestFlagWithMask(WFLAGS_LOW.GenericsMask, WFLAGS_LOW.GenericsMask_NonGeneric);
public bool ContainsGCPointers => GetFlag(WFLAGS_HIGH.ContainsGCPointers) != 0;
public bool IsDynamicStatics => GetFlag(WFLAGS2_ENUM.DynamicStatics) != 0;
}

[Flags]
internal enum EEClassOrCanonMTBits
{
EEClass = 0,
CanonMT = 1,
Mask = 1,
}
}
```

Internally the contract has a `MethodTable_1` struct that depends on the `MethodTable` data descriptor

```csharp
internal struct MethodTable_1
{
internal RuntimeTypeSystem_1.MethodTableFlags Flags { get; }
internal ushort NumInterfaces { get; }
internal ushort NumVirtuals { get; }
internal TargetPointer ParentMethodTable { get; }
internal TargetPointer Module { get; }
internal TargetPointer EEClassOrCanonMT { get; }
internal MethodTable_1(Data.MethodTable data)
{
Flags = new RuntimeTypeSystem_1.MethodTableFlags
{
MTFlags = data.MTFlags,
MTFlags2 = data.MTFlags2,
BaseSize = data.BaseSize,
};
NumInterfaces = data.NumInterfaces;
NumVirtuals = data.NumVirtuals;
EEClassOrCanonMT = data.EEClassOrCanonMT;
Module = data.Module;
ParentMethodTable = data.ParentMethodTable;
}
}
```

The contract depends on the global pointer value `FreeObjectMethodTablePointer`.
The contract additionally depends on the `EEClass` data descriptor.

```csharp
private readonly Dictionary<TargetPointer, MethodTable_1> _methodTables;

internal TargetPointer FreeObjectMethodTablePointer {get; }

public MethodTableHandle GetMethodTableHandle(TargetPointer methodTablePointer)
{
... // validate that methodTablePointer points to something that looks like a MethodTable.
... // read Data.MethodTable from methodTablePointer.
... // create a MethodTable_1 and add it to _methodTables.
return MethodTableHandle { Address = methodTablePointer }
}

internal static EEClassOrCanonMTBits GetEEClassOrCanonMTBits(TargetPointer eeClassOrCanonMTPtr)
{
return (EEClassOrCanonMTBits)(eeClassOrCanonMTPtr & (ulong)EEClassOrCanonMTBits.Mask);
}

public uint GetBaseSize(MethodTableHandle methodTableHandle) => _methodTables[methodTableHandle.Address].Flags.BaseSize;

public uint GetComponentSize(MethodTableHandle methodTableHandle) => GetComponentSize(_methodTables[methodTableHandle.Address]);

private TargetPointer GetClassPointer(MethodTableHandle methodTableHandle)
{
... // if the MethodTable stores a pointer to the EEClass, return it
// otherwise the MethodTable stores a pointer to the canonical MethodTable
// in that case, return the canonical MethodTable's EEClass.
// Canonical MethodTables always store an EEClass pointer.
}

private Data.EEClass GetClassData(MethodTableHandle methodTableHandle)
{
TargetPointer eeClassPtr = GetClassPointer(methodTableHandle);
... // read Data.EEClass data from eeClassPtr
}


public TargetPointer GetCanonicalMethodTable(MethodTableHandle methodTableHandle) => GetClassData(methodTableHandle).MethodTable;

public TargetPointer GetModule(MethodTableHandle methodTableHandle) => _methodTables[methodTableHandle.Address].Module;
public TargetPointer GetParentMethodTable(MethodTableHandle methodTableHandle) => _methodTables[methodTableHandle.Address].ParentMethodTable;

public bool IsFreeObjectMethodTable(MethodTableHandle methodTableHandle) => FreeObjectMethodTablePointer == methodTableHandle.Address;

public bool IsString(MethodTableHandle methodTableHandle) => _methodTables[methodTableHandle.Address].Flags.IsString;
public bool ContainsGCPointers(MethodTableHandle methodTableHandle) => _methodTables[methodTableHandle.Address].Flags.ContainsGCPointers;

public uint GetTypeDefToken(MethodTableHandle methodTableHandle)
{
MethodTable_1 methodTable = _methodTables[methodTableHandle.Address];
return (uint)(methodTable.Flags.GetTypeDefRid() | ((int)TableIndex.TypeDef << 24));
}

public ushort GetNumMethods(MethodTableHandle methodTableHandle) => GetClassData(methodTableHandle).NumMethods;

public ushort GetNumInterfaces(MethodTableHandle methodTableHandle) => _methodTables[methodTableHandle.Address].NumInterfaces;

public uint GetTypeDefTypeAttributes(MethodTableHandle methodTableHandle) => GetClassData(methodTableHandle).CorTypeAttr;

public bool IsDynamicStatics(MethodTableHandle methodTableHandle) => _methodTables[methodTableHandle.Address].Flags.IsDynamicStatics;
```
22 changes: 11 additions & 11 deletions docs/project/dogfooding.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dotnet new nugetconfig

Next, add the package source to NuGet.Config with the [dotnet nuget add source](https://learn.microsoft.com/dotnet/core/tools/dotnet-nuget-add-source) command:
```
dotnet nuget add source -n dotnet8 https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet8/nuget/v3/index.json
dotnet nuget add source -n dotnet9 https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet9/nuget/v3/index.json
```

Then, you will be able to add the latest prerelease version of the desired package to your project.
Expand All @@ -31,7 +31,7 @@ To use daily builds of the entire runtime, follow the steps given in the rest of
If you're using private Azure DevOps feeds for your projects, you might need to add the preview feed through the Azure-specific feed URI format, which is `azure-feed://organization/optionalProject/feed@view`. In this case, you can add the .NET development package feed as follows:

```
azure-feed://dnceng/public/dotnet8@Local
azure-feed://dnceng/public/dotnet9@Local
```

## Install prerequisites
Expand All @@ -40,19 +40,19 @@ azure-feed://dnceng/public/dotnet8@Local

2. If you are using a local copy of the dotnet CLI, take care that when you type `dotnet` you do not inadvertently pick up a different copy that you may have in your path. On Windows, for example, if you use a Command Prompt, a global copy may be in the path, so use the fully qualified path to your local `dotnet` (e.g. `C:\dotnet\dotnet.exe`). If you receive an error "error NETSDK1045: The current .NET SDK does not support targeting .NET 9.0." then you may be executing an older `dotnet`.

After setting up dotnet you can verify you are using the dogfooding version by executing `dotnet --info`. Here is an example output at the time of writing:
After setting up dotnet you can verify you are using the current preview version by executing `dotnet --info`. Here is an example output:
```
>dotnet --info
.NET SDK:
Version: 9.0.100-preview.5.22226.4
Version: 9.0.100-preview.1.23456.7
Commit: fc127ac5a4
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22616
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100-preview.5.22226.4\
Base Path: C:\Program Files\dotnet\sdk\9.0.100-preview.1.23456.7\
global.json file:
Not found
Expand All @@ -63,10 +63,10 @@ Host:
Commit: 47d9c43ab1
.NET SDKs installed:
9.0.100-preview.5.22226.4 [C:\Program Files\dotnet\sdk]
9.0.100-preview.1.23456.7 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.NETCore.App 9.0.0-preview.5.22224.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0-preview.1.23456.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Download .NET:
https://aka.ms/dotnet-download
Expand All @@ -79,7 +79,7 @@ Learn about .NET Runtimes and SDKs:
3. Our daily builds are uploaded to development feed, not NuGet - so ensure the development feed is in your nuget configuration in case you need other packages that aren't included in the download. For example, on Windows you could edit `%userprofile%\appdata\roaming\nuget\nuget.config` or on Linux edit `~/.nuget/NuGet/NuGet.Config` to add these lines:
```xml
<packageSources>
<add key="dotnet8" value="https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet8/nuget/v3/index.json" />
<add key="dotnet9" value="https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet9/nuget/v3/index.json" />
...
</packageSources>
```
Expand Down Expand Up @@ -150,7 +150,7 @@ make it self-contained by adding a RuntimeIdentifier (RID).
<!-- Ensure that the target framework is correct e.g. 'net9.0' -->
<TargetFramework>net9.0</TargetFramework>
<!-- modify build in this line with version reported by `dotnet --info` as above under ".NET runtimes installed" -> Microsoft.NETCore.App -->
<!-- moreover, this can be any valid Microsoft.NETCore.App package version from https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json -->
<!-- moreover, this can be any valid Microsoft.NETCore.App package version from https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json -->
<RuntimeFrameworkVersion>9.0.0-preview.5.22224.3</RuntimeFrameworkVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <!-- RID to make it self-contained -->
</PropertyGroup>
Expand All @@ -165,8 +165,8 @@ $ bin\Debug\net9.0\win-x64\publish\App.exe
### Daily builds table

<!--
To update this table, run 'build.sh/cmd RegenerateDownloadTable'. See
'tools-local/regenerate-readme-table.proj' to add or remove rows or columns,
To update this table, run 'build.sh/cmd -s RegenerateDownloadTable'. See
'eng/regenerate-download-table.csproj' to add or remove rows or columns,
and add links below to fill out the table's contents.
-->
<!-- BEGIN generated table -->
Expand Down
1 change: 1 addition & 0 deletions docs/project/list-of-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute
| __`SYSLIB0053`__ | AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size. |
| __`SYSLIB0054`__ | Thread.VolatileRead and Thread.VolatileWrite are obsolete. Use Volatile.Read or Volatile.Write respectively instead. |
| __`SYSLIB0055`__ | The underlying hardware instruction does not perform a signed saturate narrowing operation, and it always returns an unsigned result. Use the unsigned overload instead. |
| __`SYSLIB0057`__ | Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates. |

## Analyzer Warnings

Expand Down
1 change: 1 addition & 0 deletions docs/workflow/ci/pr-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Anyone with write access can merge a pull request manually when the following co
* The PR has been approved by at least one reviewer and any other objections are addressed.
* You can request another review from the original reviewer.
* The PR successfully builds and passes all tests in the Continuous Integration (CI) system. In case of failures, refer to the [analyzing build failures](failure-analysis.md) doc.
* The CI results are no more than 1 week old.

Typically, PRs are merged as one commit (squash merges). It creates a simpler history than a Merge Commit. "Special circumstances" are rare, and typically mean that there are a series of cleanly separated changes that will be too hard to understand if squashed together, or for some reason we want to preserve the ability to disect them.

Expand Down
Loading

0 comments on commit 50b756a

Please sign in to comment.