Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit cc29bc4

Browse files
authored
Merge pull request #24118 from dotnet-maestro-bot/merge/master-to-release/3.0
[automated] Merge branch 'master' => 'release/3.0'
2 parents 9562c55 + b1d22a4 commit cc29bc4

File tree

1,255 files changed

+24777
-18243
lines changed

Some content is hidden

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

1,255 files changed

+24777
-18243
lines changed

BuildToolsVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0-preview4-03906-01
1+
3.0.0-preview4-03913-01

Documentation/Profiling/Profiler Loading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If any of these environment variable are present, we skip the registry look up a
1616

1717
A couple things to note about this:
1818
- If you specify `CORECLR_PROFILER_PATH` _and_ register your profiler, then `CORECLR_PROFILER_PATH` always wins. Even if `CORECLR_PROFILER_PATH` points to an invalid path, we will still use `CORECLR_PROFILER_PATH`, and just fail to load your profiler.
19-
- `CORECLR_R_PROFILER` is _always required_. If you specify `CORECLR_PROFILER_PATH`, we skip the registry look up. We still need to know your profiler's CLSID, so we can pass it to your class factory's CreateInstance call.
19+
- `CORECLR_PROFILER` is _always required_. If you specify `CORECLR_PROFILER_PATH`, we skip the registry look up. We still need to know your profiler's CLSID, so we can pass it to your class factory's CreateInstance call.
2020

2121

2222
## Through the registry (Windows Only)

Documentation/Profiling/davbr-blog-archive/samples/PlugInToYourProfiler.cpp

Lines changed: 477 additions & 1 deletion
Large diffs are not rendered by default.

Documentation/Profiling/davbr-blog-archive/samples/sigparse.cpp

Lines changed: 1051 additions & 1 deletion
Large diffs are not rendered by default.

Documentation/building/windows-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Visual Studio Express is not supported.
5050

5151
## CMake
5252

53-
The CoreCLR repo build has been validated using CMake 3.9.3.
53+
The CoreCLR repo build has been validated using CMake 3.9.3. When using Visual Studio 2019 at least version 3.14.1 is required.
5454

5555
- Install [CMake](http://www.cmake.org/download) for Windows.
5656
- Add its location (e.g. C:\Program Files (x86)\CMake\bin) to the PATH environment variable.
@@ -60,7 +60,7 @@ The CoreCLR repo build has been validated using CMake 3.9.3.
6060

6161
## Python
6262

63-
Python is used in the build system. We are currently using python 2.7.9, although
63+
Python is used in the build system. We are currently using Python 2.7.9, although
6464
any recent (2.4+) version of Python should work, including Python 3.
6565
- Install [Python](https://www.python.org/downloads/) for Windows.
6666
- Add its location (e.g. C:\Python*\) to the PATH environment variable.

Documentation/deep-dive-blog-posts.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
### Posts that take a high-level overview of releases
44

55
- [Corestart 2.0: What's new for performance in .NET Core 2.0](https://www.ageofascent.com/2017/11/05/perfromance-dotnet-core-2-corestart-conference/)
6+
- [Performance improvements in .NET Core 2.0](https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-core/)
7+
- [Performance improvements in .NET Core 2.1](https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-core-2-1/)
68

79

810
### Posts that take a high-level look at the entire source:

Documentation/design-docs/AssemblyLoadContext.ContextualReflection.md

Lines changed: 91 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace System.Reflection
5151
{
5252
public static Assembly Load(string assemblyString);
5353
public static Assembly Load(AssemblyName assemblyRef);
54+
public static Assembly LoadWithPartialName (string partialName);
5455
}
5556
}
5657
```
@@ -65,8 +66,18 @@ namespace System
6566
public static Type GetType(string typeName);
6667
}
6768
}
69+
70+
namespace System.Reflection
71+
{
72+
public abstract partial class Assembly : ICustomAttributeProvider, ISerializable
73+
{
74+
public Type GetType(string typeName, bool throwOnError, bool ignoreCase);
75+
public Type GetType(string typeName, bool throwOnError);
76+
public Type GetType(string typeName);
77+
}
78+
}
6879
```
69-
#### Unamiguous APIs related to affected APIs
80+
#### Normally unamiguous APIs related to affected APIs
7081
```C#
7182
namespace System
7283
{
@@ -78,9 +89,9 @@ namespace System
7889
}
7990
}
8091
```
81-
In this case, `assemblyResolver` functionally specifies the explicit mechanism to load. This indicates the current assembly's `AssmblyLoadContext` is not being used. If the `assemblyResolver` is only serving as a first or last chance resolver, then these would also be in the set of affected APIs.
82-
#### Should be affected APIs
83-
Issue https://github.com/dotnet/coreclr/issues/22213, discusses scenarios in which various flavors of the API `GetType()` is not functioning correctly. As part of the analysis and fix of that issue, the set of affected APIs may increase.
92+
In this case, `assemblyResolver` functionally specifies the explicit mechanism to load.
93+
94+
If the `assemblyResolver` is `null`, assembly loads for these occur when `typeName` includes a assembly-qualified type reference.
8495
### Root cause analysis
8596
In .NET Framework, plugin isolation was provided by creating multiple `AppDomain` instances. .NET Core dropped support for multiple `AppDomain` instances. Instead we introduced `AssemblyLoadContext`.
8697

@@ -112,10 +123,10 @@ namespace System.Runtime.Loader
112123
{
113124
public partial class AssemblyLoadContext
114125
{
115-
private static readonly AsyncLocal<AssemblyLoadContext> asyncLocalActiveContext = new AsyncLocal<AssemblyLoadContext>(null);
126+
private static readonly AsyncLocal<AssemblyLoadContext> _asyncLocalActiveContext;
116127
public static AssemblyLoadContext CurrentContextualReflectionContext
117128
{
118-
get { return _asyncLocalCurrentContextualReflectionContext.Value; }
129+
get { return _asyncLocalCurrentContextualReflectionContext?.Value; }
119130
}
120131
}
121132
}
@@ -203,7 +214,7 @@ namespace System.Runtime.Loader
203214
{
204215
public partial class AssemblyLoadContext
205216
{
206-
public static AssemblyLoadContext CurrentContextualReflectionContext { get { return _asyncLocalCurrentContextualReflectionContext.Value; }}
217+
public static AssemblyLoadContext CurrentContextualReflectionContext { get { return _asyncLocalCurrentContextualReflectionContext?.Value; }}
207218

208219
public ContextualReflectionScope EnterContextualReflection();
209220

@@ -218,62 +229,93 @@ namespace System.Runtime.Loader
218229
```
219230
## Design doc
220231

221-
Mostly TBD.
222-
223-
### Performance Consideration
224-
#### Avoiding native / managed transitions
232+
### Affected runtime native calls
225233

226-
My natural inclination would be to replace most native calls taking a `StackCrawlMark` with callS taking the `CurrentContextualReflectionContext`. When `CurrentContextualReflectionContext` is `null`, resolve the `StackCrawlMark` first, passing the result as the inferred context.
234+
The affected runtime native calls correspond to the runtime's mechanism to load an assembly, and to get a type. Each affected native call is passed a managed reference to the CurrentContextualReflectionContext. This prevents GC holes, while running the native code. The `CurrentContextualReflectionContext` acts as the mechanism for resolving assembly names to assemblies.
227235

228-
However this may require mutiple native/managed transitions. Performance considerations may require Native calls which currently take a `StackCrawlMark` will need to be modified to also take `CurrentContextualReflectionContext`.
236+
### Unloadability
229237

230-
### Hypothetical Advanced/Problematic use cases
238+
`CurrentContextualReflectionContext` will hold an `AssemblyLoadContext` reference. This will prevent the context from being unloaded while it could be used. As an `AsyncLocal<AssemblyLoadContext>`, the setting will propagate to child threads and asynchronous tasks.
239+
After a thread or asynchronous task completes, the `AsyncLocal<AssemblyLoadContext>` will eventually be cleared, this will unblock the `AssemblyLoadContext` unload. The timing of this unload depends on the ThreadPool implementation.
231240

232-
One could imagine complicated scenarios in which we need to handle ALCs on event callback boundaries. These are expected to be rare. The following are representative patterns that demonstrate the possibility to be support these more complicated usages.
241+
### ContextualReflectionScope
233242

234-
#### An incoming event handler into an AssemblyLoadContext
235243
```C#
236-
void OnEvent()
244+
/// <summary>Opaque disposable struct used to restore CurrentContextualReflectionContext</summary>
245+
/// <remarks>
246+
/// This is an implmentation detail of the AssemblyLoadContext.EnterContextualReflection APIs.
247+
/// It is a struct, to avoid heap allocation.
248+
/// It is required to be public to avoid boxing.
249+
/// <see cref="System.Runtime.Loader.AssemblyLoadContext.EnterContextualReflection"/>
250+
/// </remarks>
251+
[EditorBrowsable(EditorBrowsableState.Never)]
252+
public struct ContextualReflectionScope : IDisposable
237253
{
238-
using (alc.Activate())
239-
{
240-
...
241-
}
242-
}
243-
```
244-
#### An incoming event handler into a collectible AssemblyLoadContext
245-
```C#
246-
class WeakAssemblyLoadContextEventHandler
247-
{
248-
WeakReference<AssemblyLoadContext> weakAlc;
254+
private readonly AssemblyLoadContext _activated;
255+
private readonly AssemblyLoadContext _predecessor;
256+
private readonly bool _initialized;
249257

250-
void OnEvent()
251-
{
252-
AssemblyLoadContext alc;
253-
if(weakAlc.TryGetTarget(out alc))
258+
internal ContextualReflectionScope(AssemblyLoadContext activating)
254259
{
255-
using (alc.Activate())
256-
{
257-
...
258-
}
260+
_predecessor = AssemblyLoadContext.CurrentContextualReflectionContext;
261+
AssemblyLoadContext.SetCurrentContextualReflectionContext(activating);
262+
_activated = activating;
263+
_initialized = true;
264+
}
265+
266+
public void Dispose()
267+
{
268+
if (_initialized)
269+
{
270+
// Do not clear initialized. Always restore the _predecessor in Dispose()
271+
// _initialized = false;
272+
AssemblyLoadContext.SetCurrentContextualReflectionContext(_predecessor);
273+
}
259274
}
260-
}
261275
}
262276
```
263-
#### A outgoing callback
277+
278+
`_initialized` is included to prevent useful default construction. It prevents the `default(ContextualReflectionScope).Dispose()` case.
279+
280+
`_predecessor` represents the previous value of `CurrentContextualReflectionContext`. It is used by `Dispose()` to restore the previous state.
281+
282+
`_activated` is included as a potential aid to debugging. It serves no other useful purpose.
283+
284+
This struct is implemented as a readonly struct. No state is modified after construction. This means `Dispose()` can be called multiple times. This means `using` blocks will always restore the previous `CurrentContextualReflectionContext` as exiting.
285+
286+
### Unusual usage patterns
287+
288+
There are some unusual usage patterns which are not recommended, but not prohibited. They all have reasonable behaviors.
289+
290+
* Clear but never restore the CurrentContextualReflectionContext
291+
```C#
292+
myAssemblyLoadContext.EnterContextualReflection(null);
293+
```
294+
295+
* Set but never clear the CurrentContextualReflectionContext
264296
```C#
265-
using (AssemblyLoadContext.Activate(null))
266-
{
267-
Callback();
268-
}
297+
myAssemblyLoadContext.EnterContextualReflection();
269298
```
270-
#### An outgoing event handler
299+
300+
* Manual dispose
271301
```C#
272-
void OnEvent()
302+
myAssemblyLoadContext.EnterContextualReflection();
303+
304+
scope.Dispose();
305+
```
306+
307+
* Multiple dispose
308+
```C#
309+
ContextualReflectionScope scope = myAssemblyLoadContext.EnterContextualReflection();
310+
311+
scope.Dispose(); // Will restore the context as set during `EnterContextualReflection()`
312+
scope.Dispose(); // Will restore the context as set during `EnterContextualReflection()` (again)
313+
```
314+
315+
* Early dispose
316+
```C#
317+
using (ContextualReflectionScope scope = myAssemblyLoadContext.EnterContextualReflection())
273318
{
274-
using (AssemblyLoadContext.Activate(null))
275-
{
276-
...
277-
}
278-
}
319+
scope.Dispose(); // Will restore the context as set during `EnterContextualReflection()`
320+
} // `using` will restore the context as set during `EnterContextualReflection()` (again)
279321
```

Documentation/project-docs/clr-configuration-knobs.csx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,13 @@ public static class ConfigKnobsDoc
350350
"## Environment/Registry Configuration Knobs\n";
351351

352352
public static string ClrConfigSectionInfo =
353-
"This table was machine-generated using `clr-configuration-knobs.csx` script from repository commit [GIT_SHORT_HASH](https://github.com/dotnet/coreclr/commit/GIT_LONG_HASH) on DATE_CREATED. It might be out of date. To generate latest documentation run `{dotnet} csi clr-configuration-knobs.csx` from this file directory.\n";
353+
"This table was machine-generated using `clr-configuration-knobs.csx` script from repository commit [GIT_SHORT_HASH](https://github.com/dotnet/coreclr/commit/GIT_LONG_HASH) on DATE_CREATED. It might be out of date. To generate latest documentation run `dotnet-script clr-configuration-knobs.csx` from this file directory.\n";
354354

355355
public static string ClrConfigSectionUsage =
356356
"When using these configurations from environment variables, the variables need to have the `COMPlus_` prefix in their names. e.g. To set DumpJittedMethods to 1, add the environment variable `COMPlus_DumpJittedMethods=1`.\n\nSee also [Setting configuration variables](../building/viewing-jit-dumps.md#setting-configuration-variables) for more information.\n";
357357

358358
public static string ClrConfigTableHeader =
359-
"\nName | Description | Type | Class | Default Value | Flags \n" +
359+
"\nName | Description | Type | Class | Default Value | Flags\n" +
360360
"-----|-------------|------|-------|---------------|-------\n";
361361

362362
public static string PalConfigurationKnobs =
@@ -421,10 +421,10 @@ public static class ConfigKnobsDoc
421421
foreach (string key in catKnobs.Keys)
422422
{
423423
var knob = catKnobs[key];
424-
writer.Write($"`{knob.Name}` | {knob.Description} | `{knob.Type}` | ");
425-
writer.Write(knob.Class.Length > 0 ? $"`{knob.Class}` | " : " | ");
426-
writer.Write(knob.DefaultValue.Length > 0 ? $"`{knob.DefaultValue}` | " : " | ");
427-
writer.WriteLine($"{ knob.Flags}");
424+
writer.Write($"`{knob.Name}` | {knob.Description} | `{knob.Type}` |");
425+
writer.Write(knob.Class.Length > 0 ? $" `{knob.Class}` |" : " |");
426+
writer.Write(knob.DefaultValue.Length > 0 ? $" `{knob.DefaultValue}` |" : " |");
427+
writer.WriteLine(knob.Flags.Length > 0 ? $" {knob.Flags}" : string.Empty);
428428
count++;
429429
}
430430

0 commit comments

Comments
 (0)