This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5821 from dotnet/master
Merge master to nmirror
- Loading branch information
Showing
36 changed files
with
1,069 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/AppContextInitializerMethod.Sorting.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Internal.TypeSystem; | ||
|
||
using Debug = System.Diagnostics.Debug; | ||
|
||
namespace Internal.IL.Stubs.StartupCode | ||
{ | ||
partial class AppContextInitializerMethod | ||
{ | ||
protected override int ClassCode => 15749517; | ||
|
||
protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) | ||
{ | ||
// Should be a singleton | ||
Debug.Assert(this == other); | ||
return 0; | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
src/ILCompiler.Compiler/src/IL/Stubs/StartupCode/AppContextInitializerMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
|
||
using Internal.TypeSystem; | ||
|
||
namespace Internal.IL.Stubs.StartupCode | ||
{ | ||
public sealed partial class AppContextInitializerMethod : ILStubMethod | ||
{ | ||
private TypeDesc _owningType; | ||
private MethodSignature _signature; | ||
private IReadOnlyCollection<string> _switches; | ||
|
||
public AppContextInitializerMethod(TypeDesc owningType, IEnumerable<string> switches) | ||
{ | ||
_owningType = owningType; | ||
_switches = new List<string>(switches); | ||
} | ||
|
||
public override TypeSystemContext Context | ||
{ | ||
get | ||
{ | ||
return _owningType.Context; | ||
} | ||
} | ||
|
||
public override TypeDesc OwningType | ||
{ | ||
get | ||
{ | ||
return _owningType; | ||
} | ||
} | ||
|
||
public override string Name | ||
{ | ||
get | ||
{ | ||
return "SetAppContextSwitches"; | ||
} | ||
} | ||
|
||
public override MethodIL EmitIL() | ||
{ | ||
ILEmitter emitter = new ILEmitter(); | ||
ILCodeStream codeStream = emitter.NewCodeStream(); | ||
|
||
MetadataType appContextType = Context.SystemModule.GetKnownType("System", "AppContext"); | ||
MethodDesc setSwitchMethod = appContextType.GetKnownMethod("SetSwitch", null); | ||
ILToken setSwitchToken = emitter.NewToken(setSwitchMethod); | ||
|
||
foreach (string switchName in _switches) | ||
{ | ||
codeStream.Emit(ILOpcode.ldstr, emitter.NewToken(switchName)); | ||
codeStream.EmitLdc(1); | ||
codeStream.Emit(ILOpcode.call, setSwitchToken); | ||
} | ||
|
||
codeStream.Emit(ILOpcode.ret); | ||
|
||
return emitter.Link(this); | ||
} | ||
|
||
public override MethodSignature Signature | ||
{ | ||
get | ||
{ | ||
if (_signature == null) | ||
{ | ||
_signature = new MethodSignature(MethodSignatureFlags.Static, 0, | ||
Context.GetWellKnownType(WellKnownType.Void), | ||
TypeDesc.EmptyTypes); | ||
} | ||
|
||
return _signature; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.