Imported Upstream version 5.14.0.78

Former-commit-id: 3494343bcc9ddb42b36b82dd9ae7b69e85e0229f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-05-10 08:37:03 +00:00
parent 74b74abd9f
commit 19234507ba
1776 changed files with 67755 additions and 31107 deletions

View File

@@ -50,6 +50,9 @@
<UsingTask TaskName="ComputeManagedAssemblies" AssemblyFile="$(IlcBuildTasksPath)" />
<Target Name="_ComputeAssembliesToCompileToNative" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)">
<!-- Fail with descriptive error message for common mistake. -->
<Error Condition="'$(RuntimeIdentifier)' == ''" Text="RuntimeIdentifier is required for native compilation. Try running dotnet publish with the -r option value specified." />
<!-- CoreRT SDK and Framework Assemblies need to be defined to avoid CoreCLR implementations being set as compiler inputs -->
<Error Condition="'@(PrivateSdkAssemblies)' == ''" Text="The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />
<Error Condition="'@(FrameworkAssemblies)' == ''" Text="The FrameworkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />

View File

@@ -33,6 +33,11 @@ See the LICENSE file in the project root for more information.
</PropertyGroup>
<Target Name="SetupOSSpecificProps" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)">
<PropertyGroup>
<NativeLibraryExtension Condition="'$(NativeCodeGen)' != 'wasm'">.a</NativeLibraryExtension>
<NativeLibraryExtension Condition="'$(NativeCodeGen)' == 'wasm'">.bc</NativeLibraryExtension>
</PropertyGroup>
<ItemGroup>
<CppCompilerAndLinkerArg Include="-I $(IlcPath)/inc" />
<CppCompilerAndLinkerArg Condition="'$(Configuration)' == 'Debug'" Include="-g -O0" />
@@ -48,24 +53,28 @@ See the LICENSE file in the project root for more information.
<NativeLibrary Condition="$(NativeCodeGen) == ''" Include="$(IlcPath)/sdk/libRuntime.a" />
<NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)/sdk/libbootstrappercpp.a" />
<NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)/sdk/libPortableRuntime.a" />
<NativeLibrary Condition="$(NativeCodeGen) == 'wasm'" Include="$(IlcPath)/sdk/libbootstrappercpp.a" />
<NativeLibrary Condition="$(NativeCodeGen) == 'wasm'" Include="$(IlcPath)/sdk/libPortableRuntime.a" />
<NativeLibrary Condition="$(NativeCodeGen) == 'wasm'" Include="$(IlcPath)/sdk/libbootstrappercpp.bc" />
<NativeLibrary Condition="$(NativeCodeGen) == 'wasm'" Include="$(IlcPath)/sdk/libPortableRuntime.bc" />
</ItemGroup>
<ItemGroup>
<AdditionalNativeLibrary Include="$(IlcPath)/sdk/libSystem.Private.CoreLib.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/System.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/System.Globalization.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/System.IO.Compression.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/System.Net.Http.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/System.Net.Security.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/System.Security.Cryptography.Native.Apple.a" Condition="'$(TargetOS)' == 'OSX'"/>
<AdditionalNativeLibrary Include="$(IlcPath)/framework/System.Security.Cryptography.Native.OpenSsl.a" Condition="'$(TargetOS)' != 'OSX'"/>
<NativeLibrary Include="$(IlcPath)/sdk/libSystem.Private.CoreLib.Native$(NativeLibraryExtension)" />
<NativeLibrary Include="$(IlcPath)/framework/System.Native$(NativeLibraryExtension)" />
<NativeLibrary Include="$(IlcPath)/framework/System.Globalization.Native$(NativeLibraryExtension)" />
<NativeLibrary Include="$(IlcPath)/framework/System.IO.Compression.Native$(NativeLibraryExtension)" />
<NativeLibrary Include="$(IlcPath)/framework/System.Net.Http.Native$(NativeLibraryExtension)" />
<NativeLibrary Include="$(IlcPath)/framework/System.Net.Security.Native$(NativeLibraryExtension)" />
<NativeLibrary Include="$(IlcPath)/framework/System.Security.Cryptography.Native.Apple$(NativeLibraryExtension)" Condition="'$(TargetOS)' == 'OSX'"/>
<NativeLibrary Include="$(IlcPath)/framework/System.Security.Cryptography.Native.OpenSsl$(NativeLibraryExtension)" Condition="'$(TargetOS)' != 'OSX'"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetOS)' == 'OSX'">
<NativeFramework Include="CoreFoundation" />
<NativeFramework Include="Security" />
</ItemGroup>
<ItemGroup>
<LinkerArg Include="@(NativeLibrary)" />
<LinkerArg Include="@(AdditionalNativeLibrary)" />
<LinkerArg Include="-g" />
<LinkerArg Include="-Wl,-rpath,'$ORIGIN'" />
<LinkerArg Include="-pthread" />
@@ -79,6 +88,7 @@ See the LICENSE file in the project root for more information.
<LinkerArg Include="-licucore" Condition="'$(TargetOS)' == 'OSX'" />
<LinkerArg Include="-dynamiclib" Condition="'$(TargetOS)' == 'OSX' and '$(NativeLib)' == 'Shared'" />
<LinkerArg Include="-shared" Condition="'$(TargetOS)' != 'OSX' and '$(NativeLib)' == 'Shared'" />
<LinkerArg Include="@(NativeFramework->'-framework %(Identity)')" Condition="'$(TargetOS)' == 'OSX'" />
</ItemGroup>
<Exec Command="command -v $(CppLinker)" IgnoreExitCode="true">

View File

@@ -45,24 +45,23 @@ See the LICENSE file in the project root for more information.
</ItemGroup>
<ItemGroup>
<AdditionalNativeLibrary Include="kernel32.lib" />
<AdditionalNativeLibrary Include="user32.lib" />
<AdditionalNativeLibrary Include="gdi32.lib" />
<AdditionalNativeLibrary Include="winspool.lib" />
<AdditionalNativeLibrary Include="comdlg32.lib" />
<AdditionalNativeLibrary Include="advapi32.lib" />
<AdditionalNativeLibrary Include="shell32.lib" />
<AdditionalNativeLibrary Include="ole32.lib" />
<AdditionalNativeLibrary Include="oleaut32.lib" />
<AdditionalNativeLibrary Include="uuid.lib" />
<AdditionalNativeLibrary Include="bcrypt.lib" />
<AdditionalNativeLibrary Include="normaliz.lib" />
<NativeLibrary Include="kernel32.lib" />
<NativeLibrary Include="user32.lib" />
<NativeLibrary Include="gdi32.lib" />
<NativeLibrary Include="winspool.lib" />
<NativeLibrary Include="comdlg32.lib" />
<NativeLibrary Include="advapi32.lib" />
<NativeLibrary Include="shell32.lib" />
<NativeLibrary Include="ole32.lib" />
<NativeLibrary Include="oleaut32.lib" />
<NativeLibrary Include="uuid.lib" />
<NativeLibrary Include="bcrypt.lib" />
<NativeLibrary Include="normaliz.lib" />
</ItemGroup>
<ItemGroup>
<LinkerArg Condition="$(NativeLib) == 'Shared'" Include="/DLL" />
<LinkerArg Include="@(NativeLibrary)" />
<LinkerArg Include="@(AdditionalNativeLibrary)" />
<LinkerArg Include="/NOLOGO /DEBUG /MANIFEST:NO" />
<!-- The runtime is not compatible with jump stubs inserted by incremental linking. -->
<LinkerArg Include="/INCREMENTAL:NO" />
@@ -77,9 +76,28 @@ See the LICENSE file in the project root for more information.
<LinkerArg Include="/OPT:ICF" />
</ItemGroup>
<Exec Command="where /Q $(CppLinker)" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="_WhereLinker"/>
<Exec Command="where /Q $(CppCompiler) &amp;&amp; where /Q $(CppLinker)" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="_WhereCppTools"/>
</Exec>
<Error Condition="'$(_WhereLinker)' != '0'" Text="Platform linker not found. Make sure to publish from a x64 Native Tools Command Prompt for VS 2017 with C++ tools installed." />
<Message Condition="'$(_WhereCppTools)' != '0'" Text="Tools '$(CppCompiler)' and '$(CppLinker)' not found on PATH. Attempting to autodetect." />
<Exec Condition="'$(_WhereCppTools)' != '0'" Command="&quot;$(MSBuildThisFileDirectory)findvcvarsall.bat&quot; amd64" IgnoreExitCode="true" ConsoleToMSBuild="true" StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" PropertyName="_FindVCVarsallOutput"/>
<Output TaskParameter="ExitCode" PropertyName="_VCVarsAllFound"/>
</Exec>
<ItemGroup Condition="'$(_VCVarsAllFound)' == '0'">
<AdditionalNativeLibraryDirectories Include="$(_FindVCVarsallOutput.Split(`#`)[1].Split(';'))" />
</ItemGroup>
<PropertyGroup Condition="'$(_VCVarsAllFound)' == '0'">
<_CppToolsDirectory>$(_FindVCVarsallOutput.Split(`#`)[0])</_CppToolsDirectory>
<CppCompiler>"$(_CppToolsDirectory)cl.exe"</CppCompiler>
<CppLinker>"$(_CppToolsDirectory)link.exe"</CppLinker>
<CppLibCreator>"$(_CppToolsDirectory)lib.exe"</CppLibCreator>
</PropertyGroup>
<Error Condition="'$(_WhereCppTools)' != '0' AND '$(_VCVarsAllFound)' == '1'" Text="Platform linker not found. To fix this problem, download and install Visual Studio 2017 from http://visualstudio.com. Make sure to install the Desktop Development for C++ workload." />
</Target>
</Project>

View File

@@ -141,7 +141,7 @@ See the LICENSE file in the project root for more information.
</Target>
<Target Name="IlcCompile"
Inputs="@(IlcCompileInput)"
Inputs="@(IlcCompileInput);@(RdXmlFile)"
Outputs="$(NativeIntermediateOutputPath)%(ManagedBinary.Filename)$(IlcOutputFileExt)"
DependsOnTargets="$(IlcCompileDependsOn)">
@@ -155,7 +155,7 @@ See the LICENSE file in the project root for more information.
<IlcArg Condition="$(Optimize) == 'true'" Include="-O" />
<IlcArg Condition="$(DebugSymbols) == 'true'" Include="-g" />
<IlcArg Condition="$(IlcGenerateMapFile) == 'true'" Include="--map:$(NativeIntermediateOutputPath)%(ManagedBinary.Filename).map.xml" />
<IlcArg Condition="$(RdXmlFile) != ''" Include="--rdxml:$(RdXmlFile)" />
<IlcArg Include="@(RdXmlFile->'--rdxml:%(Identity)')" />
<IlcArg Condition="$(OutputType) == 'Library' and $(NativeLib) != ''" Include="--nativelib" />
<IlcArg Condition="$(ExportsFile) != ''" Include="--exportsfile:$(ExportsFile)" />
<ILcArg Condition="'$(Platform)' == 'wasm'" Include="--wasm" />
@@ -202,6 +202,7 @@ See the LICENSE file in the project root for more information.
<CustomLinkerArg Include="-o $(NativeBinary)" Condition="'$(OS)' != 'Windows_NT'" />
<CustomLinkerArg Include="/OUT:$(NativeBinary)" Condition="'$(OS)' == 'Windows_NT'" />
<CustomLinkerArg Include="/DEF:$(ExportsFile)" Condition="'$(OS)' == 'Windows_NT' and $(ExportsFile) != ''" />
<CustomLinkerArg Include="/LIBPATH:&quot;%(AdditionalNativeLibraryDirectories.Identity)&quot;" Condition="'$(OS)' == 'Windows_NT' and '@(AdditionalNativeLibraryDirectories->Count())' &gt; 0" />
<CustomLinkerArg Include="-exported_symbols_list $(ExportsFile)" Condition="'$(OS)' != 'Windows_NT' and $(ExportsFile) != ''" />
<CustomLinkerArg Include="@(LinkerArg)" />
</ItemGroup>
@@ -214,8 +215,8 @@ See the LICENSE file in the project root for more information.
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(NativeBinary)))" />
<Exec Command="$(CppLinker) @(CustomLinkerArg, ' ')" Condition="'$(OS)' != 'Windows_NT' and '$(NativeLib)' != 'Static'" />
<Exec Command="$(CppLibCreator) @(CustomLibArg, ' ')" Condition="'$(OS)' != 'Windows_NT' and '$(NativeLib)' == 'Static'" />
<Exec Command="$(CppLinker) @(CustomLinkerArg, ' ')" Condition="'$(OS)' != 'Windows_NT' and '$(NativeLib)' != 'Static' and '$(NativeCodeGen)' != 'wasm'" />
<Exec Command="$(CppLibCreator) @(CustomLibArg, ' ')" Condition="'$(OS)' != 'Windows_NT' and '$(NativeLib)' == 'Static' and '$(NativeCodeGen)' != 'wasm'" />
<WriteLinesToFile File="$(NativeIntermediateOutputPath)link.rsp" Lines="@(CustomLinkerArg)" Overwrite="true" Condition="'$(OS)' == 'Windows_NT' and '$(NativeLib)' != 'Static'" />
<Exec Command="$(CppLinker) @&quot;$(NativeIntermediateOutputPath)link.rsp&quot;" Condition="'$(OS)' == 'Windows_NT' and '$(NativeLib)' != 'Static' and '$(NativeCodeGen)' != 'wasm'" />
@@ -224,12 +225,13 @@ See the LICENSE file in the project root for more information.
<PropertyGroup>
<EmccArgs>&quot;$(NativeObject)&quot; -o &quot;$(NativeBinary)&quot; -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 </EmccArgs>
<EmccArgs Condition="'$(Platform)'=='wasm'">$(EmccArgs) &quot;$(IlcPath)\sdk\libPortableRuntime.bc&quot; &quot;$(IlcPath)\sdk\libbootstrappercpp.bc&quot; </EmccArgs>
<EmccArgs Condition="'$(Platform)'=='wasm'">$(EmccArgs) &quot;$(IlcPath)/sdk/libPortableRuntime.bc&quot; &quot;$(IlcPath)/sdk/libbootstrappercpp.bc&quot; </EmccArgs>
<EmccArgs Condition="'$(Configuration)'=='Release'">$(EmccArgs) -O2 --llvm-lto 2</EmccArgs>
<EmccArgs Condition="'$(Configuration)'=='Debug'">$(EmccArgs) -g3</EmccArgs>
</PropertyGroup>
<Exec Command="&quot;$(EMSCRIPTEN)\emcc.bat&quot; $(EmccArgs)" Condition="'$(NativeCodeGen)' == 'wasm' and '$(EMSCRIPTEN)' != ''" />
<Exec Command="&quot;$(EMSCRIPTEN)\emcc.bat&quot; $(EmccArgs)" Condition="'$(NativeCodeGen)' == 'wasm' and '$(EMSCRIPTEN)' != '' and '$(OS)' == 'Windows_NT'" />
<Exec Command="&quot;$(EMSCRIPTEN)/emcc&quot; $(EmccArgs)" Condition="'$(NativeCodeGen)' == 'wasm' and '$(EMSCRIPTEN)' != '' and '$(OS)' != 'Windows_NT'" />
<Message Text="Emscripten not found, not linking WebAssembly. To enable WebAssembly linking, install Emscripten and ensure the EMSCRIPTEN environment variable points to the directory containing emcc.bat"
Condition="'$(NativeCodeGen)' == 'wasm' and '$(EMSCRIPTEN)' == ''" />
</Target>

View File

@@ -0,0 +1,30 @@
@ECHO OFF
SETLOCAL
SET vswherePath=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
IF NOT EXIST "%vswherePath%" GOTO :ERROR
FOR /F "tokens=*" %%i IN ( '
"%vswherePath%" -latest -prerelease -products * ^
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^
-property installationPath'
) DO SET vsBase=%%i
IF "%vsBase%"=="" GOTO :ERROR
CALL "%vsBase%\vc\Auxiliary\Build\vcvarsall.bat" %1% > NUL
FOR /F "delims=" %%W IN ('where link') DO (
FOR %%A IN ("%%W") DO ECHO %%~dpA#
GOTO :CAPTURE_LIB_PATHS
)
:CAPTURE_LIB_PATHS
ECHO %LIB%
EXIT /B 0
ENDLOCAL
:ERROR
EXIT /B 1

View File

@@ -16,7 +16,7 @@ using System;
//
// - Naturally compressed: Integers are stored using variable length encoding. Offsets are stored as relative offsets.
//
// - Random accesss: Random access to selected information should be fast. It is achieved by using tokens as offsets.
// - Random access: Random access to selected information should be fast. It is achieved by using tokens as offsets.
//
// - Locality: Access to related information should be accessing data that are close to each other.
//

View File

@@ -260,7 +260,7 @@ namespace Internal.NativeFormat
#endif
}
// Aggresive phase that only allows offsets to shrink.
// Aggressive phase that only allows offsets to shrink.
_phase = SavePhase.Shrinking;
for (; ; )
{

View File

@@ -78,6 +78,11 @@ namespace Internal.Text
return Encoding.UTF8.GetString(_buffer, 0, _length);
}
public string ToString(int start)
{
return Encoding.UTF8.GetString(_buffer, start, _length - start);
}
public Utf8String ToUtf8String()
{
var ret = new byte[_length];
@@ -98,5 +103,50 @@ namespace Internal.Text
Buffer.BlockCopy(_buffer, 0, newBuffer, 0, _length);
_buffer = newBuffer;
}
// Find the boundary of the last character prior to a position
// If pos points to the last byte of a char, then return pos; Otherwise,
// return the position of the last byte of the preceding char.
public int LastCharBoundary(int pos)
{
Debug.Assert(pos < _length);
if (_buffer[pos] < 128 /*10000000*/)
{
// This is a single byte character
return pos;
}
int origPos = pos;
// Skip following bytes of a multi-byte character until the first byte is seen
while (_buffer[pos] < 192 /*11000000*/)
{
pos--;
}
if (pos == origPos - 3)
{
// We just skipped a four-byte character
Debug.Assert(_buffer[pos] >= 240 /*11110000*/);
return origPos;
}
if (pos == origPos - 2 && _buffer[pos] < 240 && _buffer[pos] >= 224 /*11100000*/)
{
// We just skipped a three-byte character
return origPos;
}
if (pos == origPos - 1 && _buffer[pos] < 224)
{
// We just skipped a two-byte character
Debug.Assert(_buffer[pos] >= 192 /*11000000*/);
return origPos;
}
// We were in the middle of a multi-byte character
return pos - 1;
}
}
}

View File

@@ -1,24 +0,0 @@
// 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;
using System.Runtime.InteropServices;
using System.Text;
internal static partial class Interop
{
internal static unsafe partial class mincore
{
internal const int MUI_LANGUAGE_ID = 0x4;
internal const int MUI_LANGUAGE_NAME = 0x8;
internal const int MUI_PREFERRED_UI_LANGUAGES = 0x10;
internal const int MUI_INSTALLED_LANGUAGES = 0x20;
internal const int MUI_ALL_LANGUAGES = 0x40;
internal const int MUI_LANG_NEUTRAL_PE_FILE = 0x100;
internal const int MUI_NON_LANG_NEUTRAL_FILE = 0x200;
[DllImport("api-ms-win-core-localization-l1-2-1.dll", CharSet = CharSet.Unicode)]
internal static extern bool GetFileMUIPath(int flags, String filePath, StringBuilder language, ref int languageLength, StringBuilder fileMuiPath, ref int fileMuiPathLength, ref Int64 enumerator);
}
}

View File

@@ -1,95 +0,0 @@
// 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;
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static unsafe partial class mincore
{
[StructLayout(LayoutKind.Sequential)]
internal struct REGISTRY_TIME_ZONE_INFORMATION
{
public Int32 Bias;
public Int32 StandardBias;
public Int32 DaylightBias;
public SYSTEMTIME StandardDate;
public SYSTEMTIME DaylightDate;
public REGISTRY_TIME_ZONE_INFORMATION(TIME_ZONE_INFORMATION tzi)
{
Bias = tzi.Bias;
StandardDate = tzi.StandardDate;
StandardBias = tzi.StandardBias;
DaylightDate = tzi.DaylightDate;
DaylightBias = tzi.DaylightBias;
}
public REGISTRY_TIME_ZONE_INFORMATION(Byte[] bytes)
{
//
// typedef struct _REG_TZI_FORMAT {
// [00-03] LONG Bias;
// [04-07] LONG StandardBias;
// [08-11] LONG DaylightBias;
// [12-27] SYSTEMTIME StandardDate;
// [12-13] WORD wYear;
// [14-15] WORD wMonth;
// [16-17] WORD wDayOfWeek;
// [18-19] WORD wDay;
// [20-21] WORD wHour;
// [22-23] WORD wMinute;
// [24-25] WORD wSecond;
// [26-27] WORD wMilliseconds;
// [28-43] SYSTEMTIME DaylightDate;
// [28-29] WORD wYear;
// [30-31] WORD wMonth;
// [32-33] WORD wDayOfWeek;
// [34-35] WORD wDay;
// [36-37] WORD wHour;
// [38-39] WORD wMinute;
// [40-41] WORD wSecond;
// [42-43] WORD wMilliseconds;
// } REG_TZI_FORMAT;
//
if (bytes == null || bytes.Length != 44)
{
throw new ArgumentException(SR.Argument_InvalidREG_TZI_FORMAT, nameof(bytes));
}
Bias = ToInt32(bytes, 0);
StandardBias = ToInt32(bytes, 4);
DaylightBias = ToInt32(bytes, 8);
StandardDate.wYear = (ushort)ToInt16(bytes, 12);
StandardDate.wMonth = (ushort)ToInt16(bytes, 14);
StandardDate.wDayOfWeek = (ushort)ToInt16(bytes, 16);
StandardDate.wDay = (ushort)ToInt16(bytes, 18);
StandardDate.wHour = (ushort)ToInt16(bytes, 20);
StandardDate.wMinute = (ushort)ToInt16(bytes, 22);
StandardDate.wSecond = (ushort)ToInt16(bytes, 24);
StandardDate.wMilliseconds = (ushort)ToInt16(bytes, 26);
DaylightDate.wYear = (ushort)ToInt16(bytes, 28);
DaylightDate.wMonth = (ushort)ToInt16(bytes, 30);
DaylightDate.wDayOfWeek = (ushort)ToInt16(bytes, 32);
DaylightDate.wDay = (ushort)ToInt16(bytes, 34);
DaylightDate.wHour = (ushort)ToInt16(bytes, 36);
DaylightDate.wMinute = (ushort)ToInt16(bytes, 38);
DaylightDate.wSecond = (ushort)ToInt16(bytes, 40);
DaylightDate.wMilliseconds = (ushort)ToInt16(bytes, 42);
}
private static short ToInt16(byte[] value, int startIndex)
{
return (short)(value[startIndex] | (value[startIndex + 1] << 8));
}
private static int ToInt32(byte[] value, int startIndex)
{
return value[startIndex] | (value[startIndex + 1] << 8) | (value[startIndex + 2] << 16) | (value[startIndex + 3] << 24);
}
}
}
}

View File

@@ -75,7 +75,6 @@ internal static partial class Interop
internal const int TIME_ZONE_ID_UNKNOWN = 0;
internal const int TIME_ZONE_ID_STANDARD = 1;
internal const int TIME_ZONE_ID_DAYLIGHT = 2;
internal const int MAX_PATH = 260;
[DllImport("api-ms-win-core-timezone-l1-1-0.dll")]
internal extern static uint EnumDynamicTimeZoneInformation(uint dwIndex, out TIME_DYNAMIC_ZONE_INFORMATION lpTimeZoneInformation);

View File

@@ -274,15 +274,22 @@ namespace Internal.TypeSystem
return false;
}
private static MethodDesc FindMatchingVirtualMethodOnTypeByNameAndSig(MethodDesc targetMethod, DefType currentType)
/// <summary>
/// Find matching a matching method by name and sig on a type. (Restricted to virtual methods only)
/// </summary>
/// <param name="targetMethod"></param>
/// <param name="currentType"></param>
/// <param name="reverseMethodSearch">Used to control the order of the search. For historical purposes to
/// match .NET Framework behavior, this is typically true, but not always. There is no particular rationale
/// for the particular orders other than to attempt to be consistent in virtual method override behavior
/// betweeen runtimes.</param>
/// <param name="nameSigMatchMethodIsValidCandidate"></param>
/// <returns></returns>
private static MethodDesc FindMatchingVirtualMethodOnTypeByNameAndSig(MethodDesc targetMethod, DefType currentType, bool reverseMethodSearch, Func<MethodDesc, MethodDesc, bool> nameSigMatchMethodIsValidCandidate)
{
string name = targetMethod.Name;
MethodSignature sig = targetMethod.Signature;
// TODO: InstantiatedType.GetMethod can't handle this for a situation like
// an instantiation of Foo<T>.M(T) because sig is instantiated, but it compares
// it to the uninstantiated version
//MethodDesc implMethod = currentType.GetMethod(name, sig);
MethodDesc implMethod = null;
foreach (MethodDesc candidate in currentType.GetAllMethods())
{
@@ -293,11 +300,15 @@ namespace Internal.TypeSystem
{
if (candidate.Signature.Equals(sig))
{
if (implMethod != null)
if (nameSigMatchMethodIsValidCandidate == null || nameSigMatchMethodIsValidCandidate(targetMethod, candidate))
{
throw NotImplemented.ActiveIssue("https://github.com/dotnet/corert/issues/190");
implMethod = candidate;
// If reverseMethodSearch is enabled, we want to find the last match on this type, not the first
// (reverseMethodSearch is used for most matches except for searches for name/sig method matches for interface methods on the most derived type)
if (!reverseMethodSearch)
return implMethod;
}
implMethod = candidate;
}
}
}
@@ -313,7 +324,7 @@ namespace Internal.TypeSystem
{
while (currentType != null)
{
MethodDesc nameSigOverride = FindMatchingVirtualMethodOnTypeByNameAndSigWithSlotCheck(targetMethod, currentType);
MethodDesc nameSigOverride = FindMatchingVirtualMethodOnTypeByNameAndSigWithSlotCheck(targetMethod, currentType, reverseMethodSearch:true);
if (nameSigOverride != null)
{
@@ -339,7 +350,7 @@ namespace Internal.TypeSystem
// Loop until a newslot method is found
while ((currentType != null) && !method.IsNewSlot)
{
MethodDesc foundMethod = FindMatchingVirtualMethodOnTypeByNameAndSig(method, currentType);
MethodDesc foundMethod = FindMatchingVirtualMethodOnTypeByNameAndSig(method, currentType, reverseMethodSearch: true, nameSigMatchMethodIsValidCandidate:null);
if (foundMethod != null)
{
method = foundMethod;
@@ -353,22 +364,25 @@ namespace Internal.TypeSystem
return method;
}
private static MethodDesc FindMatchingVirtualMethodOnTypeByNameAndSigWithSlotCheck(MethodDesc method, DefType currentType)
/// <summary>
/// Find matching a matching method by name and sig on a type. (Restricted to virtual methods only) Only search amongst methods with the same vtable slot.
/// </summary>
/// <param name="method"></param>
/// <param name="currentType"></param>
/// <param name="reverseMethodSearch">Used to control the order of the search. For historical purposes to
/// match .NET Framework behavior, this is typically true, but not always. There is no particular rationale
/// for the particular orders other than to attempt to be consistent in virtual method override behavior
/// betweeen runtimes.</param>
/// <returns></returns>
private static MethodDesc FindMatchingVirtualMethodOnTypeByNameAndSigWithSlotCheck(MethodDesc method, DefType currentType, bool reverseMethodSearch)
{
MethodDesc foundMethod = FindMatchingVirtualMethodOnTypeByNameAndSig(method, currentType);
if (foundMethod != null)
{
if (VerifyMethodsHaveTheSameVirtualSlot(foundMethod, method))
{
return foundMethod;
}
}
return null;
return FindMatchingVirtualMethodOnTypeByNameAndSig(method, currentType, reverseMethodSearch, nameSigMatchMethodIsValidCandidate: s_VerifyMethodsHaveTheSameVirtualSlot);
}
private static Func<MethodDesc, MethodDesc, bool> s_VerifyMethodsHaveTheSameVirtualSlot = VerifyMethodsHaveTheSameVirtualSlot;
// Return true if the slot that defines methodToVerify matches slotDefiningMethod
private static bool VerifyMethodsHaveTheSameVirtualSlot(MethodDesc methodToVerify, MethodDesc slotDefiningMethod)
private static bool VerifyMethodsHaveTheSameVirtualSlot(MethodDesc slotDefiningMethod, MethodDesc methodToVerify)
{
MethodDesc slotDefiningMethodOfMethodToVerify = FindSlotDefiningMethodForVirtualMethod(methodToVerify);
return slotDefiningMethodOfMethodToVerify == slotDefiningMethod;
@@ -384,7 +398,7 @@ namespace Internal.TypeSystem
unificationGroup.SetDefiningMethod(methodImpl);
}
MethodDesc nameSigMatchMethod = FindMatchingVirtualMethodOnTypeByNameAndSigWithSlotCheck(unificationGroup.DefiningMethod, currentType);
MethodDesc nameSigMatchMethod = FindMatchingVirtualMethodOnTypeByNameAndSigWithSlotCheck(unificationGroup.DefiningMethod, currentType, reverseMethodSearch: true);
MetadataType baseType = currentType.MetadataBaseType;
// Unless the current type has a name/sig match for the group, look to the base type to define the unification group further
@@ -404,7 +418,7 @@ namespace Internal.TypeSystem
foreach (MethodDesc memberMethod in unificationGroup)
{
MethodDesc nameSigMatchMemberMethod = FindMatchingVirtualMethodOnTypeByNameAndSigWithSlotCheck(memberMethod, currentType);
MethodDesc nameSigMatchMemberMethod = FindMatchingVirtualMethodOnTypeByNameAndSigWithSlotCheck(memberMethod, currentType, reverseMethodSearch: true);
if (nameSigMatchMemberMethod != null)
{
if (separatedMethods == null)
@@ -504,7 +518,9 @@ namespace Internal.TypeSystem
if (foundExplicitInterface)
{
MethodDesc foundOnCurrentType = FindMatchingVirtualMethodOnTypeByNameAndSig(interfaceMethod, currentType);
MethodDesc foundOnCurrentType = FindMatchingVirtualMethodOnTypeByNameAndSig(interfaceMethod, currentType
, reverseMethodSearch: false /* When searching for name/sig overrides on a type that explicitly defines an interface, search through the type in the forward direction*/
, nameSigMatchMethodIsValidCandidate :null);
foundOnCurrentType = FindSlotDefiningMethodForVirtualMethod(foundOnCurrentType);
if (baseType == null)
@@ -540,7 +556,16 @@ namespace Internal.TypeSystem
}
else
{
return FindNameSigOverrideForInterfaceMethodRecursive(interfaceMethod, currentType);
MethodDesc foundOnCurrentType = FindMatchingVirtualMethodOnTypeByNameAndSig(interfaceMethod, currentType
, reverseMethodSearch: false /* When searching for name/sig overrides on a type that is the first type in the hierarchy to require the interface, search through the type in the forward direction*/
, nameSigMatchMethodIsValidCandidate: null);
foundOnCurrentType = FindSlotDefiningMethodForVirtualMethod(foundOnCurrentType);
if (foundOnCurrentType != null)
return foundOnCurrentType;
return FindNameSigOverrideForInterfaceMethodRecursive(interfaceMethod, baseType);
}
}
}
@@ -605,7 +630,10 @@ namespace Internal.TypeSystem
if (currentType == null)
return null;
MethodDesc nameSigOverride = FindMatchingVirtualMethodOnTypeByNameAndSig(interfaceMethod, currentType);
MethodDesc nameSigOverride = FindMatchingVirtualMethodOnTypeByNameAndSig(interfaceMethod, currentType
, reverseMethodSearch: true /* When searching for a name sig match for an interface on parent types search in reverse order of declaration */
, nameSigMatchMethodIsValidCandidate:null);
if (nameSigOverride != null)
{
return FindSlotDefiningMethodForVirtualMethod(nameSigOverride);

View File

@@ -2,7 +2,6 @@
// 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;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Metadata;

View File

@@ -209,7 +209,10 @@ namespace Internal.IL
private static bool IsNativeCallingConventionCompatible(TypeDesc type)
{
if (type.IsPointer || type.IsByRef)
if (type.IsPointer)
return true;
if (type.IsByRef)
return IsNativeCallingConventionCompatible(((ParameterizedType)type).ParameterType);
if (!type.IsValueType)

View File

@@ -87,7 +87,7 @@ namespace Internal.IL.Stubs
var rangeExceptionLabel = _emitter.NewCodeLabel();
ILCodeLabel typeMismatchExceptionLabel = null;
if (!_elementType.IsValueType)
if (_elementType.IsGCPointer)
{
// Type check
if (_method.Kind == ArrayMethodKind.Set)

View File

@@ -549,25 +549,6 @@ namespace Internal.IL.Stubs
}
}
// Workaround for places that emit IL that doesn't conform to the ECMA-335 CIL stack requirements.
// https://github.com/dotnet/corert/issues/5152
// This class and all references to it should be deleted when the issue is fixed.
// Do not add new references to this.
public class ILStubMethodILWithNonConformingStack : ILStubMethodIL
{
public ILStubMethodILWithNonConformingStack(MethodDesc owningMethod, byte[] ilBytes, LocalVariableDefinition[] locals, Object[] tokens, MethodDebugInformation debugInfo)
: base(owningMethod, ilBytes, locals, tokens, debugInfo)
{
}
public ILStubMethodILWithNonConformingStack(ILStubMethodIL methodIL)
: base(methodIL)
{
}
public override int MaxStack => GetILBytes().Length;
}
public class ILCodeLabel
{
private ILCodeStream _codeStream;
@@ -665,7 +646,7 @@ namespace Internal.IL.Stubs
return newLabel;
}
public MethodIL Link(MethodDesc owningMethod, bool nonConformingStackWorkaround = false)
public MethodIL Link(MethodDesc owningMethod)
{
int totalLength = 0;
int numSequencePoints = 0;
@@ -711,17 +692,8 @@ namespace Internal.IL.Stubs
debugInfo = new EmittedMethodDebugInformation(sequencePoints);
}
ILStubMethodIL result;
if (nonConformingStackWorkaround)
{
// nonConformingStackWorkaround is a workaround for https://github.com/dotnet/corert/issues/5152
result = new ILStubMethodILWithNonConformingStack(owningMethod, ilInstructions, _locals.ToArray(), _tokens.ToArray(), debugInfo);
}
else
{
result = new ILStubMethodIL(owningMethod, ilInstructions, _locals.ToArray(), _tokens.ToArray(), debugInfo);
result.CheckStackBalance();
}
var result = new ILStubMethodIL(owningMethod, ilInstructions, _locals.ToArray(), _tokens.ToArray(), debugInfo);
result.CheckStackBalance();
return result;
}

View File

@@ -107,6 +107,7 @@ namespace Internal.IL.Stubs
{
ILEmitter emitter = ilCodeStreams.Emitter;
ILCodeStream fnptrLoadStream = ilCodeStreams.FunctionPointerLoadStream;
ILCodeStream marshallingCodeStream = ilCodeStreams.MarshallingCodeStream;
ILCodeStream callsiteSetupCodeStream = ilCodeStreams.CallsiteSetupCodeStream;
TypeSystemContext context = _targetMethod.Context;
@@ -155,7 +156,7 @@ namespace Internal.IL.Stubs
ILLocalVariable vDelegateStub = emitter.NewLocal(delegateMethod.DelegateType);
fnptrLoadStream.EmitStLoc(vDelegateStub);
fnptrLoadStream.EmitLdLoc(vDelegateStub);
marshallingCodeStream.EmitLdLoc(vDelegateStub);
MethodDesc invokeMethod = delegateMethod.DelegateType.GetKnownMethod("Invoke", null);
callsiteSetupCodeStream.Emit(ILOpcode.callvirt, emitter.NewToken(invokeMethod));
}
@@ -304,10 +305,10 @@ namespace Internal.IL.Stubs
EmitPInvokeCall(pInvokeILCodeStreams);
}
_marshallers[0].LoadReturnValue(unmarshallingCodestream);
unmarshallingCodestream.Emit(ILOpcode.ret);
return new PInvokeILStubMethodIL((ILStubMethodIL)emitter.Link(_targetMethod, nonConformingStackWorkaround: true),
IsStubRequired());
return new PInvokeILStubMethodIL((ILStubMethodIL)emitter.Link(_targetMethod), IsStubRequired());
}
public static MethodIL EmitIL(MethodDesc method,
@@ -395,7 +396,7 @@ namespace Internal.IL.Stubs
}
}
public sealed class PInvokeILStubMethodIL : ILStubMethodILWithNonConformingStack
public sealed class PInvokeILStubMethodIL : ILStubMethodIL
{
public bool IsStubRequired { get; }
public PInvokeILStubMethodIL(ILStubMethodIL methodIL, bool isStubRequired) : base(methodIL)

View File

@@ -52,6 +52,18 @@ namespace Internal.IL.Stubs
(byte)ILOpcode.ldarg_0, (byte)ILOpcode.ldarg_1,
(byte)ILOpcode.prefix1, unchecked((byte)ILOpcode.ceq),
(byte)ILOpcode.ret }, Array.Empty<LocalVariableDefinition>(), null);
case "IsAddressGreaterThan":
return new ILStubMethodIL(method, new byte[]
{
(byte)ILOpcode.ldarg_0, (byte)ILOpcode.ldarg_1,
(byte)ILOpcode.prefix1, unchecked((byte)ILOpcode.cgt_un),
(byte)ILOpcode.ret }, Array.Empty<LocalVariableDefinition>(), null);
case "IsAddressLessThan":
return new ILStubMethodIL(method, new byte[]
{
(byte)ILOpcode.ldarg_0, (byte)ILOpcode.ldarg_1,
(byte)ILOpcode.prefix1, unchecked((byte)ILOpcode.clt_un),
(byte)ILOpcode.ret }, Array.Empty<LocalVariableDefinition>(), null);
case "ByteOffset":
return new ILStubMethodIL(method, new byte[]
{

View File

@@ -0,0 +1,20 @@
// 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;
namespace Internal.IL.Stubs
{
partial class ValueTypeGetFieldHelperMethodOverride
{
protected internal override int ClassCode => 2036839816;
protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer)
{
var otherMethod = (ValueTypeGetFieldHelperMethodOverride)other;
return comparer.Compare(_owningType, otherMethod._owningType);
}
}
}

View File

@@ -0,0 +1,145 @@
// 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
{
/// <summary>
/// Synthetic method override of "int ValueType.__GetFieldHelper(Int32, out EETypePtr)". This method is injected
/// into all value types that cannot have their Equals(object) and GetHashCode() methods operate on individual
/// bytes. The purpose of the override is to provide access to the value types' fields and their types.
/// </summary>
public sealed partial class ValueTypeGetFieldHelperMethodOverride : ILStubMethod
{
private DefType _owningType;
private MethodSignature _signature;
internal ValueTypeGetFieldHelperMethodOverride(DefType owningType)
{
_owningType = owningType;
}
public override TypeSystemContext Context
{
get
{
return _owningType.Context;
}
}
public override TypeDesc OwningType
{
get
{
return _owningType;
}
}
public override MethodSignature Signature
{
get
{
if (_signature == null)
{
TypeSystemContext context = _owningType.Context;
TypeDesc int32Type = context.GetWellKnownType(WellKnownType.Int32);
TypeDesc eeTypePtrType = context.SystemModule.GetKnownType("System", "EETypePtr");
_signature = new MethodSignature(0, 0, int32Type, new[] {
int32Type,
eeTypePtrType.MakeByRefType()
});
}
return _signature;
}
}
public override MethodIL EmitIL()
{
TypeDesc owningType = _owningType.InstantiateAsOpen();
ILEmitter emitter = new ILEmitter();
TypeDesc eeTypePtrType = Context.SystemModule.GetKnownType("System", "EETypePtr");
MethodDesc eeTypePtrOfMethod = eeTypePtrType.GetKnownMethod("EETypePtrOf", null);
ILToken eeTypePtrToken = emitter.NewToken(eeTypePtrType);
var switchStream = emitter.NewCodeStream();
var getFieldStream = emitter.NewCodeStream();
ArrayBuilder<ILCodeLabel> fieldGetters = new ArrayBuilder<ILCodeLabel>();
foreach (FieldDesc field in owningType.GetFields())
{
if (field.IsStatic)
continue;
ILCodeLabel label = emitter.NewCodeLabel();
fieldGetters.Add(label);
getFieldStream.EmitLabel(label);
getFieldStream.EmitLdArg(2);
// We need something we can instantiate EETypePtrOf over. Also, the classlib
// code doesn't handle pointers.
TypeDesc boxableFieldType = field.FieldType;
if (boxableFieldType.IsPointer || boxableFieldType.IsFunctionPointer)
boxableFieldType = Context.GetWellKnownType(WellKnownType.IntPtr);
MethodDesc ptrOfField = eeTypePtrOfMethod.MakeInstantiatedMethod(boxableFieldType);
getFieldStream.Emit(ILOpcode.call, emitter.NewToken(ptrOfField));
getFieldStream.Emit(ILOpcode.stobj, eeTypePtrToken);
getFieldStream.EmitLdArg(0);
getFieldStream.Emit(ILOpcode.ldflda, emitter.NewToken(field));
getFieldStream.EmitLdArg(0);
getFieldStream.Emit(ILOpcode.sub);
getFieldStream.Emit(ILOpcode.ret);
}
if (fieldGetters.Count > 0)
{
switchStream.EmitLdArg(1);
switchStream.EmitSwitch(fieldGetters.ToArray());
}
switchStream.EmitLdc(fieldGetters.Count);
switchStream.Emit(ILOpcode.ret);
return emitter.Link(this);
}
public override Instantiation Instantiation
{
get
{
return Instantiation.Empty;
}
}
public override bool IsVirtual
{
get
{
return true;
}
}
public override string Name
{
get
{
return "__GetFieldHelper";
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More